How to use it
- 1. Pick an algorithmSimulated annealing wiggles one tour; the genetic algorithm breeds forty; ant colony lays pheromone.
- 2. Press runWatch the tour untangle itself. The dashed grey line is the greedy nearest-neighbour baseline to beat.
- 3. Watch the inner stateTemperature, generation diversity or pheromone trails - each method’s “mind” is drawn live.
- 4. Race themSame cities, same time budget. Reset, switch, run - which gets below the baseline fastest?
Travelling salesman, three ways
Algorithm
Run
Inner state
Red = best tour found. Faint red = the tour being tried right now.
Best-so-far tour length per iteration. Grey dash = greedy nearest-neighbour; good metaheuristics dive under it.
Try these experiments
- Run annealing and watch the “worse moves accepted” tile: high while hot, near zero when cold. That early recklessness is what escapes local optima.
- On the same 35-city map, race all three for ~15 seconds each. Note ants often find good tours early; annealing polishes deepest.
- Restart annealing several times - different final tours! Metaheuristics trade the guarantee of optimality for speed at scale.
About this tool
The concept
TSP with 45 cities has ~1054 tours - enumeration is hopeless. Metaheuristics search intelligently: accept some bad moves, recombine good parents, follow collective trails.
How it works
SA: 2-opt moves, accept worse with e−Δ/T, geometric cooling. GA: order crossover + swap mutation, tournament selection. ACO: 20 ants, pheromone τα·(1/d)β with evaporation.
Winning strategy
None dominates - the No-Free-Lunch theorem. Diversify early, intensify late: exactly what cooling schedules, mutation decay and pheromone evaporation all do.