Relax an integer program to an LP/SDP, then round with coins: SetCover → O(ln n); MaxCut → Goemans–Williamson 0.878 via a random hyperplane. Then solving LP by randomization (Seidel, MSW, Clarkson).
Course 2-INF-135/15 Pravdepodobnostné algoritmy, LS 2025/26.
Source slides: 04_metody78.pdf (24 pages). Continues the methods block.
This deck is the randomized-rounding method and its richer cousin
semidefinite rounding, followed by a separate topic: using randomization to
solve the LP itself.
Where we are
The methods block has been a catalogue of tricks. Two more, both built on
linear programming:
Method A — randomized rounding. Hard combinatorial problems are integer
programs. Drop the integrality (relax), solve the easy continuous problem, then
turn the fractional answer back into an integral one by flipping biased coins.
Method B — randomized LP solving. The LP we lean on is itself only
“easy” in theory. In small dimension we can solve it very fast by feeding the
constraints in random order.
The unifying object is the LP. Part A uses an LP oracle as a subroutine; part B
builds one. Keep them mentally separate — they answer different questions.
Part A — Relaxation and rounding
A.0 The relaxation–rounding recipe
The basic LP task: minimize cTx subject to Ax≤b, x≥0.
Complexity of LP.
Over R (continuous x): the simplex method is polynomial on
average but exponential in the worst case; ellipsoid/interior-point methods are
polynomial. So a real LP is “easy”.
Over Z (integer programming): only exponential algorithms are
known — integer programming is NP-hard.
That gap is the whole game. When a problem is naturally an integer program, we do:
Relax — replace each discrete constraint (e.g. yi∈{0,1}) by a
continuous one (0≤yi≤1). Call it LPrel.
Solve the relaxation to get a fractional optimum xrel∗.
Roundxrel∗ into a feasible integralx.
Randomized rounding = step 3 done with coins: read each fractional value
xi∗∈[0,1] as a probability and set the integer bit by a coin flip with
that bias.
Two things must be checked after rounding: feasibility (is the rounded x still
a valid solution?) and cost (how much worse than c(x∗), hence than the true
integral optimum?). The relaxed optimum is always a lower bound on the integral
optimum (the integral solutions are a subset of the feasible region), so any factor
we lose against c(x∗) is also a factor against the true OPT — that is exactly what
an approximation ratio is.
A.1 SetCover — the model problem
Input. A universe X={x1,…,xn}, a family of sets
S={S1,…,Sm} with Si⊆X, and weights w:S→R+.
Output. A choice I⊆{1,…,m} minimizing
∑i∈Iw(Si) such that ⋃i∈ISi=X — cover every element as
cheaply as possible.
As an integer program. Let yi∈{0,1} indicate “set Si is chosen”.
Constraint (1) says every element is in at least one chosen set. The relaxation
LPrel replaces (2) with 0≤yi≤1.
A.2 SetCover — deterministic rounding (factor f)
A warm-up before the randomized version, to see what “rounding” even means.
Let y∗=(y1∗,…,ym∗) be the optimal relaxed solution and define the
frequency
f=imax{number of sets that contain xi}
(the most-covered element’s multiplicity). Round by a fixed threshold:
yi=1⟺yi∗≥f1.
Claim: y is feasible. Take any element x. It lies in at most f sets, and by
constraint (1) the fractional values on those sets sum to ≥1. With ≤f
nonnegative numbers summing to ≥1, at least one must be ≥1/f — so that
set gets rounded up to 1 and covers x.
Claim: c(y)≤f⋅c(y∗). Whenever yi=1 we had yi∗≥1/f, i.e.
1≤fyi∗; and when yi=0 trivially 0≤fyi∗. So termwise
yi≤fyi∗, hence
c(y)=i∑yiw(Si)≤fi∑yi∗w(Si)=fc(y∗).
Deterministic rounding gives an f-approximation. Clean, but f can be as
large as m. Randomization will replace f by O(lnn) — far better when sets
are large.
A.3 SetCover — randomized rounding (O(lnn), and it is optimal)
Now read the fractional values as probabilities. With y∗ the relaxed optimum,
define a random y by
yi=1with probability yi∗,independently.
Cost is right in expectation. By linearity,
E[c(y)]=i∑Pr[yi=1]w(Si)=i∑yi∗w(Si)=c(y∗).
So one rounding matches the relaxed optimum on average. The danger is
feasibility — a single rounding may leave some element uncovered.
How likely is an element to be missed? Let Si1,…,Sik be all sets
containing xi. Independence gives
Pr[xi not covered]=j=1∏k(1−yij∗)≤j=1∏ke−yij∗=e−∑jyij∗≤e−1,
using 1−t≤e−t and the LP constraint ∑jyij∗≥1. (Equivalently,
fixing the sum to 1, the product ∏(1−yij∗) is largest when all are equal
to 1/k, giving (1−1/k)k≤e−1.)
So one rounding covers each element with probability ≥1−1/e≈0.63 — good
but not enough.
Amplify by stacking roundings. Generate clnn independent roundings
y1,…,yclnn and take their union (choose a set if any copy chose it).
Then
Pr[xi covered by no yj]≤(e−1)clnn=n−c≤2n1
for a suitable constant c. Union-bounding over all n elements,
Pr[∃xi covered by no yj]≤n⋅2n1=21.
So with probability ≥21 the union is a feasible cover. Its expected
weight is ≤clnn⋅c(y∗) (each of the clnn roundings has expected cost
c(y∗)). Combining the two events (re-running the whole thing a constant number of
times) yields a feasible cover of weight O(lnn)⋅c(y∗)=O(lnn)⋅OPT.
Punchline (professor-pleaser). Randomized rounding gives an
O(lnn)-approximation for SetCover — and this is essentially optimal: unless
P=NP, no polynomial algorithm beats ratio (1−o(1))lnn
(Feige; Dinur–Steurer). The relaxation discards exactly the right amount of
structure: the LP optimum is a fractional cover, and reading it as a probability
distribution lands you on the inapproximability threshold.
A.4 MaxCut — an integer quadratic program
Randomized rounding of a linear program (SetCover) was the easy case. MaxCut forces
us to a richer relaxation.
Input. Undirected graph G=(V,E), weights w:E→Q+.
Output. A cut (S,Sˉ) of maximum total crossing weight
max∑e∈S×Sˉw(e).
Use a ±1 indicator per vertex, yi∈{−1,+1}:
(S,Sˉ)=({vi:yi=1},{vi:yi=−1}).
The product yiyj reads off the relationship:
yiyj={−1+1vi,vj on different sides (edge cut),vi,vj on the same side.
So 21(1−yiyj) is exactly the indicator “edge ij is cut”, and MaxCut
becomes a quadratic integer program:
max211≤i<j≤n∑wi,j(1−yiyj)s.t.yi2=1,yi∈Z.
The constraint yi2=1 is what makes this not an LP — it is genuinely quadratic,
and MaxCut is NP-hard. We need a relaxation that respects the quadratic structure.
Enter semidefinite programming.
A.5 Semidefinite programming (SDP) — the toolbox
An SDP optimizes over a matrix of variables instead of a vector:
Y is an n×n matrix of real variables;
maximize a linear function of the entries yi,j;
subject to linear constraints on the yi,j;
plusY symmetric and positive semidefinite (PSD):
Y⪰0⟺∀X∈Rn:XTYX≥0⟺Y has all eigenvalues≥0⟺∃U:Y=UTU.
The last form is the one we exploit: a PSD matrix is a Gram matrixY=UTU, so
its entries yi,j=ui⋅uj are inner products of vectors ui (the columns
of U). PSD = “is realizable as a set of vectors”.
Solvability. An SDP can be solved to within additive error ε in
time poly(n,log(1/ε)) (ellipsoid method — the PSD cone is
convex). So, like LP, SDP is “easy”.
Standard form S. Given symmetric real matrices C,D1,…,Dk∈Mn and
scalars d1,…,dk:
S:maxC∘Ys.t.Di∘Y=di(1≤i≤k),Y⪰0,
where A∘B=∑i,jA[i,j]B[i,j] is the Frobenius (entrywise) inner
product.
LP is a special case. If C,D1,…,Dk are all diagonal, only the
diagonal of Y matters and S degenerates to an ordinary LP. SDP strictly
generalizes LP — it sees correlations between variables, which is exactly what a
quadratic objective needs.
Quadratic and vector programs.
A quadratic program optimizes a quadratic function (integer-valued variables)
under quadratic constraints.
A vector program has vector variables v1,…,vn∈Rn
and optimizes a linear function of the inner products vi⋅vj,
under linear constraints on those inner products.
The pipeline is: strict quadratic program → vector program → SDP, and the
SDP we can solve.
A.6 MaxCut as a vector program (the relaxation)
Take the quadratic program and perform the substitution “scalar → vector,
product → inner product”:
The constraint vi⋅vi=1 says each vi is a unit vector
on the sphere Sn−1. We have relaxed “each vertex gets a sign ±1” (two
antipodal points on a line) to “each vertex gets a unit vector in Rn” —
strictly more freedom, so
OPTυ≥OPT.
As an SDP: set xij=vi⋅vj, so the Gram matrix
Y=(xij)=UTU (column i of U is vi) is PSD. Solve the SDP, recover
the vectors vi from Y=UTU. Now we must round vectors back to ±1.
A.7 Goemans–Williamson rounding — the random hyperplane
We have a fractional optimum: unit vectors x1∗,…,xn∗ with value
OPTυ. Let Θi,j be the angle between xi∗ and xj∗;
since they are unit vectors,
cosΘi,j=∥xi∗∥∥xj∗∥xi∗⋅xj∗=xi∗⋅xj∗.
The pair’s contribution to the relaxed objective is
2wi,j(1−cosΘi,j). Reading the geometry:
Θ=0⇒(1−cosΘ)=0,Θ=2π⇒1,Θ=π⇒2.
So the relaxation rewards pairs that point in opposite directions (large angle).
A good rounding should therefore put vertices with a large angle on opposite sides
of the cut. The trick:
Cut with a random hyperplane through the origin. Pick a uniformly random unit
vector p∈RSn−1 (sample each coordinate as a standard Gaussian, then
normalize) and set
S={vi:xi∗⋅p≥0},Sˉ=V∖S.
The hyperplane with normal p slices the sphere; vertices land in S or Sˉ by
which side their vector falls on.
Separation probability.
Pr[vi,vj separated]=πΘi,j.
Why. Project p onto the 2-D plane spanned by xi∗,xj∗ and let r be that
projection; only this plane matters for separating i,j. The two vectors split the
circle, and the hyperplane separates them exactly when r lands in one of the two
arcs “between” them — total arc 2Θi,j out of 2π, giving
2Θi,j/2π=Θi,j/π.
A.8 The 0.878 ratio
Let W be the (random) weight of the cut produced. By linearity and the separation
probability,
The Goemans–Williamson constantα≈0.87856 is the minimum of a
one-variable function — it comes purely from the geometry of “angle vs. chord”, not
from the graph. The deep point: a random hyperplane recovers a constant fraction
α of the relaxed value pair-by-pair, with no dependence on n.
A.9 From expectation to high probability
E[W]≥αOPT is only an average. For a maximization Monte Carlo we
must show a single run lands near its mean with constant probability — then repeat.
Let T=∑e∈Ew(e) be the total weight, and write E[W]=aT (so
a=E[W]/T). We bound p=Pr[W<(1−ε)aT]. Since always W≤T,
split the expectation by the bad event:
aT=E[W]≤p⋅(1−ε)aT+(1−p)⋅T.
Solving for p,
p≤1−a+aε1−a=1−1−a+aεaε.
Now lower-bound a. A random/greedy cut already gives ≥T/2, and
aT=E[W]≥αOPTυ≥αOPT≥α2T,
so a≥α/2. Plugging in, p≤1−c for a constant
c=Θ(ε)>0.
Amplify. Run 1/c independent rounds and keep the best cut W′:
Pr[W′≥(1−ε)aT]≥1−(1−c)1/c≥1−e−1.
Finally, since aT≥αOPT>0.87856OPT and α=0.878567…
leaves slack, we can pick ε so small that (1−ε)aT≥0.87856OPT.
Theorem (Goemans–Williamson, 1995). There is a randomized approximation
algorithm for MaxCut with approximation ratio 0.87856.
Professor-pleasers.
The relaxation is the engine: an SDP relaxation is strictly stronger than any
LP relaxation for MaxCut, because the quadratic objective lives on inner
products, and only PSD matrices encode “these are real vectors”.
The rounding is one random hyperplane — astonishingly, it loses only a factor
0.878 uniformly.
It is conjecturally optimal: under the Unique Games Conjecture (Khot et al.),
no polynomial algorithm beats 0.87856 for MaxCut. As with SetCover, randomized
rounding lands exactly on the hardness threshold.
Part B — Solving the LP itself by randomization
Part A used an LP/SDP solver as a black box. Part B builds a fast solver for the
case that matters in computational geometry: few dimensions d, many constraints
n. The goal is running time linear in n, with the (possibly bad) dependence
isolated in d.
Geometric picture: we seek the lowest point (minimize the objective, say x1) in
the intersection of n halfspaces in Rd. Adding a constraint can only
raise the optimum (the feasible region shrinks) — monotonicity we lean on
throughout.
B.0 Vocabulary (read once, refer back)
H — the set of constraints; H+ — the trivial constraints x≥0.
FH — feasible region for the constraints in H.
vH — the optimal point in FH (and, by abuse, its objective value).
BasisB — a minimal set of constraints that determines vB:
∀B′⊊B:vB′<vB. In Rd a basis has ≤d
constraints (a vertex is pinned by d tight constraints).
Basis for H — the minimal basis defining vH.
xviolatesh: x fails constraint h (write x∈/h, viewing h as a
halfspace).
h is extreme in H: vH−h<vH (dropping h strictly lowers the
optimum — h is “binding”).
Assumptions: minimize w.r.t. x1; FH=∅; each vertex is determined by
exactly d constraints (non-degeneracy).
Idea. Insert the n constraints one at a time in random order, maintaining the
current optimum v.
d=1: solve directly in O(n).
d=2: pick h∈RH, let v be the optimum of the constraints seen so far.
If v∈h (satisfies the new constraint): v is still optimal — do nothing.
If v∈/h (violates it): the new optimum must lie on the line of h.
Project all other constraints onto h and solve a 1-D problem in O(n).
d≥3: analogously — if v violates h, the new optimum lies on h’s
hyperplane, giving a (d−1)-dimensional subproblem.
The cost of one insertion (the clever part). Expected insertion cost is
E[insert]=(1−n2)O(1)+n2O(n)=O(1),
so E[T(n,2)]=O(n). Where does the 2/n come from? Backward analysis.
Backward analysis. Look at the final configuration of n constraints. Its
optimum vH is pinned by the basis — at most d=2 constraints. Now imagine the
random insertion run in reverse: the last-inserted constraint is a uniformly
random one of the n. We pay the expensive O(n) reprojection only if that
last constraint is one of the ≤2 basis constraints — probability ≤2/n.
No need to track the actual history: by symmetry of a random permutation, the last
element is uniform, and only the ≤d basis constraints are expensive. The general
recurrence:
Linear in n (good), but the d! in the dimension is brutal. Fixing that d! is
the whole point of the next two algorithms.
B.2 Matoušek–Sharir–Welzl (MSW) — keep a candidate basis
Weakness of Seidel. When v violates h, Seidel forgets everything and rebuilds
from scratch. Idea (MSW): also carry a candidate basisC⊆H with
vC≤vH — a running hint, a lower bound on the optimum that we refine.
MSW(H, C): // initial call: MSW(H ∪ H+, H+)
1: if H = C then return C
2: h ∈_R H − C // random constraint not yet in the hint
3: (v_B, B) ← MSW(H − h, C) // solve without h
4: if v_B violates h // h matters → fold it into the basis
then return MSW(H, basis(B ∪ {h})) // recompute basis, O(d²)
else return (v_B, B)
The key quantity: Pr[recompute at line 4]. This is
p=Pr[vB∈/h] for a random h.
Trivial bound:p≤∣H−C∣d=n−dd (at most d basis
constraints out of ∣H−C∣ candidates can be “binding”).
Better: if C already contains k extreme constraints, p≤n−dd−k.
Hidden dimension — the potential that drives the analysis:
Δ(H,C)=d−#{necessary constraints in C},
where h is necessary in C if vH−h<vC (removing h would drop the
optimum below the current candidate value, so h is locked into every basis). Then
Pr[v∈/h,h∈RH−C]≤n−dΔ(H,C).
Δ counts how many basis constraints we have not yet pinned down — it only
decreases as the algorithm runs (vC never falls, necessary constraints stay
necessary). Ordering the extreme constraints by vH−e1≤⋯≤vH−et,
adding ek+i to C drops Δ by i, and each is equally likely to be picked
— this is what makes the recurrences solvable.
Punchline. MSW replaces Seidel’s d! by 2d — and a sharper analysis (the
original article) gives a subexponential expectation
E[#ops]=e2dln(n/d)+O(d+lnn),
the best known bound for combinatorial LP. The hint C is the whole trick: never
throw away progress — carry a lower bound and refine it.
B.3 Clarkson 1 — solve by sampling
A different idea: most constraints are irrelevant, so sample a few, solve the small
LP, collect the violators, and grow a kept set S.
Clarkson1(H, r): // find S ⊇ B, B = basis for H
1: S ← ∅
2: repeat
3: R ← sample(H − S, r) // r = min{ d√n , |H \ S| }
4: v ← v_{S ∪ R} with basis B // if |S ∪ R| ≤ 9d², use another solver
5: V ← { h ∈ H : v violates h }
6: if |V| ≤ 2√n then S ← S ∪ V
7: until V = ∅
8: return (v, B)
The sampling lemma. With S⊆H, R a random r-subset of H∖S,
m=∣H∖S∣, and V the constraints violated by vR∪S:
E[∣V∣]≤r−dd(m−r+1).
With r=dn this is ≤n. So each round the violator set is small
(the test “∣V∣≤2n” almost always passes), and:
each successful round adds ≥1 constraint of the final basis B to S;
since ∣B∣≤d, there are ≤d successful rounds;
hence ∣S∣≤d⋅2n=O(dn) throughout.
Why the lemma holds (the counting argument). Let
CH={vT∪S:T⊆H∖S} be all optima over subsets, and
CR={vT∪S:T⊆R}. For x∈CH, let
nx=∣{h∈H:x violates h}∣ and ix=1[x=vR∪S].
Then E[∣V∣]=∑xnxE[ix] with
E[ix]=Pr[x=vR∪S]=(rm)(r−dm−nx−d)
— R must contain x’s d defining constraints and avoid the nx it violates.
The quantity (r−d−1m−nx−d)/(rm) that appears after a
rearrangement is precisely Pr[x∈CR violates exactly one h∈R];
summed over CR it is the expected number of points of CR that violate exactly
one sampled constraint, and geometrically there are ≤d such points. That
≤d is the source of the bound:
E[∣V∣]≤r−dd(m−r+1)≤n.
Intuition. A sample of size r “catches” the optimum so well that it leaves only
a d/r fraction of constraints violated. Oversampling by a factor d shrinks the
leftover work to n.
Time. In expectation Clarkson 1 solves 2(d+1) linear programs each with
≤(2d2+1)n constraints; “small” instances go to simplex in dO(d).
Overall O(d2n)+(logn)logd+2dO(d) — i.e. O(d2n) plus
lower-order terms.
The improvement: instead of permanently moving violators into S, double their
weight and sample proportionally to weight. Important constraints quickly become
heavy and get picked.
Clarkson2(H):
1: ∀h ∈ H : w_h ← 1
2: repeat
3: W ← Σ_{h∈H} w_h
4: R ← sample(H, 9d²) with Pr[h chosen] = w_h / W
5: find v_R // e.g. simplex
6: V ← { h ∈ H : v_R violates h }
7: if Σ_{h∈V} w_h ≤ 2W / (9d − 1) then ∀h ∈ V : w_h ← 2 w_h
8: until V = ∅
9: return v_R
Per-round bound. With r=9d2 the sampling lemma gives
By Markov, the doubling condition in line 7 (w(V)≤2W/(9d−1)) holds in at
least every second round — so we make Ω(rounds) genuine doublings.
Number of rounds is O(dlogn). Two opposing potentials on the basis B:
Every round with V=∅ has at least one basis constraint violated, so
≥1 basis constraint gets doubled. After kd doublings,
w(B)=∑h∈B2nh where ∑h∈Bnh≥kd; by convexity this is
minimized when balanced, so w(B)≥d2k — the basis weight grows
exponentially.
Meanwhile the total weight barely grows: each round multiplies W by at most
1+9d−12 (only the violated weight, ≤2W/(9d−1), doubles), so after
kd rounds W≤n(1+9d−12)kd≤ne2kd/(9d−1).
Since B⊆H forces w(B)≤W always,
d2k≤ne2kd/(9d−1),
and for k>O(logn) the left side overtakes the right — a contradiction. Hence
k=O(logn) and the number of rounds is kd=O(dlogn).
Punchline (the multiplicative-weights idea). Doubling the weight of every
violated constraint forces the truly important (basis) constraints to gain weight
exponentially, while the total weight rises only by a bounded factor per round.
Because the part can’t outweigh the whole, only O(dlogn) rounds are possible.
This is the weighted-majority / multiplicative-weights potential argument, here
driving an LP solver.
Final time. Combining Clarkson 2 with MSW for the small subproblems:
O(d2n+eO(dlogd)).
Linear in n, subexponential in d — the headline result for randomized LP.
The single sentence tying Part A and Part B together:
Linear programming is the bridge between “hard discrete optimum” and “easy
continuous optimum”: randomness crosses it in both directions — coins round a
fractional LP optimum into a near-optimal integral one (rounding), and a random
order of constraints turns LP solving itself into expected-linear time (LP-type
algorithms).