Sub topic 10
Approximation Schemes: Trading Accuracy for Time
This chapter assumes you know the approximation ratio from earlier chapters, Big-O notation, and the idea of strong versus weak NP-hardness. So far every algorithm in this tutorial has had one fixed guarantee, such as 2 for vertex cover or H_n for set cover. An approximation scheme gives you a setting instead: you choose how close to optimal you want the answer, and you pay for that closeness in running time.
The Definitions
An approximation scheme is a family of algorithms Aε, one for each ε > 0. On any instance, Aε returns a solution of cost at most (1 + ε)·OPT for a minimization problem, or value at least (1 − ε)·OPT for a maximization problem.
The schemes are grouped by how the running time depends on ε:
| Scheme | Running time requirement | Typical form |
|---|---|---|
| PTAS (polynomial-time approximation scheme) | Polynomial in n for each fixed ε | O(n^(1/ε)), O(n^(2/ε²)) |
| EPTAS (efficient PTAS) | f(1/ε) · poly(n), with the exponent of n independent of ε | O(2^(1/ε) · n log n) |
| FPTAS (fully polynomial-time approximation scheme) | Polynomial in both n and 1/ε | O(n³/ε) |
The usual mistake is to treat a PTAS as practical just because it is called "polynomial." A running time of n^(1/ε) is polynomial when ε = 0.1, but the polynomial has degree 10. A PTAS is allowed to put ε in the exponent of n. An FPTAS is not.
Seeing the Cost Difference
The script below compares step counts for a PTAS with time n^(1/ε) and an FPTAS with time n³/ε, at n = 100.
def ptas_cost(n, eps):
return n ** (1 / eps)
def fptas_cost(n, eps):
return n ** 3 / eps
n = 100
for eps in [0.5, 0.25, 0.1]:
print(f"eps={eps}: PTAS ~ {ptas_cost(n, eps):.2e}, FPTAS ~ {fptas_cost(n, eps):.2e}")At ε = 0.5 the PTAS needs about 10⁴ steps and wins. At ε = 0.1 it needs about 10²⁰ steps, while the FPTAS needs about 10⁷. The two costs grow at very different rates as ε shrinks.
Where the Schemes Come From
Most schemes use one of two patterns:
- Guess the large part, approximate the rest. Try every placement of the roughly 1/ε largest items exactly, then handle the small items greedily. Small items can add only an ε fraction of error. Enumerating all placements of the large items is what puts 1/ε into the exponent, so this pattern usually gives a PTAS. Makespan scheduling on m identical machines, with m part of the input, has a PTAS built this way.
- Round the numbers, then solve exactly. Scale the input values down so that a pseudo-polynomial dynamic program runs in time polynomial in n and 1/ε. The rounding loses at most an ε fraction of the optimum. This pattern gives an FPTAS, and the next chapter applies it to knapsack.
When an FPTAS Cannot Exist
Suppose a minimization problem has integer costs and OPT ≤ p(n) for some polynomial p. Run an FPTAS with ε = 1/(p(n) + 1). The returned cost is below OPT + 1, and since costs are integers it must equal OPT. The running time is still polynomial, so the problem is solved exactly. For a strongly NP-hard problem, this means:
Weakly NP-hard problems, such as knapsack, can be solved exactly in pseudo-polynomial time. These are the problems where you should look for an FPTAS.
Exercise
An algorithm achieves a (1 + ε)-approximation in O(2^(1/ε) · n²) time. Is it a PTAS, an EPTAS, or an FPTAS?
Show answer
It is a PTAS and also an EPTAS, because the exponent of n does not depend on ε. It is not an FPTAS, because the running time is exponential in 1/ε rather than polynomial.
Exercise
A maximization problem has integer values with OPT ≤ n². Which ε makes an FPTAS return an exact optimum, and why?
Show answer
Any ε < 1/n² works, for example ε = 1/(n² + 1). The returned value is at least (1 − ε)·OPT > OPT − 1, and since values are integers it must equal OPT. The running time stays polynomial because 1/ε is O(n²).