🧩 Constraint Solving POTD:Problem of the Day: Traveling Salesman Problem (TSP) #55368
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 #55752. |
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
The Traveling Salesman Problem (TSP) asks: given a set of cities and the distances between them, find the shortest route that visits each city exactly once and returns to the starting city.
Concrete Instance (4-City TSP):
Suppose we have cities A, B, C, D with distances:
Find a tour (e.g., A → C → D → B → A) that minimizes total distance. The tour above costs 7 + 11 + 20 + 10 = 48.
Input/Output:
ncities, distance matrixd[i,j]Σ d[π(i), π(i+1)]for i=1..n (with wraparound)Why It Matters
Real-world applications:
TSP appears everywhere optimization matters: from airport ground-handling to industrial robot arm motion planning.
Modeling Approaches
Approach 1: Constraint Programming (CP)
Variables:
succ[i]∈ {0..n-1} — the city visited immediately after city idist_total∈ N — total tour lengthConstraints:
succ[i]is distinct (permutation)circuit(succ)global constraint to ensure a single cycledist_total = Σ distance[i, succ[i]]for all idist_totalAdvantages:
circuitconstraint has efficient filteringDisadvantages:
Approach 2: Integer Linear Programming (MIP)
Variables:
x[i,j]∈ {0,1} — edge from city i to city j is in the touru[i]∈ R — position of city i in the tour (for subtour elimination)Constraints:
Σ_j x[i,j] = 1andΣ_i x[i,j] = 1for each city iu[i] - u[j] + n·x[i,j] ≤ n-1for i ≠ jΣ distance[i,j]·x[i,j]Advantages:
Disadvantages:
Modeling Approaches
Example Model (MiniZinc)
Key Techniques
1. Global Constraint Filtering
The
circuitconstraint (available in CP solvers like Gecode, Choco, OR-Tools) uses graph algorithms to:2. Branching Heuristics & Search
3. Lower Bounds & Relaxation
Challenge Corner
Open Question:
The TSP is NP-hard, but consider this variant:
Symmetry-breaking bonus:
The 4-city instance has rotational symmetry (A→B→C→D→A is equivalent to B→C→D→A→B). How would you add constraints to break this symmetry and reduce search space?
References
Applegate, D., Bixby, R., Chvátal, V., & Cook, W. (2006). The Traveling Salesman Problem: A Computational Study. Princeton University Press.
Hooker, J. N. (2012). Integrated Methods for Optimization (2nd ed.). Springer.
Constraint Programming online resources:
Heuristic algorithms for TSP:
All reactions