NetLogo banner

 Contact Us

 Modeling Commons

 User Manuals:


NetLogo User Community Models

(back to the NetLogo User Community Models)


by Daniel Washington (Submitted: 06/01/2012)

[screen shot]

Download UNMdensity-fidelity
If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".

(You can also run this model in your browser, but we don't recommend it; details here.)


This is a model of ant colony foraging behavior, based on the behavior and foraging ecology of harvester ants (genus Pogonomyrmex). This behavior is an example of a system where the simple behaviors of individuals (the ants) result in the emergent behavior of the complex system that is the ant colony. In particular, this model focuses on two strategies for information use and sharing:

- Pheromone recruitment, where ants leave trails from food sources back to the nest, which other ants can follow to find sites where other ants have found food previously. This allows ants to share information about where food has been found, and where there may be more food.
- Site fidelity, where individual ants remember the location where they last found food, and return to that location to search for more food without recruiting other ants to the site. This is a strategy for using individual rather than shared information.

This model demonstrates how ant colony behavior can be more effective as a whole unit than as individual ants. The user is able to control the ants on the left side of the simulation, by adjusting sliders that control aspects of the ants' behavior, and see a real-time comparison to optimized ant behavior on the right side.


The ants in the simulation follow four distinct behaviors.

- Initial expansion: At the beginning of the simulation, all ants start at the nest, and move away from the nest to cover ground and distribute themselves around their territory before beginning to search. (Distance_to_walk slider)
- Random search: Searching ants move at 1/4 their maximum speed (as when traveling away from or returning to the nest, following trails, or returning to known foraging sites) and make random turns while looking for food. (Turn_while_searching slider)
- Returning to the nest: When they find food, ants return to the nest, and may draw pheromone or move towards the nest at full speed. (site_fidelity slider)
- Leaving the nest: Ants decide to follow pheromone trails from the nest, or to return to the last place the ant found food, or begin a random search for food at the nest. (Density_recruit, Lay_a_trail, and evaporation_rate sliders)

The right side of the simulation is optimized using a genetic algorithm. Genetic algorithms are an optimization scheme inspired by natural selection. The behavior of the ants in this simulation is controlled by the selection of various parameters (such as a parameter that determines how much ants turn as they search for food, or how fast pheromone trails evaporate from the grid) and the effectiveness of the ant behaviors at collecting food depends on these parameter values. The genetic algorithm creates a random population of parameter sets, and tests each of these parameter sets for their ability to collect food quickly by running the model with each set of parameters. It selects successful parameter sets, recombines them with other sets, and introduces occasional random mutation into each parameter. It repeats this process over many generations until it converges on an optimal parameter set.

In the simulation, the ant colony on the right side of the grid is controlled by the parameters selected by the genetic algorithm. The colony on the left side is controlled by the user, via sliders that set the values for the parameters that determine the ants' behaviors. Can you find parameter combinations that beat the genetic algorithm? One approach may be to continulously tune parameters as the model runs to adjust the ants' behaviors to the food available on the grid over time. This may allow more efficient food collection because the genetic algorithm cannot change its parameters from moment to moment. It will be a greater challenge to find a single set of parameters that beat the genetic algorithm in the long term.


The simulation window is split into two halves. The right half is controlled by an optimized parameter set, and the left half is controlled by the user via the sliders. There are 7 sliders that alter behavior and 5 sliders that can change the initial setup.

The behavior sliders:

- Initial_expansion determines how far ants travel from the nest at the beginning of each simulation. This parameter determines the probability each tick that a traveling ant will stop traveling and begin to search. With larger values, ants tend to begin searching closer to the nest; with smaller values, ants tend to begin searching farther away.
- Turn_while_searching determines how much ants turn during their random search for food. With high values, ants turn more and search more thoroughly in a local area; with low values, ants turn less and cover more distance.
- Lay_a_trail determines ants' likelihood of laying pheromone trails as they return to the nest after finding food. With higher values, ants are more likely to leave trails. A value of 1 means that ants will lay a pheromone trail every time they find food. With values less than 1, the tendency to leave trails is also influenced by the presence of other food an ant senses nearby - ants more frequently leave trails to places where there is other food for nestmates to find.
- Site_fidelity determines ants' likelihood of deciding to return to the current location after delivering food to the nest. This allows individual ants to make use of personal memory to return to places where they have found food previously, and where more food may be found. As above, with higher values, ants are more likely to decide to return to the current location. A value of 1 means ants return to the location every time they find food. With values less than 1, this is also influenced by the presence of other food in the immediate area.
- Density_Recruit determines ants' likelihood of following pheromone trails, if they are present, from the nest after delivering food. With increasing values, ants are more likely to follow trails from the nest. This allows ants to travel to sites where food has been found by other ants. Note that the decision to follow trails conflicts with the decision to return to the last site where the ant has found food, as an ant can't do both. Therefore an optimal strategy for making use of both individual and shared information must strike a balance between these two. Because ants with individual knowledge of sites where more food is present should return to those sites instead of following pheromone trails, an ant's tendency to follow trails from the nest decreases with the amount of other food in the area where it last found food.
- Abandon_trail determine the probability each tick that an ant following a pheromone trail will leave the trail and begin searching. Ants in nature sometimes abandon pheromone trails before reaching their end in order to search for other nearby foods that have not been discovered yet.
- Trail_evaporation determines the rate that pheromone trails evaporate from the grid. Pheromone trails evaporate so that ants tend to follow trails to places where food has been found more recently. For high values, pheromone trails evaporate more quickly; for low values, pheromone trails are more permanent.

The setup sliders influence: Colony size (ant_number) and food quantity (large_piles, low_density_piles, medium_piles, random_food)


The simulation provides real time feedback through the graphs at the bottom of the screen and the boxes at the bottom of the runtime windows. The monitors give real time information about how much food has been collected on each side of the simulation. The graphs show how much of each food type is remaining. These graphs may be turned off to increase runtime speed.


Can you beat the ideal colony?
The goal for the user in this simulation is to find a set of behaviors that can consistently beat the computer controlled counterpart. Experiment with the sliders described in "How It Works" above. Try different values for each slider one at a time and observe how it changes the behavior of the ants on the left side of the simulation. After learning how each of the sliders changes the ant's behavior, can you come up with a different combination of parameter values that collects food faster than the genetic algorithm? You may be able to beat the genetic algorithm by managing the sliders' values over time to change the ants behaviors according to circumstances within a particular run, such as when an ant discovers the large pile of seeds. It may be a bigger challenge to find a single set of parameters that beat the genetic algorithm over many runs.

If you can beat the computer with a set of parameters on a standard 50 ant colony, try to scale it up! Experiment with 10- or 100- ant colonies and see if they behave as effectivey if there are more or fewer ants. In addition to adding or subtracting ants, you can see how to optimize the collection behavior if there is more or less food. Is it easier to find new parameters that beat the genetic algorithm for colonies of different sizes or different food distributions? Why might this be?


Netlogo has numerous data exportation features and graphing capabilities. These are utilized in this model through the plots at the bottom of the screen. Additionally, the program can be made to export comprehensive data on each run to a word doument which can then be analyzed in Excel or Matlab.

This model was created by Daniel Washington and Dr. Kenneth Letendre
in the lab of Dr. Melanie Moses, Departments of Computer Science and
Biology, at the University of New Mexico. Funding was from the
National Science Foundation's program in Advancing Theory in Biology
(grant #EF 1038682).

More information about the model and the ants upon which the model is
based can be found in:

T.P. Flanagan, K. Letendre, W.R. Burnside, G.M. Fricke and M.E. Moses.
(2011). “How Ants Turn Information into Food.” Proceedings of the 2011
IEEE Conference on Artificial Life:178-185.


T.P. Flanagan, K. Letendre, W.R. Burnside, G.M. Fricke and M.E. Moses.
(2012). “The Effect of Colony Size and Food Distribution on Harvester
Ant Foraging.” PLoS ONE (in press).

Original simulation URL:

(back to the NetLogo User Community Models)