LP Relaxation & Rounding
Solve the relaxed problem, then round: vertex cover, set cover and integrality gaps.
Integer programs express almost every NP-hard optimization problem, and linear programs are solvable in polynomial time. Drop the word "integer", solve, and round the fractions back: the art lies in the rounding, and the limit of the art is one number per relaxation, its integrality gap.
What you’ll learn
- Write weighted vertex cover and set cover as integer programs, relax them, and prove that rounding the vertex-cover LP at gives a 2-approximation.
- Define the integrality gap and use it to bound what any LP-based analysis can prove: on for vertex cover, for set cover.
- Use LP duality to design and analyze a primal–dual algorithm that never solves an LP.
- Analyze randomized rounding for set cover with the union bound, and the algorithm for MAX-SAT that combines two roundings.
- Explain the Goemans–Williamson algorithm for MAX-CUT: a semidefinite relaxation rounded by a random hyperplane, with ratio .
Relax, solve, round
In weighted vertex cover every vertex has a weight , and you want a cover of least total weight. The matching algorithm of the Optimized lesson ignores weights and can fail badly: on a star whose center weighs 10 and whose four leaves weigh 1, it may pay 11 where 4 suffice. Write the problem as an integer program, with meaning " is in the cover":
Linear programs are solvable in polynomial time, by the ellipsoid method (Khachiyan, 1979) or by interior-point methods (Karmarkar, 1984), and the simplex method is fast in practice. So an optimal fractional solution is a computable lower bound. Rounding it turns it into a cover.
A cover. Every edge has , so the larger of the two values is at least , and that endpoint is in :
Cost. Every vertex of has , so rounding it up to 1 at most doubles its contribution:
The vertex-cover LP has a remarkable structure: it always has an optimal solution with every , and then some minimum-weight cover contains every vertex valued 1 and avoids every vertex valued 0 (Nemhauser & Trotter, 1975). The Optimal lesson Parameterized Algorithms & Kernelization turns this into a kernel with at most vertices.
For vertex cover, the complete graph with unit weights is the wall. Setting every satisfies all edge constraints, and adding the constraints of all edges, , shows that nothing is cheaper: . But a cover that leaves out two vertices leaves their edge uncovered, so .
What is for unit-weight vertex cover on ?
Show the answer
1.8
and , so the ratio is . In general it is , which tends to 2: no analysis against this LP can prove a ratio below 2.
Duality and the primal–dual method
Every linear program has a dual that bounds it from the other side. For the vertex-cover LP, put a variable on every edge, a payment that edge offers toward covering itself; no vertex may be overpaid:
The primal–dual method, introduced for this problem by Bar-Yehuda and Even (1981), builds a cover and a dual solution side by side and never solves an LP. Scan the edges; whenever one is still uncovered, raise its payment until one of its endpoints becomes tight (its constraint holds with equality), and put the tight endpoints in the cover.
def primal_dual_vc(edges, w):
slack = dict(w) # w[v] minus the payments made to v
y, cover = {}, set()
for u, v in edges:
if u in cover or v in cover:
continue # this edge is already covered
d = min(slack[u], slack[v]) # raise y_uv until u or v is tight
y[(u, v)] = d
slack[u] -= d
slack[v] -= d
cover |= {x for x in (u, v) if slack[x] == 0}
return cover, sum(y.values()) # a cover, and a dual value <= OPT
w = {'c': 10, 'a': 1, 'b': 1, 'd': 1, 'e': 1}
star = [('c', 'a'), ('c', 'b'), ('c', 'd'), ('c', 'e')]
cover, dual = primal_dual_vc(star, w)
print(sorted(cover), dual) # ['a', 'b', 'd', 'e'] 4On the star, each edge pays 1 and makes its leaf tight, while the center's slack falls from 10 to 6 and it never becomes tight. The cover is the four leaves, weight 4, and the dual value 4 proves it optimal. With unit weights both endpoints become tight at once: this is exactly the maximal-matching algorithm.
A cover. After an uncovered edge is processed, at least one of its endpoints is tight, hence in :
A feasible dual. Payments stop as soon as a vertex is tight, so no slack becomes negative, and weak duality applies:
Tight vertices are paid for by edges. Each is tight, and a payment is counted once for each endpoint of in , at most twice:
In the primal–dual analysis, where does the factor 2 come from?
- From rounding fractional values of at least up to 1
- From weak duality, which loses a factor of 2
- Each payment is counted once for every endpoint of in the cover, and an edge has two endpoints
- From the approximation ratio of the LP solver
Show the answer
C. Each payment is counted once for every endpoint of in the cover, and an edge has two endpoints
counts once per endpoint of in , so at most twice. Weak duality, , loses nothing.
Randomized rounding for set cover
For weighted set cover, with sets of weights over a universe of elements, the LP relaxation is:
Threshold rounding still works, but with threshold , where is the largest number of sets containing one element, and it gives ratio , which can be as large as . Randomized rounding (Raghavan & Thompson, 1987) reads as a probability instead: in each of independent rounds, take every set with probability , and output the union of all the sets taken.
One element, one round. Using and the LP constraint of element :
Many rounds. With independent rounds, and the union bound over the elements:
Cost. By linearity of expectation each round costs on average, and by Markov's inequality the total reaches four times its mean with probability at most :
Together. For the output is a cover of cost below with probability at least ; repeat until it is.
Greedy already achieves , so why bother? Because randomized rounding is a method. It applies to any covering LP, including ones with side constraints, to routing problems (Raghavan and Thompson's original motivation), and, with Chernoff bounds in place of the union bound, to packing problems whose constraints must hold with high probability.
Why does randomized rounding for set cover use about rounds instead of one?
- One round would cost more than the LP optimum
- The LP must be re-solved after each round
- To make the expected cost equal to
- In one round an element can stay uncovered with probability about ; after rounds this is at most , small enough for a union bound over all elements
Show the answer
D. In one round an element can stay uncovered with probability about ; after rounds this is at most , small enough for a union bound over all elements
One round covers each element with probability at least , a constant, so with many elements some would almost surely be missed. Independent rounds multiply the failure probabilities, and beats the terms of the union bound. The price is the factor in the cost.
Beyond thresholds: MAX-SAT and MAX-CUT
In MAX-SAT you are given clauses, each an OR of literals, and want an assignment that satisfies as many as possible. Two very different algorithms each fail where the other shines. A uniformly random assignment satisfies a clause of literals with probability : excellent for long clauses, only for a single literal. LP rounding solves the relaxation below and then sets each variable true with probability .
| Clause length | Random assignment, | LP rounding, | Average |
|---|---|---|---|
| 1 | 0.5 | 1 | 0.75 |
| 2 | 0.75 | 0.75 | 0.75 |
| 3 | 0.875 | 0.7037 | 0.7894 |
| 4 | 0.9375 | 0.6836 | 0.8105 |
Random assignment. Since :
LP rounding, by the bound in the caption above:
Keep the better one. Its expectation is at least the average of the two, and the table's last column is at least for every :
MAX-CUT asks for a split of the vertices into two sides that cuts as many edges as possible. A random split cuts half of them in expectation, and for two decades was essentially the best ratio known. Goemans and Williamson (1995) replaced the LP by a semidefinite program (SDP): relax each side label to a unit vector .
Pick a uniformly random direction and put vertex on side . Projected onto the plane of and , the direction is uniform on a circle, so the hyperplane separates the two vectors exactly when it falls inside the angle between them:
Compare with the edge's SDP term, , at the worst angle:
Sum over the edges by linearity of expectation:
import math
# alpha_GW: the worst ratio between Pr[cut] = theta/pi and the SDP term (1 - cos theta)/2
N = 10**6
alpha, theta = min((2 / math.pi * t / (1 - math.cos(t)), t)
for t in (math.pi * i / N for i in range(1, N + 1)))
print(round(alpha, 5), round(math.degrees(theta), 1)) # 0.87857 133.6A brute-force minimization over a million angles. The worst angle is about .
The 5-cycle shows that this SDP cannot do much better: consecutive vectors apart give an SDP value of , while the best cut has 4 edges, a ratio of . And if the Unique Games Conjecture holds, beating by any constant is NP-hard (Khot, Kindler, Mossel & O'Donnell, 2007, with the "Majority is Stablest" theorem of Mossel, O'Donnell & Oleszkiewicz, 2010): see Hardness of Approximation & the PCP Theorem.
Key takeaways
- An LP relaxation gives a computable lower bound ; rounding the vertex-cover LP at gives a 2-approximation for weighted vertex cover, and the LP is half-integral (Nemhauser & Trotter).
- The integrality gap limits every analysis against a relaxation: on for vertex cover, more than for set cover.
- Primal–dual algorithms raise dual payments until constraints become tight and pay only for tight elements; the ratio is how many times one payment can be counted, 2 for vertex cover and for set cover.
- Randomized rounding with rounds, the union bound and Markov's inequality gives for set cover; combining two roundings gives for MAX-SAT, and an SDP with a random hyperplane gives for MAX-CUT.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
The vertex-cover LP has integrality gap on . Which statement follows?
- No polynomial-time algorithm can achieve a ratio below 2 for vertex cover
- Rounding at returns an optimal cover of every complete graph
- On some graphs the LP optimum is smaller than
- No proof of the form for all graphs can have
Show the answer
D. No proof of the form for all graphs can have
On , , so any valid for every is at least 2. The gap limits this proof technique; whether some other algorithm beats 2 is a different, open question tied to the Unique Games Conjecture.
With all weights equal to 1, what does the primal–dual vertex-cover algorithm do?
- It solves the LP and rounds at
- It takes both endpoints of every uncovered edge it meets: the maximal-matching algorithm
- It repeatedly takes a vertex of maximum degree
- It returns an optimal cover, certified by the dual
Show the answer
B. It takes both endpoints of every uncovered edge it meets: the maximal-matching algorithm
An uncovered edge raises its payment to , which makes both endpoints tight at once, so both enter the cover; the edges that pay form a maximal matching.
In randomized rounding for set cover, an element stays uncovered in one round with probability at most . With independent rounds and elements, what does the union bound give for the probability that some element stays uncovered?
- At most
- At most
- At most
- At most
Show the answer
C. At most
Each element survives all rounds with probability at most , by independence across rounds; summing over the elements gives , which is at most once .
In the Goemans–Williamson analysis, an edge whose vectors meet at angle is cut with probability and contributes to the SDP. At which angle is the ratio of the two smallest?
- At , opposite vectors
- As , where both quantities vanish
- At , where the ratio is 1
- At , where the ratio is about
Show the answer
D. At , where the ratio is about
The ratio equals 1 at and at , tends to infinity as (the SDP term vanishes like ), and reaches its minimum near .
Further reading
- D. P. Williamson & D. B. Shmoys, The Design of Approximation Algorithms (Cambridge University Press, 2011), chapters 1, 5, 6 and 7.
- M. X. Goemans & D. P. Williamson, "Improved approximation algorithms for maximum cut and satisfiability problems using semidefinite programming," Journal of the ACM 42(6) (1995), 1115–1145.
- M. X. Goemans & D. P. Williamson, "New 3/4-approximation algorithms for the maximum satisfiability problem," SIAM Journal on Discrete Mathematics 7(4) (1994), 656–666.
- P. Raghavan & C. D. Thompson, "Randomized rounding: a technique for provably good algorithms and algorithmic proofs," Combinatorica 7(4) (1987), 365–374.
- R. Bar-Yehuda & S. Even, "A linear-time approximation algorithm for the weighted vertex cover problem," Journal of Algorithms 2(2) (1981), 198–203.