An Analysis of Several Heuristics for the Traveling Salesman Problem III: Nearest and Cheapest Insertion Are Within a Factor of TwoResearch Paper
Motivation
The traveling salesman problem (TSP) asks for a shortest closed route through a finite set of points. It is NP-hard, and in practice tours are built by fast constructive heuristics whose output is then improved or used as is. A central question in the analysis of algorithms, raised in this form by Rosenkrantz, Stearns and Lewis in 1977, is how far such a heuristic can be from optimal in the worst case, as a function of the number of points , when the distances satisfy the triangle inequality.
The paper (SIAM J. Comput. 6(3), 1977) answers this for several heuristics. For the general class of insertion methods it proves a logarithmic bound (Theorem 3); for two specific rules, nearest insertion and cheapest insertion, it proves a bound that does not grow with : the tour is less than twice the optimal (Theorem 4), and more precisely at most times the optimal (Corollary, eq. (4.12)). Theorem 5 of the same paper shows the constant is attained, so this is the exact worst case of both rules. These results, with Christofides' 3/2 bound of 1976, are the classical reference points for approximation ratios of TSP construction heuristics and appear in standard OR and approximation-algorithm texts.
Setting
A traveling salesman graph has a finite node set with and a distance that is symmetric, nonnegative and satisfies the triangle inequality . A tour is a circuit visiting every node exactly once; its length is the sum of its edge lengths, and OPTIMAL is the least tour length.
A subtour is a tour on a subset of (a one-node subtour has no edges). For , inserts into where it is cheapest: if has at least two nodes, choose an edge of minimizing and replace it by ; if , form the two-node tour on . is the length of minus the length of .
An insertion method builds subtours with and for some , ; INSERT is the length of . With :
- nearest insertion chooses each with ;
- cheapest insertion chooses each with .
The start node and every tie (between candidate nodes, and between candidate edges) are arbitrary. TREE denotes the length of a minimal spanning tree of .
Formalization targets
Goal: Corollary to Theorem 4, eq. (4.12)
For every traveling salesman graph on nodes and every run of nearest insertion or of cheapest insertion,
Milestones
- Lemma 2, (3.3): for , .
- Eq. (3.7): for every insertion method, .
- Eqs. (4.9)–(4.10): nearest insertion satisfies for all , (4.5).
- Proof of Theorem 4: cheapest insertion satisfies (4.5) as well.
- Lemma 3: every insertion run satisfying (4.5) has (4.6).
- Eq. (4.11): .
Theorem 4 itself, when is not identically zero, is included as a companion statement.
Significance
The bound says that two simple and construction rules are never worse than a factor from optimal on any metric instance, a guarantee independent of , in contrast with nearest neighbor and with arbitrary insertion orders, whose ratios the same paper shows can grow logarithmically. Lemma 3 is reusable on its own: any insertion rule satisfying the local inequality (4.5) inherits the bound , and the paper notes that similar arguments apply to nearest addition and nearest merger.
The result has been proved since 1977. The Prove2Me library has a machine-checked proof of the weaker statement for nearest insertion only with constant (SupplyChainTheory.nearest_insertion_bound, from Snyder–Shen, Theorem 10.7) and of (SupplyChainTheory.mst_lower_bound). This mission asks for the paper's full statement: both rules, the exact constant , and the general Lemma 3 via its correspondence between insertion steps and spanning-tree edges. Paired with the tightness result of the companion mission (Theorem 5), it would give a formally verified exact worst-case ratio for both heuristics.
Difficulty
Lemma 2 and inequality (4.5) are local consequences of the triangle inequality; the difficulty is global. The obvious attempt at Lemma 3 charges step to the tree edge joining to its nearest node of , but distinct steps can then be charged to the same tree edge, and the sum of the charges no longer bounds . Any correct argument must control how the insertion order interacts with the structure of an arbitrary spanning tree, which in Lean means reasoning about paths in SimpleGraph together with the evolving subtours. For cheapest insertion the chosen node need not be a nearest node, so (4.5) is not immediate from the rule. Finally, the goal's constant is sharper than the bound obtained from , so the weaker spanning-tree bound already in the library does not suffice.
Formalization scope
Nodes are Fin n with (the paper's nodes shifted to ). The distance satisfies the paper's three axioms plus the normalization , which never affects a tour, subtour or tree length. Tours are permutations; OPTIMAL is a minimum over all of them (Finset.inf'). Subtours are lists of distinct nodes with closed length. is encoded as insertion of at a list position whose resulting length is minimal over all positions, which is the minimization of (3.1) over the edges of ; COST is the corresponding minimum increase. The subtour index is 1-based as printed (, final). The distance is taken in , so no default value enters the nearest rule. Spanning trees are SimpleGraph (Fin n) with IsTree; statements about TREE are phrased over every spanning tree (upper bounds) or some spanning tree (bounds on TREE), which is equivalent. Ratios are multiplied out, so the goal needs no nontriviality hypothesis; Theorem 4's strict form carries the paper's exclusion of the identically zero distance (p. 564).
A formalization in which TOUR inserts at an arbitrary rather than a cheapest position, or in which the run fixes the start node or the tie-breaking, would state a different (and, for arbitrary positions, false) theorem; the statements here quantify over every run.
A complete development needs subtour-length lemmas for List.insertIdx, the telescoping identity (3.7), and a spanning-tree edge-assignment argument on Mathlib's SimpleGraph paths; the last two are reusable for other insertion rules and for the companion missions of this series. Proofs of any milestone are welcome independently.
Selected references
- D. J. Rosenkrantz, R. E. Stearns, P. M. Lewis II, An Analysis of Several Heuristics for the Traveling Salesman Problem, SIAM Journal on Computing 6(3):563–581, 1977. https://doi.org/10.1137/0206041
- N. Christofides, Worst-Case Analysis of a New Heuristic for the Travelling Salesman Problem, Report 388, GSIA, Carnegie Mellon University, 1976. https://doi.org/10.1007/s43069-021-00101-z (reprint in Operations Research Forum 3, 2022)
- L. V. Snyder, Z.-J. M. Shen, Fundamentals of Supply Chain Theory, 2nd ed., Wiley, 2019, Chapter 10 (Theorem 10.7). https://doi.org/10.1002/9781119584445