Branch-and-Cut for VRP

SL 225 project · Logistics and Freight Modeling

Solving truck routing exactly, with better cuts

N. R. Achuthan, L. Caccetta and S. P. Hill, An Improved Branch-and-Cut Algorithm for the Capacitated Vehicle Routing Problem, Transportation Science 37(2):153–169, 2003.

Presented by Rahul Dev Sharma

Roadmap

Where we are going

  1. The problema depot, seven customers, trucks that carry 10
  2. Writing it for a computerthe two-index model, rule by rule
  3. How the computer solves itlower bounds, cuts and branching
  4. What the paper addsthree new kinds of cuts
  5. The paper's results1,650 test problems
  6. Our implementationhow we built it and reproduced the results
  7. Wrap-upstrengths, limits, questions

1 · The problem

One depot, seven customers, trucks that carry 10

  • Depot = node 1 (black square). Every truck starts and ends there.
  • Customer $j$ wants $q_j$ (next to each circle). A truck carries $Q = 10$.
  • Visit each customer once, never overload a truck, drive the least distance.

Total demand 28, so at least $\lceil 28/10 \rceil = 3$ trucks. This is the capacitated vehicle routing problem.

1 · The problem

Let's plan the routes by hand

Let's join customers whose shared trip saves the most distance, until a truck is full.

  • Customer 2 nearly fills a truck alone: 1 → 2 → 1, load 9.
  • Next truck: 1 → 7 → 3 → 4 → 5 → 1, load 10.
  • Last truck: 1 → 6 → 8 → 1, load 9. Total 322.4.

A good plan. Is it the best one?

1 · The problem

A good plan is not a proof

  • The best plan costs 318.2, 1.3% shorter.
  • Only 354 plans here: we checked them all. With 50 customers: hopeless.

An exact method proves optimality: push the lower bound up until it meets the plan.

2 · Writing it for a computer

Let's describe a plan by the roads it uses

For each pair $i \lt j$, one number $x_{ij}$: how many times a truck drives between $i$ and $j$.

  • 1 if driven once, 0 if not; 2 for an out-and-back trip: 1 → 2 → 1 is $x_{12} = 2$.
  • No truck, no direction, only roads: the two-index model.
  • Pairs that cannot share a truck ($q_i + q_j \gt Q$) get no variable.

2 · Writing it for a computer

What we minimise: total distance

For every road: its length times how many times it is driven. Add up.

(1.1) $$\min \; \sum_{i \lt j} \htmlClass{tA}{\underbrace{c_{ij}}_{\text{length}}} \; \htmlClass{tB}{\underbrace{x_{ij}}_{\text{times driven}}}$$

Best plan: $97.8 + 93.4 + 127.0 = 318.2$.

2 · Writing it for a computer

Rule 1: one truck in, one truck out

At a customer, one truck arrives and one leaves: its roads add up to 2. At the depot, every truck leaves and returns: $2m$.

(1.2) and (1.3) $$\htmlClass{tA}{\underbrace{\sum_{j \in \mathscr C} x_{1j}}_{\text{roads at the depot}}} = 2\,\htmlClass{tB}{\underbrace{m}_{\text{trucks}}} \qquad \htmlClass{tC}{\underbrace{\sum_{i \lt k} x_{ik} + \sum_{j \gt k} x_{kj}}_{\text{roads at customer } k}} = 2$$

These are the degree constraints. Let's check them on the best plan.

2 · Writing it for a computer

Is rule 1 enough? No.

With only (1.1)–(1.3), the cheapest answer costs 246.0: below the best plan.

  • Rule 1 holds at every node.
  • But 3–4–5–6 is a loop that never visits the depot, and it carries 11 > 10.

We need a rule that forbids such loops.

2 · Writing it for a computer

Rule 2: a group of customers needs enough trucks

A group $S$ needs at least $\ell(S) = \lceil q(S)/Q \rceil$ trucks. Each truck covers a run of $S$'s customers, and a run of $r$ has $r - 1$ roads inside.

(1.4) $$\htmlClass{tA}{\underbrace{\sum_{i,j \in S} x_{ij}}_{\text{roads inside } S}} \;\le\; \htmlClass{tB}{\underbrace{|S|}_{\text{customers}}} - \htmlClass{tC}{\underbrace{\ell(S)}_{\text{trucks } S \text{ needs}}}$$

Loop $\{3,4,5,6\}$: 4 roads inside, only $4 - \lceil 11/10 \rceil = 2$ allowed. Broken: that answer is gone.

2 · Writing it for a computer

Too many rules to write down

  • One rule (1.4) per group: 99 groups for 7 customers, about $10^{30}$ for 100.
  • So: start without them, solve, and add only the rules the answer breaks.

A rule added because the answer breaks it is a cut: the "cut" in branch-and-cut.

3 · How the computer solves it

A lower bound: allow fractions

Let roads be used "half-way" ($x = \tfrac12$): a linear program (LP), which computers solve fast.

  • More options than real plans, so its value is a lower bound: $246.0 \le$ best $\le 322.4$.

The game: push the lower bound up. Cuts do that.

3 · How the computer solves it

Let's watch the cutting-plane loop

  1. Solve the LP.
  2. Find rules the answer breaks.
  3. Add them as cuts. Repeat.

Each round removes the current wrong answer, and the bound climbs.

Each cut's group lights up on the map; click a cut in the list to see another.

3 · How the computer solves it

When cuts run out: branch

At 318.0 no rule is broken, but road 3–4 is used half-way.

  • Split: road 3–4 unused ($x_{34} = 0$) or used ($x_{34} = 1$).
  • Unused: more cuts, bound 319.15, still fractional: split again.
  • Used: a real plan, 318.2. New best plan.
  • Both halves of the first branch have bound 319.15 > 318.2: pruned.

Lower bound = upper bound = 318.2, proven optimal.

4 · What the paper adds · the starting point

A known rule: leave enough trucks for everyone else

Trucks that serve only customers of $S$ are useless to the others, who still need $\ell(\bar S)$ trucks.

(1.7) $$\htmlClass{tA}{\underbrace{x(S)}_{\text{roads inside}}} + \htmlClass{tB}{\underbrace{x(1{:}S)}_{\text{depot roads into } S}} - \htmlClass{tC}{\underbrace{m}_{\text{trucks}}} \;\le\; |S| - \htmlClass{tD}{\underbrace{\ell(\bar S)}_{\text{trucks the others need}}}$$

Starting LP, $S = \{2,7,8\}$: all three trucks are busy there, none left for the other four. 3 > 1: broken.

4 · What the paper adds · new cut 1

Groups that cannot share a truck

If $S$ with any two of the groups $T_1, \dots, T_k$ overloads a truck, the truck through $S$ can reach at most one of them.

(2.3) $$3\,\htmlClass{tA}{\underbrace{x(S)}_{\text{inside } S}} + \htmlClass{tB}{\underbrace{x(E[S,T])}_{S \text{ to the } T\text{'s}}} + \htmlClass{tC}{\underbrace{\textstyle\sum_p x(T_p)}_{\text{inside each } T_p}} \;\le\; 3|S| - 2 + |T| - k$$

$S = \{3\}$, $T = \{4\}, \{5,6\}$: $3 + 1 + 7 = 11 \gt 10$. The starting LP links 3 to both: 3 > 2, broken, though no single group is overloaded.

4 · What the paper adds · why it matters

Where the old rules run dry

Round 5 of our loop, bound 317.35: no (1.4), (1.7), (2.1) or (2.9) is broken. The old method would have to branch here.

  • The new (2.8) still finds a cut: $S = \{4,5\}$ with $\{3\}, \{6\}, \{8\}$, loads 11, 12, 13, all over 10.
  • $2x(S) + x(E[S,T]) + \sum_p x(T_p) \le 2|S| + |T| - 4$: here $3.5 \gt 3$.

That is how the new cuts lift the root bound to 318.0 instead of 317.35.

4 · What the paper adds · new cut 2

Don't split a group that fits in one truck

If $S$ fits in one truck, joining two trips that serve only $S$ is never longer.

(2.9), for $q(S) \le Q$ $$\htmlClass{tA}{\underbrace{x(S)}_{\text{roads inside } S}} + \htmlClass{tB}{\underbrace{x(1{:}S)}_{\text{depot roads into } S}} \;\le\; |S| + 1$$

Two trips to 7 and 8: 77.0. One trip 1 → 7 → 8 → 1: 68.9, load $8 \le 10$.

A new kind of rule: it removes some real (wasteful) plans but always keeps an optimal one. An optimality cut.

4 · What the paper adds · new cut 3

A cap on the number of trucks

In an optimal plan, any two routes together are heavier than $Q$, or we would merge them. So each route carries more than $Q/2$ on average.

Corollary 2.5, from (2.10) $$m \;\le\; \Bigg\lfloor \frac{2\,(\htmlClass{tA}{\underbrace{q(\mathscr C)}_{\text{total demand}}} + \delta)}{\htmlClass{tB}{\underbrace{Q}_{\text{capacity}}} + 1 + \delta} \Bigg\rfloor$$

Toy: $\lfloor 2 \cdot 29 / 12 \rfloor = 4$, and at least 3 are needed: the fleet is 3 or 4.

4 · What the paper adds

Does it help on the toy?

old cutsall cuts
root bound317.35318.0
tree nodes75
optimum318.2318.2

Same answer, higher root bound, smaller tree.

5 · The paper's results

What the paper reports

  • 1,650 random problems with 15–100 customers, plus 24 from the literature; 1 hour of CPU each on a 1990s workstation.
  • Three algorithms: NEW (all cuts, Searches 1–6), A = (1.4) + (1.7), B = (1.4) only.
  • NEW solves 1,369 of 1,590 problems, against 1,239 for A and 1,107 for B, in about half of B's total time.
  • The gain is largest when trucks are tight, and vanishes when one truck carries everything.

6 · Our implementation

How we implemented it

model.pythe two-index model (1.1)–(1.3)
cuts/one file per rule: (1.4), (1.7), (2.1), (2.3)/(2.8), (2.9), (2.10)
searches.pySearches 1–6, in the paper's order
solver.pycut loop at the root, then branch-and-bound
verify.pyturns every answer back into routes and checks it

Python 3.12 + Gurobi 13. Gurobi does the LPs and the branching; a callback runs our searches at every node and adds the cuts they find.

Gurobi's own cuts and heuristics are switched off, so any difference between NEW, A and B comes from the paper's cuts alone.

6 · Our implementation

How we reproduced the results

  1. Rebuild the test problems. The authors' problems were never published, so we regenerated all 1,650 with the recipe on p. 161 and fixed seeds.
  2. Run NEW, A and B on the same problems with identical settings (one Gurobi thread, same time limit).
  3. Check every answer: routes rebuilt and re-costed; the same optimum as CVRPLIB on all 18 benchmarks we solved; brute-force tests that no cut removes a real plan.
  4. Compare with the paper table by table.

6 · Our implementation

What we found: the claim holds

On the 267 problems that all three algorithms solved:

NEWAB
Root bound, % of optimum99.1598.5998.56
Median tree size (nodes)184039
Total time (s)5,1869,2779,444

Higher bound, trees about half the size, time almost halved. Our root bounds match the paper's cell by cell, typically within half a percentage point.

Differences: our times are 10–1,000× smaller (hardware and solver), and A and B come out close, where the paper has A ahead of B.

7 · Wrap-up

Strengths and limits

Strengths

  • Optimality cuts (2.9)/(2.10): rules justified by what an optimal plan looks like, not only by feasibility. A new idea.
  • A large, systematic test, with a clear comparison against the two earlier algorithms.

Limits

  • The test problems were not published, so others cannot rerun them exactly.
  • (2.9)/(2.10) need triangle-inequality distances and a free (or minimal) fleet.
  • Later methods (Lysgaard et al. 2004; Fukasawa et al. 2006; Pecin et al. 2017) add more cuts and column generation and solve much larger problems.

7 · Wrap-up

AI usage declaration

  • I studied the paper and decided what to present, in what order, and how: the running 7-customer example, the step-by-step builds, and the focus on why the new cuts matter.
  • I used Claude (Anthropic) as an assistant to carry out that plan. It drafted the slides, the interactive example and the figures to my direction, and I reviewed and revised them over many rounds.
  • The re-implementation code (Python + Gurobi) is AI-assisted. I directed it, ran the experiments and checked the results against the paper.

Every number on these slides was checked against the paper or our own runs.

7 · Wrap-up

Three things to remember

  1. Model: one number per road. Rule 1: one truck in, one out. Rule 2: a group needs enough trucks, too many rules to write, so they are added as cuts.
  2. Method: the LP gives a lower bound, cuts push it up, branching finishes; stop when it meets the best plan.
  3. Paper: new cuts raise the bound, so trees shrink and more problems are solved. We reproduced this.

Thank you. Questions?

Backup · likely question

"(2.9) cuts off optimal solutions. Can the algorithm miss the optimum?"

No. (2.9) can remove some optimal plans (Remark 2.2), but Theorem 2.3 guarantees that at least one optimal plan satisfies all of them, so the optimal value is still found.

Proof idea (Theorem 2.3):

  1. Suppose an optimal plan breaks (2.9) for a group $S$ with $q(S) \le Q$. Then two whole routes stay inside $S$.
  2. Join them end to end: the load is at most $q(S) \le Q$, and by the triangle inequality the cost does not go up.
  3. The new plan is still optimal and has one fewer violation. Repeat until none is left.

Backup · likely question

"What if distances break the triangle inequality, or the fleet is fixed?"

  • No triangle inequality: joining two routes can cost more, the proof breaks, and (2.9) could cut off every optimal plan. The paper assumes it throughout (p. 154); Euclidean distances satisfy it.
  • Fixed fleet $m$: safe only if $m$ is the minimum fleet. With more trucks than needed it can make the problem infeasible (Remark 2.3). Our code switches (2.9) on only in the safe cases.
  • Other dominance rules together with (2.9)? Not without a new proof: each rule keeps some optimal plan, possibly a different one (Remark 2.6).

Backup · likely questions

Questions about the model

  • Why two-index, not three-index or set partitioning? One variable per road and no symmetry between identical trucks. The price: capacity must be written as exponentially many group rules, added as cuts. Set partitioning gives stronger bounds but needs column generation.
  • Is $\ell(S) = \lceil q(S)/Q \rceil$ the true number of trucks? No, a lower bound. Three customers of demand 6 with $Q = 10$ need 3 trucks, not 2. The rule stays valid, just weaker.
  • (1.7) equals (1.4) for the other customers. What is new? Nothing in the model; the gain is in finding cuts: a small group $S$ can reveal a broken rule on its large complement.

Backup · likely question

"Are the searches exact? How is branching done?"

  • Not exact. Searches 1–6 are greedy heuristics, each at most $O(n^3)$ (Remark 3.1). Exact separation of these capacity rules is NP-hard in general, so heuristics are standard.
  • If no cut is found, a broken rule may still exist; the algorithm then branches, so the answer is still exact.
  • Branching on a fractional road, as in Achuthan et al. (1996). It also branches after tailing off: six rounds in a row with almost no bound improvement.

Backup · if asked how cuts are found

Finding broken rules fast: Searches 1–6

There are far too many groups to test them all, so the paper uses six quick greedy searches on the LP picture.

  • Start from the connected pieces of the LP answer (roads with $x \gt 0$). In our example: $\{2\}$, $\{3,4,5,6\}$, $\{7\}$, $\{8\}$. Each piece is a candidate $S$.
  • Searches 1–2: shrink a piece while the rule stays broken: (1.4), (2.1), (2.9).
  • Search 3: try unions of pieces for (1.7) and (2.9).
  • Searches 4–6 (new): grow groups by merging neighbours, and look for the "$S$ plus groups $T$" pattern of (2.3)/(2.8).

Fixed order of checks, with Searches 4–6 only when 1–3 find nothing. Each search costs at most $O(n^3)$. The searches are heuristics: they can miss a broken rule, which branching then covers.

Backup · likely question

"Why is (1.7) the same as (1.4) for the other customers?"

Using only the degree rules, with $\bar S$ = the other customers:

  1. Every road has two ends: customers give $2|\mathscr C|$, the depot $2m$, so the total road value is $|\mathscr C| + m$.
  2. Summing (1.3) over $\bar S$ and subtracting gives $x(S) + x(1{:}S) - m = |S| - |\bar S| + x(\bar S)$.
  3. So (1.7) for $S$ reads $x(\bar S) \le |\bar S| - \ell(\bar S)$: exactly (1.4) for $\bar S$.

Same LP, different view: a small set near the depot exposes a broken rule on its large complement. Toy: $\{2,7,8\}$ and $\{3,4,5,6\}$ are both broken by 2.

Backup · likely question

"Why does the three-set cut (2.3) hold?"

Take a real plan. Inside $S$ the routes form $r$ separate paths, so $x(S) \le |S| - r$, and $\sum_p x(T_p) \le |T| - k$.

  • $r = 1$: only the two ends leave $S$, so $x(E[S,T]) \le 2$. If every bound were tight, one truck would carry $S$ and two $T$'s, which the condition forbids, so one bound has slack 1: $3(|S| - 1) + 2 + |T| - k - 1$.
  • $r \ge 2$: each path meets $T$ in at most 2 roads: $3(|S| - r) + 2r + |T| - k \le 3|S| - 2 + |T| - k$.

(2.8) plus $x(S) \le |S| - 1$ gives (2.3) with $k = 3$, so (2.8) is the stronger one. Useful when $\ell(S) = 1$ and $k \ge 3$ (Remark 2.1).

Backup · likely question

"How did the hard benchmark problems go?"

problempaper rootour rootpaperours
CMT1 (50)514.58516.37optimal, 487 soptimal, 1 s
CMT12 (100)785.29818.14open*optimal, 21 s
F-n45-k4721.88723.36optimal, 35 soptimal, 1 s
F-n72-k4238.51238.48optimal, 172 soptimal, 5 s
F-n135-k71120.161155.18openoptimal, 370 s
CMT4 (150)950.65973.51openopen
CMT5 (199)1114.171196.06openopen

Single-customer routes allowed; best-known value as the first upper bound; our limit 3,600 s. *The paper solves CMT12 only when single-customer routes are not allowed (458 s). Our root bounds are higher on 13 of the 14 problems.

Backup · likely question

"Where do your results differ from the paper's, and why?"

  • Times 10–1,000× smaller: about 30 years of hardware and LP-solver progress, not the method.
  • A and B close: with our fixed root loop, (1.7) adds little that (1.4) and Search 1 don't already find.
  • More nodes on the tightest problems: the paper re-separates at every node until no cut is left and adds Gomory cuts; Gurobi gives our callback one or two rounds per node, so we branch more.
  • Slightly lower root bounds when one truck carries all: we add no Gomory cuts.

Speaker notes