liveBook · Manning

Traveling Salesman problem

As explained in Inside AI

The traveling salesman problem is an optimization problem that seeks the best route visiting each location exactly once and returning to the starting location.

The traveling salesman problem asks for the best order in which to visit several cities, visiting each exactly once and returning to the start. “Best” may mean shortest, cheapest, or most scenic. The difficulty grows rapidly as more locations create a combinatorial explosion of possible routes. section 2.5

A genetic algorithm approaches the problem by:

  • Creating an initial population of possible routes, either randomly or with heuristics. section 2.5
  • Scoring each route with a fitness function, such as total distance. section 2.5
  • Selecting stronger routes and combining portions of routes to produce new candidates. section 2.5

Why exhaustive search fails

The number of routes rises from 24 for four locations to 2,432,902,008,176,640,000 for twenty, making a list-and-check strategy impractical. section 2.5

Figure 2.2 Flowchart of a genetic algorithm
figure

Use the flowchart to follow the genetic algorithm’s route-generation, evaluation, selection, and crossover cycle. section 2.5

How Inside AI covers it

How deep it goes
Explains route representation, fitness evaluation, selection, and crossover, but does not provide implementation details.
Examples
Uses city tours and route-count comparisons, including a twenty-location example with an astronomical number of possible routes.
What you can do after
Evaluate/understand why genetic search can replace exhaustive route comparison when possible solutions grow dramatically.
How it connects
Connects combinatorial explosion with genetic algorithms, heuristics, fitness functions, selection, and crossover.

Also explained in

Compare how 6 books explain Traveling Salesman problem →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Inside AI. The section links point to the parts of the book it draws on.