🐜 Algorithms · Swarm Intelligence
📅 Березень 2026⏱ 13 min🟡 Середній

Ant Colony Optimisation: How Ants Solve Hard Problems

A single ant has a brain with roughly 250,000 neurons. A colony of 100,000 ants collectively solves shortest-path problems that stump computers. The secret: stigmergy — coordination through chemical trails, with no blueprint or central control.

1. The Biology of Ant Trails

When a scout ant finds food, it carries some back to the nest while depositing pheromones — volatile organic chemicals — along the ground. Other ants detect these chemicals with their antennae and follow the trail. If they reach the food, they reinforce the trail on their return. If the food is gone, they don't deposit pheromones, and the trail fades through evaporation.

This leads to a remarkable emergent behaviour observed by biologists in the 1980s: when two food sources are placed at equal distances but connected by paths of different lengths, an ant colony will consistently converge on the shorter path — without any ant knowing the path lengths in advance.

Why? Ants that take the shorter path complete the round-trip faster. They therefore reinforce that path more frequently per unit time. Stronger pheromone trails attract more ants, creating a positive feedback loop that eventually channels the entire colony to the short path.

2. Stigmergy & Positive Feedback

Stigmergy (from Greek: stigma = mark, ergon = work) means indirect coordination through environmental modification. No ant issues commands; no ant has a map. The environment itself stores the colony's accumulated experience as a chemical gradient.

Two competing forces keep the system from locking prematurely onto a local optimum:

Emergence analogy: Stigmergy is also how termites build mounds (up to 9 metres high, with ventilation, fungal gardens, and royal chambers) without any central blueprint. Each termite responds only to local stimuli — yet the collective produces complex, adaptive architecture.

3. The ACO Algorithm

Marco Dorigo formalised Ant Colony Optimisation in his 1992 PhD thesis (with the Ant System algorithm). The framework generalises to any combinatorial optimisation problem that can be represented as a graph with paths.

The general ACO loop:

  1. Initialise: Place a small amount of pheromone τ₀ on all edges. Place m artificial ants at random nodes.
  2. Construct solutions: Each ant builds a complete solution by visiting nodes. At each step, the ant chooses the next node probabilistically, favouring edges with more pheromone and shorter distance.
  3. Evaluate solutions: Calculate the tour length (or objective value) for each ant's solution.
  4. Update pheromones: Evaporate pheromone on all edges (multiply by 1−ρ). Then deposit new pheromone on the edges used by the best solutions.
  5. Repeat until convergence or time budget exhausted.

4. Probability Formula & Updates

The transition probability for an ant at node i choosing to move to node j is:

p(i→j) = [τ(i,j)^α · η(i,j)^β] / Σₖ [τ(i,k)^α · η(i,k)^β] τ(i,j) = pheromone level on edge (i,j) η(i,j) = heuristic desirability, typically 1/d(i,j) where d = distance α = pheromone importance parameter (typically 1) β = heuristic importance parameter (typically 2-5) Σₖ = sum over all unvisited neighbours k If α → 0: ants ignore pheromones (greedy nearest-neighbour) If β → 0: ants follow pheromones blindly (positive feedback only)

After all ants complete their tours, pheromone is updated:

τ(i,j) ← (1−ρ)·τ(i,j) + Δτ(i,j) ρ ∈ [0,1] = evaporation rate (typically 0.1-0.5) Δτ(i,j) = Σ_ants [ Q / L_ant ] if ant used edge (i,j), else 0 Q = pheromone deposit constant L_ant = total tour length of that ant Better solutions → shorter tour → more pheromone per edge → higher probability of being reused

5. ACO Variants

Ant Colony System (ACS)

Dorigo & Gambardella (1997). Key improvements: (1) only the globally best ant deposits pheromone on its tour, (2) local pheromone update during construction (ant reduces pheromone as it traverses an edge, promoting exploration of other edges), (3) pseudorandom proportional rule — ants take the best deterministic step with probability q₀, probabilistic step otherwise. ACS is typically faster and better than the original Ant System on TSP.

Max-Min Ant System (MMAS)

Stützle & Hoos (2000). Pheromone levels are bounded between τ_min and τ_max, preventing stagnation (where all ants follow the same path). Only the best ant (or best-so-far) reinforces. Extensive empirical testing shows MMAS produces best results on most TSP benchmarks.

Ant Colony Optimisation with Multiple Ant States (hypercube ACO)

Normalises pheromone to [0,1], enabling direct comparison between different problem instances and easier parameter tuning.

6. Benchmark: Travelling Salesman Problem

The Travelling Salesman Problem (TSP) — find the shortest tour visiting n cities exactly once — is the canonical benchmark for ACO. It is NP-hard: brute-force enumeration requires (n−1)!/2 tours.

TSP tour count vs. brute force: 10 cities: 181,440 tours (feasible) 20 cities: 6×10¹⁶ tours (infeasible) 50 cities: 3×10⁶² tours (hopelessly large) ACO performance on standard benchmarks (TSPLIB): eil51 (51 cities, optimal = 426): MMAS finds 426-429 (within 1%) pr1002 (1002 cities): ACO within 1-2% of optimal in seconds

ACO does not guarantee the optimal tour, but finds near-optimal solutions fast. For most practical problems (logistics, circuit board drilling, gene sequencing), a 1–2% gap from optimal is entirely acceptable.

7. Applications & Limitations

Limitations