Simulating ants communities through Internet

Manuel Alfonseca, Juan de Lara,,
Dept. Ingeniería Informática, Universidad Autónoma de Madrid Ctra. De Colmenar, km. 15, 28049 Madrid, Spain

This paper has been submited to DISC'00. It is an interactive article, in the sense that it has interactive simulations in it. This article has been generated automatically using C-OOL.


This paper describes the simulation of large ants communities through Internet. The simulation is done by means of an Object Oriented Continuous Simulation Language, designed by our group, called OOCSMP. Each ant taking part in the simulation is modelled as an object; the objective of each ant is to collect food for their community. Exchange of information can occur between colliding ants. Different situations, such as low memory ants, forgetful ants, and species of hunting ants are considered. These situations may serve as analogies for knowledge flow between human masses. A distributed scheme, executable from several Internet enabled computers, is also described for larger simulations.


Continuous simulation, Web-based simulation, Distributed simulation, Large Communities.


Internet is becoming ever more popular. The number of computers connected to it makes it possible to take advantage of the combined power of these computers and the network connecting them to solve more interesting and complex problems [Java99]. Many disciplines are re-evaluating their philosophies and techniques [Page00] in view of the services offered by Internet. As for simulation, some such services are the distributed networked architecture and common protocols for computer communication.

Object-oriented programming originated in the sixties in a discrete simulation language, SIMULA67 [Dahl66], which incorporated many of the ideas later included by Alan Kay in the first general purpose object-oriented language, Smalltalk [Digi90], and by Bjarne Stroustrup in C++ [Stro91]. Object-oriented continuous simulation languages and tools, however, took longer to arrive. Object orientation has been added to continuous simulation in two different ways:

OOCSMP is an object oriented extension of the old CSMP [IBM72] continuous simulation language, sponsored by IBM in the seventies and the eighties. OOCSMP is especially useful when the system to be modelled is composed of similar agents that interact. Other extensions that we have added to OOCSMP are: a matrix and vector algebra, the possibility of including multimedia elements in the simulations, the capability to solve partial differential equations, primitives to produce distributed simulations, etc. A compiler (C-OOL, a Compiler for the OOCSMP Language) has been built for this language. The compiler is able to generate three object languages with the simulation models: Java, plain C++, and C++/Amulet [Myer97]. In this paper, we will focus on the capability to generate Java applets.
We have used the compiler in two ways when generating Java: In previous publications, we have used different approaches to the simulation of ecosystems [Alf00b], such as solving differential equations of Volterra type. In this paper we are presenting some techniques to simulate systems composed of a large number of interacting elements. These techniques are illustrated by performing a simulation of ant communities. In this simulation, each ant will be modelled as an object. The territory where the simulation will take place is divided in regions; each region is placed in a different machine. Migration of ants between regions can take place. We have tested the system with different situations, such as low memory ants, forgetful ants, species of carnivore ants, etc.
The paper is organized as follow: section two presents the distribution scheme we use, and the advantages of using Internet in our simulation. Section three presents the basic problem in the single-machine case. Section four presents some interesting situations that have been tested. Section five extends the problem to make it distributed. Finally, section six presents the conclusions and the future work.

Distributed computing through Internet

Java is one of the most popular Internet languages. It allows platform independence and wide availability of Java programs (applets), because an applet can be accessed in a remote place and executed locally, by means of a web browser. Java programs can also communicate among themselves by means of Remote Method Invocation (RMI). RMI is similar to the traditional Remote Procedure Call (RPC) in distributed computing. In the Java distributed object model, a remote object is one whose methods can be invoked from another Java Virtual Machine, potentially on a different host.
We have implemented distribution in OOCSMP using the RMI packages, but this is transparent from the OOCSMP programmer viewpoint. The programmer only has to decide in which machine the simulation objects will be created and their behaviour executed. It is also possible to replicate objects in several machines. A single model is programmed, but it must be compiled for each machine taking part in the simulation.
The compiler locates automatically the synchronization points, and places semaphores to keep the distribution simulation equivalent to the serial one. The compiler also sets synchronization points to keep the same simulation time in all the machines taking part in the simulation.
In spite of its this high latency, the use of Internet as the interconnecting network for computing purposes has some advantages:

We must build our simulation models with latency in mind; a model will be efficient in our distribution scheme if we can identify clusters of objects that interact mostly between them, and less with other clusters. We will place each one of these clusters in the same machine to minimize communications. It is also possible to replicate computation rather than communication.
In our distribution scheme, each machine taking part in the simulation executes the simulation loop. There are no master-slave relationships between processes.

The basic model

The problem we want to simulate is a model of several ants' communities. Each community is composed of a large number of individuals (about 500), but for this applet we will consider communities of initially 125 ants, but this number can be changed. Each individual is modelled as an OOCSMP object. Each community is modelled as a collection of these objects.
In the basic model, the ants know the their anthill position, and are able to remember the position of one place where there is food. When two ants meet, they can exchange information if one of them knows where to find food. When an ant finds food, it takes some portion of it to the anthill and returns again until the food ends. In the first approximation to this problem, we will consider the amount of food to be unlimited.
We cannot properly consider these OOCSMP objects as "agents", because agents are usually considered to exhibit some kind of reasoning and learning capabilities. They are normally programmed using artificial intelligence techniques such as fuzzy logic, artificial neural networks, etc [Wool95]. Although our ants have some agent characteristics [Knap98], such as autonomy, social ability, reactivity, etc, their behaviour is programmed with equations, and they cannot reason.
Each ant will have a reference to its territory. The territory is represented as an OOCSMP class which contains information about the different food locations. For the basic model, a single territory is considered.
This basic model has a very compact representation in OOCSMP. The model is shown here.
In this model we have encapsulated all the ant behaviour in the class named "ANT", provided with methods STEP (DYNAMIC section, lines 44-45) and COLLIDE. The first method chooses between moving randomly, if the ant doesn't know where to find food, going to fetch food, or returning home if it is carrying food. The COLLIDE method checks if there is a colliding ant. If so, information is exchanged about food location. In OOCSMP, if a method is called on a collection of objects, an implicit iteration is created (the method is invoked for each element in the collection). If one of the parameters of the method is the same collection of objects that receives the message, the message is sent to each object once for every object in the collection, except for itself (an ant does not exchange information with itself). The same happens if the method is invoked over a class (in OOCSMP a collection of objects is created automatically with all the objects in a class, with the same name as the class). Each ant also plots itself in a coordinates graphic (line 58). This graphic shows the anthill position at the (0,0) coordinates, as well as the food positions.
One hundred and twenty-five ants are created (line 63) for the simulation. In the main simulation loop (line 65) we compute the number of ants that know where to find food. This 'global knowledge' curve is plotted together with each ant position, and shows interesting results, even in this basic scenario, as can be seen in the following model.

You can experiment with the simulation by changing food positions: reset the simulation (reset button), and before pressing Continue press button T1 and change arrays FOX and FOY. The press Continue. It is also possible to change the number of ants (variable _NUMANTS, accessible by pressing the Globals button).

It can be seen that this curve (the right side in figure one) exhibits a logarithmic behaviour, that depends on the distance of food locations from the anthill, and on the number of food locations. For distant food locations, the curve is shifted to the right, with less slope. As simulation time advances, it is more difficult for the ants to communicate food locations, because ants are more dispersed, so the slope of the curve decreases. On the left graphic, it can be observed a high concentration of ants around the anthill and the food places.
This model is highly scalable, as we just have to change the number of ants created. For bigger simulations, a distributed approach is appropriate, as will be seen in section five. In the next section, we will describe some interesting situations that happen when the basic model is modified.
next page