Learn
Lesson · Integer Programming · Cuts, and one hard problem

The Travelling Salesman Problem

The assignment problem is a relaxation of the travelling salesman problem: it forces one departure and one arrival per city and permits several disjoint subtours. The constraints that would forbid them are exponentially many, so they are added only when a solution actually violates one. Relaxation, cut, branch, repeat solves small instances exactly — and a heuristic tour is only as good as the bound you can measure it against.

assignment relaxation one departure and one arrival per city; subtours allowed subtour cut forbid an arc of the shortest subtour, then re-solve and branch distinct undirected tours, fixed start (n − 1)!/2 360 at n = 7 6 cities 60 tours bound 80 subtours (1 5)(2 3)(4 6) optimum 88 in 5 nodes nearest neighbour 96, measured gap 8 = 1/12 nearest neighbour then 2-opt 88 — optimal here, and only a bound says so
A relaxation that leaves subtours, and a gap you can measure

Core ideas

What this lesson establishes

One hard idea: the relaxation here is not “drop integrality” but “drop one requirement”, and the requirement it drops is the one that makes a tour a tour.

1

The assignment problem is the relaxation

Choose, for each city, one city to leave for and one to arrive from, at minimum total cost. Every tour satisfies that; so does a set of disjoint subtours, which is not a tour at all. So the assignment optimum is a lower bound on the tour, and the subtours it returns are the exact way in which it failed to be an answer.

2

The constraints that forbid subtours are added on demand

There is one subtour-elimination constraint for every proper subset of the cities, which is exponentially many and cannot be written down. They are also almost all slack at the optimum, so they are added when a solution violates one: solve, find the shortest subtour, forbid an arc of it, re-solve. That is the branching, and it is a cut in the sense of the previous lesson.

3

Near-optimal is meaningless without a bound

A nearest-neighbour tour on the lab's six-city instance costs 96. Whether that is good is not a question the tour can answer. Against the optimum of 88 it is 8 worse, a measured 1/12 of the tour in hand; and improving it by 2-opt gives 88 exactly, which is optimal — a fact that only the bound could have established.

The material

A bound, the subtours it leaves, and the gap a heuristic leaves

How many tours there actually are, where the bound comes from, and why a measured gap and a proved ratio are different kinds of knowledge.

Before any method, the count — because three different numbers are in circulation and each is correct for something else. On n cities there are n! orderings of the cities; (n − 1)! tours from a fixed start, counting each once per direction; and (n − 1)!/2 distinct undirected tours, which is what you are choosing among when the cost from one city to another is the same both ways.

n = 7 n! = 5040 orderings of the cities 7!/2 = 2520 each ordering once per direction (n−1)! = 720 tours from a fixed start, both ways (n−1)!/2 = 360 DISTINCT UNDIRECTED TOURS n = 6 (n−1)!/2 = 60 and the lab enumerates exactly 60

Those 360 at seven cities are why the lab stops at seven: 360 tours can be enumerated instantly, so an exact answer is available to check every bound against, and that is worth more at this size than another city. The cap is this lab's own and it is a consequence of (n − 1)!/2 — nothing to do with the n! orderings that Discrete Mathematics’ Hamilton lab enumerates, which is a different quantity on a different object.

The claim “the number of tours is n!” is therefore an overcount by a factor of 2n: at seven cities 5040 against 360, and 5040 ÷ 360 = 14 = 2 × 7. The factor n is the arbitrary choice of starting city and the factor 2 is the direction, neither of which changes the tour or its length.

Definition · Subtour-elimination constraint

For a proper non-empty subset S of the cities, the constraint says that the chosen arcs may not form a closed cycle inside S: at least one arc must leave S. There is one such constraint per subset, so there are exponentially many, and a formulation that wrote them all down could not be built for a moderate n.

Example · Six cities: the bound, the subtours, and the tree

On the lab's opening instance the assignment relaxation is worth 80, and it returns three two-city subtours: cities 1 and 5 shuttling between each other, 2 and 3, and 4 and 6. That is a bound and not a route. Forbid one arc of the shortest subtour and re-solve; two of the children come back with a four-city subtour and a two-city one, still not a tour; forbid an arc again and the next child is a genuine tour worth 88. Five nodes in total, and the answer 88 is the route 1 → 2 → 4 → 6 → 3 → 5 → 1.

A measured gap, and a proved ratio

Nearest neighbour from city 1 gives 1 → 5 → 3 → 4 → 6 → 2 → 1, costing 96. Against the optimum of 88 that is 8 worse, which is 8/96 = 1/12 of the tour in hand — a measured gap, on this instance, for this heuristic, which the panel shows as 8.3%. with a gap of zero. That happens, and it is worth knowing rather than assuming, which takes a bound.

A measured gap and a proved ratio are different kinds of knowledge and the difference is worth a paragraph. The Algorithms path’s “Metric TSP by MST Doubling” proves a factor of two for every metric instance there is, for ever, without solving any of them. This lesson measures 1/12 on one instance, exactly, and claims nothing about the next one. The first is a theorem about a class; the second is a fact about a case — and on your own data, the fact is often what you need and is the only one of the two you can compute.

Three results are used here and proved elsewhere. The other exact method is the dynamic programme over subsets of “DP over Subsets: Held–Karp”, which runs in n² 2ⁿ time — a different trade, since it beats (n − 1)! badly and still grows exponentially. Why the problem is hard at all is “Reductions and Their Direction”, in the same subject. And the two-approximation above is that path's as well. None of the three is derived here.

The apparent tension between “hard” and “solved exactly in five nodes” is not one. Hardness is a statement about every instance of every size; a certificate is a statement about the instance in front of you. Branch and cut solves small and structured instances routinely, and the gap it reports on the ones it cannot close is exactly the honest form of the same fact — which is what this course has been building toward since the first rounded point failed.

Every cost in the lab is an integer or a fraction, so every tour length, every bound and every gap on the page is exact. That is deliberate: the one place this problem could produce an irrational number is a Euclidean distance, and a comparison between two tours that differs in the sixth decimal place is not a comparison anybody should be making on a rounded value.

Interactive

The travelling salesman

A relaxation that leaves subtours, the cuts that forbid them, and a heuristic with a number attached

Every tour, and a bound insteadthe assignment relaxation drops the one-cycle rule, and the subtours it leaves are the branching
the optimal tourthe heuristic toura node still openclosed by the bound

Method

Solving a small tour exactly, and measuring a heuristic

Five steps, and the count in the first one is what keeps the last one honest.

1

Count the tours before choosing a method

(n − 1)!/2 distinct undirected tours: 60 at six cities, 360 at seven, 2 520 at eight. Enumeration is the right method for exactly as long as that number is small, and knowing where that stops is why the other four steps exist.

2

Solve the assignment relaxation

One departure and one arrival per city, at minimum cost. Its value is a lower bound on every tour. If it happens to return a single cycle, that cycle is the optimal tour and you are finished.

3

Find the subtours and forbid an arc of the shortest

The shortest subtour is the cheapest one to break and gives the fewest children. Forbidding one arc is a cut: no tour is lost, because a tour cannot contain that subtour anyway. The panel names the banned arc by its raw index, so the city drawn as 1 appears in that column as 0.

4

Branch, and keep the bound with each node

Each child is another assignment problem with one arc forbidden, so the bound rises as arcs are banned. Close a node the moment its bound cannot beat the best tour in hand — the three closing reasons are the ones from the search lesson.

5

Measure the heuristic against the bound and report the pair

A tour of 96 is a number. A tour of 96 against a proved optimum of 88 is a result: 8 worse, 1/12 of it. Without the second number, “near-optimal” has nothing behind it.

Counts, bounds and gaps

Score 0 / 0

Six plants, the assignment bound, and two heuristic tours

The lab's opening instance at six cities, with the costs symmetric. Every figure is exact and every one can be checked against the panel.

6 cities, symmetric costs. distinct undirected tours: 5!/2 = 60 not 720 = 6!, which counts orderings not 360 = 6!/2, and not 120 = 5!, which counts each tour twice ASSIGNMENT RELAXATION value 80, and it returns three two-city subtours: (1 5) (2 3) (4 6) 80 is a lower bound on every tour; it is not a route THE TREE node 0 bound 80 subtours (1 5)(2 3)(4 6) branch on (1 5) node 1 bound 88 subtours (1 2 3 5)(4 6) branch on (4 6) node 2 bound 88 subtours (1 5 3 2)(4 6) closed by the bound node 3 bound 96 one cycle: a tour, worth 96 node 4 bound 88 one cycle: a tour, worth 88 ← the optimum 5 nodes. optimum 88 on 1 → 2 → 4 → 6 → 3 → 5 → 1 check by enumeration: all 60 tours tried, best is 88 HEURISTICS, MEASURED nearest neighbour from city 1: 1 → 5 → 3 → 4 → 6 → 2 → 1 = 96 gap 96 − 88 = 8, 8/96 = 1/12 of the tour in hand, shown as 8.3% then 2-opt: = 88 gap 0 — optimal on this instance, and the bound is how you know

Node 0's three two-city subtours are the clearest possible picture of what the relaxation dropped. Shuttling between two plants satisfies “one departure and one arrival each” perfectly, costs very little, and visits nothing. The 8 between 80 and 88 is the price of the requirement that the route be one cycle.

Node 2 is closed by the bound at 88, equal to the best tour in hand, which is the same closure the search lesson used: nothing in a node beats the node's bound. And node 3 is a reminder that a node returning a tour does not return the best one — 96 is a genuine tour and it is beaten two nodes later.

For a faded rehearsal, raise the lab to seven cities. The supplied first move is the count: (7 − 1)!/2 = 360 distinct undirected tours, six times the sixty at six cities. Predict whether the root bound rises or falls when a city is added, then read the optimum, the node count, and the measured gap of the 2-opt tour — which this time is not zero.

Common mistakes

1
Calling a heuristic tour near-optimal with no bound“Near” is a comparison and there is nothing to compare with until something has been proved. On the lab's instance nearest neighbour is 8 off, which is 1/12 of the tour, and on the next instance it could be 40%; the word carries no information either way. A tour and a bound is a result; a tour alone is a route.
2
Quoting the number of tours as n!n! counts orderings of the cities, and the tours it corresponds to are counted 2n times each: once per starting city and once per direction. At seven cities that is 5040 against 360. The overcount matters because it is the number that decides whether enumeration is possible, and it is wrong by a factor of fourteen at the size where the decision is made.
3
Taking an assignment solution as a routeOne departure and one arrival per city is satisfied by a set of disjoint shuttles, and the lab's opening relaxation returns exactly that: three pairs of plants visiting each other. Its value is a perfectly good bound and its arcs are not a plan, which is the same distinction as a fractional y in the modelling lessons.

Check your understanding

✓
Finish when a tour without a bound beside it reads as an unfinished result.

You should be able to say how many distinct undirected tours a size has and why the other two counts are counts of something else, solve the assignment relaxation and name the subtours it leaves, add a subtour cut and branch to an optimal tour with its certificate, and report a heuristic tour with its measured gap while distinguishing that from a proved ratio.

Note: The cost matrix here is integer or rational, so every tour length, bound and gap on the page is exact. A Euclidean coordinate preset would introduce surds; if one is ever added, the distances are square roots of integers, printed as surds and rounded only for display, with every comparison between tours made on the exact value. A square root of a non-square is the one place this course could round, and it does not.

Kept in this browser only, for you. Nothing is sent anywhere and nothing checks it. Carry it to another device.

Feedback and recommendations

Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.

No recommendations yet for this lesson.