Integrality Gaps
When the constraint matrix is not totally unimodular, the LP relaxation can be strictly better than any integer solution. The integrality gap measures how much better, in the worst case over all instances. It is the single most important number about a relaxation for approximation algorithms: an algorithm whose analysis compares its output with the LP value can never prove a ratio better than the gap. This lesson defines the gap, computes it for vertex cover (exactly 2), states it for set cover (), shows how to see a gap in the plane with the lp-2d lab, and ends with max-cut, whose LP gap of 2 is the reason the next section moves to semidefinite programming.
Definition
For a minimization problem with an LP relaxation, the integrality gap is
the supremum over all instances (with ). For a maximization problem it is , so that it is again at least 1. Two kinds of statement are made about it:
- Lower bounds on the gap come from a family of bad instances.
- Upper bounds usually come from a rounding algorithm: if every LP solution can be rounded to an integer solution of cost at most times the LP value, then , so the gap is at most .
When the two match, the analysis of the rounding is tight relative to this LP; doing better needs a stronger relaxation (more constraints, or an SDP), not a cleverer analysis.
Seeing a gap in the plane
The lab draws a polygon, the integer points inside it, the LP optimum for the objective direction and the best integer point. With the "thin triangle" preset and degrees (maximize ), the LP optimum is the apex but the best integer point is : a gap of in absolute terms, a ratio of . Turn and watch the gap change with the direction: for some directions the LP optimum is an integer corner and the gap is zero.
In two dimensions the gap for a fixed polygon is a curiosity. The gaps that matter are those of whole problem families, where they grow with the instance size or stay at a fixed constant like 2.
Vertex cover: the gap is exactly 2
Upper bound by threshold rounding. Let be an optimal LP solution and take . Every edge has , so one endpoint has value at least : is a cover. Its weight is . So the gap is at most 2, and threshold rounding is a 2-approximation (Hochbaum, 1982).
Lower bound from complete graphs. In , the all- vector is feasible with value , while any vertex cover misses at most one vertex, so . The ratio tends to 2.
from itertools import combinations
from scipy.optimize import linprog
def vc_lp(n, edges):
rows = [[-1 if v in e else 0 for v in range(n)] for e in edges]
return float(linprog([1] * n, A_ub=rows, b_ub=[-1] * len(edges), bounds=[(0, 1)] * n, method="highs").fun)
def vc_ip(n, edges):
return min(k for k in range(n + 1) for C in combinations(range(n), k) if all(u in C or v in C for u, v in edges))
print(" n LP IP ratio 2 - 2/n")
for n in range(3, 9):
E = list(combinations(range(n), 2))
lp, ip = vc_lp(n, E), vc_ip(n, E)
print(f"{n:2} {lp:4.1f} {ip:4} {ip / lp:.4f} {2 - 2 / n:.4f}") n LP IP ratio 2 - 2/n
3 1.5 2 1.3333 1.3333
4 2.0 3 1.5000 1.5000
5 2.5 4 1.6000 1.6000
6 3.0 5 1.6667 1.6667
7 3.5 6 1.7143 1.7143
8 4.0 7 1.7500 1.7500
The rounding argument and the bound are both very simple, and yet nothing better is known: no polynomial-time algorithm is known to achieve for any constant , and under the Unique Games Conjecture none exists (Khot and Regev, 2008). Adding the odd-cycle constraints or many rounds of lift-and-project hierarchies does not reduce the gap below for several of the standard hierarchies.
The next program applies threshold rounding to random graphs with random weights and compares the rounded cover with the LP value and the true optimum.
import random
from itertools import combinations
from scipy.optimize import linprog
rng = random.Random(1982)
print("trial LP value rounded optimum rounded / LP")
for trial in range(1, 6):
n = 9
E = [e for e in combinations(range(n), 2) if rng.random() < 0.4]
w = [rng.randint(1, 9) for _ in range(n)]
rows = [[-1 if v in e else 0 for v in range(n)] for e in E]
x = linprog(w, A_ub=rows, b_ub=[-1] * len(E), bounds=[(0, 1)] * n, method="highs-ds").x
lp = sum(wi * xi for wi, xi in zip(w, x))
C = [v for v in range(n) if x[v] >= 0.5 - 1e-9]
rounded = sum(w[v] for v in C)
opt = min(sum(w[v] for v in S) for k in range(n + 1) for S in combinations(range(n), k)
if all(u in S or v in S for u, v in E))
print(f"{trial:5} {float(lp):8.3f} {rounded:7} {opt:7} {float(rounded / lp):12.3f}")trial LP value rounded optimum rounded / LP
1 24.000 24 24 1.000
2 21.000 21 21 1.000
3 25.500 47 26 1.843
4 23.000 44 24 1.913
5 11.000 11 11 1.000
In three trials the LP optimum is integral and rounding returns an optimal cover. In trials 3 and 4 the LP puts on many vertices, rounding takes all of them, and the result comes close to the factor 2, although the optimum is only slightly above the LP value. The extreme points of the vertex cover polytope are half-integral (every coordinate is , or ; Nemhauser and Trotter, 1974), so the loss of rounding comes entirely from the -coordinates.
Set cover: a logarithmic gap
For set cover with elements, the dual fitting analysis of greedy shows that the gap is at most . It is also : there are instances (for example, built from the vector space , with elements the non-zero vectors and sets the complements of hyperplanes) where the LP value is about 2 while every cover needs about sets. So the gap of the standard set cover LP is , matching greedy's ratio up to a constant factor and, by Feige's and Dinur-Steurer's results, the best ratio achievable in polynomial time.
Max-cut: why an LP is not enough
Max-cut asks for a vertex set maximizing the number of edges with exactly one end in . A natural LP uses for the side of and for "edge is cut", with and . Setting every allows for every edge, so the LP value is always , whatever the graph. On complete graphs the true maximum cut is , about half of .
from itertools import combinations
print(" n edges (LP value) max cut LP / max cut")
for n in [3, 4, 5, 8, 16, 32]:
m = n * (n - 1) // 2
best = (n // 2) * (n - n // 2) # the max cut of K_n splits the vertices in halves
print(f"{n:2} {m:16} {best:7} {m / best:12.4f}") n edges (LP value) max cut LP / max cut
3 3 2 1.5000
4 6 4 1.5000
5 10 6 1.6667
8 28 16 1.7500
16 120 64 1.8750
32 496 256 1.9375
The gap tends to 2, which is no better than the trivial bound "at most all edges", and a random cut already gets half of the edges in expectation. Constraints on single edges cannot express that a triangle never has all three edges cut. Adding such constraints (triangle inequalities ) fixes triangles, but on suitable sparse graphs the gap stays close to 2 even with them, and even after many rounds of the Sherali-Adams hierarchy (Charikar, Makarychev and Makarychev, 2009). The breakthrough came from a relaxation that is not linear at all: replace each by a unit vector and the LP by a semidefinite program, which is the subject of the next section.
Test yourself
What is the integrality gap of the standard vertex cover LP?
- 2
- 1
Why can an LP-based analysis never prove a ratio better than the integrality gap?
- Because LPs are slow
- Because on the worst instances even is a factor gap away from , so no solution is within a smaller factor of the LP value
- Because rounding is random
- It can
What is the integrality gap of the standard set cover LP with elements?
- 2
- 1
What does the simple max-cut LP give for every graph?
- The exact max cut
- The value , by setting all and all
- Zero
- Half the edges