Ant Colony Optimization
Ant Colony Optimization (ACO)
- Year introduced
- 1996
- Original authors
- M. Dorigo; V. Maniezzo; A. Colorni
- Source of inspiration
- Ant pheromone trails
- Search space
- Combinatorial
- Optimization types
- Feature Selection, Neural Architecture Search, Hyperparameter Optimization
- Applied research in the repository
- 8
Overview
A constructive algorithm: each ant builds a solution step by step by probabilistic choice based on the pheromone τ and the heuristic information η, then the pheromone is updated by evaporation and deposit. It was designed for combinatorial problems such as TSP, and has a continuous version, ACO_R.
Source of inspiration and mechanism

Ants lay pheromone as they walk, so the pheromone concentrates on the shorter paths because they are travelled faster; with evaporation the bad paths are forgotten. This indirect collective memory (Stigmergy) is the basis of the algorithm.
Initialization
Equal initial pheromone on all edges (or a random archive in ACO_R).
Update mechanism
The pheromone is updated after all ants (or only the best ones in MMAS) finish building.
Exploration
Evaporation prevents the pheromone from piling up on a single path; randomness comes from the probabilistic choice.
Exploitation
Good paths are reinforced by the deposit; in ACO_R a small q favours the best solutions.
Mathematical description
In Ant System the probability of moving from i to j is computed from the strength of the pheromone and the heuristic information, then the pheromone evaporates at rate ρ and a deposit inversely proportional to the path length is added. In ACO_R (Socha & Dorigo 2008) the pheromone is replaced by an archive of solutions sampled with a Gaussian kernel.
Transition probability
p_{ij}^{k} = \frac{\tau_{ij}^{\alpha}\,\eta_{ij}^{\beta}}{\sum_{l\in N_i^k} \tau_{il}^{\alpha}\,\eta_{il}^{\beta}}η_ij=1/d_ij in TSP.
Pheromone update
\tau_{ij} \leftarrow (1-\rho)\,\tau_{ij} + \sum_{k} \Delta\tau_{ij}^{k},\quad \Delta\tau_{ij}^{k} = \frac{Q}{L_k}ρ is the evaporation rate, L_k the tour length of ant k.
ACO_R: weight of solution l in the archive
\omega_l = \frac{1}{qk\sqrt{2\pi}} e^{-\frac{(l-1)^2}{2q^2k^2}}q controls the preference for better solutions.
ACO_R: standard deviation
\sigma_l^{i} = \xi \sum_{e=1}^{k} \frac{\left|s_e^{i} - s_l^{i}\right|}{k-1}ξ is similar to the evaporation rate.
Computational complexity: O(T\cdot m\cdot n^{2})\ \text{(TSP)};\quad O(T\cdot m\cdot k\cdot D)\ \text{(ACO}_R)
Pseudocode
Initialize pheromone tau
for t = 1..T:
for each ant k:
build a solution step by step using p_ij
evaluate solutions
evaporate: tau = (1 - rho) * tau
deposit pheromone on edges of good solutions
return best solution
# ACO_R (continuous): keep an archive of k solutions sorted by fitness;
# each ant picks a guide l with prob ~ w_l and samples N(s_l, sigma_l)Python implementation
This code was actually run while building the lab (NumPy) on the sphere function to make sure it works; this is a run test, not a performance claim.
import numpy as np
def aco_r(f, lb, ub, dim, archive=30, ants=20, iters=200, q=0.1, xi=0.85, seed=0):
"""ACO for continuous domains (ACO_R, Socha & Dorigo 2008): Gaussian kernel over a solution archive."""
rng = np.random.default_rng(seed)
k = archive
S = rng.uniform(lb, ub, (k, dim))
fs = np.apply_along_axis(f, 1, S)
order = np.argsort(fs); S, fs = S[order], fs[order]
rank = np.arange(1, k + 1)
w = np.exp(-((rank - 1) ** 2) / (2 * (q * k) ** 2)) / (q * k * np.sqrt(2 * np.pi))
p = w / w.sum()
curve = []
for _ in range(iters):
new = np.empty((ants, dim))
for a in range(ants):
l = rng.choice(k, p=p) # choose a guiding solution
sigma = xi * np.abs(S - S[l]).sum(axis=0) / (k - 1)
new[a] = rng.normal(S[l], sigma + 1e-12)
new = np.clip(new, lb, ub)
fn = np.apply_along_axis(f, 1, new)
S = np.vstack([S, new]); fs = np.concatenate([fs, fn])
order = np.argsort(fs)[:k]; S, fs = S[order], fs[order]
curve.append(fs[0])
return S[0], fs[0], curve
if __name__ == "__main__":
sphere = lambda z: float(np.sum(z ** 2))
best, val, curve = aco_r(sphere, -100, 100, dim=10)
print("best fitness:", val)
Coefficients
| Parameter | Symbol | Typical value | Range | Description |
|---|---|---|---|---|
| Pheromone weight | α | 1 | 0.5 – 2 | Influence of the pheromone |
| Heuristic weight | β | 2–5 | 1 – 5 | Influence of the heuristic information |
| Evaporation rate | ρ | 0.1–0.5 | 0.01 – 0.5 | Evaporation rate |
| ACO_R locality | q | 0.1 | 0.01 – 0.5 | Preference for better solutions |
| ACO_R deviation | ξ | 0.85 | 0.5 – 1 | Sampling range |
Advantages
- Excellent for combinatorial and routing problems
- Builds solutions constructively, so it handles constraints easily
- Incorporates problem-specific heuristic knowledge.
Limitations
- Needs adaptation for continuous problems
- Memory cost O(n²) for the pheromone matrix
- Sensitive to ρ, α and β.
Use in artificial intelligence
Domains documented in the card: Machine learning, deep learning, Feature Selection, hyperparameter tuning, Architecture search
TSP, task scheduling and routing, feature selection with features represented as nodes, continuous problems through ACO_R.
Related models in the relationship table
- Decision Tree — Feature selection Published result
- K-Nearest Neighbors — Feature selection Published result
- Naive Bayes — Feature selection Published result
Hybridization potential
- GA — Genetic Algorithm Design this hybrid
- PSO — Particle Swarm Optimization Design this hybrid
- SA — Simulated Annealing Design this hybrid
These are partnerships suggested theoretically in the card; any resulting design is presented as a "proposed hybrid method" until its results are compared with the literature.
Applied research from the repository
- Thyroid disease classification based on ant colony optimization algorithm with hybrid particle swarm and grey wolf optimization PSO-GWO Partially verified
- Information-Theory-based Nondominated Sorting Ant Colony Optimization for Multiobjective Feature Selection in Classification Partially verified
- An Ant Colony Optimization Based Feature Selection for Web Page Classification Partially verified
- Ant Colony Optimization Based Feature Selection Method for QEEG Data Classification Partially verified
- Ant colony optimization-based feature selection method for surface electromyography signals classification Partially verified
- Combination of Ant Colony Optimization and Bayesian Classification for Feature Selection in a Bioinformatics Dataset Partially verified
- Ant colony optimization for continuous domains Verified
- Ant colony Optimization for Feature Selection and Classification of Microcalcifications in Digital Mammograms Partially verified
Related lessons
Original reference
M. Dorigo; V. Maniezzo; A. Colorni (1996). Ant system: optimization by a colony of cooperating agents. IEEE Transactions on Systems, Man, and Cybernetics, Part B (Cybernetics), IEEE.
Verified DOI: 10.1109/3477.484436
