Skip to content
StackDecode
AI & ML Atlas
Artificial IntelligencealgorithmInteractive simulation

Ant Colony Optimisation

Virtual ants lay pheromone on good routes so later ants follow them.

The idea

Real ants find short paths because shorter routes get more pheromone per trip. In ACO each artificial ant builds a tour using probabilities that favour strong pheromone and short edges. After a round, pheromone evaporates a little and good tours are reinforced, so the colony converges on a short route.

P(i→j) ∝ τᵢⱼ^α · (1/dᵢⱼ)^β

Watch it run

This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.

12345678
  • pheromone
  • best tour

Eight cities. Every road starts with the same faint scent (pheromone, orange). Ants will build tours and leave scent on the roads they use.

round:
0
best length:
–
1/26

Thicker orange roads carry more pheromone.

Step by step

  1. 1Start with equal pheromone on every edge.
  2. 2Each ant builds a tour, choosing edges in proportion to pheromone × closeness.
  3. 3Evaporate some pheromone from every edge.
  4. 4Add pheromone along each ant's tour, more for shorter tours.
  5. 5Repeat; the best tour emerges.

Where it is used

Travelling salesman, vehicle routing, network routing.

Watch out for

Needs tuning of evaporation and α, β. It can lock onto an early mediocre route.

Related