Sub topic 2
Approximation Ratios: What a Guarantee Means
This chapter assumes you know Big-O notation and what polynomial time means, and that you have seen NP-hardness. The previous chapter explained why exact algorithms for NP-hard optimization problems are impractical. This chapter defines exactly what an approximation algorithm promises in their place.
The Definition
An optimization problem gives each feasible solution a numeric cost or value. For an instance I, write OPT(I) for the best possible objective value and ALG(I) for the value your algorithm returns. Assume all objective values are positive.
An algorithm is a ρ-approximation if it runs in polynomial time and, for every instance I:
| Problem type | Guarantee | Ratio convention |
|---|---|---|
| Minimization | ALG(I) ≤ ρ · OPT(I) | ρ ≥ 1 |
| Maximization | ALG(I) ≥ ρ · OPT(I) | ρ ≤ 1 |
So a 2-approximation for a minimization problem never returns a solution more than twice as expensive as the best one. A 1/2-approximation for a maximization problem always captures at least half the best value. In both cases, a ratio closer to 1 means a stronger guarantee.
What the Guarantee Covers
The bound is a worst-case statement. It must hold on every input, including inputs built specifically to defeat the algorithm. Doing well on benchmarks does not establish a ratio, and failing on one instance disproves it.
The ratio ρ can also depend on the input size. For example, a guarantee of ρ(n) = ln n + 1 is still useful even though it grows with n. Later chapters show that for some problems this is the best achievable ratio.
The ratio is multiplicative. An additive guarantee, ALG ≤ OPT + c, is stronger, and few NP-hard problems admit one. Multiplicative bounds also stay the same when you rescale the units of the objective.
Computing a Ratio on One Instance
The helper below reports how far a single solution is from optimal, using the conventions from the table above.
def observed_ratio(alg_value, opt_value, minimize=True):
if alg_value <= 0 or opt_value <= 0:
raise ValueError("ratios assume positive objective values")
return alg_value / opt_value if minimize else alg_value / opt_value
print(observed_ratio(12, 8, minimize=True)) # 1.5: cost is 50% above optimum
print(observed_ratio(30, 40, minimize=False)) # 0.75: captures 75% of optimumThe same division works for both cases. Only the reading changes: ≥ 1 for minimization, ≤ 1 for maximization. A single observed ratio is evidence about one instance. It does not prove a guarantee.
Common Errors
- Confusing the observed ratio with the guarantee. The guarantee bounds the worst case over all inputs. Typical behavior is often much better.
- Forgetting the running time. Any problem has a 1-approximation if you allow exponential time. The polynomial-time requirement is what makes the ratio meaningful.
- Mixing conventions. If you read "2-approximation" for a maximization problem under the wrong convention, you misread the result.
- Assuming you can compare against OPT. OPT is usually unknown. The next chapter shows how proofs avoid computing it.
Exercise
Algorithm A for a minimization problem returns costs of 10, 14, and 9 on three instances whose optima are 8, 7, and 9. Can you conclude that A is a 1.5-approximation? What ratio do the data rule out?
Show answer
No. The observed ratios are 1.25, 2.0, and 1.0, and a guarantee must hold on every instance, not just the ones tested. The second instance has ratio 2.0, so A is not a ρ-approximation for any ρ < 2. The data cannot confirm any upper bound.
Exercise
A maximization algorithm always returns at least 0.875 · OPT. How would a source that writes all ratios as numbers ≥ 1 state this guarantee?
Show answer
As OPT ≤ (8/7) · ALG, which is a ratio of 8/7 ≈ 1.143, because 1 / 0.875 = 8/7.