Logo image cannot be loaded

Termites nest simulation : model

This page illustrates how the IODA modeling methodology designs a simulation that aims at reproducing the termites nest construction phenomenon. It uses the following plan:

  1. Simulation problem description
  2. First phase: identification of agents and interactions
  3. Second phase: Specification of interactions (1/2)
  4. Third phase: Specification of the environment (1/2)
  5. Fourth phase: Specification of interactions (2/2)
  6. Fifth phase: Agents description (1/2)
  7. Sixth phase: Specification of the environment (2/2)
  8. Seventh phase: Agents description (2/2)
  9. Eighth phase: Agents interaction selection
  10. Nineth phase: Time representation
  11. Tenth phase: Simulation initialization
  12. References

This simple model is used to describe as accurately as possible the thought process leading to the final model. Consequenlty, the speech used in this page is quite didactic. If you are only interested in how the model is formulated, then focus on the images that lie all along the example.

Back to top Simulation problem description

This modeling problem is inspired from the Termites model of Mitchell Resnick [1].

This simulation aims at reproducing the behavior of termites gathering wood chips into piles. The termites follow a set of simple rules. Each termite starts wandering randomly. If it bumps into a wood chip, it picks the chip up, and continues to wander randomly. When it bumps into another wood chip, it finds a nearby empty space and puts its wood chip down. With these simple rules, the wood chips eventually end up in a single pile.

The expected emergent phenomenon is the creation of piles of wood chips.

Back to top First phase: identification of agents and interactions

The first agent family of this simulation is obvious: Termite agents. Thus, in this early step of the modeling phase, the interaction matrix is:
Source \ Target
Termite
As the specification above states, Termite agents start the simulation Wandering in the environment.
Thus, an assignation element can be added in the matrix displayed above. This assignation element requires no target agent, since it corresponds to a move made independently from the other agents in the environment. The interaction matrix of the simulation becomes:
Source \ Target
Termite (Wander)
The model also states that If it bumps into a wood chip, it picks the chip up. Thus, a new entity is identified: Wood chips. Since IODA designs any entity of the simulation with agents, Wood chip corresponds to a new agent family. A new interaction between Termites and Wood chips can be added to the matrix, in order to make Termites able to Pick up Wood chips.
The sentence If it bumps into a wood chip means that the distance between the Termite and the Wood chip has to be 0. This leads to the matrix shown to the right.
Source \ Target Wood chip
Termite (Wander) (Pick up, d=0)
Wood chip
The model states that When it bumps into another wood chip, it finds a nearby empty space. Thus, a new interactions has to be added between Termite and Wood chip agents: Find empty place. Finding a nearby empty place can be achieved by moving in the environment until the Termite bumps no more into Wood chips. This role will be played by the Find empty place, which will be performed unless the distance between source and target is greater than 0.
Once a nearby empty place is found, the Termite puts the Wood chip it carries on the ground. This interaction does not require a target agent, since the Find empty place interaction made sure that no Wood chips lie at the current position of the Termite.
Source \ Target Wood chip
Termite
(Wander)
(Put down)
(Pick up, d=0)
(Find empty place, d=0)
Wood chip

Back to top Second phase: Specification of interactions (1/2)

Finding a nearby empty place can be achieved by wandering in the environment until the distance between the Termite and every Wood chips is greater than 0. Consequently, the Find empty place interaction can either inherit from the Wander interaction (see Fig.1), or be simply replaced by the Wander interaction (see Fig.2).

Highslide JS
Fig.1: Solution where the Find empty place interaction inherits from the Wander interaction.
Source \ Target Wood chip
Termite
(Wander)
(Put down)
(Pick up, d=0)
(Wander, d=0)
Wood chip
Fig.2: Solution where the Find empty place is replaced by the Wander interaction.

From this point on, the Find empty place inherits from the Wander interaction.

The Wander interaction is common in simulations taking place in a two or three-dimensional space. Thus, finding such interaction in an interaction library is not impossible. Yet, for illustration purpose, we make the assumption that such a library does not exist in this modeling problem.

Defining how an agent moves in the environment depends on the specificities of the environment. Indeed:

  • in a three dimensional continuous space, three floating point coordinates are used;
  • in a two dimensional continuous space, two floating point coordinates are used;
  • in a two dimensional discrete space, two integer coordinates are used.

Back to top Third phase: Specification of the environment

For this simulation, we choose to use a two dimensional continuous environment. This choice makes the assumption that the altitude and the ground topology has no influence on the nest formation phenomenon. Moreover, we assume that the environment is a torus.

Back to top Fourth phase: Specification of interactions (2/2)

Now that the notion of position within the environment is defined, the semantic of the Wander interaction can be determined. In our case, we suppose that random moves are achieved by turning the source agent with a particular angle, and then by moving it forward in a particular distance. The angle and the distance depend on the properties of the agent, thus they will be expressed in abstract primitive.

The angle used to turn the agent is based on a primitive called getDeviationAngle(), which returns a double value expressing the angular speed, in radians, of the agent. The angle is a random number drawn within the interval [- getDeviationAngle(); getDeviationAngle()]. The distance of the move depends on agents speed, which is provided thanks to the getSpeed() primitive.

If we consider that the environment provides two methods moveAgentForward(Agent, double) and turnAgent(Agent, double), and that random number generation is achieved thanks to the random() function, then the Wander interaction corresponds to:

degenerate interaction
Wander(Source)
Description Source agent wanders, by turning from a random number, and then moving forward for a particular distance.
Trigger true
Preconditions true
Actions
double angle = Source.getDeviationAngle() x (2 x random() - 1);
environment.turnAgent(Source, angle);
environment.moveAgentForward(Source, Source.getSpeed());

Consequently, this interaction defines a single function, called Wander Source Function, which specification is:

function in interaction
Wander Source Function
Primitive name Primitive documentation
getDeviationAngle() Defines in which interval the angle used to turn the agent is drawn. This interval is [-getDeviationAngle(); getDeviationAngle()].
getSpeed() Defines the distance of the move.

Apart from the one being degenerate and the other not, there is no difference between the Wander and the Find empty place interactions. Thus, the Find empty place interaction has the following specification (super.trigger(Source) means to call the trigger of the parent interaction):

interaction
Find empty place(Source, Target)
Description Source agent finds an empty place, by getting away from it currently place, which is occupied by target agent. It gets away by turning from a random number, and then moving forward for a particular distance.
Trigger super.trigger(Source)
Preconditions super.preconditions(Source)
Actions super.actions(Source);

Since the Target has to define no primitive, the Find empty place Target Function function in interaction Find empty place is empty. The Find empty place Source Function function in this interaction is the same than the Wander Source Function function in interaction Wander.

function in interaction
Find empty place Source Function
Primitive name Primitive documentation
getDeviationAngle() Defines in which interval the angle used to turn the agent is drawn. This interval is [-getDeviationAngle(); getDeviationAngle()].
getSpeed() Defines the distance of the move.
function in interaction
Find empty place Target Function
Primitive name Primitive documentation

The analysis of the problem leads to the conclusion that the Pick up interaction can be performed only if it is not already carrying something. This point is defined thanks to an abstract primitive called carriesSomething(). Adding the target of the interaction to the inventory of the source is made thanks to the setCarriedElement(Target) primitive. Obviously, this interaction removes from the environment the Target of the interaction once the Source picked it up.

Consequently, the Pick up interaction corresponds to:

interaction
Pick up(Source, Target)
Description Source agent Picks up target agent. Target agent is removed from the environment, and put into the inventory of source agent.
Trigger true
Preconditions ¬ Source.carriesSomething()
Actions
environment.remove(Target);
Source.setCarriedElement(Target);

Since the Target has to define no primitive, the Pick up Target Function function in interaction Pick up is empty.

function in interaction
Pick up Source Function
Primitive name Primitive documentation
carriesSomething() Checks if the agent is already carrying anything.
setCarriedElement(Agent t) Adds to the inventory of the agent the t agent.
function in interaction
Pick up Target Function
Primitive name Primitive documentation

The Put down interaction can be performed only if the Source agent already carries something. Thus, this interaction also manipulates the carriesSomething() primitive. The getCarriedElement() primitive returns the agent carried by the source agent.

If we consider that the environment provides a method add(Agent, Position) that adds an Agent at a particular position in the environment, and a method getPosition(Agent) that tells the position of an agent in the environment, the the Put down interaction corresponds to:

degenerate interaction
Put down(Source)
Trigger true
Preconditions Source.carriesSomething()
Actions
Agent a = Source.getCarriedElement()
environment.add(a, envronment.getPosition(Source));

The function associated to this interaction is then:

function in interaction
Put down Source Function
Primitive name Primitive documentation
carriesSomething() Checks if the agent is already carrying anything.
getCarriedElement() Gets the agent carried by the source agent, and returns it. This method removes the agent from the inventory of the source.

Back to top Fifth phase: Agents description (1/2)

During this phase, we have to determine:

  • what abstract primitives each agent family has to implement;
  • how to implement these primitives;
  • how do agent perceive in the environment;

If we read the interaction matrix, we can find out which function is played by the agent families in the different interaction occuring during simulation. In our case, the Termite agent family plays a Source function in the Wander, Pick up, Put down and Find empty place interaction. Wood chips play a Target function in the Pick up and Find empty place interactions. By observing the specification of these interactions, we can identify which primitives have to be implemented by agent families.

If we consider that writing this.inventory corresponds to accessing the inventory attribute of the agent, then the specification of agents primitives is:

Agent family Primitive name Primitive implementation
Termite getDeviationAngle() return π / 4
getSpeed() return 1
carriesSomething() return this.inventorynull
setCarriedElement(Agent t) this.inventory = t;
getCarriedElement()
Agent tmp = this.inventory
this.inventory = null
return tmp

This implementation of the primitives means that:

  • Termites have an attribute called inventory, which type is Agent;
  • the deviation angle and speed of all termites is the same.

How perception is made depends on how agents are represented in the environment. This requires to refine the definition of the environment.

Back to top Sixth phase: Specification of the environment (2/2)

We suppose that agent are represented by a ground surface in the environment. In such an environment:

  • Termites are represented by a point;
  • Wood chips are represented by a 1 x 1 square surface;

The position of an agent corresponds to the position of the center of its surface.

In such an environment, the distance between agents is the minimal distance that separates their ground surface.

Back to top Seventh phase: Agents description (2/2)

In the latter definition of the environment, the halo can be defined as a surface. In such a case, perceived agents are agents, which surface intersects the halo.

For that simulation, we arbitrarily chose that Termites agent perceive only by touch. Thus, their halo is a point (their position).

Wood chips do not perceive in the environment.

Back to top Eighth phase: Agents interaction selection

The interpretation of the problem description leads to the identification of the following refined interaction matrix:

Source \ Target Wood chip
Termite
(Wander, p=0)
(Put down, p=1)
(Pick up, d=0, p=3)
(Find empty place, d=0, p=2)
Wood chip

This matrix means that the top priority of Termites is to Pick up Wood chips. If they cannot, it means either that they already carry one, or that no one can be found at a distance of 0. In the first case, they have to find a location where to put the Wood chips: Find an empty place if current position is occupied by a Wood chip, or Put down carried Wood chip if current place is empty. In the second case, they have to find a Wood chip to carry, and thus Wander in the environment.

Back to top Nineth phase: Time representation

Since the impact of time on that simulation is assumed to be almost nonexistent, we chose it arbitrarily: a discrete time representation, where agents act in sequence.

Back to top Tenth phase: Simulation initialization

We (arbitrarily) suppose here that the simulation takes place in a 50 x 50 environment, containing 100 Termites put in the environment at random positions, and 1000 Wood chips also put in the environment at random positions. At the beginning of the simulation, Termites are carrying nothing.

Back to top References

  1. Wilensky, U. (1997). NetLogo Termites model. http://ccl.northwestern.edu/netlogo/models/Termites. Center for Connected Learning and Computer-Based Modeling, Northwestern University, Evanston, IL.

Copyright © 2001-2009 Philippe Mathieu  --   Legal mentions  --   Valid XHTML 1.0 Transitional  --  W3C validation image