Sub topic 16
Approximation Classes: PTAS, FPTAS, and APX
This chapter assumes you already know the material from earlier chapters: how an approximation ratio is defined, what a PTAS and an FPTAS are, the knapsack FPTAS, and the idea of a gap reduction from the PCP chapter. It also assumes you are comfortable with NP-completeness and strong NP-hardness. The aim here is to sort problems into classes by how well they can be approximated. You will also learn the reductions that keep a problem in its class and the common mistakes people make when placing a problem.
The Landscape of NPO
An NP optimization problem (NPO) has polynomial-time checkable solutions and a polynomial-time computable objective. Every problem in this tutorial belongs to NPO. Inside NPO, the approximation classes form a chain:
| Class | Membership condition | Typical members |
|---|---|---|
| PO | Solvable exactly in polynomial time | Shortest path, bipartite matching |
| FPTAS | For every ε > 0, ratio 1 + ε (or 1 − ε) in time poly(n, 1/ε) | 0/1 knapsack, scheduling on a fixed number of machines |
| PTAS | For every fixed ε > 0, ratio 1 + ε in time poly(n), where the exponent may depend on ε | Euclidean TSP, makespan with m in the input |
| APX | Some constant ratio c in polynomial time | Vertex cover, Max-3SAT, Max-Cut, metric TSP |
| log-APX | Ratio O(log n) | Set cover, dominating set |
| poly-APX | Ratio poly(n) | Max independent set, max clique |
| NPO | Any problem with poly-time verifiable solutions | General TSP |
The inclusions PO ⊆ FPTAS ⊆ PTAS ⊆ APX ⊆ log-APX ⊆ poly-APX ⊆ NPO hold unconditionally. If P ≠ NP, every inclusion is strict, and each class has a natural problem that separates it from the next.
Why Each Separation Holds
Each strict inclusion has a different reason behind it.
- FPTAS ≠ PTAS. Strong NP-hardness rules out an FPTAS (the next section explains why). Makespan minimization with the number of machines m as part of the input is strongly NP-hard. It still has a PTAS, from Hochbaum and Shmoys.
- PTAS ≠ APX. Vertex cover, Max-3SAT, and metric TSP are APX-hard. The PCP theorem implies that each of them has a constant below which approximation is NP-hard: 1.36 for vertex cover, 7/8 + ε for Max-3SAT, and 123/122 for metric TSP.
- APX ≠ log-APX. Set cover cannot be approximated within (1 − ε) ln n unless P = NP (Dinur and Steurer). This makes the greedy H_n bound essentially optimal.
- log-APX ≠ poly-APX. Max clique cannot be approximated within n^(1−ε) for any ε > 0 unless P = NP.
- poly-APX ≠ NPO. General TSP has no ratio that is a polynomial-time computable function of n. The Hamiltonian-cycle gap reduction from the earlier chapter uses huge edge weights to show this.
Strong NP-Hardness Rules Out an FPTAS
This is the most useful membership test in practice.
The proof runs an FPTAS with ε = 1/(p(n, U) + 1). For a maximization problem, the returned value is at least (1 − ε)·OPT > OPT − 1. Values are integers, so the returned value equals OPT. The running time is poly(n, 1/ε) = poly(n, U), which is pseudo-polynomial. A strongly NP-hard problem stays NP-hard when U is bounded by a polynomial in n. On those inputs the procedure is a true polynomial-time exact algorithm, so P = NP.
You can see the mechanism with the knapsack FPTAS. Choose ε small enough and the scheme becomes exact. Its running time then depends on the values, which is why knapsack is only weakly NP-hard.
from itertools import combinations
def knapsack_fptas(values, weights, capacity, eps):
n = len(values)
k = eps * max(values) / n
scaled = [int(v // k) for v in values]
total = sum(scaled)
INF = float("inf")
min_w = [0] + [INF] * total
keep = [[False] * (total + 1) for _ in range(n)]
for i in range(n):
for p in range(total, scaled[i] - 1, -1):
cand = min_w[p - scaled[i]] + weights[i]
if cand < min_w[p]:
min_w[p] = cand
keep[i][p] = True
best = max(p for p in range(total + 1) if min_w[p] <= capacity)
items, p = [], best
for i in range(n - 1, -1, -1):
if keep[i][p]:
items.append(i)
p -= scaled[i]
return sorted(items)
def brute_force(values, weights, capacity):
n = len(values)
best = 0
for r in range(n + 1):
for combo in combinations(range(n), r):
if sum(weights[i] for i in combo) <= capacity:
best = max(best, sum(values[i] for i in combo))
return best
values, weights, capacity = [60, 100, 120], [10, 20, 30], 50
eps = 1 / (sum(values) + 1) # eps * OPT < 1, so the answer is exact
items = knapsack_fptas(values, weights, capacity, eps)
print(items, sum(values[i] for i in items), brute_force(values, weights, capacity))The program prints [1, 2] 220 220. Now picture a strongly NP-hard problem such as bin packing or 3-partition. The same trick would solve it exactly in time polynomial in the numbers, and the numbers are small on the hard instances.
APX-Hardness and Approximation-Preserving Reductions
Ordinary Karp reductions keep feasibility but not the quality of a solution. A reduction that transfers approximability has to map solutions back while controlling the error.
- A PTAS-reduction from problem A to problem B maps each instance x of A to an instance f(x) of B. It also maps each solution y of f(x) back to a solution g(x, y) of A. If y is within ratio 1 + δ(ε) on B, then g(x, y) is within ratio 1 + ε on A. A PTAS for B then gives a PTAS for A.
- An L-reduction is a common special case that is easier to check. It needs constants α and β with OPTB(f(x)) ≤ α·OPTA(x) and |costA(g(y)) − OPTA| ≤ β·|costB(y) − OPTB|. Under these conditions, relative error grows by at most a factor αβ.
A problem is APX-hard if every APX problem PTAS-reduces to it. It is APX-complete if it is also in APX. Max-3SAT is the canonical APX-complete problem, and the PCP theorem is what makes it hard. Vertex cover on bounded-degree graphs, Max-Cut, and metric TSP are APX-complete through L-reductions from Max-3SAT.
Gotchas When Placing a Problem
Asymptotic versus absolute ratios
Bin packing has no absolute ratio below 3/2 unless P = NP. The reason is that deciding whether 2 bins suffice is the Partition problem, so bin packing is not in PTAS. It does have an asymptotic PTAS, which uses at most (1 + ε)·OPT + 1 bins. Read the definition behind any "PTAS" claim before you rely on it.
What is part of the input
Makespan on a fixed number m of machines has an FPTAS. When m is part of the input, the problem becomes strongly NP-hard, and it has a PTAS but no FPTAS. Euclidean TSP has a PTAS (Arora, Mitchell), metric TSP is APX-complete, and general TSP is not in APX. Small changes to the input model move a problem across class boundaries.
Weighted versus unweighted, and restricted inputs
Max independent set is in poly-APX on general graphs. On planar graphs it has a PTAS (Baker's technique), and on bounded-degree graphs it is in APX. A hardness result always applies to a specific input family.
"Polynomial for each fixed ε" can be impractical
A PTAS with running time n^(1/ε) puts the problem in PTAS. At ε = 0.01 that time is n^100. Efficient PTASs (EPTAS) run in f(1/ε)·poly(n) and sit between FPTAS and PTAS. If you need small ε in practice, ask whether an EPTAS exists.
Choosing What to Aim For
When you face a new NP-hard optimization problem, use these steps:
- Check whether it is strongly NP-hard with polynomially bounded integer optima. If it is, do not look for an FPTAS. If it is weakly NP-hard, a value-scaling DP like the knapsack one may give an FPTAS.
- Look for an L-reduction from Max-3SAT, vertex cover, or another APX-complete problem. If one exists, stop looking for a PTAS and aim for the best constant.
- If the problem embeds set cover with a ratio-preserving reduction, Θ(log n) is the realistic target.
- If it embeds clique or Hamiltonian cycle with large weights, a provable guarantee may be impossible. Use heuristics, restrict the input class, or use exact methods for small instances.
Exercise
The problem 3-partition is strongly NP-hard. Explain why a scheduling problem whose decision version encodes 3-partition, and whose makespan is an integer bounded by the sum of job lengths, cannot have an FPTAS unless P = NP.
Show answer
Run the hypothetical FPTAS with ε = 1/(S + 1), where S is the sum of job lengths and bounds OPT. The result is at most (1 + ε)·OPT < OPT + 1, so being an integer it equals OPT. The time is poly(n, S), which is polynomial on 3-partition instances because their numbers are bounded by a polynomial in n. That would solve a strongly NP-hard problem in polynomial time, so P = NP.
Exercise
Vertex cover is in APX with ratio 2 and is APX-hard. What exactly does APX-hardness rule out, and what does it leave open?
Show answer
It rules out a PTAS unless P = NP: some constant c > 1 exists below which approximation is NP-hard (about 1.36 is known). It leaves open whether any constant between that threshold and 2 is achievable. Under the Unique Games Conjecture, 2 − ε is hard, so the matching algorithm would be optimal.
Exercise
Bin packing is NP-hard to approximate within any ratio below 3/2, yet it is said to have an "approximation scheme." Reconcile these statements.
Show answer
The 3/2 bound concerns absolute ratio. Deciding whether OPT = 2 is Partition, so any ratio below 3/2 would solve Partition exactly. The scheme is asymptotic: it uses at most (1 + ε)·OPT + 1 bins, and the additive +1 dominates only when OPT is small. Bin packing is in APX, not in PTAS, but it has an asymptotic PTAS.