Integer & Combinatorial Optimization

Branch and bound, traveling salesman, and knapsack

Integer and Combinatorial Optimization

When variables must be integers, optimization becomes fundamentally harder. Rounding the continuous solution often gives a poor answer. Branch and bound systematically searches the integer solution space using LP relaxations as bounds. Classic problems like the traveling salesman and knapsack showcase both exact and heuristic approaches.

Branch and Bound

Branch and bound solves integer LPs by exploring a tree of sub-problems. Each node solves an LP relaxation. Branches where the bound is worse than the best known integer solution are pruned.

Root LP(3.75, 1.25) = 22.75
Problem: max 5x + 4y, s.t. x+y ≤ 5, 10x+6y ≤ 45, x,y ≥ 0 integer
Best integer: --
Node "Root LP" has fractional solution. Bound = 22.75. Branch needed.
Step 1 of 7

Key insight: The LP relaxation bound guides the search. Tighter bounds mean more pruning and faster solutions. This is why LP solving speed matters even for integer problems.

Traveling Salesman Problem

Find the shortest tour visiting every city exactly once. The TSP is NP-hard, but heuristics like nearest-neighbor and 2-opt local search find good solutions fast. Compare with the brute-force optimal on a small instance.

6 cities: nearest neighbor heuristic builds a quick tour, 2-opt improves it by swapping edges, and brute force finds the true optimum.

Key insight: 2-opt improves tours by swapping edge pairs. It typically gets within 5-10% of optimal on random instances. The gap between heuristic and optimal shrinks for structured problems.

Knapsack Problem

Select items with given weights and values to maximize total value without exceeding capacity. Dynamic programming solves this exactly, but the greedy heuristic (best value-to-weight ratio first) sometimes fails.

012345678Capacity w--000000000GemRingCoinCrownVase
Gem (w=2, v=12)
Ring (w=1, v=10)
Coin (w=3, v=20)
Crown (w=4, v=15)
Vase (w=5, v=25)

The DP table fills cell by cell: dp[i][w] = max value using items 1..i with capacity w. The highlighted path traces the optimal selection. Greedy (by value/weight ratio) may differ from optimal.

Key insight: The DP table reveals the optimal substructure: the best solution for capacity w using items 1..i builds on solutions for smaller sub-problems. This is the essence of dynamic programming.

Key Takeaways

  • Integer optimization is NP-hard in general; branch and bound uses LP relaxations to prune the search.
  • Heuristics like 2-opt and nearest-neighbor give good approximate solutions quickly.
  • Dynamic programming solves knapsack and similar problems with optimal substructure exactly.