TExcelTAD

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 (Θ(log⁡n)\Theta(\log n)), 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

gap=sup⁡IOPTIP(I)OPTLP(I) ≥1,\text{gap} = \sup_{I} \frac{\text{OPT}_{IP}(I)}{\text{OPT}_{LP}(I)} \ \ge 1,

the supremum over all instances II (with OPTLP(I)>0\text{OPT}_{LP}(I) > 0). For a maximization problem it is sup⁡IOPTLP(I)/OPTIP(I)\sup_I \text{OPT}_{LP}(I) / \text{OPT}_{IP}(I), 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 α\alpha times the LP value, then OPTIP≤ALG≤α⋅OPTLP\text{OPT}_{IP} \le \text{ALG} \le \alpha \cdot \text{OPT}_{LP}, so the gap is at most α\alpha.

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 θ\theta and the best integer point. With the "thin triangle" preset and θ=90\theta = 90 degrees (maximize yy), the LP optimum is the apex (4,3.375)(4, 3.375) but the best integer point is (4,3)(4, 3): a gap of 0.3750.375 in absolute terms, a ratio of 1.1251.125. Turn θ\theta and watch the gap change with the direction: for some directions the LP optimum is an integer corner and the gap is zero.

00224466881010maximise 0.00x + 1.00ysubject to−3x + 4y ≤ 1.53x + 4y ≤ 25.5x ≥ 0, y ≥ 0LP optimum (a vertex)best integer pointlevel line c · v = z*

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 x∗x^* be an optimal LP solution and take C={v:xv∗≥12}C = \{ v : x^*_v \ge \frac{1}{2} \}. Every edge uvuv has xu∗+xv∗≥1x^*_u + x^*_v \ge 1, so one endpoint has value at least 12\frac{1}{2}: CC is a cover. Its weight is ∑v∈Cwv≤∑vwv⋅2xv∗=2⋅LP\sum_{v \in C} w_v \le \sum_v w_v \cdot 2 x^*_v = 2 \cdot \text{LP}. So the gap is at most 2, and threshold rounding is a 2-approximation (Hochbaum, 1982).

Lower bound from complete graphs. In KnK_n, the all-12\frac{1}{2} vector is feasible with value n2\frac{n}{2}, while any vertex cover misses at most one vertex, so τ(Kn)=n−1\tau(K_n) = n - 1. The ratio n−1n/2=2−2n\frac{n - 1}{n/2} = 2 - \frac{2}{n} tends to 2.

python · try it yourself
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 2−ε2 - \varepsilon for any constant ε>0\varepsilon > 0, 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 2−o(1)2 - o(1) 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.

python · try it yourself
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 12\frac{1}{2} 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 00, 12\frac{1}{2} or 11; Nemhauser and Trotter, 1974), so the loss of rounding comes entirely from the 12\frac{1}{2}-coordinates.

Set cover: a logarithmic gap

For set cover with nn elements, the dual fitting analysis of greedy shows that the gap is at most Hn≤1+ln⁡nH_n \le 1 + \ln n. It is also Ω(log⁡n)\Omega(\log n): there are instances (for example, built from the vector space F2k\mathbb{F}_2^k, with elements the non-zero vectors and sets the complements of hyperplanes) where the LP value is about 2 while every cover needs about k=log⁡2(n+1)k = \log_2(n + 1) sets. So the gap of the standard set cover LP is Θ(log⁡n)\Theta(\log n), 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 SS maximizing the number of edges with exactly one end in SS. A natural LP uses xv∈[0,1]x_v \in [0, 1] for the side of vv and ze∈[0,1]z_e \in [0, 1] for "edge ee is cut", with zuv≤xu+xvz_{uv} \le x_u + x_v and zuv≤2−xu−xvz_{uv} \le 2 - x_u - x_v. Setting every xv=12x_v = \frac{1}{2} allows ze=1z_e = 1 for every edge, so the LP value is always ∣E∣\lvert E \rvert, whatever the graph. On complete graphs the true maximum cut is ⌊n2/4⌋\lfloor n^2/4 \rfloor, about half of ∣E∣\lvert E \rvert.

python · try it yourself
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 zuv+zvw+zuw≤2z_{uv} + z_{vw} + z_{uw} \le 2) 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 xvx_v 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?

  1. 32\frac{3}{2}
  2. 2
  3. ln⁡n\ln n
  4. 1

Why can an LP-based analysis never prove a ratio better than the integrality gap?

  1. Because LPs are slow
  2. Because on the worst instances even OPTIP\text{OPT}_{IP} is a factor gap away from OPTLP\text{OPT}_{LP}, so no solution is within a smaller factor of the LP value
  3. Because rounding is random
  4. It can

What is the integrality gap of the standard set cover LP with nn elements?

  1. 2
  2. Θ(log⁡n)\Theta(\log n)
  3. Θ(n)\Theta(n)
  4. 1

What does the simple max-cut LP give for every graph?

  1. The exact max cut
  2. The value ∣E∣\lvert E \rvert, by setting all xv=12x_v = \frac{1}{2} and all ze=1z_e = 1
  3. Zero
  4. Half the edges