Ant Colony Optimization (acopy)

Swarm Intelligence Algorithm

Ant Colony Optimization (ACO) is a nature-inspired metaheuristic algorithm based on the foraging behavior of ants. Developed by Marco Dorigo in the 1990s, it mimics how ants find optimal paths from their nest to food sources by depositing and following pheromone trails. The algorithm uses a population of artificial ants that build solutions incrementally, guided by pheromone information and heuristic values.

Ant Foraging Metaphor

Ant Colony Optimization mimics ant foraging behavior:

  • Pheromone Trails: Chemical markers indicating solution quality
  • Ant Agents: Artificial ants building solutions step by step
  • Probabilistic Construction: Choose next move based on pheromone and heuristic info
  • Collective Intelligence: Global optimization through local interactions

Interactive 3D Visualization

See Ant Colony Optimization in action on 3D optimization surfaces:

Loading 3D visualization...

Requires WebGL support

Instructions: Choose a test function and algorithm, then click Start to watch the step-by-step optimization process.

Implementation Details

Component Details Links
Original Algorithm Marco Dorigo
Pheromone-based metaheuristic inspired by ant foraging.
Continuous variant: ACOR (Socha & Dorigo, 2008).
Published: 1992 (ACO), 2008 (ACOR)
ACOR Paper
Reference Implementation mealpy ACOR
Tested against mealpy's continuous ACOR.
Reference: mealpy.swarm_based.ACOR.OriginalACOR
mealpy
HumpDay Python HumpDay AntColonyOpt
Socha-Dorigo continuous ACOR: maintain an archive of k solutions ranked by fitness; sample new solutions from a Gaussian kernel over the archive (mixture weights from rank-based probabilities).
Pure Python; no required dependencies.
File: humpday/optimizers/evolutionary_algorithms.py
Source
HumpDay JavaScript Browser AntColonyOpt
Mirrors the Python ACOR port.
Class: AntColonyOpt
JS Implementation

Performance characteristics

  • Best for: Continuous optimization with multimodal landscapes. The archive sampler keeps diversity while concentrating mass near good solutions.
  • Worst for: Tight-budget smooth problems where a directional method (CMA-ES, PRIMA) would converge faster.
  • Per generation: draw new samples from the Gaussian-kernel mixture over the archive; evaluate; merge into the archive and keep the top k.
  • Relative to mealpy ACOR at n_trials=200, n_dim=2: HumpDay wins on sphere and Ackley; ties on Rosenbrock. See SOTA status for the live numbers.

Educational resources

Core algorithm components

  • Archive: a sorted set of the k best solutions found so far. Each archive entry is a vector in [0, 1]n.
  • Rank-based weights: archive entry i gets sampling weight wi ∝ exp(−i2/(2q2k2)), concentrating mass at the top.
  • Gaussian kernel sampler: draw a new solution by (1) picking an archive entry by weight, then (2) sampling each coordinate from a Gaussian centred on that entry's coordinate, with bandwidth equal to a scaled mean absolute deviation across the archive.
  • Archive update: evaluate the new sample and merge it into the archive; drop the worst entry to maintain size k.