Part V · where the trunks converge · spine

23

Combinatorial approximation algorithms

Greedy, matchings, spanning trees and sorting, each with a lower bound on the optimum it can compute, and a proof that fits on one slide.

needs 22, 16, 15, 13~1½ h slides + 2½ h lablab: uv run co lab 23

23 · overview

The route

1 · the shape of a guarantee

A computable lower bound on OPT. Greedy set cover and its prices.

2 · packings

Vertex cover by maximal matching; k-center by farthest-first.

3 · metric TSP

Double tree (2), Christofides (3/2), and the 2021 improvement.

4 · scheduling, and the gap to practice

List scheduling, LPT; tight families; ratios measured against CP-SAT.

getting around

Words with a dotted underline are glossary terms: click one for its definition. G lists every term in the unit, N shows the notes. Optional extra: interactive figures, linked from the slides they support by a small ▸ chip; skip them freely.

section 1

The shape of a guarantee

Compare against something you can compute.

23 · guarantees

Every proof in this unit has one shape

OPT is unknown, and computing it is NP-hard. So find a lower bound $\mathrm{LB}$ with

$$\mathrm{ALG} \le \rho \cdot \mathrm{LB} \quad\text{and}\quad \mathrm{LB} \le \mathrm{OPT}$$

That makes it a $\rho$-approximation. The algorithm constructs its solution and its lower bound together. The lab returns both, so tests check each inequality separately.

the limit of the method

If some instance has $\mathrm{OPT} / \mathrm{LB} = r$, no analysis against that $\mathrm{LB}$ can prove a ratio below $r$. That's the integrality gap of unit 05 again, for bounds that aren't LPs.

problemlower boundρ
set coverprices ÷ $H_d$: a feasible LP dual (unit 03)$H_d$
vertex coversize of any matching2
k-centerhalf the spacing of $k + 1$ points2
metric TSPminimum spanning tree2
metric TSPMST, and ½·tour ≥ matching on odd vertices3/2
makespan$\max(\sum p / m,\ \max p)$$2 - 1/m$
makespan, LPT… and $2\,p_{m+1}$ after sorting$4/3 - 1/(3m)$

23 · guarantees

Greedy set cover and its prices

Greedy set cover: buy the set with the least cost per newly covered element. Charge each new element that price.

price lemma

For every set $S$: $\sum_{e \in S} \mathrm{price}_e \le H_{|S|}\, c_S$.

why

While some of $S$ was still uncovered, $S$ itself was on offer at $c_S$ divided by what it still covered, and greedy never pays more than the best offer. The last element of $S$ costs at most $c_S$, the one before at most $c_S/2$, and so on: $H_{|S|}\,c_S$. Add over an optimal cover to get $\mathrm{ALG} \le H_d \cdot \mathrm{OPT}$.

full proof in the notes (N)

Johnson 1974; Lovász 1975; Chvátal 1979. Unit 22: $(1-\varepsilon)\ln n$ is NP-hard, so this is optimal.

tight family

Singletons $\{i\}$ at cost $L/(i+1)$, and the whole universe at $L + 1$ ($L = \mathrm{lcm}(1..n)$). Greedy takes every singleton, at total cost $L \cdot H_n$.

instancegreedy / OPTbound
tight, $n = 8$2.715$H_8 = 2.718$
tight, $n = 16$3.381$H_{16} = 3.381$
20 random (120 elements, 80 sets)mean 1.173, max 1.302$H_d \approx 3.6$

Lab then, optima by CP-SAT.

23 · guarantees · example

Greedy set cover, on five elements

Elements 0–4. Sets: $S_0 = \{2\}$ cost 5, $\ S_1 = \{0\}$ cost 1, $\ S_2 = \{1,2,3,4\}$ cost 6, $\ S_3 = \{0,1,3,4\}$ cost 4.

greedy, step by step
stepcost per new elementbuysprices charged
1$5,\ 1,\ \tfrac64,\ \tfrac44$S1 (tie, lower index)element 0: 1
2$5,\ \cdot,\ \tfrac64,\ \tfrac43$S31, 3, 4: $\tfrac43$ each
3$5,\ \cdot,\ 6,\ \cdot$S0element 2: 5

Total $1 + 4 + 5 = $ 10 $=$ the sum of the prices.

the optimum

S1 $+$ S2: cost 7. Greedy's step 2 looked cheapest ($\tfrac43$ against $\tfrac32$) but left element 2 to be bought alone at 5.

the price lemma, checked

On S2, four elements, cost 6: its prices are $\tfrac43 + 5 + \tfrac43 + \tfrac43 = 9 \le H_4 \cdot 6 = 12.5$.

On S1: $1 \le H_1 \cdot 1 = 1$.

Adding over the optimal cover: $10 \le 12.5 + 1$, so greedy is within $H_4 \approx 2.08$ of optimal. Actual ratio $10/7 = 1.43$.

section 2

Packings

Objects no single choice can serve twice.

23 · packings

Vertex cover by matching; k-center by farthest-first

vertex cover

Take a maximal matching $M$ (scan edges, keep those with both ends free). Cover: all $2|M|$ endpoints (matching-based vertex cover).

  • Feasible: an uncovered edge could have joined $M$.
  • $\mathrm{OPT} \ge |M|$: matching edges share no vertex, so each needs its own.

Tight on $K_{n,n}$: $2n$ against $n$. UGC-hard to beat (unit 22).

Measured, G(n, p) with n = 50 to 200: mean 1.53–1.59, worst 1.74.

k-center (Gonzalez 1985)

$k$-center by farthest-first traversal: start anywhere; repeatedly add the point farthest from the chosen centres. Radius $r$ = the farthest distance left.

  • The $k$ centres and the final farthest point are $k + 1$ points pairwise $\ge r$ apart: a packing witness.
  • Two share an optimal centre, so $r \le 2\,\mathrm{OPT}$ by the triangle inequality.

NP-hard to beat $2 - \varepsilon$ (Hsu & Nemhauser 1979).

Measured, 80 points: mean 1.64 (k = 3), 1.42 (k = 6), 1.28 (k = 10); worst 1.91.

section 3

Metric TSP

Trees, matchings, Euler, and a shortcut.

23 · metric TSP

The double tree: 2

The double-tree algorithm for metric TSP.

012 345 walk 0 1 2 4 5 4 2 1 0 3 0 → tour 0 1 2 4 5 3

Solid: the MST. Dashed: the one shortcut, replacing 5 → 4 → 2 → 1 → 0 → 3.

  1. $\mathrm{MST} \le \mathrm{OPT}$ (minimum spanning tree): delete one edge of the optimal tour and a spanning path remains.
  2. Walk around the tree, using every edge twice: length $2\,\mathrm{MST}$.
  3. Skip vertices already visited (shortcutting). Each skip replaces a path by one edge, no longer by the triangle inequality.

So $\mathrm{tour} \le 2\,\mathrm{MST} \le 2\,\mathrm{OPT}$. The walk's shortcut is exactly a preorder of the tree.

Measured, 30 instances with $n \le 60$: mean 1.30–1.37, worst 1.49.

without the triangle inequality

Step 3 fails, and unit 22's Hamiltonian-cycle gadget shows no ratio at all is possible.

23 · metric TSP

Christofides: 3/2

Christofides' algorithm, five steps, each a unit of the course.

  1. MST $T$ (unit 13). $w(T) \le \mathrm{OPT}$.
  2. Odd vertices $O$ of $T$: an even number (handshake lemma).
  3. Min-weight perfect matching $M$ on $O$ (unit 15's blossom, weighted). $w(M) \le \mathrm{OPT}/2$.
  4. Euler circuit of $T + M$: every degree is now even.
  5. Shortcut: triangle inequality.
why the matching costs at most half the tour

Shortcut the optimal tour to visit only $O$: length $\le \mathrm{OPT}$. Its edges alternate between two perfect matchings on $O$. The cheaper is $\le \mathrm{OPT}/2$, and $M$ is cheaper still.

ndouble treeChristofidesMST/OPTM/OPT
201.323 (max 1.486)1.112 (1.194)0.8190.337
401.301 (1.446)1.101 (1.130)0.8300.336
601.370 (1.443)1.136 (1.191)0.8670.332

Lab then: 10 instances per size, mean (max), optima by CP-SAT's circuit constraint (under 2 s on average).

45 years at 3/2

Christofides (1976) and Serdyukov (1978). Karlin, Klein & Oveis Gharan (2021): $3/2 - 10^{-36}$, by sampling a random spanning tree from the max-entropy distribution fitted to the Held–Karp LP.

23 · metric TSP · example

Both TSP algorithms, on six points

The six points of the double-tree figure, distances rounded to integers (one unit = 10 px).

012345
0·816101723
1·9121317
2·1499
3·1018
4·8
the lower bounds

MST: $01, 03, 12, 24, 45$ = $8 + 10 + 9 + 9 + 8 =$ 44 $\le$ OPT.

Odd vertices of the MST: 3 and 5 (leaves). Their only perfect matching: edge $35$, weight 18 $\le$ OPT/2.

Optimal tour (brute force): $0\,1\,2\,5\,4\,3$, length 54. Check: $44 \le 54$ and $18 \le 27$.

algorithmtourlengthpromised at most
double tree0 1 2 4 5 362$2 \cdot 44 = 88$
Christofides0 3 5 4 2 162$44 + 18 = 62$
optimum0 1 2 5 4 354

Both tours are the same cycle traversed from different ends: ratio $62 / 54 = 1.15$. Christofides lands exactly on its own bound $w(T) + w(M) = 62$, because shortcutting its Euler circuit $0\,3\,5\,4\,2\,1\,0$ saved nothing.

The optimum avoids the long edge 35 (18) by visiting 5 from 2 and 4, and 3 from 4 and 0.

section 4

Scheduling

And the distance between guarantee and practice.

23 · scheduling

List scheduling and LPT (Graham 1966, 1969)

$n$ jobs, $m$ identical machines, minimise the makespan (identical machines). Lower bounds: $\mathrm{OPT} \ge \sum_j p_j / m$ and $\mathrm{OPT} \ge \max_j p_j$.

list scheduling: each job to the least-loaded machine

Let job $j$ finish last. Its machine was least loaded, so it held $\le (\sum p - p_j)/m$:

$$\begin{aligned} C &\le \tfrac{1}{m}\textstyle\sum p + (1 - \tfrac1m)\,p_j \\ &\le (2 - \tfrac1m)\,\mathrm{OPT}\end{aligned}$$
LPT: sort longest first

If the last job $j$ sets the makespan and $j > m$, then $p_j \le p_{m+1}$ and two of the first $m+1$ jobs share a machine in OPT: $p_j \le \mathrm{OPT}/2$, giving $3/2$. A finer counting argument gives $4/3 - 1/(3m)$.

$n / m$list sched.LPT
12 / 31.135 (1.282)1.025 (1.070)
30 / 51.107 (1.233)1.012 (1.030)
60 / 101.131 (1.178)1.012 (1.027)

20 instances each, times uniform on 1..100, mean (max).

tight familym = 3m = 10
$m(m-1)$ ones, then $m$: list sched.5/319/10
pairs $2m{-}1 \dots m{+}1$, three $m$: LPT11/939/30

Better: a PTAS (Hochbaum & Shmoys 1987) and, for fixed $m$, an FPTAS (Sahni 1976). Strongly NP-hard when $m$ is part of the input, so no FPTAS then.

23 · scheduling · example

The tight families, on seven jobs

six jobs of 1, then one of 3; three machines

List scheduling spreads the ones evenly: loads $2, 2, 2$. The 3 then lands on a machine with 2: makespan 5.

Optimum: the 3 alone, three ones on each other machine: 3. Ratio $5/3 = 2 - \tfrac13$, exactly the bound.

LPT places the 3 first and then the ones: 3, optimal.

jobs 5, 5, 4, 4, 3, 3, 3; three machines
jobgoes toloads after
5, 5, 4one each5, 5, 4
4the 45, 5, 8
3a 58, 5, 8
3the other 58, 8, 8
3any11, 8, 8

Optimum: $\{5,4\}, \{5,4\}, \{3,3,3\}$, makespan 9. LPT's ratio $11/9 = \tfrac43 - \tfrac19$, exactly its bound for $m = 3$.

23 · beyond

Local search as an approximation algorithm: k-median

$k$-median: open $k$ facilities, minimising the sum of distances from clients to their nearest open facility (k-center minimises the maximum).

Arya et al. (2004)

Local search that swaps up to $p$ facilities at a time, stopping at a local optimum, is a $(3 + 2/p)$-approximation: local search with a guarantee.

The proof pairs each optimal facility with a swap and adds up the local optimality inequalities of all the swaps: the same "compare against OPT piece by piece" as the price lemma.

k-medianratio
single swaps5
$p$ swaps$3 + 2/p$
LP-based (Byrka et al. 2015, and later)below 2.7
NP-hard (Jain, Mahdian & Saberi 2002)$1 + 2/e \approx 1.736$

To stop in polynomial time, accept a swap only if it improves by a factor $1 - \varepsilon/\mathrm{poly}(n)$. That costs a $(1 + \varepsilon)$ factor in the ratio.

Unit 26 uses local search for speed; this is local search with a proof.

23 · lab

Lab 23 — what you build

about 2½ hours · uv run co lab 23
  1. Greedy set cover with prices, $H_k$, and the tight family.
  2. Packings: maximal-matching vertex cover; farthest-first k-center with its witness.
  3. Prim and the double tree.
  4. Christofides: odd vertices, Hierholzer, and the composition.
  5. List scheduling and LPT, with both tight families.
uv run co test 23
uv run co then 23     # ratios against CP-SAT optima · tight families · the lower bounds themselves

23 · checkpoint

Done when

checkpoint
  • All five lab steps are ✓.
  • Your Christofides never exceeds 1.5× the optimum on instances you can solve exactly, and you can point at the line of code for each step of the proof.
  • For each algorithm you can name its lower bound, its tight family, and how far random instances sit from both.

Reading

Williamson & Shmoys (2011), ch. 1–2.
Vazirani, Approximation Algorithms (2001), ch. 2–3.
Arya et al., SIAM J. Comput. 33 (2004).
Karlin, Klein & Oveis Gharan, STOC 2021.

Next

24 LP rounding and primal–dual: weighted vertex cover, randomized set cover, facility location · 26 metaheuristics.