the weighted 5-cycleweights $3, 2, 2, 3, 4$ on $v_0, \dots, v_4$ LP 7 (all ½), optimum 8, threshold rounding 14, primal–dual 10the optimal cover$v_0, v_1, v_3$: $3 + 2 + 3 = 8$ the cheapest three vertices touching all five edges (filled)the primal–dual cover$v_0, v_1, v_2, v_3$: $3 + 2 + 2 + 3 = 10$ dual sum 6, so its own certificate says $10 \le 2 \cdot 6$ (filled)the three-element examplesets $\{0,1\}, \{1,2\}, \{0,2\}$, unit cost each set misses one element; LP $= 1.5$ at $x = \tfrac12$, OPT $= 2$. It is GF(2)k with $k = 2$the 4-cycle instance$S_0 = \{0,1\}$: 3, $\ S_1 = \{1,2\}$: 2, $\ S_2 = \{2,3\}$: 3, $\ S_3 = \{3,0\}$: 2 elements 0–3, set: cost, $f = 2$. Primal–dual buys $S_3, S_0, S_1$ for 7; the optimum $S_1 + S_3$ costs 4set $S_0$$\{0,1\}$, cost 3 bought second, when element 1 raised $y_1$; redundant in the endset $S_1$$\{1,2\}$, cost 2 bought third, when element 2 raised $y_2$; in the optimumset $S_2$$\{2,3\}$, cost 3 never boughtset $S_3$$\{3,0\}$, cost 2 bought first, when element 0 raised $y_0$ by 2; in the optimumthe instance on a linefacilities A at 0 and B at 10, opening cost 4 each; clients at 1, 2, 9 distance is the gap on the line. Optimum: open both, cost 12facility Aat position 0, opening cost 4 fully paid by $c_0$ and $c_1$ at time 3.5: opens thenfacility Bat position 10, opening cost 4 fully paid by $c_2$ alone at time 5: opens thenclient $c_0$at position 1: 1 from A, 9 from B pays A from time 1; freezes at $\alpha = 3.5$client $c_1$at position 2: 2 from A, 8 from B pays A from time 2; freezes at $\alpha = 3.5$client $c_2$at position 9: 9 from A, 1 from B pays B from time 1; freezes at $\alpha = 5$
Part V · where the trunks converge · spine
24
LP rounding and the primal–dual method
One lower bound for everything: the LP relaxation. Round its solution, or grow its dual and buy what the dual pays for. Either way, its integrality gap is the limit.
needs 23, 03~1½ h slides + 2½–3 h lablab: uv run co lab 24
24 · overview
The route
1 · rounding
Vertex cover at ½; half-integrality; randomized rounding for set cover and its union bound.
Kn and GF(2)k: instances that bound every LP-based proof.
4 · measured
LP, optimum, algorithm on the same instances, and where greedy wins.
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.
Threshold rounding: take $v$ iff $x_v \ge \tfrac12$. Feasible: $x_u + x_v \ge 1$ forces one of them to $\ge \tfrac12$. Cost: every chosen $v$ has $w_v \le 2 w_v x_v$, so the cost is $\le 2\,\mathrm{LP} \le 2\,\mathrm{OPT}$.
half-integrality (Nemhauser & Trotter 1975)
Every vertex of this polytope has all $x_v \in \{0, \tfrac12, 1\}$.
C5: LP 2.5, OPT 3, rounding takes all 5.
Lab then, 24 weighted random graphs (weights 1–20):
LP / OPT
rounding / OPT
primal–dual / OPT
half-integral
0.89
1.74–1.75
1.38–1.40
24 / 24
24 · rounding · example
Rounding a weighted 5-cycle
Vertex weights inside the circles. The LP puts ½ on every vertex.
method
takes
weight
/ OPT
LP relaxation
all at ½
7
0.875
optimum (brute force)
$v_0, v_1, v_3$
8
1
threshold at ½
all five
14
1.75
primal–dual (section 2)
$v_0, v_1, v_2, v_3$
10
1.25
reading it
Every $x_v = \tfrac12$ meets the threshold, so rounding pays the full weight 14, exactly $2 \times \mathrm{LP}$: the guarantee is met with equality. The integrality gap of this instance is $8 / 7$, so no rounding of this LP can prove better than 1.14 here.
and $t$ rounds with probability $\le e^{-t}$. The union bound over $n$ elements: $\Pr[\text{not a cover}] \le n e^{-t}$.
Cost. $\mathbb{E}[\text{cost}] \le t \cdot \mathrm{LP}$, by linearity of expectation. Take $t \approx \ln n$.
combining both: notes (N)
Lab then: failure rate of the whole cover, 4 000 draws over 10 instances (150 elements):
t
measured
bound $150e^{-t}$
1
0.896
≥ 1
2
0.728
≥ 1
4
0.123
≥ 1
7
0.0033
0.137
The union bound is loose by 40× at $t = 7$. Tests check the per-element probabilities exactly, against simulation.
Raghavan & Thompson (1987) introduced randomized rounding for routing, where Chernoff bounds are needed because loads add up. For set cover the union bound alone gives $O(\log n)$.
24 · rounding · example
Randomized rounding, on three elements
Elements $\{0, 1, 2\}$, unit-cost sets $\{0,1\}$, $\{1,2\}$, $\{0,2\}$. Any two sets cover; one doesn't. OPT $= 2$.
The LP puts $x = \tfrac12$ on each set: every element is in two sets, $\tfrac12 + \tfrac12 = 1$. LP $= 1.5$.
element 0, one round
It is missed only if neither $\{0,1\}$ nor $\{0,2\}$ is picked: $(1 - \tfrac12)(1 - \tfrac12) = \tfrac14$. The general bound says $\le e^{-1} = 0.37$.
$t$
miss, one element
union bound $3e^{-t}$
expected cost
1
0.25
1.10
1.50
2
0.0625
0.41
2.25
3
0.0156
0.15
2.63
5
0.00098
0.020
2.91
Misses fall like $4^{-t}$, faster than the bound's $e^{-t}$. The cost rises towards 3, all sets, as $t$ grows: more rounds buy coverage with money.
section 2
Primal–dual
Raise duals, buy primals, pay for what you bought.
For each uncovered $e$: raise $y_e$ until some set containing $e$ is tight.
Buy every tight set containing $e$.
Primal–dual set cover, Bar-Yehuda & Even (1981).
why the factor is f, the largest frequency
Each bought set is paid for by its elements' $y$, and an element sits in at most $f$ sets, so it pays at most $f$ times:
$$\begin{aligned}\text{cost} &= \textstyle\sum_{j \text{ bought}} c_j = \sum_{j \text{ bought}} \sum_{e \in S_j} y_e \\ &\le f \textstyle\sum_e y_e \le f \cdot \mathrm{LP} \le f \cdot \mathrm{OPT}\end{aligned}$$
complementary slackness, relaxed
Primal CS exact: $x_j > 0 \Rightarrow$ set $j$ tight. Dual CS relaxed: $y_e > 0 \Rightarrow$ $e$ covered at most $f$ times, not exactly once. The approximation ratio is exactly the relaxation factor.
Never solves an LP. Vertex cover is $f = 2$: a 2-approximation in linear time.
24 · primal–dual · example
Primal–dual set cover, traced
Four elements on a cycle. Sets $S_0 = \{0,1\}$ cost 3, $S_1 = \{1,2\}$ cost 2, $S_2 = \{2,3\}$ cost 3, $S_3 = \{3,0\}$ cost 2. Each element is in 2 sets: $f = 2$.
element
sets, still unpaid
raise $y$ by
tight, buy
0
S0: 3, S3: 2
2
S3 (covers 3, 0)
1
S0: 1, S1: 2
1
S0 (covers 0, 1)
2
S1: 1, S2: 3
1
S1 (covers 1, 2)
3
already covered
the bill
Bought S3, S0, S1: cost $2 + 3 + 2 = 7$.
Dual $y = (2, 1, 1, 0)$, sum 4, feasible: each set's elements pay at most its cost. So $\mathrm{OPT} \ge 4$.
Guarantee $7 \le f \cdot 4 = 8$ ✓. Optimum: S1 $+$ S3 covers everything for 4.
S0 was bought and turned out redundant: S3 and S1 already cover 0 and 1. Primal–dual has no clean-up step here; Steiner forest's reverse delete is exactly such a step.
The dual of the facility location LP. Phase 1. All $\alpha_j$ grow at rate 1. Once $\alpha_j \ge d_{ij}$, client $j$ pays $\beta_{ij} = \alpha_j - d_{ij}$ toward $i$. When $i$ is fully paid, it opens temporarily. A client stops growing (freeze) once it's tight with an open facility.
Phase 2. Temporarily open facilities conflict if a client pays both. Keep a maximal non-conflicting set, in opening order. Clients go to the nearest kept facility.
why 3 (metric), in words
Each client's $\alpha_j$ is a lower bound on what it must cost. If the facility it froze with was kept, it is within $\alpha_j$. If not, a kept facility is reachable by a three-hop detour, each hop at most $\alpha_j$ long: at most $3\alpha_j$.
full proof in the notes (N)
Jain–Vazirani, lab then:
F × C
LP integral
JV / OPT
Σα / OPT
10 × 40
10/10
1.031 (1.119)
0.990
20 × 80
10/10
1.057 (1.140)
0.995
30 × 120
10/10
1.054 (1.103)
0.992
24 · primal–dual · example
Jain–Vazirani on a line
Facilities A and B (squares, opening cost 4 each), clients at positions 1, 2, 9. Distance is the gap on the line.
time
event
1
c0 reaches A, c2 reaches B: both start paying
2
c1 reaches A; A now collects $(t-1) + (t-2)$
3.5
A has collected $2.5 + 1.5 = 4$: opens; c0, c1 freeze at $\alpha = 3.5$
5
B has collected $5 - 1 = 4$ from c2: opens; $c_2$ freezes at $\alpha = 5$
the result
No client pays both, so both are kept. Cost: opening $4 + 4$, serving $1 + 2 + 1$: 12. The dual $\sum\alpha = 3.5 + 3.5 + 5 = 12$ is a lower bound, so this is optimal, and the certificate proves it.
Pairs $(s_i, t_i)$ in a weighted graph: the cheapest edge set connecting every pair. The LP has one covering constraint per cut separating some pair, exponentially many.
Primal–dual (Agrawal, Klein & Ravi 1995; Goemans & Williamson 1995): grow duals on all active components at once, buy tight edges, then reverse delete unnecessary ones. Ratio 2, by showing active components touch at most twice as many bought edges as there are components, on average.
iterative rounding (Jain 2001)
Steiner network: each pair needs $r_{ij}$ edge-disjoint paths. Theorem: every extreme point of the LP has some edge with $x_e \ge \tfrac12$. Algorithm: solve, fix that edge to 1, update the residual requirements, re-solve. Ratio 2.
The proof is a counting argument on tight constraints forming a laminar family, the same structure as the matroid intersection polytope (unit 13). It set off a line of results on degree-bounded spanning trees (Singh & Lau 2007: optimal cost, degrees exceeded by at most 1).
section 3
Integrality gaps
The limit of every LP-based proof.
24 · gaps
Instances that realise the gap
integrality gap
$\sup_I \mathrm{OPT}(I) / \mathrm{LP}(I)$ for minimisation. An algorithm proved via $\mathrm{ALG} \le \rho\,\mathrm{LP}$ has $\rho \ge$ the gap, since it can't beat OPT on the worst instance.
Gap instances. Vertex cover, $K_n$. All ½ gives $n/2$. Two uncovered vertices leave their edge uncovered, so $\mathrm{OPT} = n - 1$. Gap $2 - 2/n$.
Set cover, GF(2)k. The smallest case, $k = 2$: three sets on three elements, each set missing one element; LP 1.5, OPT 2: the three-element example of section 1. Elements and sets are the nonzero vectors; set $v$ holds $\{u : u \cdot v = 1\}$. Every set has $2^{k-1}$ elements, so $x = 2^{1-k}$ gives LP $< 2$. Sets $v_1, \dots, v_r$ miss every nonzero $u$ orthogonal to all of them, so $\mathrm{OPT} = k$.
k
sets
LP
OPT
OPT/LP
greedy
primal–dual
3
7
1.750
3
1.71
3
4
4
15
1.875
4
2.13
4
8
5
31
1.938
5
2.58
5
16
6
63
1.969
6
3.05
6
32
7
127
1.984
7
3.53
7
64
a limit on proofs, not on algorithms
Greedy is optimal on every member. The gap says no analysis against this LP can certify better than $\approx \tfrac12\log_2 n$ here, not that finding a good cover is hard.
24 · measured
LP bound, optimum, algorithm: what the measurements say
Set cover, 10 instances, 150 elements and 100 sets, optimum by CP-SAT:
algorithm
mean / OPT
worst
guarantee
LP bound
0.937
1.000
—
randomized, $t = 7$, best of 20
1.728
2.140
$O(\log n)$
primal–dual
1.964
2.556
$f = 21$
greedy (unit 23)
1.148
1.326
$H_d \approx 5$
Greedy beats both LP-based algorithms on random set cover, while guaranteeing about the same.
Primal–dual beats rounding on weighted vertex cover (1.39 against 1.75), with the same guarantee of 2. Rounding takes every half.
The LP is tight on random facility location: integral 30 times of 30.
The gap families are built by hand. Nothing random came close to them.
An approximation ratio is a certificate, and practice asks a different question. Unit 26 answers it with heuristics, and unit 28 with a method for comparing them honestly.
24 · lab
Lab 24 — what you build
about 2½–3 hours · uv run co lab 24
Vertex cover LP and threshold rounding.
Randomized rounding for set cover, with exact miss probabilities and the union bound.
Primal–dual set cover.
Jain–Vazirani: event-driven dual ascent in exact arithmetic, pruning, assignment.
Integrality gaps: $K_n$ and GF(2)k.
uv run co test 24
uv run co then 24 # LP · optimum · algorithm on 72 instances · failure rates · out/then.png
24 · checkpoint
Done when
checkpoint
All five lab steps are ✓.
You can exhibit an instance realising the integrality gap of a given LP, and explain why it proves that no rounding of that LP can beat that ratio.
You can say why greedy solves that same instance optimally without contradicting anything.