Ant Colony Optimisation
Algorithms · Julia · SimulationThe following is a article adaptation of a research project I did on Ant Colony Optimisation.
1. Introduction
The Travelling Salesman Problem (TSP) is an NP-hard combinatorial optimisation problem aimed at finding the minimum-cost Hamiltonian circuit1 for some weighted graph.
TSP is ubiquitous across various domains and fields, such as network performance, package delivery routing, water resource management, and beyond [1].
Within this article, we are considering the classic formulation of this problem, where each node represents a city and edge weights represent the distances between them. This setup allows us to pose the problem statement simply and clearly:
Given a list of cities and the distances between each pair, what is the shortest possible route that visits every city exactly once and returns to the origin city?
As this problem is NP-hard, the complexity of finding an optimal solution to TSP is computationally intractable for large graph sizes. A theoretically close-to-optimal method is the Bellman-Held-Karp algorithm, which is still exponential in runtime with Big-O of [2].
As such, approximation algorithms are generally used in practice to generate best-effort solutions to TSP. One such class of algorithms are “Ant Colony Optimisation” (ACO) algorithms, from which the model for this article is sourced.
The term “Ant Colony Optimisation” describes the metaheuristic of simulating ants to optimise paths in some search space. The Ant Colony Model (ACM) used in ACO is a bio-inspired stochastic algorithm, modelled on the real-life foraging behaviours of ants in an ant colony.
Real life ants have limited visual perceptive faculties, and some species are completely blind [3]. In order to coordinate, they lay trail pheromone on the ground they walk. The path that an ant takes is random, with preference for paths marked by strong pheromone concentrations. When introduced to a new environment, ants will explore the search space randomly, and over time converge to a more efficient network by positively reinforcing shorter paths. The search procedure for ants is an autocatalytic process where the shortest routes are reinforced by the fact that pheromones have less time to dissipate when they are travelled quicker.
ACMs take inspiration from this. For a given graph, the general procedure starts with simulating a population of artificial ants that each construct a solution by randomly moving from node to node, biasing their choices toward edges with higher pheromone concentrations and favorable heuristic metrics. Once the ants complete their tours, the virtual pheromone levels are updated. By letting the shortest routes found by the ants have the greatest effect on the pheromone trails, subsequent generations are guided toward more optimal paths. The next iteration of ants will be more likely to select better paths, and will then influence the next iteration of ants after that with their own findings. The result is a dynamic system that converges to probabilistically better distributions of solutions every iteration. The next section will expand on the mechanics of this.
The base model for this analysis will be the original “Ant-Cycle” (AC) algorithm (commonly referred to as the Ant System), introduced by Marco Dorigo in 1992 [4]. To address the base model’s susceptibility to stagnation, the proposed extension divides the simulated ant population into two distinct classes of ant. “Explorers” will operate with a high tendency towards greedily selecting the shortest local paths, relying heavily on distance heuristics rather than existing pheromone trails. Conversely, “Foragers” will exhibit a stronger bias towards exploiting established pheromone trails to positively reinforce known efficient routes. This heterogeneous approach aims to balance broad search space exploration with the rapid exploitation of optimal paths, directly mitigating the risk of premature convergence.
Ultimately, this article seeks to utilise the stochastic computational simulation of ant colonies to generate near-optimal solutions for the TSP, whilst conducting rigorous empirical and theoretical analyses to evaluate the model’s vulnerability to local optima. This investigation begins with a Markov chain-based analytical model of a restricted state space to calculate the exact theoretical probability of suboptimality, then extrapolate this to full-sized problems as a trend. These analytical derivations are validated against numerical results obtained via Monte Carlo simulations. Finally, the heterogeneous heuristic extension is introduced, evaluated, and directly compared against the baseline model to demonstrate its impact on convergence rates and final solution optimality.
2. Ant Colony Model
2.1. Model Details
Building upon the search process outlined in the Introduction, candidate solutions are constructed in each iteration. As a simulated ant traverses the graph, its routing decisions are stochastic; at any given node, the ant selects its next destination by sampling a discrete probability distribution weighted by both historical trail data and local heuristics.To formally define the transition probability for an ant positioned at node , we introduce the following notation:
- Let represent the current pheromone concentration on the edge , and be the matrix of these pheromones.
- Let denote the distance of traversing an edge from .
- Let be the set of valid, unvisited candidate nodes remaining in the ant’s current tour.
Figure 1 depicts an ant at some node with three nodes left to visit in its trail ().
When constructing the probability distribution for the ant to sample from, we want to make its choice biased towards stronger pheromones but also a heuristic value to guide convergence. Thus we must introduce a heuristic factor, , that nudges the probability function in the right direction where the search space has not been adequately explored. Hence, the probability that an ant selects a given path is given by
Where . By making , we both bias ants toward stronger pheromone values, and shorter distances. In Figure 1, the ant is most likely to choose , as
- The distance is the shortest of the available options.
- The relatively high pheromone concentration indicates that previous generations of ants were successful when choosing that edge.
So far, however, we have no control over the relative effects of and . To this end, we introduce two model parameters , which act as exponents to modulate the relative influence of historical trail pheromone density versus locality. Incorporating these tuning parameters yields:
In a given iteration of this algorithm, many2 ants are simulated, each beginning at randomly uniformly sampled starting nodes.
Once all ants have been simulated and have each provided a candidate path, , with total distance , the pheromone matrix, , must be updated to encode the relative success of these traversals. This global update phase consists of two processes: pheromone evaporation and pheromone deposition.
First, to bound the pheromone accumulation and to allow the simulated colony to gradually “forget” sub-optimal paths, all edges in the graph undergo a uniform evaporation process. We introduce an evaporation rate parameter , which dictates the fraction of pheromone that dissipates per iteration:
Following evaporation, the system simulates the ants depositing new pheromones. Each ant deposits a quantity of pheromone exclusively on the edges belonging to its constructed tour, . The volume of pheromone deposited is inversely proportional to the total distance of the tour, scaled by a constant . This mechanism ensures that shorter, more optimal paths receive stronger reinforcement. The specific pheromone contribution added by ant to edge is defined as:
Consequently, the complete global pheromone update rule applied to every edge at the conclusion of an iteration combines both evaporation and the cumulative deposition from all ants:
The initial state of the pheromone matrix must be defined prior to the first iteration. A standard convention is to initialise all transitions to a uniform positive constant (e.g., for all ). This uniform distribution ensures that the initial algorithmic search space is entirely exploratory and driven primarily by the heuristic factor .
The result of this update process is not a guarantee that any single ant will find the optimal traversal in a given iteration, but rather tracking the best traversal found so far is a matter of recording it across iterations as the search progresses. The pheromone update does not directly select for the best path; it simply increases the likelihood that future ants will be guided toward it