Link them together and run the simulation

Example with a Netlogo random walk model

The model used is a simple random walk where, for each simulation step, agents (so-called walkers) choose a random direction and step forward. The Netlogo model specification is available here. The exchanged data will be here the walkers positions (x,y) the same for input and output. In this simplistic case, the model exchange theses data with itself (i.e. its input port correspond to its output port). Since not very useful for simulation results, this example allows to introduce the very first concepts and their implementation

In this tutorial, we present the linkage between all the entities (agents and artefact) in order to run the simulation.

random walk example 1

Make them work together

Now that we have created all the needed entities (one model-artefact, one model-agent and one coupling-artefact), the last thing to do is to link them together and to run the simulation process.

The first thing to do is to create an instance of the model-agent, one instance of the model-artefact and link them together. Then we create the coupling-artefact instance which is in fact composed of an input and an output port (see concepts). Since we have only one agent and that we decided to couple our model with itself (see the figure above), we need to link our model-agent with the coupling-artefact input and output port (note that when coupling several models together, the model-agent is not necessarily linked with the same coupling-artefact ports).

Finally, the last step is to initiate the model, post the initial output data (in order to bootstrap the process) and the to execute the model. (Get the code)

 * In this example, we take only one model and its simulator. We couple the
 * input port of the model with its own output port. This way, we show that the
 * AA4MM framework can be used with a single model and its simulator.<br>
 * This model used is a simple random walk. Each agent choose randomly the
 * direction it is going to take.
 @author Julien Siebert
 @since Darjeeling
public class TestRandomWalk {

   @param args
  public static void main(String[] args) {

    // create the agent model
    RandomWalkModelAgent agtRandomWalk = new RandomWalkModelAgent();

    // create the model artifact and link it with the agent
    RandomWalkModelArtefact modRandomWalk = new RandomWalkModelArtefact(40,
    // link agent and model artifact

    // create the coupling artifacts and link them with the agent
    IPCA_WalkerPositions tp_ipca = new IPCA_WalkerPositions(
        TurtlePositions.class, "turtle_positions_ipca");
    OPCA_WalkerPositions tp_opca = new OPCA_WalkerPositions(
        TurtlePositions.class, "turtle_positions_opca");
    // link

    // initialize, post ouptuData and execute the model