The travelling salesman problem (TSP) asks the following question: Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city exactly once and returns to the origin city? It is an NP-hard problem in combinatorial optimization, important in operations research and theoretical computer science.
TSP can be formulated as an integer linear program. Label the cities with the numbers and define: For , let be an artificial variable, and finally take to be the distance from city to city . Then TSP can be written as the following integer linear programming problem:
The first set of equalities requires that each city be arrived at from exactly one other city, and the second set of equalities requires that from each city there is a departure to exactly one other city. The last constraints enforce that there is only a single tour covering all cities, and not two or more disjointed tours that only collectively cover all cities. To prove this, it is shown below (1) that every feasible solution contains only one closed sequence of cities, and (2) that for every single tour covering all cities, there are values for the dummy variables that satisfy the constraints.
To prove that every feasible solution contains only one closed sequence of cities, it suffices to show that every subtour in a feasible solution passes through city 0 (noting that the equalities ensure there can only be one such tour). For if we sum all the inequalities corresponding to for any subtour of steps not passing through city 0, we obtain: which is a contradiction.
It now must be shown that for every single tour covering all cities, there are values for the dummy variables that satisfy the constraints. Without loss of generality, define the tour as originating (and ending) at city 0. Choose if city is visited in step . Then since can be no greater than and can be no less than 1; hence the constraints are satisfied whenever . For , we have satisfying the constraint.
The problem has been shown to be NP-hard (more precisely, it is complete for the complexity class FPNP; see function problem), and the decision problem version (“given the costs and a number x, decide whether there is a round-trip route cheaper than x”) is NP-complete.
In the general case, finding a shortest travelling salesman tour is NPO-complete. If the distance measure is a metric and symmetric, the problem becomes APX-complete and Christofides’s algorithm approximates it within 1.5.
If the distances are restricted to 1 and 2 (but still are a metric) the approximation ratio becomes 8/7. In the asymmetric, metric case, only logarithmic performance guarantees are known, the best current algorithm achieves performance ratio ; it is an open question if a constant factor approximation exists.