4. Inspectors and Monitors
This fourth step illustrates how to monitor more precisely the simulation. Practically, we will define monitors to follow the evolution of specific variables (or expressions) whereas inspectors allow the user to follow the state of a given agent (or a species).
Formulation​
- Adding of a monitor to follow the evolution of the number of prey agents
Model Definition​
global variable​
We add a new global variable:
nb_preys: returns, each time it is called, the current number of (live) prey agents
To do so we use the -> expression facet which returns the value of expression, each time it is called.
We use as well the operator length that returns the number of elements in a list.
Thus, in the global section, we add the nb_preys global variable:
int nb_preys -> length (prey);
monitor​
A monitor allows users to follow the value of an arbitrary expression in GAML. It has to be defined in an output section. The model defines a monitor with a label and a value expression:
monitor "Monitor name" value: an_expression;
In this model, we define a monitor to follow the value of the variable nb_preys:
monitor "Number of preys" value: nb_preys;
inspector​
A species browser displays agents of a species. The image shows the species browser in the interface.

An agent inspector shows the state of an individual agent. The image shows an agent inspector.

Complete Model​
loading...