Repository navigation
🧩 Constraint Solving POTD:Problem of the Day: Traveling Salesman Problem #75889
Closed
Replies: 1 comment
|
This discussion has been marked as outdated by Constraint Solving — Problem of the Day. A newer discussion is available at Discussion #76225. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem Statement
Given a set of cities and the distance between every pair, find the shortest tour that visits each city exactly once and returns to the start. This is the Traveling Salesman Problem (TSP).
Small instance (5 cities, symmetric distances):
nand ann × ndistance matrixd.For this instance the optimum is 26, reached by two tours:
A→B→D→C→E→AandA→B→D→E→C→A(reverses of each other are the same tour, so the true count is 12 undirected tours, which we verified by enumeration).Why It Matters
Modeling Approaches
1. Constraint Programming with a
circuitglobalsucc[i] ∈ {1..n}, the city visited immediately after cityi.circuit(succ)requires the successor links to form a single Hamiltonian cycle (no self-loops, no subtours).min Σi d[i, succ[i]].circuitpropagator tracks chains of fixed successors and prunes any value that would close a subtour early. Scaling is limited without extra bounding, so it works well for small and medium instances.Example Model (MiniZinc pseudo-code)
2. MIP with Miller–Tucker–Zemlin (MTZ) subtour elimination
x_ij(1 if the tour goesi → j), and integer positionu_i ∈ {2..n}fori ≥ 2.Σj x_ij = 1andΣi x_ij = 1(each city has one outgoing and one incoming arc).u_i − u_j + n·x_ij ≤ n − 1fori ≠ j,i, j ≥ 2(forbids subtours).min Σij d_ij · x_ij.O(n2)constraints) and is easy to extend. Its LP relaxation is weak, so the bound is loose. The stronger alternative is branch-and-cut with lazily added subtour-elimination cuts, which is how Concorde solves instances with thousands of cities.Key Techniques
circuitpropagator is far stronger than decomposing intoalldifferentplus clauses that forbid subtours, because it reasons about reachability across the whole chain structure.succvariables and re-solve the small subproblem. Pair this with 2-opt or Or-opt moves for fast, high-quality heuristic solutions.Challenge Corner
succremoves the reversed duplicates without cutting off any optimal tour?n2binaries in the MTZ model with a single-commodity flow formulation? How many constraints does it need, and how does its LP bound compare?[ai, bi]. How does the MTZ model change? How would a CP solver use the windows in propagation, for example with interval variables?References
All reactions