-
Notifications
You must be signed in to change notification settings - Fork 99
RoadTrafficModel_step6
This 6th step illustrates how to display charts.
- Add a chart to display the evolution of the road destruction: the mean value of the
destruction_coeff
of theroad
agents, and its max value (refreshed every 10 simulation steps). - Add a chart to display the activity of the
people
agent (working or staying home, refreshed every 10 simulation steps).
First, we add a chart of type series
to display the road destruction evolution. To compute the mean of the destruction_coeff
, we combine the mean and collect
operators. collect
takes a container and an expression as operands and will compute a new list, each element being the evaluation on the container operand of the expression. mean
computes the average of all the elements of a list. For the max, we use the max_of
operator. (Note that the operator mean_of
also exists to replace mean
and collect
).
output {
display chart_display refresh:every(10#cycles) {
chart "Road Status" type: series size: {1, 0.5} position: {0, 0} {
data "Mean road destruction" value: mean (road collect each.destruction_coeff) style: line color: #green ;
data "Max road destruction" value: road max_of each.destruction_coeff style: line color: #red ;
}
...
}
}
Second, we add a chart of type pie
to display the activity of the people
agents. We use for that the objective
variable of the people
agents and the count
operator that allows computing the number of elements of a list that verify a condition.
output {
...
display chart_display refresh: every(10#cycles) {
...
chart "People Objectif" type: pie style: exploded size: {1, 0.5} position: {0, 0.5}{
data "Working" value: people count (each.objective="working") color: #magenta ;
data "Resting" value: people count (each.objective="resting") color: #blue ;
}
}
}
We chose to display the 2 charts on the same display. As a consequence, we specified the size
and position
of each of them to define the layout of this display.
https://github.com/gama-platform/gama/blob/GAMA_1.9.2/msi.gama.models/models/Tutorials/Road%20Traffic/models/Model%2006.gaml
- Installation and Launching
- Workspace, Projects and Models
- Editing Models
- Running Experiments
- Running Headless
- Preferences
- Troubleshooting
- Introduction
- Manipulate basic Species
- Global Species
- Defining Advanced Species
- Defining GUI Experiment
- Exploring Models
- Optimizing Model Section
- Multi-Paradigm Modeling
- Manipulate OSM Data
- Diffusion
- Using Database
- Using FIPA ACL
- Using BDI with BEN
- Using Driving Skill
- Manipulate dates
- Manipulate lights
- Using comodel
- Save and restore Simulations
- Using network
- Headless mode
- Using Headless
- Writing Unit Tests
- Ensure model's reproducibility
- Going further with extensions
- Built-in Species
- Built-in Skills
- Built-in Architecture
- Statements
- Data Type
- File Type
- Expressions
- Exhaustive list of GAMA Keywords
- Installing the GIT version
- Developing Extensions
- Introduction to GAMA Java API
- Using GAMA flags
- Creating a release of GAMA
- Documentation generation