Skip to main content
Version: 🚧 Alpha 🚧

2. Charts

This step adds live monitors and a time-series chart to the epidemic model. It also pauses the experiment when every agent is infected.

Incremental Model 2 running in GAMA, with the agent display and disease-spreading chart populated.

Global variables and stopping condition​

The global agent counts infected and susceptible people at each simulation step. infected_rate is the proportion infected; the reflex pauses the experiment when that value reaches 1.0.

global {
int nb_people <- 500;
float agent_speed <- 5.0 #km/#h;
float step <- 1 #minutes;
geometry shape <- envelope(square(500 #m));
float infection_distance <- 2.0 #m;
float proba_infection <- 0.05;
int nb_infected_init <- 5;
int nb_people_infected <- nb_infected_init update: people count (each.is_infected);
int nb_people_not_infected <- nb_people - nb_infected_init update: nb_people - nb_people_infected;
float infected_rate update: nb_people_infected / nb_people;

reflex end_simulation when: infected_rate = 1.0 {
experiment.pause();
}
}

Monitors​

Monitors belong in the experiment's output section. This example displays the current simulation hour and the infected proportion.

output {
monitor "Current hour" value: current_date.hour;
monitor "Infected people rate" value: infected_rate;
}

Time-series chart​

The chart is refreshed every 10 cycles and plots the infected and susceptible counts. marker: false hides point markers and style: spline draws smooth curves.

display chart refresh: every(10 #cycles) renderer: 2d {
chart "Disease spreading" kind: series style: spline {
data "susceptible" value: nb_people_not_infected color: #green marker: false;
data "infected" value: nb_people_infected color: #red marker: false;
}
}

Complete model​

Open the Incremental Model 2 source in the GAMA model library to see these blocks in their full context and run the model.