1. Local search ladder
How to use
eil51
Outcome
Nearest neighbor 513.610 → 2-opt 440.900 → optimum 426.
Elysia Tools
Navigation
Math
Load TSPLIB instances, go from nearest neighbor to 2-opt to annealing, and compare how far each method lands from the known optimum.
Open static visualizationAt a Glance

Verified Results
Every parameter set and result below is a fixed output of this page's built-in model (each asserted before delivery) and reproduces directly: set the Parameters column in the interactive panel.
| Scenario | Parameters | Result |
|---|---|---|
| Local search ladder | eil51 | nearest neighbor 513.610 -> 2-opt 440.900 -> TSPLIB optimum 426 |
| Ground-truth optima | eil51 / berlin52 | 426 / 7542 built in as TSPLIB constants |
| Annealing run | n = 50, pinned seed | 83250 steps, 12585 accepted (6139 uphill); best 6.249 beats 2-opt on this seed |
| Adaptive T0 | auto schedule | initial temperature 1.1005 set automatically, bit-exact deterministic |
| Cooling profile | geometric alpha | uphill acceptance 7.4% of all moves - the annealing signature |
Sources
Papers and datasets underlying this visualization - every formula, algorithm, and data anchor on the page traces back to the sources below.
Metropolis N., Rosenbluth A. W., Rosenbluth M. N., Teller A. H., Teller E. (1953). Equation of State Calculations by Fast Computing Machines. Journal of Chemical Physics 21(6), 1087-1092.
Croes G. A. (1958). A Method for Solving Traveling-Salesman Problems. Operations Research 6(6), 791-812.
Beardwood J., Halton J. H., Hammersley J. M. (1959). The shortest path through many points. Mathematical Proceedings of the Cambridge Philosophical Society 55(4), 299-327.
Related
Next
Kirkpatrick S., Gelatt C. D., Vecchi M. P. (1983). Optimization by Simulated Annealing. Science 220(4598), 671-680.
Reinelt G. (1991). TSPLIB - A Traveling Salesman Problem Library. ORSA Journal on Computing 3(4), 376-384.
mastqe. TSPLIB instance files (community mirror). GitHub.
Tool usage guide
The traveling salesman problem (TSP) is hard to solve exactly on large instances, but a few simple heuristics often find routes of decent quality. This page first builds an initial route with nearest neighbor, improves it with 2-opt, then checks whether simulated annealing can improve it further, using TSPLIB instances with known optima to measure how far each method stays from the optimal solution.
Nearest neighbor builds quickly, but its routes usually still contain crossings (eil51: 513.610); 2-opt swaps two edges to remove the crossings it can find, bringing the length down to 440.900; the known optimum for that instance is 426. Simulated annealing occasionally accepts a worse move with probability exp(−δ/T), and as the temperature decays geometrically it often narrows the remaining gap.
Each figure has a stated source: the optimum 7542 for berlin52 is a built-in TSPLIB constant, and a fixed-seed annealing run of 83250 steps (12585 accepted, 6139 of them uphill) reached 6.249 on the 50-city instance — better than 2-opt under the same seed. The initial temperature 1.1005 is set automatically from a sample of the move distribution.
| Instance | Cities | Optimum |
|---|---|---|
| eil51 | 51 | 426 |
| berlin52 | 52 | 7542 |
| circle40 | 40 | convex hull |
| random200 | 200 | unknown — a real challenge |
Pure descent gets stuck: once every 2-opt move would make the route longer, the search freezes in a local minimum. Annealing allows a controlled budget of bad moves — here 7.4% of all moves — spent mostly while the temperature is high to buy an escape, shrinking to zero as cooling proceeds; while the acceptance rate decays, the best-so-far route length only ever decreases.
Guarantees
Annealing comes with no optimality guarantee — only convergence in the limit of infinitely slow cooling. The page always shows the TSPLIB optimum when one is known, and solution quality is measured as the gap to that known optimum.
How to use
eil51
Outcome
Nearest neighbor 513.610 → 2-opt 440.900 → optimum 426.
How to use
n = 50, fixed seed
Outcome
83250 steps, best 6.249 — beats 2-opt on this seed.
It removes all route crossings — which is already optimal for points on a circle — but on random instances it typically still leaves 3–5%; 3-opt and Or-opt close more of the gap, at cubic cost.
By sampling random moves: the initial acceptance probability is aimed at a target — automatic, deterministic, and it lands at 1.1005 on the default instance.