Simulation

Genetic Algorithms for Routing — An Interactive Evolution Simulator

Stop improving one plan and start breeding a population of them. Includes the permutation trap that breaks naive crossover.

What this simulation shows

Every method covered so far in this series works on one solution at a time. Two-Opt improves the current route. Simulated Annealing follows the current route and occasionally accepts a worse one. Tabu Search keeps a memory about the current route. There is always one plan being modified.

A genetic algorithm abandons that model. It maintains a whole population of candidate routes simultaneously, scores each one, lets the better ones reproduce, and builds the next generation from their offspring. No individual route is being improved — the population improves, because good structural fragments survive across generations while poor ones die out.

This simulator evolves a delivery route around Yorkshire and shows both the current population and the fitness curve over time.

How to use it

Press Start evolution and watch the Fitness over generations chart. The characteristic shape is a steep early improvement followed by a long, flat tail: early generations discover the obvious structure quickly, then progress slows sharply as the population converges and its members start resembling one another.

Then dismantle it with the controls.

Population size governs genetic diversity. Set it small and the population converges in a handful of generations onto whatever it started near — fast, and usually mediocre. Larger populations explore more but cost proportionally more computation per generation.

Crossover rate controls how much recombination happens versus straight copying. Randy mutation rate is the counterweight: mutation is the only mechanism reintroducing genuinely new material once the population has converged. Set it to zero and evolution stalls permanently. Set it too high and inheritance stops meaning anything, degenerating into random search.

Elite routes retained decides how many top performers survive untouched. Without elitism, the best solution found can be lost to a bad generation. With too much, the population is dominated by a few individuals and diversity collapses.

Compare Tournament selection with Roulette-wheel selection. Roulette gives selection probability in proportion to fitness, which lets one early standout dominate the gene pool. Tournaments are less sensitive to that.

Finally, press Demonstrate naive crossover. This is the most instructive control on the page. Splice two valid parent routes at a random point and the child will usually visit some customers twice and others not at all — because a route is a permutation, not an independent list of genes. Real implementations need order-aware operators specifically designed to preserve validity.

What to take away

Genetic algorithms are strong when the search space is large and poorly understood, and awkward in operational software: they are slow, stochastic, and have several interacting parameters requiring tuning. That tuning problem is itself worth studying experimentally — which is what the Design of Experiments dissertation covers, using a genetic algorithm built in Java for the Travelling Salesman Problem.

Camden County Karma Routing Lab

Earl evolves a better Yorkshire delivery route.

A genetic algorithm does not keep improving one route. It manages a population, selects the stronger candidates, combines useful route sections and introduces occasional Randy-style disruption so the search does not become stuck.

📝
EarlDefines the objective and keeps the best route on the list.
🎲
RandyIntroduces mutation: often unhelpful, occasionally brilliant.
⚠️
JoyRepresents operational constraints that cannot be ignored.
🧠
DarnellExplains why crossover, diversity and selection matter.

Best route in the current population

Generation 0
Yorkshire delivery problemLeeds depot · six required stops
Distance
Improvement0.0%
Population diversity
Best fitness
Chromosome encoding
1. Selection

Stronger routes have a higher chance of becoming parents, but weaker routes are not eliminated immediately because they may still contain a useful section.

2. Order crossover

A contiguous sequence from one parent is preserved, while unused towns are added in the relative order found in the second parent.

3. Mutation

Two towns are swapped or a section is inverted. This maintains diversity and can move the population away from a local optimum.

4. Elitism

The best routes move directly into the next generation, preventing a strong solution from being lost through unlucky crossover or mutation.

How to use this simulation

Change one input at a time, run the model, and compare the result with the starting state. Then repeat the experiment with a different constraint or strategy so you can see which relationships drive the outcome.

What to look for

Look for trade-offs, thresholds, feedback loops, and points where a locally attractive decision produces a worse system-wide result. The simulation is intended to make the article's idea observable, not to predict a real operation.

Limitations

This is a deliberately simplified model. It omits the data quality, exceptions, human judgement, and operational constraints of a live system, so treat its behaviour as an illustration of a mechanism rather than as a planning recommendation.

Back to Simulations