Neural-Path/Notes
40 min

Integer Programming: Branch & Bound & Cutting Planes

Integer programming extends LP by requiring some or all variables to take integer values. This single constraint transforms polynomial-time LP into an NP-hard problem — but branch-and-bound with cutting planes makes large instances tractable in practice by combining LP relaxation bounds with intelligent search.

Concepts

The feasible region of an LP is a convex polytope. The optimal solution always lies at a vertex. The objective function sweeps as a hyperplane — the last vertex it touches is optimal.

112233440x₁x₂∇c(2,2), val=4
Optimal: (2,2) with objective value 4. Blue dashed = constraints. Green solid = optimal iso-line (c·x = 4).

Adding a single constraint — "some variables must be integers" — transforms polynomial-time LP into NP-hard ILP. The feasible region is no longer a convex polytope but a discrete lattice of points; the LP relaxation gives a lower bound, and the gap between this relaxation and the true integer optimum determines how much search is required. Branch-and-bound uses LP bounds to prune this search, while cutting planes tighten the relaxation by slicing off fractional vertices.

ILP Formulation

A mixed-integer linear program (MILP) has the form:

min  cxs.t.Axb,  xjZ for jI,  x0\min \; c^\top x \quad \text{s.t.} \quad Ax \leq b, \; x_j \in \mathbb{Z} \text{ for } j \in \mathcal{I}, \; x \geq 0

When all integer variables are binary (xj{0,1}x_j \in \{0, 1\}), the problem is a binary integer program (BIP). ILP is NP-hard in general: 3-SAT reduces to BIP by encoding clauses as linear constraints.

The integrality constraint xjZx_j \in \mathbb{Z} is the minimal change from LP that encodes combinatorial choice. Without it, every yes/no decision becomes a continuous dial — and the LP optimum simply sets that dial to a fraction. The formulation forces the solver to commit: a variable is either included or not, a route is taken or skipped. That commitment is what makes ILP expressive enough to encode SAT, and exactly what makes it NP-hard.

LP Relaxation and Integrality Gap

The LP relaxation drops the integrality constraints, replacing xjZx_j \in \mathbb{Z} with xj0x_j \geq 0. Let zLPz_{LP} be its optimal value and zILPz_{ILP} the integer optimum. Then:

zLPzILP(for minimization)z_{LP} \leq z_{ILP} \quad (\text{for minimization})

The integrality gap is zILP/zLPz_{ILP} / z_{LP} (or zLP/zILPz_{LP} / z_{ILP} for maximization). A tight LP relaxation means a small gap and a strong bound for branch-and-bound.

The LP relaxation gives the continuous optimum; integer solutions are the lattice points at vertices of the feasible region. The convex hull of all integer-feasible points is the integer hull — if we could optimize over it directly (a tighter LP), we would get the ILP optimum immediately. Cutting planes approximate the integer hull.

Branch-and-Bound

Branch-and-bound maintains a search tree where each node is an LP relaxation with additional variable bounds.

Algorithm:

  1. Solve the LP relaxation at the root. If the solution is integer-valued, done.
  2. Branch: pick a fractional variable xjZx_j^* \notin \mathbb{Z}. Create two child nodes by adding constraints xjxjx_j \leq \lfloor x_j^* \rfloor (left child) and xjxjx_j \geq \lceil x_j^* \rceil (right child).
  3. Bound: at each node, solve the LP relaxation. If its objective znodezbestz_{\text{node}} \geq z_{\text{best}} (current best integer solution), prune the subtree — no integer solution here can improve on what we have.
  4. Fathom: if the LP relaxation is infeasible, prune. If it gives an integer solution better than zbestz_{\text{best}}, update the incumbent.

The key insight: each node's LP relaxation lower-bounds every integer solution reachable in that subtree. Tight LP bounds lead to aggressive pruning and small trees.

Cutting Planes

A cutting plane (or cut) is a valid inequality πxπ0\pi^\top x \leq \pi_0 satisfied by all integer-feasible points but violated by the current LP relaxation solution. Adding cuts tightens the LP relaxation toward the integer hull without branching.

Gomory cut: Given a row of the optimal simplex tableau corresponding to a fractional basic variable:

xi+jNaˉijxj=bˉi,bˉiZx_i + \sum_{j \in N} \bar{a}_{ij} x_j = \bar{b}_i, \quad \bar{b}_i \notin \mathbb{Z}

Write aˉij=aˉij+fij\bar{a}_{ij} = \lfloor \bar{a}_{ij} \rfloor + f_{ij} and bˉi=bˉi+fi\bar{b}_i = \lfloor \bar{b}_i \rfloor + f_i with 0<fi<10 < f_i < 1. The Gomory cut is:

jNfijxjfi\sum_{j \in N} f_{ij} x_j \geq f_i

This is valid for all integer solutions (since xjZx_j \in \mathbb{Z} implies the sum is an integer, and if less than 1 it must be 0\leq 0, contradicting fi>0f_i > 0) but violated by the current LP solution where the sum equals fifi=0<fif_i - f_i = 0 < f_i. Wait — more precisely, the current LP solution satisfies the row equation with fractional bˉi\bar{b}_i, so the fractional parts satisfy fijxj=fi\sum f_{ij} x_j = f_i only if xjx_j are at their LP values. Any integer solution must have the left side as a non-negative integer, so at least fi=1>fi\lceil f_i \rceil = 1 > f_i... or zero. Since fi>0f_i > 0, the cut forces fijxjfi\sum f_{ij} x_j \geq f_i which eliminates the current LP vertex.

Repeated Gomory cuts provably converge to the integer hull in finite steps, though convergence can be slow in practice. Commercial solvers use problem-specific cuts (clique cuts, cover cuts, flow cuts) alongside Gomory cuts.

Modeling Tricks

Big-M constraints encode logical implications. To force y=1xby = 1 \Rightarrow x \leq b:

xb+M(1y)x \leq b + M(1 - y)

When y=0y = 0, the constraint becomes xb+Mx \leq b + M, which is inactive if MM is large enough. Choosing MM too large weakens the LP relaxation; too small makes the model infeasible. A good bound from problem structure is always preferable.

Linearizing a product. To linearize z=x1x2z = x_1 x_2 with x1{0,1}x_1 \in \{0,1\} and x2[0,U]x_2 \in [0, U]:

zUx1,zx2,zx2U(1x1),z0z \leq U x_1, \quad z \leq x_2, \quad z \geq x_2 - U(1 - x_1), \quad z \geq 0

These four constraints force z=x1x2z = x_1 x_2 exactly for binary x1x_1.

Worked Example

0/1 Knapsack by Branch-and-Bound

Four items with weights w=(2,3,4,5)w = (2, 3, 4, 5), values v=(3,4,5,6)v = (3, 4, 5, 6), capacity W=8W = 8.

ILP formulation:

max  3x1+4x2+5x3+6x4s.t.2x1+3x2+4x3+5x48,  xi{0,1}\max \; 3x_1 + 4x_2 + 5x_3 + 6x_4 \quad \text{s.t.} \quad 2x_1 + 3x_2 + 4x_3 + 5x_4 \leq 8, \; x_i \in \{0,1\}

LP relaxation (root): Solve continuously. Greedy by value/weight: item 1 (3/2=1.53/2=1.5), item 2 (4/3=1.334/3=1.33), item 3 (5/4=1.255/4=1.25), item 4 (6/5=1.26/5=1.2). Take items 1, 2 fully (weight 5), then 3/43/4 of item 3. Objective: 3+4+3.75=10.753 + 4 + 3.75 = 10.75. x3=0.75x_3 = 0.75 is fractional.

Branch on x3x_3:

  • Left branch (x3=0x_3 = 0): LP relaxation over items 1, 2, 4 with capacity 8. Take 1, 2 (weight 5), then 3/53/5 of item 4. Obj: 3+4+3.6=10.63 + 4 + 3.6 = 10.6. Fractional x4x_4.
    • Branch on x4x_4: left (x4=0x_4 = 0) gives integer solution {x1,x2}\{x_1, x_2\}, value = 7. Right (x4=1x_4 = 1): weight constraint 2x1+3x232x_1 + 3x_2 \leq 3; best integer: x2=1x_2=1, value = 4+6=104 + 6 = 10. Incumbent = 10.
  • Right branch (x3=1x_3 = 1): Remaining capacity 4. LP over items 1, 2, 4. Take item 1 (weight 2), then 2/52/5 of item 4. Obj: 5+3+2.4=10.4>105 + 3 + 2.4 = 10.4 > 10; explore. Branch on x4x_4: right (x4=1x_4 = 1, weight 5 > 4, infeasible). Left (x4=0x_4 = 0): items 1, 2 in capacity 4. Take x1=1,x2=2/3x_1 = 1, x_2 = 2/3 fractional. Branch: x2=0x_2 = 0 \Rightarrow value =5+3=8<10= 5 + 3 = 8 < 10, prune. x2=1x_2 = 1: weight 2+3+4=9>82 + 3 + 4 = 9 > 8, infeasible.

Optimal: x2=1,x4=1x_2 = 1, x_4 = 1, value = 10.

Gomory Cut

After the LP relaxation gives x3=0.75x_3 = 0.75 at the root, the simplex tableau row for x3x_3 is (schematically):

x3+0.5s1=0.75x_3 + 0.5 s_1 = 0.75

Here f3=0.75f_3 = 0.75, fs1=0.5f_{s_1} = 0.5. The Gomory cut is 0.5s10.750.5 s_1 \geq 0.75, i.e., s11.5s_1 \geq 1.5, i.e., 2x1+3x2+4x3+5x46.52x_1 + 3x_2 + 4x_3 + 5x_4 \leq 6.5. This cut tightens the LP relaxation and eliminates the fractional solution.

Connections

Where Your Intuition Breaks

Branch-and-bound sounds like exhaustive search with pruning — but the pruning is doing almost all the work. On well-structured problems (tight LP relaxations, good incumbent solutions found early), commercial solvers prune 99.99% of the tree and solve million-variable instances in seconds. On adversarial instances (poorly-constructed Big-M models, near-integer LP relaxations with many fractional variables), the tree explodes exponentially and the same solver stalls. The misconception is that NP-hardness means "always slow in practice." It means "worst-case exponential" — and the solver's entire engineering effort goes into making the worst case rare by tightening bounds, finding incumbents early via primal heuristics, and adding cuts that eliminate fractional vertices without branching.

Complexity and Tractability

ILP is NP-hard in general, but not all instances are hard. Problem structure matters enormously:

💡Intuition

When is the LP relaxation automatically integral? If the constraint matrix AA is totally unimodular (TU) — every square submatrix has determinant in {1,0,1}\{-1, 0, 1\} — then every vertex of the LP feasible polytope is integral. Network matrices (incidence matrices of directed graphs) are TU, which is why max-flow and shortest path LPs always give integer solutions for integer data. You get integer optima from a plain LP.

StructureComplexityExample
TU constraint matrixPolynomial (solve LP)Max-flow, bipartite matching
Fixed number of integer variablesPolynomial in data (Lenstra)Small mixed-ILPs
General ILPNP-hardKnapsack, TSP
Fixed dimension nnPolynomial (Lenstra-Lenstra-Lovász)nn-dim ILP

Big-M Sensitivity

⚠️Warning

Big-M constraints are a common modeling pitfall. A very large MM makes the LP relaxation weak — the constraint xb+M(1y)x \leq b + M(1-y) is nearly inactive even when y=0y = 0, so the LP bound is loose and branch-and-bound explores a huge tree. Always derive the tightest valid MM from problem data (e.g., upper bounds on variables), or reformulate using indicator constraints that the solver handles natively.

Branch-and-Cut in Practice

Modern ILP solvers (Gurobi, CPLEX, HiGHS) use branch-and-cut: integrate cutting planes at every node of the branch-and-bound tree, not just at the root. Combined with strong branching (evaluate several candidate branching variables), primal heuristics for fast incumbents, and diving strategies, commercial solvers routinely solve instances with millions of variables and constraints in minutes — despite worst-case NP-hardness.

Enjoying these notes?

Get new lessons delivered to your inbox. No spam.