Channels ▼


Ant Colony Algorithms

Source Code Accompanies This Article. Download It Now.

Pheromones and Stigmergy

When traveling from their nest to food sources, a real ant deposits a chemical on the ground called a "pheromone." The ant uses this trail to find its way back to the nest, and other ants, which deposit more pheromone in turn, can then follow the trail. Over time, the colony of ants develops well-trodden paths, defined in part by the amount of pheromone left by ants that have previously traversed the same route. The ants never need to interact directly, as all the information about the actions of other ants comes from the strength of the pheromone trail. This indirect communication mechanism is called "stigmergy," a term that comes from the study of colonies of social insects.

How Does it Work?

The only features that ants in an ACO share with their real counterparts are:

  • The ability to react to their local environment; specifically, to "smell" which of several trails is most attractive.
  • A limited amount of vision, to see which of the trails in their immediate vicinity is shortest.
  • The ability to deposit pheromone.

At no point does any ant have an overview of the entire network. Instead, it is limited to sensing its immediate environment. This makes the ability to solve global optimization problems all the more impressive.

The algorithm works as follows. Initially, all trails have a small, random amount of pheromone already in place.

A worker ant sets out from the first city on the tour. At each city, the ant decides which is the next to be visited. For all cities that have not already been visited, the ant rates the attractiveness of traveling to that city by evaluating the following expression:

Here, ai,j measures the attractiveness of the route under consideration between towns i and j. ci,j is the pheromone concentration on the route between the current city and the destination under consideration. The higher the amount of pheromone, the more attractive is this path. The concentration is weighted by a power term .

di,j is the length of the route under consideration. The longer the route, the less attractive it will be. This term is also weighted by another power term .

The form of this equation shows that a nearby node with a large amount of pheromone on its route will be very attractive as a potential destination. Conversely, a distant node with very little pheromone will be unattractive. However, a distant node with a large amount of pheromone may be equally likely to be chosen as a close node with relatively little pheromone.

Turning the attractiveness (or otherwise) of the various paths into a decision about which path to take is relatively straightforward. If you add together all the attractiveness measures for each valid route and divide each measure by this total, you produce the probability that a given route will be taken, which is:

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.