docGAMAv1 8 0
docGAMAv1 8 0
docGAMAv1 8 0
0 documentation
by GAMA team
http://gama-platform.org
GAMA v1.8.0 documentation
v 1.8.0 2
Contents
I Home 5
1 GAMA 7
II Introduction 13
2 Introduction 15
4 Enhancements in 1.7/1.8 25
IV Moving to 1.9 31
V Platform 35
6 Platform 37
3
GAMA v1.8.0 documentation Contents
8 Installation 41
9 Launching GAMA 47
10 Headless Mode 53
11 Updating GAMA 61
12 Installing Plugins 69
13 Troubleshooting 81
v 1.8.0 4
GAMA v1.8.0 documentation Contents
28 Displays 201
31 Preferences 213
33 Introduction 231
v 1.8.0 5
GAMA v1.8.0 documentation Contents
43 Inheritance 295
v 1.8.0 6
GAMA v1.8.0 documentation Contents
67 Recipes 459
71 Calling R 519
v 1.8.0 7
GAMA v1.8.0 documentation Contents
v 1.8.0 8
GAMA v1.8.0 documentation Contents
93 Statements 727
94 Types 863
96 Expressions 899
97 Literals 901
99 Pseudo-variables 919
101Operators 927
IX Tutorials 1391
103Tutorials 1393
v 1.8.0 9
GAMA v1.8.0 documentation Contents
v 1.8.0 10
GAMA v1.8.0 documentation Contents
v 1.8.0 11
GAMA v1.8.0 documentation Contents
XI Extensions 1715
151Extensions 1717
v 1.8.0 12
GAMA v1.8.0 documentation Contents
164Concepts 1795
165Packages 1801
168Documentation 1809
171References 1847
v 1.8.0 13
GAMA v1.8.0 documentation Contents
172Projects 1865
174Introduction 1879
175References 1883
v 1.8.0 14
Part I
Home
15
Chapter 1
GAMA
Its latest version, 1.8, can be freely downloaded or built from source, and comes
pre-loaded with several models, tutorials and a complete on-line documentation.
17
GAMA v1.8.0 documentation Chapter 1. GAMA
• Transport
• Urban planning
• Epidemiology
• Environment
Training sessions
Some training sessions about topics such as “urban management”, “epidemiology”,
“risk management” are also provided by the team. Since GAMA is an open-source
software that continues to grow, if you have any particular needs for improvement,
feel free to share it to its active community!
v 1.8.0 18
GAMA v1.8.0 documentation Chapter 1. GAMA
We provide you a continual support through the active mailing list where the team
will answer your questions. Besides, you can learn GAML on your own, following
the step by step tutorial, or personal learning path in order reach the point you are
interested in.
v 1.8.0 19
GAMA v1.8.0 documentation Chapter 1. GAMA
to highlight a certain aspect of your simulation. Add easily new visual aspects to
your agents.
Advanced 3D displays are provided: you can control lights, cameras, and also adding
textures to your 3D objects. On the other hand, dedicated statements allow you to
define easily charts, such as series, histogram, or pies.
During the simulations, some advanced features are available to inspect the population
of your agents. To make your model more interactive, you can add easily some user-
controlled action panels, or mouse events.
v 1.8.0 20
GAMA v1.8.0 documentation Chapter 1. GAMA
Development Team
GAMA is developed by several teams under the umbrella of the IRD/SU international
research unit UMMISCO:
• UMI 209 UMMISCO, IRD, 32 Avenue Henri Varagnat, 93143 Bondy Cedex,
France.
• DREAM Research Team, University of Can Tho, Vietnam (2011 - 2019).
• UMR 5505 IRIT, CNRS/University of Toulouse 1, France (2010 - 2019).
• UR MIAT, INRA, 24 Chemin de Borde Rouge, 31326 Castanet Tolosan Cedex,
France (2016 - 2019).
• UMR 6228 IDEES, CNRS/University of Rouen, France (2010 - 2019).
• UMR 8623 LRI, CNRS/University Paris-Sud, France (2011 - 2019).
• MSI Research Team, Vietnam National University, Hanoi, Vietnam (2007 -
2015).
Citing GAMA
If you use GAMA in your research and want to cite it (in a paper, presentation,
whatever), please use this reference:
A complete list of references (papers and PhD theses on or using GAMA) is available
on the references page.
v 1.8.0 21
GAMA v1.8.0 documentation Chapter 1. GAMA
Acknowledgement
YourKit supports open source projects with its full-featured Java Profiler. YourKit,
LLC is the creator of YourKit Java Profiler and YourKit .NET Profiler, innovative
and intelligent tools for profiling Java and .NET applications.
v 1.8.0 22
Part II
Introduction
23
Chapter 2
Introduction
25
GAMA v1.8.0 documentation Chapter 2. Introduction
environment for building spatially explicit multi-agent simulations. It has been first
developed by the Vietnamese-French research team MSI (located at IFI, Hanoi, and
part of the IRD/SU International Research Unit UMMISCO) from 2007 to 2010,
and is now developed by a consortium of academic and industrial partners led by
UMMISCO, among which the University of Rouen, France, the University of Toulouse
1, France, the University of Orsay, France, the University of Can Tho, Vietnam, the
National University of Hanoi, EDF R&D, France, and CEA LISC, France.
Some of the features of GAMA are illustrated in the videos above (more can be found
in our Youtube channel).
Beyond these features, GAMA also offers:
v 1.8.0 26
GAMA v1.8.0 documentation Chapter 2. Introduction
Documentation
The documentation can be accessed from the sidebar of this page. A good starting
point for new users is the installation page.
Source Code
Which you can also browse from the web here. It is, in any case, recommended to
follow the instructions on this page in order to build GAMA from source.
v 1.8.0 27
GAMA v1.8.0 documentation Chapter 2. Introduction
Copyright Information
This is a free software (distributed under the GNU GPL v3 license), so you can have
access to the code, edit it and redistribute it under the same terms. Independently
of the licensing issues, if you plan on reusing part of our code, we would be glad to
know it !
Developers
GAMA is being designed, developed and maintained by an active group of researchers
coming from different institutions in France and Vietnam. Please find below a short
introduction to each of them and a summary of their contributions to the platform:
v 1.8.0 28
GAMA v1.8.0 documentation Chapter 2. Introduction
Citing GAMA
If you use GAMA in your research and want to cite it (in a paper, presentation,
whatever), please use this reference:
Taillandier, P., Gaudou, B., Grignard, A., Huynh, Q.N., Marilleau, N.,
Caillou, P., Philippon, D., Drogoul, A. (2018), Building, composing and
experimenting complex spatial models with the GAMA platform. In
Geoinformatica, Springer, https://doi.org/10.1007/s10707-018-00339-6.
v 1.8.0 29
GAMA v1.8.0 documentation Chapter 2. Introduction
A complete list of references (papers and PhD theses on or using GAMA) is available
on the references page.
Contact Us
To get in touch with the GAMA developers team, please sign in for the gama-
[email protected] mailing list. If you wish to contribute to the platform,
you might want, instead or in addition, to sign in for the [email protected]
mailing list. On both lists, we generally answer quite quickly to requests.
Finally, to report bugs in GAMA or ask for a new feature, please refer to these
instructions to do so.
v 1.8.0 30
Part III
31
Chapter 3
Java version
Due to changes in the libraries used by GAMA 1.7 and 1.8, this version now requires
JDK/JVM 1.8 to run. Please note that GAMA has not been tested with JDK
1.9 and 1.10.
33
GAMA v1.8.0 documentation Chapter 3. Changes from 1.6.1 to 1.8
v 1.8.0 34
Chapter 4
Enhancements in 1.7/1.8
Simulations
• simulations can now be run in parallel withing an experiment (with their outputs,
displays, etc.)
• batch experiments inherit from this possibility and can now run their repetitions
in parallel too.
• concurrency between agents is now possible and can be controlled on a species/-
grid/ask basis (from multi-threaded concurrency to complete parallelism within
a species/grid or between the targets of an ask statement)
Language
• gama : a new immutable agent that can be invoked to change preferences or
access to platform-only properties (like machine-time)
• abort: a new behavior (like reflex or init) that is executed once when the
agent is about to die
• try and catch statements now provide a robust way to catch errors happening
in the simulations.
• super (instead of self) and invoke (instead of do) can now be used to call an
action defined in a parent species.
• date : new data type that offers the possibility to use a real calendar, to define
a starting_date and to query a current_date from a simulation, to parse
35
GAMA v1.8.0 documentation Chapter 4. Enhancements in 1.7/1.8
dates from date files or to output them in custom formats. Dates can be added,
subtracted, compared. Various new operators (minus_months, etc.) allow for a
fine manipulation of their data. Time units (#sec, #s, #mn, #minute, #h, #hour,
#day, etc.) can be used in conjunction with them. Interval of dates (date1
to date2) can be created and used as a basis for loops, etc. Various simple
operators allow for defining conditions based on the current_date (after(date1),
before(date2), since(date1), etc.).
• font type allows to define fonts more precisely in draw statements
• BDI control architecture for agents
• file management, new operators, new statements, new skills(?), new built-in
variables, files can now download their contents from the web by using standard
http: https: addresses instead of file paths.
• The save can now directly manipulate files and . . . save them. So something
like save shape_file("bb.shp", my_agents collect each.shape); is possi-
ble. In addition, a new facet attributes allows to define complex attributes to
be saved.
• assert has a simpler syntax and can be used in any behaviour to raise an error
if a condition is not met.
• test is a new type of experiments (experiment aaa type: test ...), equiva-
lent to a batch with an exhaustive search method, which automatically displays
the status of tests found in the model.
• new operators (sum_of, product_of, etc.)
• casting of files works
• co-modeling (importation of micro-models that can be managed within a macro-
model)
• populations of agents can now be easily exported to CSV files using the save
statement
• Simple messaging skill between agents
• Terminal commands can now be issued from within GAMA using the console
operator
• New status statement allows to change the text of the status.
• light statement in 3D display provides the possibility to custom your lights
(point lights, direction lights, spot lights)
• Displays can now inherit from other displays (facets parent and virtual to
describe abstract displays)
• on_change: facet for attributes/parameters allows to define a sequence of
statements to run whenever the value changes.
v 1.8.0 36
GAMA v1.8.0 documentation Chapter 4. Enhancements in 1.7/1.8
• species and experiment now support the virtual boolean facet (virtual species
can not be instantiated, and virtual experiments do not show up).
• experiment now supports the auto_run boolean facet (to run automatically
when launched)
• experiment now supports the benchmark boolean facet (to produce a CSV
summary of the time spent in the different statements / operators of GAMA)
• experiments can now have their own file (xxx.experiment) and specify the
model they are targeting by providing the path to the model in the new model:
facet (similar to import).
• experiments can sport a new type: test, a specialised type of batch experiment
that can be run automatically from the GUI or in headless and reports back
the result of the tests found in its model
Data import
Navigator
• Shapefiles are now copied, pasted and deleted together with their support files
• External files are automatically linked from the workspace and the links are
filed under an automatically created external folder in the project
• The “Refresh” command in the navigator pop-up refreshes the files, cleans the
metadata and recompiles the models in order to obtain a “fresh” workspace
again
• A search control allows to instantaneously find models based on their names
(not contents)
• Wizards for creating .experiment file and test experiments
• The new project Wizard now leads by default to the new file wizard
v 1.8.0 37
GAMA v1.8.0 documentation Chapter 4. Enhancements in 1.7/1.8
Editor
• doc on built-in elements, templates, shortcuts to common tasks, hyperlinks to
files used
• improvement in time, gathering of infos/todos
• warnings can be removed from model files
• resources / files can be dropped into editors to obtain declaration/import of
the corresponding files
Headless
• A new option -validate path/to/dir allows to run a complete validation of
all the models in the directory
• A new option -test path/to/dir allows to run all the tests defined in a
directory
Models library
• New models (make a list)
Preferences
• For performances and bug fixes in displays
• For charts defaults
Simulation displays
• OpenGL displays should be up to 3 times faster in rendering
• fullscreen mode for displays (ESC key)
• CTRL+O for overlay and CTRL+L for layers side controls
• cleaner OpenGL displays (less garbage, better drawing of lines, rotation helper,
sticky ROI, etc.)
v 1.8.0 38
GAMA v1.8.0 documentation Chapter 4. Enhancements in 1.7/1.8
Error view
• Much faster (up to 100x !) display of errors
• Contextual menu to copy the text of errors to clipboard or open the editor on it
Validation
• Faster validation of multi-file models (x2 approx.)
• Much less memory used compared to 1.6.1 (/10 approx.)
• No more “false positive” errors
Console
• Interactive console allows to directly interact with agents (experiments, simula-
tions and any agent) and get a direct feedback on the impact of code execution
using a new interpreter integrated with the console. Available in the modeling
perspective (to interact with the new gama agent) as well as the simulation
perspective (to interact with the current experiment agent).
v 1.8.0 39
GAMA v1.8.0 documentation Chapter 4. Enhancements in 1.7/1.8
Monitor view
• monitors can have colors
• monitors now have contextual menus depending on the value displayed (save as
CSV, inspect, browse. . . )
Serialization
• Serialize simulations and replay them
• Serialization and deserialization of agents between simulations
v 1.8.0 40
Part IV
Moving to 1.9
41
Chapter 5
43
GAMA v1.8.0 documentation Chapter 5. Goals of GAMA 1.9 (see branch here)
v 1.8.0 44
Part V
Platform
45
Chapter 6
Platform
GAMA consists of a single application that is based on the RCP architecture provided
by Eclipse. Within this single application software, often referred to as a platform,
users can undertake, without the need of additional third-parties softwares, most
of the activities related to modeling and simulation, namely editing models and
simulating, visualizing and exploring them using dedicated tools.
First-time users may however be intimidated by the apparent complexity of the
platform, so this part of the documentation has been designed to ease their first
contact with it, by clearly identifying tasks of interest to modelers and how they can
be accomplished within GAMA.
It is accomplished by firstly providing some background about important notions
found throughout the platform, especially those of workspace and projects and
explaining how to organize and navigate through models. Then we take a look at the
edition of models and its various tools and components (dedicated editors and related
tools, of course, but also validators). Finally, we show how to run experiments on
these models and what support the user interface can provide to users in this task.
47
GAMA v1.8.0 documentation Chapter 6. Platform
v 1.8.0 48
Chapter 7
The GAMA platform can be easily installed in your machine, either if you are using
Windows, Mac OS or Ubuntu. GAMA can then be extended by using a number of
additional plugins.
This part is dedicated to explain how to install GAMA, launching GAMA and
extend the platform by installing additional plugins. All the known issues concerning
installation are also explain. The GAMA team provides you a continuous support by
proposing corrections to some serious issues through updating patchs. In this part,
we will also present you briefly an other way to launch GAMA without any GUI :
the headless mode.
• Installation
• Launching GAMA
• Headless Mode
• Updating GAMA
• Installing Plugins
• Troubleshooting
49
GAMA v1.8.0 documentation Chapter 7. Installation and Launching
v 1.8.0 50
Chapter 8
Installation
We made efforts to make the last release of GAMA (1.8.0) as easy as possible to
install, by providing a version with an embedded Java JDK, limiting the installation
to a 3-steps procedure: download, extract and launch.
Table of contents
• Installation
– Download GAMA
– Install procedure
– System Requirements
– Installation of Java
∗ On MacOS X
∗ On Windows
∗ On Ubuntu & Linux
– Troubleshooting with Mac OS Sierra
Download GAMA
51
GAMA v1.8.0 documentation Chapter 8. Installation
It is important to notice that each version has its own pros and contras:
• the version including the Java JDK is easier to install as it only requires to unzip
the downloaded file and to run it. But the provided JDK is not automatically
updated to fix security issues. This JDK should thus not be used with any
other applications.
• the version without JDK requires Java 1.8 Oracle JDK to be installed on
your computer (at least the update 161). The advantage of this version is that
the file download is lighter and that the user can update the Java JDK to
prevent new security vulnerabilities.
Note that the previous versions (GAMA 1.8RC2 and 1.7) came with 32 bits version
for Windows and Linux (but without any version with an included Java JDK). You
first need to determine which version to use (it depends on your computer, which may,
or not, support 64 bits instructions, but also on the version of Java already installed,
as the number of bits of the two versions must match). It is not recommended to
use it, as many issues have been fixed and many improvements have been
introduced in the release. Nevertheless, it can be downloaded from the page.
Install procedure
After having downloaded the chosen GAMA version from the Downloads page, you
only have to extract the zip file wherever you want on your machine, and launch
GAMA.
System Requirements
GAMA 1.8.0 requires approximately 540MB of disk space (resp. 250MB in its version
without Java JDK) and a minimum of 4GB of RAM (to increase the portion of
memory usable by GAMA, please refer to these instructions).
v 1.8.0 52
GAMA v1.8.0 documentation Chapter 8. Installation
The version with JDK does not require the installation of any other software and in
particular the Java JDK.
The version without JDK requires that Java 1.8 Oracle JDK is installed on your
machine.
Please note that GAMA is not considered as compatible with Java 1.9
and Java 1.10 as it has not been tested under these environments.
Installation of Java
On all environments, the recommended Java Virtual Machine under which GAMA has
been tested is the one distributed by Oracle (http://www.oracle.com/technetwork/
java/javase/downloads/jdk8-downloads-2133151.html). Please make sure to in-
stall the JDK (Java Development Kit) and not the JRE (Java Runtime
Environment). GAMA may work with the standard JRE, although it will be slower
and may even crash (esp. under MacOS X).
On Mac OS X
The latest version of GAMA requires a JVM (or JDK or JRE) compatible with Java
1.8 to run.
Note for GAMA 1.6.1 users: if you plan to keep a copy of GAMA 1.6.1, you will need to
have both Java 1.6 (distributed by Apple) and Java 1.8 (distributed by Oracle) installed
at the same time. Because of this bug in SWT (https://bugs.eclipse.org/bugs/show_-
bug.cgi?id=374199), GAMA 1.6.1 will not run correctly under Java 1.8 (all the
displays will appear empty). To install the JDK 1.6 distributed by Apple, follow the
instructions here: http://support.apple.com/kb/DL1572. Alternatively, you might
want to go to https://developer.apple.com/downloads and, after a free registration step
if you’re not an Apple Developer, get the complete JDK from the list of downloads.
On Windows
Please notice that, by default, Internet Explorer and Chrome browsers will download
a 32 bits version of the JRE. Running GAMA 32 bits for Windows is ok, but you may
want to download the latest JDK instead, in order to both improve the performances
of the simulator and be able to run GAMA 64 bits.
v 1.8.0 53
GAMA v1.8.0 documentation Chapter 8. Installation
In order for Java to be found by Windows, you may have to modify environment
variables:
The Oracle JDK License has changed for releases starting April 16, 2019. The result
is that it’s now more complicated to install Oracle JDK on Unix system than before.
If you want to simplify the process, you can download GAMA with an embarked
JDK. But keep in mind that this JDK should only be used to run GAMA-Platform.
If you still want to install Oracle JDK 8 on your machine, here are some workarounds:
* For Debian based OS * For Arch-based OS
See the troubleshooting page for more information on workarounds for problems on
Ubuntu.
v 1.8.0 54
GAMA v1.8.0 documentation Chapter 8. Installation
/! WARNING /!\
OpenJDK is not the recommended way to run GAMA and is not (and
won’t be) supported.
We won’t help you if you run in any trouble using this JDK.
Another solution will be to install OpenJDK, the free implementation under the GNU
General Public License.
If you use a Debian based OS (Ubuntu, Linux Mint, . . . ), you need to do:
sudo apt-get install openjdk-8-jdk
If you use a Red Hat-based OS (CentOS, Fedora, Scientific Linux . . . ), you need to
do:
su -c "yum install java-1.8.0-openjdk"
v 1.8.0 55
GAMA v1.8.0 documentation Chapter 8. Installation
v 1.8.0 56
Chapter 9
Launching GAMA
Running GAMA for the first time requires that you launch the application (Gama.app
on MacOS X, Gama.exe on Windows, Gama on Linux, located in the folder called
Gama once you have unzipped the archive). Other folders and files are present here,
but you don’t have to care about them for the moment. In case you are unable to
launch the application, of if error messages appear, please refer to the installation or
troubleshooting instructions.
Table of contents
• Launching GAMA
– Launching the Application
– Choosing a Workspace
– Welcome Page
1. In a so-called headless mode (i.e. without user interface, from the command
line, in order to conduct experiments or to be run remotely). Please refer to
the corresponding instructions.
57
GAMA v1.8.0 documentation Chapter 9. Launching GAMA
2. From the terminal, using a path to a model file and the name or number of an
experiment, in order to allow running this experiment directly (note that the
two arguments are optional: if the second is omitted, the file is imported in the
workspace if not already present and opened in an editor; if both are omitted,
GAMA is launched as usual):
• Gama.app/Contents/MacOS/Gama path_to_a_model_file#
experiment_name_or_number on MacOS X
• Gama path_to_a_model_file#experiment_name_or_number on Linux
• Gama.exe path_to_a_model_file#experiment_name_or_number on Windows
v 1.8.0 58
GAMA v1.8.0 documentation Chapter 9. Launching GAMA
Choosing a Workspace
Past the splash screen, GAMA will ask you to choose a workspace in which to store
your models and their associated data and settings. The workspace can be any folder
in your filesystem on which you have read/write privileges. If you want GAMA to
remember your choice next time you run it (it can be handy if you run Gama from
the command line), simply check the corresponding option. If this dialog does not
show up when launching GAMA, it probably means that you inherit from an older
workspace used with GAMA 1.6 or 1.5.1 (and still “remembered”). In that case, a
warning will be produced to indicate that the models library is out of date, offering
you the possibility to create a new workspace.
You can enter its address or browse your filesystem using the appropriate button.
If the folder already exists, it will be reused (after a warning if it is not already a
workspace). If not, it will be created. It is always a good idea, when you launch a
new version of GAMA for the first time, to create a new workspace. You will then,
later, be able to import your existing models into it. Failing to do so might lead to
odd errors in the various validation processes.
v 1.8.0 59
GAMA v1.8.0 documentation Chapter 9. Launching GAMA
Figure 9.3: This pop-up appears when the user wants to create a new workspace.
Click on OK.
Welcome Page
As soon as the workspace is created, GAMA will open and you will be presented with
its first window. GAMA is based on Eclipse and reuses most of its visual metaphors
for organizing the work of the modeler. The main window is then composed of several
parts, which can be views or editors, and are organized in a perspective. GAMA
proposes 2 main perspectives: Modeling, dedicated to the creation of models, and
Simulation, dedicated to their execution and exploration. Other perspectives are
available if you use shared models.
The default perspective in which GAMA opens is Modeling. It is composed of a
central area where GAML editors are displayed, which is surrounded by a Navigator
view on the left-hand side of the window, an Outline view (linked with the open
editor) and the Problems view, which indicates errors and warnings present in the
models stored in the workspace.
In the absence of previously open models, GAMA will display a Welcome page (actually
a web page), from which you can find links to the website, current documentation,
tutorials, etc. This page can be kept open (for instance if you want to display the
documentation when editing models) but it can also be safely closed (and reopened
later from the “Views” menu).
From this point, you are now able to edit a new model, navigate in the models
libraries, or import an existing model.
v 1.8.0 60
GAMA v1.8.0 documentation Chapter 9. Launching GAMA
v 1.8.0 61
GAMA v1.8.0 documentation Chapter 9. Launching GAMA
v 1.8.0 62
Chapter 10
Headless Mode
The aim of this feature is to be able to run one or multiple instances of GAMA
without any user interface, so that models and experiments can be launched on a
grid or a cluster. Without GUI, the memory footprint, as well as the speed of the
simulations, are usually greatly improved.
In this mode, GAMA can only be used to run experiments and that editing or
managing models is not possible. In order to launch experiments and still benefit
from a user interface (which can be used to prepare headless experiments), launch
GAMA normally (see here) and refer to this page for instructions.
Table of contents
• Headless Mode
– Command
∗ Bash Script
∗ Java Command
– Experiment Input File
∗ Heading
∗ Parameters
∗ Outputs
– Output Directory
– Simulation Output
63
GAMA v1.8.0 documentation Chapter 10. Headless Mode
∗ Step
∗ Variable
– Snapshot files
Command
There are two ways to run a GAMA experiment in headless mode: using a dedicated
shell script (recommended) or directly from the command line. These commands
take 2 arguments: an experiment file and an output directory.
Bash Script
It can be found in the headless directory located inside Gama. Its name is gama-
headless.sh on MacOSX and Linux, and gama-headless.bat on Windows.
bash gama-headless.sh [m/c/t/hpc/v] $1 $2
• with:
– $1 input parameter file : an xml file determining experiment parameters
and attended outputs
– $2 output directory path : a directory which contains simulation results
(numerical data and simulation snapshot)
– options [-m/c/t/hpc/v]
∗ -m memory : memory allocated to gama
∗ -c : console mode, the simulation description could be written with
the stdin
∗ -t : tunneling mode, simulation description are read from the stdin,
simulation results are printed out in stdout
∗ -hpc nb_of_cores : allocate a specific number of cores for the experi-
ment plan
∗ -v : verbose mode. trace are displayed in the console
• For example (using the provided sample), navigate in your terminal to the
headless folder inside your GAMA root folder and type:
v 1.8.0 64
GAMA v1.8.0 documentation Chapter 10. Headless Mode
bash gama-headless.sh samples/predatorPrey.xml outputHeadLess
As specified in predatorPrey.xml, this command runs the prey - predator model for
1000 steps and record a screenshot of the main display every 5 steps. The screenshots
are recorded in the directory outputHeadLess (under the GAMA root folder).
Note that the current directory to run gama-headless command must be $GAMA_-
PATH/headless
Java Command
java -cp $GAMA_CLASSPATH -Xms512m -Xmx2048m -Djava.awt.headless=true
org.eclipse.core.launcher.Main -application msi.gama.headless.id4 $1
$2
• with:
– $GAMA_CLASSPATH gama classpath: contains relative or absolute path
of jars inside the gama plugin directory and jars created by users
– $1 input parameter file: an xml file determining experiment parameters
and attended outputs
– $2 output directory path: a directory which contains simulation results
(numerical data and simulation snapshot)
Note that the output directory is created during the experiment and should not exist
before.
v 1.8.0 65
GAMA v1.8.0 documentation Chapter 10. Headless Mode
Note that several simulations could be determined in one experiment plan. These
simulations are run in parallel according to the number of allocated cores.
Heading
<Simulation id="2" sourcePath="./predatorPrey/predatorPrey.gaml"
finalStep="1000" experiment="predPrey">
• with:
– id: permits to prefix output files for experiment plan with huge simulations.
– sourcePath: contains the relative or absolute path to read the gaml model.
– finalStep: determines the number of simulation step you want to run.
– experiment: determines which experiment should be run on the model.
This experiment should exist, otherwise the headless mode will exit.
Parameters
One line per parameter you want to specify a value to:
<Parameter name="nb_predator_init" type="INT" value="53" />
• with:
– name: name of the parameter in the gaml model
– type: type of the parameter (INT, FLOAT, BOOLEAN, STRING)
– value: the chosen value
v 1.8.0 66
GAMA v1.8.0 documentation Chapter 10. Headless Mode
Outputs
One line per output value you want to retrieve. Outputs can be names of monitors
or displays defined in the ‘output’ section of experiments, or the names of attributes
defined in the experiment or the model itself (in the ‘global’ section).
... with the name of a monitor defined in the 'output' section of
the experiment...
<Output id="2" name="number_of_preys" framerate="1" />
... with the name of a (built-in) variable defined in the
experiment itself...
<Output id="4" name="duration" framerate="1" />
• with:
– name : name of the output in the ‘output’/‘permanent’ section in the
experiment or name of the experiment/model attribute to retrieve
– framerate : the frequency of the monitoring (each step, each 2 steps, each
100 steps. . . ).
• Note that :
– the lower the framerate value the longer the experiment.
– if the chosen output is a display, an image is produced and the output file
contains the path to access this image
Output Directory
During headless experiments, a directory is created with the following structure:
Outputed-directory-path/
|-simulation-output.xml
|- snapshot
|- main_display2-0.png
|- main_display2-10.png
|- ...
• with:
– simulation-output.xml: containing the results
v 1.8.0 67
GAMA v1.8.0 documentation Chapter 10. Headless Mode
Is it possible to change the output directory for the images by adding the attribute
“output_path” in the xml :
If we write <Output id="1" name="my_display" file:"/F:/path/imageName"
framerate="10" />, then the display “my_display” will have the name “imageName-
stepNb.png” and will be written in the folder “/F:/path/”
Simulation Output
...
• With:
v 1.8.0 68
GAMA v1.8.0 documentation Chapter 10. Headless Mode
Step
<Step id='1' >
<Variable name='main_display' value='main_display2-0.png'/>
<Variable name='number_of_preys' value='624'/>
<Variable name='number_of_predators' value='51'/>
<Variable name='duration' value='6' />
</Step>
There is one Variable block per Output identified in the output experiment file.
Variable
<Variable name='main_display' value='main_display2-0.png'/>
• with:
– name: name of the output, the model variable
– value: the current value of model variable.
Note that the value of an output is repeated according to the framerate defined in
the input experiment file.
Snapshot files
This directory contains images generated during the experiment. There is one image
per displayed output per step (according to the framerate). File names follow a
naming convention, e.g:
[outputName][SimulationID]_[stepID].png -> main_display2-20.png
v 1.8.0 69
GAMA v1.8.0 documentation Chapter 10. Headless Mode
v 1.8.0 70
Chapter 11
Updating GAMA
Unless you are using the version of GAMA built from the sources available in the
GIT repository of the project (see here), you are normally running a specific release
of GAMA that sports a given version number (e.g. GAMA 1.6.1, GAMA 1.7, etc.).
When new features were developed, or when serious issues were fixed, the release
you had on your disk, prior to GAMA 1.6.1, could not benefit from them. Since this
version, however, GAMA has been enhanced to support a self_update mechanism,
which allows to import from the GAMA update site additional plugins (offering new
features) or updated versions of the plugins that constitute the core of GAMA.
Table of contents
• Updating GAMA
– Manual Update
– Automatic Update
Manual Update
To activate this feature, you have to invoke the “Check for Updates” or “Install New
Software. . . ” menu commands in the “Help” menu.
71
GAMA v1.8.0 documentation Chapter 11. Updating GAMA
The first one will only check if the existing plugins have any updates available, while
the second will, in addition, scan the update site to detect any new plugins that
might be added to the current installation.
In general, it is preferable to use the second command, as more options (including
that of desinstalling some plugins) are provided. Once invoked, it makes the following
dialog appear:
GAMA expects the user to enter a so-called update site. You can copy and paste the
following line (or choose it from the drop-down menu as this address is built inside
GAMA):
http://updates.gama-platform.org
GAMA will then scan the entire update site, looking both for new plugins (the
example below) and updates to existing plugins. The list available in your installation
will, of course, be different from the one displayed here.
v 1.8.0 72
GAMA v1.8.0 documentation Chapter 11. Updating GAMA
Figure 11.2: Window where the user enters the address of an update site and can
choose plugins to install.
v 1.8.0 73
GAMA v1.8.0 documentation Chapter 11. Updating GAMA
v 1.8.0 74
GAMA v1.8.0 documentation Chapter 11. Updating GAMA
Choose the ones you want to install (or update) and click “Next. . . ”. A summary page
will appear, indicating which plugins will actually be installed (since some plugins
might require additional plugins to run properly), followed by a license page that you
have to accept. GAMA will then proceed to the installation (that can be canceled
any time) of the plugins chosen.
During the course of the installation, you might receive the following warning, that
you can dismiss by clicking “OK”.
Once the plugins are installed, GAMA will ask you whether you want to restart or
not. It is always safer to do so, so select “Yes” and let it close by itself, register the
new plugins and restart.
Automatic Update
GAMA offers a mechanism to monitor the availability of updates to the plugins
already installed. To install this feature, open the preferences of GAMA and choose
the button “Advanced. . . ”, which gives access to additional preferences.
In the dialog that appears, navigate to “Install/Update > Automatic Updates”. Then,
enable the option using the check-box on the top of the dialog and choose the best
v 1.8.0 75
GAMA v1.8.0 documentation Chapter 11. Updating GAMA
settings for your workflow. Clicking on “OK” will save these preferences and dismiss
the dialog.
From now on, GAMA will continuously support you in having an up-to-date version
of the platform, provided you accept the updates.
v 1.8.0 76
GAMA v1.8.0 documentation Chapter 11. Updating GAMA
v 1.8.0 77
GAMA v1.8.0 documentation Chapter 11. Updating GAMA
v 1.8.0 78
Chapter 12
Installing Plugins
Besides the plugins delivered by the developers of the GAMA platform, which can be
installed and updated as explained here, there are a number of additional plugins
that can be installed to add new functionalities to GAMA or enhance the existing
ones. GAMA being based on Eclipse, a number of plugins developed for Eclipse are
then available (a complete listing of Eclipse plugins can be found in the so-called
Eclipse MarketPlace).
There are, however, three important restrictions:
1. The current version of GAMA is based on Eclipse Juno (version number 3.8.2),
which excludes de facto all the plugins targeting solely the 4.3 (Kepler) or 4.4
(Luna) versions of Eclipse. These will refuse to install anyway.
2. The Eclipse foundations in GAMA are only a subset of the complete Eclipse
platform, and a number of libraries or frameworks (for example the Java
Development Toolkit) are not (and will never be) installed in GAMA. So
plugins relying on their existence will refuse to install as well.
3. Some components of GAMA rely on a specific version of other plugins and will
refuse to work with other versions, essentially because their compatibility will
not be ensured anymore. For instance, the parser and validator of the GAML
language in GAMA 1.6.1 require XText v. 2.4.1 to be installed (and neither
XText 2.5.4 nor XText 2.3 will satisfy this dependency).
79
GAMA v1.8.0 documentation Chapter 12. Installing Plugins
create an issue if a plugin does not work, in order for us to see what the requirements
to make it work are and how we can satisfy them (or not) in GAMA.
Table of contents
• Installing Plugins
– Installation
– Selected Plugins
∗ Overview
∗ Git
∗ CKEditor
∗ Startexplorer
∗ Pathtools
∗ CSV Edit
∗ Quickimage
Installation
Installing new plugins is a process identical to the one described when updating
GAMA, with one exception: the update site to enter is normally provided by the
vendor of the additional plugin and must be entered instead of GAMA’s one in
the dialog. Let us suppose, for instance, that we want to install a RSS feed reader
available on this site. An excerpt from the page reads that :
So we just have to follow these instructions, which leads us to the following dialog, in
which we select “RSS view” and click “Next”.
The initial dialog is followed by two other ones, a first to report that the plugin
satisfies all the dependencies, a second to ask the user to accept the license agreement.
v 1.8.0 80
GAMA v1.8.0 documentation Chapter 12. Installing Plugins
v 1.8.0 81
GAMA v1.8.0 documentation Chapter 12. Installing Plugins
Once we dismiss the warning that the plugin is not signed and accept to restart
v 1.8.0 82
GAMA v1.8.0 documentation Chapter 12. Installing Plugins
GAMA, we can test the new plugin by going to the “Views” menu.
The new RSS view is available in the list of views that can be displayed in GAMA.
And we can enjoy (after setting some preferences available in its local menu) monitoring
the Issues of GAMA from within GAMA itself !
Selected Plugins
In addition to the RSS reader described above, below is a list of plugins that have
been tested to work with GAMA. There are many others so take the time to explore
them !
Overview
• A very useful plugin for working with large model files. It renders an overview
of the file in a separate view (with a user selectable font size), allowing to know
where the edition takes place, but also to navigate very quickly and efficiently
to different places in the model.
• Update site: http://sandipchitaleseclipseplugins.googlecode.com/svn/trunk/text.overview.updatesite/
• After installing the plugin, an error might happen when closing GAMA. It is
harmless. After restarting GAMA, go to Views > Open View > Others. . . >
Overview >.
v 1.8.0 83
GAMA v1.8.0 documentation Chapter 12. Installing Plugins
v 1.8.0 84
GAMA v1.8.0 documentation Chapter 12. Installing Plugins
Git
• Git is a version control system (like CVS or SVN, extensively used in GAMA)
http://git-scm.com/. Free sharing space are provided on GitHub among oth-
ers. Installing Git allows to share or gather models that are available in Git
repositories.
• Update site (general): http://download.eclipse.org/releases/mars/ (Alternative-
ly, you can use http://download.eclipse.org/egit/updates)
• Select the two following plugins:
– Eclipse EGit
– Git Team Provider Core
CKEditor
• CKEditor is a lightweight and powerful web-based editor, perfect for almost
WYSIWYG edition of HTML files. It can be installed, directly in GAMA, in
order to edit .html, .htm, .xml, .svg, etc. files directly without leaving the
platform. No other dependencies are required. A must !
• Update site: http://kosz.bitbucket.org/eclipse-ckeditor/update-site
Startexplorer
• A nice utility that allows the user to select files, folders or projects in the
Navigator and open them in the filesystem (either the UI Explorer, Finder,
v 1.8.0 85
GAMA v1.8.0 documentation Chapter 12. Installing Plugins
whatever, or in a terminal).
• Update site: http://basti1302.github.com/startexplorer/update/
Pathtools
• Same purpose as StartExplorer, but much more complete, and additionally
offers the possibility to add new commands to handle files (open them in specific
editors, execute external programs on them, etc.). Very nice and professional.
Works flawlessly in GAMA except that contributions to the toolbar are not
accepted (so you have to rely on the commands present in the Navigator pop-up
menu).
• Update site: http://pathtools.googlecode.com/svn/trunk/
PathToolsUpdateSite/site.xml
• Website: https://pathtools.googlecode.com
CSV Edit
• An editor for CSV files. Quite handy if you do not want to launch Excel every
time you need to inspect or change the CSV data files used in models.
• Update site: http://csvedit.googlecode.com/svn/trunk/csvedit.update
TM Terminal
• A powerful, yet simple, terminal which can connect locally or via ssh or other
methods.
• Update site (general): http://download.eclipse.org/releases/mars/
• Select the following plugin: TM Terminal
Quickimage
• A lightweight viewer of images, which can be useful when several images are
used in a model.
• Update site: http://psnet.nu/eclipse/updates
v 1.8.0 86
GAMA v1.8.0 documentation Chapter 12. Installing Plugins
v 1.8.0 87
GAMA v1.8.0 documentation Chapter 12. Installing Plugins
v 1.8.0 88
GAMA v1.8.0 documentation Chapter 12. Installing Plugins
v 1.8.0 89
GAMA v1.8.0 documentation Chapter 12. Installing Plugins
v 1.8.0 90
Chapter 13
Troubleshooting
This page exposes some of the most common problems a user may encounter when
running GAMA — and offers advices and workarounds for them. It will be regularly
enriched with new contents. Note also that the Issues section of the website might
contain precious information on crashes and bugs encountered by other users. If
neither the workarounds described here nor the solutions provided by other users allow
to solve your particular problem, please submit a new issue report to the developers.
Table of contents
• Troubleshooting
– Table of contents
– On Ubuntu (& Linux Systems)
∗ Workaround if GAMA crashes when displaying web contents
∗ Workaround if GAMA does not display the menus (the ‘Edit’ menu is
the only one working)
∗ Workaround if you use a GTK dark theme
– On Windows
– On MacOS X
∗ Workaround in case of glitches in the UI
∗ Workaround in case of corrupted icons in menus under El Capitan
– Memory problems
– Submitting an Issue
91
GAMA v1.8.0 documentation Chapter 13. Troubleshooting
In case GAMA crashes whenever trying to display a web page or the pop-up online
documentation, you may try to edit the file Gama.ini and add the line -Dorg.
eclipse.swt.browser.DefaultType=mozilla to it. This workaround is described
here: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=705420 and in Issue 700 (on
Google Code).
If, when selecting a menu, nothing happens (or, in the case of the ‘Agents’ menu,
all population submenus appear empty), it is likely that you have run into this
issue: https://bugs.eclipse.org/bugs/show_bug.cgi?id=330563. The only workaround
known is to launch GAMA from the command line (or from a shell script) after
having told Ubuntu to attach its menu back to its main window. For example (if you
are in the directory where the “Gama” executable is present):
export UBUNTU_MENUPROXY=0
./Gama
No fix can be provided from the GAMA side for the moment.
If your Desktop Environment use GTK (list here) and you’re using a dark theme on
your session, GAMA will apply the same theme and look badly.
To solve it, you should change the variable environment on application startup. The
easy way to keep that change is to modify the file .desktop
With the official GAMA 1.8 release, the display is based on GTK 3.
v 1.8.0 92
GAMA v1.8.0 documentation Chapter 13. Troubleshooting
To change the display here, you should change the variable GTK_THEME to the
theme that you prefer using. So the exec line for your desktop file will look like this :
Exec=env GTK_THEME=Matcha-aliz:light /path/to/../GAMA1.8/Gama
Before the official GAMA 1.8 release, the display is based on GTK 2
To change the display here, you should change the variable GTK2_RC_FILES to
the theme that you prefer using. As the variable suggests, you should point directly
to the style file and not just indicate the new theme. So the exec line for you desktop
file will look like this :
Exec=env GTK2_RC_FILES=/usr/share/themes/Matcha-aliz/gtk-2.0/gtkrc /
path/to/../GAMA1.8_RC2/Gama
On Windows
No common trouble. . .
On MacOS X
v 1.8.0 93
GAMA v1.8.0 documentation Chapter 13. Troubleshooting
Memory problems
The most common causes of problems when running GAMA are memory problems.
Depending on your activities, on the size of the models you are editing, on the
size of the experiments you are running, etc., you have a chance to require more
memory than what is currently allocated to GAMA. A typical GAMA installation
v 1.8.0 94
GAMA v1.8.0 documentation Chapter 13. Troubleshooting
will need between 40 and 200MB of memory to run “normally” and launch small
models. Memory problems are easy to detect: on the bottom right corner of its
window, GAMA will always display the status of the current memory. The first
number represents the memory currently used (in MB), the second (always larger) the
memory currently allocated by the JVM. And the little trash icon allows to “garbage
collect” the memory still used by agents that are not used anymore (if any). If GAMA
appears to hang or crash and if you can see that the two numbers are very close, it
means that the memory required by GAMA exceeds the memory allocated.
There are two ways to circumvent this problem: the first one is to increase the memory
allocated to GAMA by the Java Virtual Machine. The second, detailed on this page
is to try to optimize your models to reduce their memory footprint at runtime. To
increase the memory allocated, first locate the file called Gama.ini. On Windows and
Ubuntu, it is located next to the executable. On MacOS X, you have to right-click
on Gama.app, choose “Display Package Contents. . . ”, and you will find Gama.ini in
Contents/MacOS. This file typically looks like the following (some options/keywords
may vary depending on the system), and we are interested in two JVM arguments:
-Xms supplies the minimal amount of memory the JVM should allocate to GAMA,
-Xmx the maximal amount. By changing these values (esp. the second one, of course,
for example to 4096M, or 4g), saving the file and relaunching GAMA, you can
probably solve your problem. Note that 32 bits versions of GAMA will not accept to
run with a value of -Xmx greater than 1500M. See here for additional information on
these two options.
Submitting an Issue
If you think you have found a new bug/issue in GAMA, it is time to create an issue
report here! Alternatively, you can click the Issues tab on the project site, search if a
similar problem has already been reported (and, maybe, solved) and, if not, enter a
new issue with as much information as possible:
v 1.8.0 95
GAMA v1.8.0 documentation Chapter 13. Troubleshooting
v 1.8.0 96
GAMA v1.8.0 documentation Chapter 13. Troubleshooting
• The GAMA model or code you are having trouble with. If possible, attach a
complete model.
• Screenshots or other files that help describe the issue.
Two files may be particularly interesting to attach to your issue: the configuration
details and the error log. Both can be obtained quite easily from within GAMA
itself in a few steps. First, click the “About GAMA. . . ” menu item (under the
“Gama” menu on MacOS X, “Help” menu on Linux & Windows)
v 1.8.0 97
GAMA v1.8.0 documentation Chapter 13. Troubleshooting
v 1.8.0 98
GAMA v1.8.0 documentation Chapter 13. Troubleshooting
In the dialog that appears, you will find a button called “Installation Details”.
Click this button and a new dialog appears with several tabs.
To provide a complete information about the status of your system at the time of the
error, you can
(1) copy and paste the text found in the tab “Configuration” into your issue.
Although, it is preferable to attach it as a text file (using textEdit, Notepad or
Emacs e.g.) as it may be too long for the comment section of the issue form.
(2) click the “View error log” button, which will bring you to the location, in your
file system, of a file called “log”, which you can then attach to your issue as
well.
v 1.8.0 99
GAMA v1.8.0 documentation Chapter 13. Troubleshooting
v 1.8.0 100
GAMA v1.8.0 documentation Chapter 13. Troubleshooting
v 1.8.0 101
GAMA v1.8.0 documentation Chapter 13. Troubleshooting
v 1.8.0 102
Chapter 14
The workspace is a directory in which GAMA stores all the current projects on
which the user is working, links to other projects, as well as some meta-data like
preference settings, current status of the different projects, error markers, and so on.
Except when running in headless mode, GAMA cannot function without a valid
workspace.
The workspace is organized in 3 categories, which are themselves organized into
projects.
The projects present in the workspace can be either directly stored within it (as
sub-directories), which is usually the case when the user creates a new project, or
linked from it (so the workspace will only contain a link to the directory of the project,
supposed to be somewhere in the filesystem or on the network). A same project can
be linked from different workspaces.
GAMA models files are stored in these projects, which may contain also other
files (called resources) necessary for the models to function. A project may, of
course, contain several model files, especially if they are importing each other, if
they represent different views on the same topic, or if they share the same resources.
Learning how to navigate in the workspace, how to switch workspace or how to
import, export is a necessity to use GAMA correctly. It is the purpose of the following
sections.
103
GAMA v1.8.0 documentation Chapter 14. Workspace, Projects and Models
v 1.8.0 104
Chapter 15
All the models that you edit or run using GAMA are accessible from a central location:
the Navigator, which is always on the left-hand side of the main window and cannot
be closed. This view presents the models currently present in (or linked from) your
workspace.
Table of contents
• Navigating in the Workspace
– The Different Categories of Models
∗ Models library
∗ Plugin models
∗ User models
– Inspect Models
– Moving Models Around
– Closing and Deleting Projects
105
GAMA v1.8.0 documentation Chapter 15. Navigating in the Workspace
v 1.8.0 106
GAMA v1.8.0 documentation Chapter 15. Navigating in the Workspace
their actual location, model files need to be stored in projects, which may contain
also other files (called resources) necessary for the models to function. A project may
of course contain several model files, especially if they are importing each other, if
they represent different models on the same topic, or if they share the same resources.
Models library
This category represents the models that are shipped with each version of GAMA.
They do not reside in the workspace, but are considered as linked from it. This link
is established every time a new workspace is created. Their actual location is within
a plugin (msi.gama.models) of the GAMA application. This category contains four
main projects in GAMA 1.6.1, which are further refined in folders and sub-folders
that contain model files and resources.
v 1.8.0 107
GAMA v1.8.0 documentation Chapter 15. Navigating in the Workspace
v 1.8.0 108
GAMA v1.8.0 documentation Chapter 15. Navigating in the Workspace
It may happen, in some occasions, that the library of models is not synchronized with
the version of GAMA that uses your workspace. This is the case if you use different
versions of GAMA to work with the same workspace. In that case, it is required that
the library be manually updated. This can be done using the “Update library” item
in the contextual menu.
To look up for a particular model in the library, users can use the “Search for file”
menu item. A search dialog is then displayed, which allows to look for models by
their title (for example, models containing “GIS” in the example below).
v 1.8.0 109
GAMA v1.8.0 documentation Chapter 15. Navigating in the Workspace
Plugin models
This category represents the models that are related to a specific plugin (additional
or integrated by default). The corresponding plugin is shown between parenthesis.
For each projects, you can see the list of plugins needed, and a caption to show you if
the plugin is actually installed in your GAMA version or not : green if the plugin is
installed, red otherwise.
User models
This category regroups all the projects that have been created or imported in the
workspace by the user. Each project is actually a folder that resides in the folder
v 1.8.0 110
GAMA v1.8.0 documentation Chapter 15. Navigating in the Workspace
of the workspace (so they can be easily located from within the filesystem). Any
modification (addition, removal of files. . . ) made to them in the file system (or using
another application) is immediately reflected in the Navigator and vice-versa.
Model files, although it is by no means mandatory, usually reside in a sub-folder of
the project called “models”.
Inspect Models
Each models is presented as a node in the navigation workspace, including Experiment
buttons and/or Requires node and/or Uses node.
• Require node : The node Require is present if your model uses some plugins
(additional or integrated by default). Each plugin is listed in this node, with a
green icon if the plugin is already installed in your GAMA, and a red one if it
is not the case. If the plugin you want in not installed, an error will be raised
in your model. Please read about how to install plugins to learn some more
about it.
v 1.8.0 111
GAMA v1.8.0 documentation Chapter 15. Navigating in the Workspace
• Uses node : The node Uses is present if your model uses some external
resources, and if the path to the resource is correct (if the path to the resource
is not correct, the resource will not be displayed under Uses)
v 1.8.0 112
GAMA v1.8.0 documentation Chapter 15. Navigating in the Workspace
v 1.8.0 113
GAMA v1.8.0 documentation Chapter 15. Navigating in the Workspace
v 1.8.0 114
GAMA v1.8.0 documentation Chapter 15. Navigating in the Workspace
within them, directly in the Navigator. Drag’n drop operations are supported, as
well as copy and paste. For example, the model “Life.gaml”, present in the “Models
Library”, can perfectly be copied and then pasted in a project in the “Users Model”.
This local copy in the workspace can then be further edited by the user without
altering the original one.
Users can choose to get rid of old projects by either closing or deleting them.
Closing a project means that it will still reside in the workspace (and be still visible,
although a bit differently, in the Navigator) but its model(s) won’t participate to the
build process and won’t be displayable until the project is opened again.
v 1.8.0 115
GAMA v1.8.0 documentation Chapter 15. Navigating in the Workspace
v 1.8.0 116
GAMA v1.8.0 documentation Chapter 15. Navigating in the Workspace
Deleting a project must be invoked when the user wants this project to not appear in
the workspace anymore (unless, that is, it is imported again). Invoking this command
will effectively make the workspace “forget” about this project, and this can be further
doubled with a deletion of the projects resources and models from the filesystem.
v 1.8.0 117
GAMA v1.8.0 documentation Chapter 15. Navigating in the Workspace
v 1.8.0 118
GAMA v1.8.0 documentation Chapter 15. Navigating in the Workspace
v 1.8.0 119
GAMA v1.8.0 documentation Chapter 15. Navigating in the Workspace
v 1.8.0 120
Chapter 16
Changing Workspace
Table of contents
• Changing Workspace
– Switching to another Workspace
– Cloning the Current Workspace
121
GAMA v1.8.0 documentation Chapter 16. Changing Workspace
v 1.8.0 122
GAMA v1.8.0 documentation Chapter 16. Changing Workspace
just repeat this step (the previous location is normally now accessible from the combo
box).
Another possibility, if you have models in your current workspace that you would
like to keep in the new one (and that you do not want to import one by one after
switching workspace), or if you change workspace because you suspect the current
one is corrupted, or outdated, etc. but you still want to keep your models, is to clone
the current workspace into a new (or existing) one.
Please note that cloning (as its name implies) is an operation that will
make a copy of the files into a new workspace. So, if projects are stored
in the current workspace, this will result in two different instances of
the same projets/models with the same name in the two workspaces.
However, for projects that are simply linked from the current workspace,
only the link will be copied (which allows to have different workspaces
“containing” the same project)
v 1.8.0 123
GAMA v1.8.0 documentation Chapter 16. Changing Workspace
This can be done by entering the new workspace location and choosing “Clone current
workspace” in the previous dialog instead of “Ok”.
If the new location does not exist, GAMA will ask you to confirm the creation and
cloning using a specific dialog box. Dismissing it will cancel the operation.
If the new location is already the location of an existing workspace, another con-
firmation dialog is produced. It is important to note that all projects in
the target workspace will be erased and replaced by the projects in the
current workspace if you proceed. Dismissing it will cancel the operation.
There are two cases where cloning is not accepted. The first one is when the user
tries to clone the current workspace into itself (i.e. the new location is the same as
the current location).
The second case is when the user tries to clone the current workspace into one of its
subdirectories (which is not feasible).
v 1.8.0 124
GAMA v1.8.0 documentation Chapter 16. Changing Workspace
v 1.8.0 125
GAMA v1.8.0 documentation Chapter 16. Changing Workspace
v 1.8.0 126
Chapter 17
Importing Models
Importing a model refers to making a model file (or a complete project) available
for edition and experimentation in the workspace. With the exception of headless
experiments, GAMA requires that models be manageable in the current workspace
to be able to validate them and eventually experiment them.
There are many situations where a model needs to be imported by the user: someone
sent it to him/her by mail, it has been attached to an issue report, it has been shared
on the web or an SVN server, or it belongs to a previous workspace after the user
has switched workspace. The instructions below apply equally to all these situations.
Since model files need to reside in a project to be managed by GAMA, it is usually
preferable to import a whole project rather than individual files (unless, of course,
the corresponding models are simple enough to not require any additional resources,
in which case, the model file can be imported with no harm into an existing project).
GAMA will then try to detect situations where a model file is imported alone and, if
a corresponding project can be found (for instance, in the upper directories of this
file), to import the project instead of the file. As the last resort, GAMA will import
orphan model files into a generic project called “Unclassified Models” (which will be
created if it does not exist yet).
Table of contents
• Importing Models
– The “Import. . . ” Menu Command
127
GAMA v1.8.0 documentation Chapter 17. Importing Models
– Silent import
– Drag’n Drop / Copy-Paste Limitations
Silent import
Another (possibly simpler, but less controllable) way of importing projects and models
is to either pass a path to a model when launching GAMA from the command line or
to double-click on a model file (ending in .gaml) in the Explorer or Finder (depending
on your OS).
If the file is not already part of an imported project in the current workspace, GAMA
will:
v 1.8.0 128
GAMA v1.8.0 documentation Chapter 17. Importing Models
v 1.8.0 129
GAMA v1.8.0 documentation Chapter 17. Importing Models
v 1.8.0 130
GAMA v1.8.0 documentation Chapter 17. Importing Models
v 1.8.0 131
GAMA v1.8.0 documentation Chapter 17. Importing Models
This procedure may fail, however, if a project of the same name (but in a different
location) already exists in the workspace, in which case GAMA will refuse to import
the project (and hence, the file). The solution in this case is to rename the project to
import (or to rename the existing project in the workspace).
v 1.8.0 132
Chapter 18
Editing models
Editing models in GAMA is very similar to editing programs in a modern IDE like
Eclipse. After having successfully launched the program, the user has two fundamental
concepts at its disposal: a workspace, which contains models or links to models
organized like a hierarchy of files in a filesystem, and the workbench (aka, the main
window), which contains the tools to create, modify and experiment these models.
Understanding how to navigate in the workspace is covered in another section and,
for the purpose of this section, we just need to understand that it is organized in
projects, which contain models and their associated data. Projects are further
categorized, in GAMA, into three categories: Models Library (built-in models shipped
with GAMA and automatically linked from the workspace), Shared Models, and User
Models.
This section covers the following sub-sections :
133
GAMA v1.8.0 documentation Chapter 18. Editing models
v 1.8.0 134
Chapter 19
The GAML Editor is a text editor that proposes several services to support the
modeler in writing correct models: an integrated live validation system, a ribbon
header that gives access to experiments, information, warning and error markers.
Table of contents
• The GAML Editor - Generalities
– Creating a first model
– Status of models in editors
– Editor Preferences
– Multiple editors
– Local history
135
GAMA v1.8.0 documentation Chapter 19. The GAML Editor - Generalities
v 1.8.0 136
GAMA v1.8.0 documentation Chapter 19. The GAML Editor - Generalities
the “Use default location” option checked. An error will be displayed if the project
name already exists in the workspace, in which case you will have to change it. Two
projects with similar names can not coexist in the workspace (even if they belong to
different categories).
Once the project is created (or if you have an existing project), navigate to it and
right-click on it. This time, choose “New. . . >Model file. . . ” to create a new model.
A new dialog is displayed, which asks for several required or optional information.
The Container is normally the name of the project you have selected, but you can
choose to place the file elsewhere. An error will be displayed if the container does
not exist (yet) in the workspace. You can then choose whether you want to use a
template or not for producing the initial file, and you are invited to give this file a
name. An error is displayed if this name already exists in this project. The name of
the model, which is by default computed with respect to the name of the file, can be
actually completely different (but it may not contain white spaces or punctuation
v 1.8.0 137
GAMA v1.8.0 documentation Chapter 19. The GAML Editor - Generalities
v 1.8.0 138
GAMA v1.8.0 documentation Chapter 19. The GAML Editor - Generalities
characters). The name of the author, as well as the textual description of the model
and the creation of an HTML documentation, are optional.
Once this dialog is filled and accepted, GAMA will display the new “empty” model.
Although GAML files are just plain text files, and can therefore be produced or
modified in any text processor, using the dedicated GAML editor offers a number of
advantages, among which the live display of errors and model statuses. A model can
v 1.8.0 139
GAMA v1.8.0 documentation Chapter 19. The GAML Editor - Generalities
actually be in four different states, which are visually accessible above the editing
area: Functional (orange color), Experimentable (green color), InError (red color),
InImportedError_(yellow color). See the section on model compilation for more
precise information about these statuses._
In its initial state, a model is always in the Functional state, which means it compiles
without problems, but cannot be used to launch experiments. The InError state,
depicted below, occurs when the file contains errors (syntactic or semantic ones).
While the file is not saved, these errors remain displayed in the editor and nowhere
else. If you save the file, they are now considered as “workspace errors” and get
displayed in the “Problems” view below the editor.
Reaching the Experimentable state requires that all errors are eliminated and that at
least one experiment is defined in the model, which is the case now in our toy model.
The experiment is immediately displayed as a button in the toolbar, and clicking on
it will allow to launch this experiment on your model. See the section about running
experiments for more information on this point.
Experiment buttons are updated in real-time to reflect what’s in your code. If more
than one experiment is defined, corresponding buttons will be displayed in addition
to the first one.
v 1.8.0 140
GAMA v1.8.0 documentation Chapter 19. The GAML Editor - Generalities
v 1.8.0 141
GAMA v1.8.0 documentation Chapter 19. The GAML Editor - Generalities
v 1.8.0 142
GAMA v1.8.0 documentation Chapter 19. The GAML Editor - Generalities
Editor Preferences
Text editing in general, and especially in Eclipse-based editors, sports a number of
options and preferences. You might want to turn off/on the numbering of the lines,
change the fonts used, change the colors used to highlight the code, etc. All of these
preferences are accessible from the “Preferences. . . ” item of the editor contextual
menu.
Explore the different items present there, keeping in mind that these preferences will
apply to all the editors of GAMA and will be stored in your workspace.
v 1.8.0 143
GAMA v1.8.0 documentation Chapter 19. The GAML Editor - Generalities
v 1.8.0 144
GAMA v1.8.0 documentation Chapter 19. The GAML Editor - Generalities
v 1.8.0 145
GAMA v1.8.0 documentation Chapter 19. The GAML Editor - Generalities
The Default theme of EditBox might not suit everyone’s tastes, so the preferences
allow to entirely customize how the “boxes” are displayed and how they can support
the modeler in better understanding “where” it is in the code. The “themes” defined
in this way are stored in the workspace, but can also be exported for reuse in other
workspaces, or sharing them with other modelers.
Multiple editors
GAMA inherits from Eclipse the possibility to entirely configure the placement of the
views, editors, etc. This can be done by rearranging their position using the mouse
(click and hold on an editor’s title and move it around). In particular, you can have
several editors side by side, which can be useful for viewing the documentation while
coding a model.
Local history
Among the various options present to work with models, which you are invited to try
out and test at will, one, called Local history is particularly interesting and worth a
small explanation. When you edit models, GAMA keeps in the background all the
successive versions you save (the history duration is configurable in the preferences),
whether or not you are using a versioning system like SVN or Git. This local history
is accessible from different places in GAMA (the Navigator, the Views menu, etc.),
including the contextual menu of the editor.
This command invokes the opening of a new view, which you can see on the figure
below, and which lists the different versions of your file so far. You can then choose
one and, right-clicking on it, either open it in a new editor, or compare it to your
current version.
This allows you to precisely pinpoint the modifications brought to the file and, in
case of problems, to revert them easily, or even revert the entire file to a previous
version. Never lose your work again !
This short introduction to GAML editors is now over. You might want to take a look,
now, at how the models you edit are parsed, validated and compiled, and how this
information is accessible to the modeler.
v 1.8.0 146
GAMA v1.8.0 documentation Chapter 19. The GAML Editor - Generalities
v 1.8.0 147
GAMA v1.8.0 documentation Chapter 19. The GAML Editor - Generalities
v 1.8.0 148
GAMA v1.8.0 documentation Chapter 19. The GAML Editor - Generalities
v 1.8.0 149
GAMA v1.8.0 documentation Chapter 19. The GAML Editor - Generalities
v 1.8.0 150
Chapter 20
The GAML Editor provide some tools to make the editing easier, covering a lot of
functionalities, such as tools for changes of visualization, tools for navigation through
your model, tools to format your code, or also tools to help you finding the correct
keywords to use in a given context.
Table of contents
• The GAML Editor Toolbar
– Visualization tools in the editor
– Navigation tools in the editor
– Format tools in the editor
– Vocabulary tools in the editor
151
GAMA v1.8.0 documentation Chapter 20. The GAML Editor Toolbar
v 1.8.0 152
GAMA v1.8.0 documentation Chapter 20. The GAML Editor Toolbar
The second toggle provides you the possibility to expand or collapse lines in your
model depending on the indentation. This feature can be very useful for big models,
to collapse the part you have already finished.
This third toggle is used to show occurrences when your cursor is pointing on one
word.
One particular option, shipped by default with GAMA, is the possibility to not only
highlight the code of your model, but also its structure (complementing, in that sense,
the Outline view). It is a slightly modified version of a plugin called EditBox, which
can be activated by clicking on the “green square” icon in the toolbar.
v 1.8.0 153
GAMA v1.8.0 documentation Chapter 20. The GAML Editor Toolbar
The Default theme of EditBox might not suit everyone’s tastes, so the preferences
allow to entirely customize how the “boxes” are displayed and how they can support
the modeler in better understanding “where” it is in the code. The “themes” defined
in this way are stored in the workspace, but can also be exported for reuse in other
workspaces, or sharing them with other modelers.
The two last tools of this section are used to increase / decrease the size of the
displayed text.
In the Editor toolbar, you have some tools for search and navigation through the
code. Here are the explanation for each functionalities:
In order to search an occurrence of a word (or the part of a word), you can type your
search in the field, and the result will be highlighted automatically in the text editor.
With the left / right arrows, you can highlight the previous / next occurrence of the
word. The two toggles just in the right side of the search field are used to constraint
the results as “case sensitive” or “whole word”. If you prefer the eclipse interface for
the search engine, you can also access to the tool by taping Ctrl+F.
The two arrow shape buttons that are coming after are used to jump from the current
location of your cursor to the last position, even if the last position was in an other
file (and even if this file has been closed !).
v 1.8.0 154
GAMA v1.8.0 documentation Chapter 20. The GAML Editor Toolbar
v 1.8.0 155
GAMA v1.8.0 documentation Chapter 20. The GAML Editor Toolbar
v 1.8.0 156
GAMA v1.8.0 documentation Chapter 20. The GAML Editor Toolbar
Show outline
This last tool of this section is used to show the global architecture of your model,
with explicit icons for each section. A search field is also available, if you want to
search a specific section. By double clicking one line of the outline, you can jump
directly to the chosen section. This feature can be useful if you have big model to
manipulate.
Some other tools are available in the toolbar to help for the indentation of the model:
Those two first buttons are used to shift a line (or a group of lines) on the left or the
right.
v 1.8.0 157
GAMA v1.8.0 documentation Chapter 20. The GAML Editor Toolbar
Format
Re-serialize
Comment
The two last buttons of this section are useful to comment a line (or a group of lines).
v 1.8.0 158
GAMA v1.8.0 documentation Chapter 20. The GAML Editor Toolbar
Templates
The templates button is used to insert directly a code snippet in the current position
of the cursor. Some snippets are already available, ordered by scope. You can custom
the list of template as much as you want, it is very easy to add a new template.
With this feature, you can easily know the list of built-in attributes and built-in
actions you can use in such or such context. With this feature, you can also insert
some templates to help you, for example to insert a pre-made species using a particular
skill, as it is shown it the following screenshot:
All the comments are generated automatically from the current documentation.
v 1.8.0 159
GAMA v1.8.0 documentation Chapter 20. The GAML Editor Toolbar
v 1.8.0 160
GAMA v1.8.0 documentation Chapter 20. The GAML Editor Toolbar
Operators
Once again, this powerful feature is used to generate example of structures for all the
operators, ordered by categories.
Colors
Here is the list of the name for the different pre-made colors you can use. You can
also add some custom colors.
v 1.8.0 161
GAMA v1.8.0 documentation Chapter 20. The GAML Editor Toolbar
Validation of Models
When editing a model, GAMA will continuously validate (i.e. compile) what the
modeler is entering and indicate, with specific visual affordances, various information
on the state of the model. This information ranges from documentation items to
errors indications. We will review some of them in this section.
Table of contents
• Validation of Models
– Syntactic errors
– Semantic errors
– Semantic warnings
– Semantic information
– Semantic documentation
– Changing the visual indicators
– Errors in imported files
– Cleaning models
Syntactic errors
These errors are produced when the modeler enters a sentence that has no meaning
in the grammar of GAML (see the documentation of the language). It can either be a
163
GAMA v1.8.0 documentation Chapter 21. Validation of Models
non-existing symbol (like “globals” (instead of global) in the example below), a wrong
punctuation scheme, or any other construct that puts the parser in the incapacity of
producing a correct syntax tree. These errors are extremely common when editing
models (since incomplete keywords or sentences are continuously validated). GAMA
will report them using several indicators: the icon of the file in the title of the editor
will sport an error icon and the gutter of the editor (i.e. the vertical space beside
the line numbers) will use error markers to report two or more errors: one on the
statement defining the model, and one (or more) in the various places where the
parser has failed to produce the syntax tree. In addition, the toolbar over the editor
will turn red and indicate that errors have been detected.
Hovering over one of these markers indicates what went wrong during the syntactic
validation. Note that these errors are sometimes difficult to interpret, since the parser
might fail in places that are not precisely those where a wrong syntax is being used
(it will usually fail after).
v 1.8.0 164
GAMA v1.8.0 documentation Chapter 21. Validation of Models
Semantic errors
When syntactic errors are eliminated, the validation enters a so-called semantic phase,
during which it ensures that what the modeler has written makes sense with respect
to the various rules of the language. To understand the difference between the two
phases, take a look at the following example.
This sentence below is syntactically correct:
species my_species parent: my_species;
v 1.8.0 165
GAMA v1.8.0 documentation Chapter 21. Validation of Models
them as precisely as possible, underlining the places where they have been found and
outputting hopefully meaningful error messages. In the example below, for instance,
we use a wrong number of arguments for defining a square geometry. Although the
sentence is syntactically correct, GAMA will nevertheless issue an error and prevent
the model from being experimentable.
The message accompanying this error can be obtained by hovering over the error
marker found in the gutter (multiple messages can actually be produced for a same
error, see below).
While the editor is in a so-called dirty state (i.e. the model has not been saved), errors
are only reported locally (in the editor itself). However, as soon as the user saves
a model containing syntactic or semantic errors, they are “promoted” to become
workspace errors, and, as such, indicated in other places: the file icon in the Navigator,
and a new line in the Errors view.
v 1.8.0 166
GAMA v1.8.0 documentation Chapter 21. Validation of Models
v 1.8.0 167
GAMA v1.8.0 documentation Chapter 21. Validation of Models
Semantic warnings
The semantic validation phase does not only report errors. It also outputs various
indicators that can help the modeler in verifying the correctness of his/her model.
Among them are warnings. A warning is an indication that something is not
completely right in the way the model is written, although it can probably be worked
around by GAMA when the model will be executed. For instance, in the example
below, we pass a string argument to the facet “number:” of the “create” statement.
GAMA will emit a warning in such a case, indicating that “number:” expects an
integer, and that the string passed will be casted to int when the model will be
executed. Warnings are to be considered seriously, as they usually indicate some
flaws in the logic of the model.
Hovering over the warning marker will allow the modeler to have access to the
explanation and hopefully fix the cause of the warning.
v 1.8.0 168
GAMA v1.8.0 documentation Chapter 21. Validation of Models
Semantic information
Besides warnings, another type of harmless feedback is produce by the semantic
validation phase: information markers. They are used to indicate useful information
to the modeler, for example that an attribute has been redefined in a sub-species,
or that some operation will take place when running the model (for instance, the
truncation of a float to an int). The visual affordance used in this case is voluntarily
discrete (a small “i” in the editor’s gutter).
As with the other types of markers, information markers unveil their messages when
being hovered.
Semantic documentation
The last type of output of the semantic validation phase consists in a complete
documentation of the various elements present in the model, which the user can
retrieve by hovering over the different symbols. Note that although the best effort is
being made in producing a complete and consistent documentation, it may happen
v 1.8.0 169
GAMA v1.8.0 documentation Chapter 21. Validation of Models
v 1.8.0 170
GAMA v1.8.0 documentation Chapter 21. Validation of Models
that some symbols do not produce anything. In that case, please report a new Issue
here.
The default visual indicators depicted in the examples above to report errors, warnings
and information can be customized to be less (or more) intrusive. This can be done
by choosing the “Preferences. . . ” item of the editor contextual menu and navigating
to “General > Editors > Text Editors > Annotations”. There, you will find the
various markers used, and you will be able to change how they are displayed in
the editor’s view. For instance, if you prefer to highlight errors in the text, you can
change it here.
v 1.8.0 171
GAMA v1.8.0 documentation Chapter 21. Validation of Models
v 1.8.0 172
GAMA v1.8.0 documentation Chapter 21. Validation of Models
v 1.8.0 173
GAMA v1.8.0 documentation Chapter 21. Validation of Models
Finally, even if your model has been cleansed of all errors, it may happen that it
refuses to launch because it imports another model that cannot be compiled. In the
following screenshot, “My First Model.gaml” imports “My Imported Model.gaml”,
which sports a syntactic error.
In such a case, the importing model refuses to compile (although it is itself valid) and
to propose experiments. There are cases, however, where the same importation can
work. Consider the following example, where, this time, “My Imported Model.gaml”
sports a semantic error in the definition of the global ‘shape’ attribute. Without
further modifications, the use case is similar to the first one.
However, if “My First Model.gaml” happens to redefine the shape attribute (in global),
it is now considered as valid. All the valid sections of “My Imported Model.gaml”
are effectively imported, while the erroneous definition is superseded by the new one.
v 1.8.0 174
GAMA v1.8.0 documentation Chapter 21. Validation of Models
v 1.8.0 175
GAMA v1.8.0 documentation Chapter 21. Validation of Models
Cleaning models
It may happen that the metadata that GAMA maintains about the different projects
(which includes the various markers on files in the workspace, etc.) becomes corrupted
from time to time. This especially happens if you frequently switch workspaces, but
not only. In those (hopefully rare) cases, GAMA may report incorrect errors for
perfectly legible files.
When such odd behaviors are detected, or if you want to regularly keep your metadata
in a good shape, you can clean all your project, by clicking on the button “Clear and
validate all projects” (in the syntax errors view).
v 1.8.0 176
GAMA v1.8.0 documentation Chapter 21. Validation of Models
v 1.8.0 177
GAMA v1.8.0 documentation Chapter 21. Validation of Models
v 1.8.0 178
Chapter 22
Running Experiments
1. The first, and most common way, consists in launching an experiment from
the Modeling perspective, using the user interface proposed by the simulation
perspective to run simulations.
2. The second way, detailed on this page, allows to automatically launch an
experiment when opening GAMA, subsequently using the same user interface.
3. The last way, known as running headless experiments, does not make use of
the user interface and allows to manipulate GAMA entirely from the command
line.
All three ways are strictly equivalent in terms of computations (with the exception of
the last one omitting all the computations necessary to render simulations on displays
or in the UI). They simply differ by their usage:
1. The first one is heavily used when designing models or demonstrating several
models.
2. The second is intended to be used when demonstrating or experimenting a
single model.
3. The last one is useful when running large sets of simulations, especially over
networks or grids of computers.
179
GAMA v1.8.0 documentation Chapter 22. Running Experiments
v 1.8.0 180
Chapter 23
GAMA supports multiple ways of launching experiments from within the Modeling
Perspective, in editors or in the navigator.
Table of contents
• Launching Experiments from the User Interface
– From an Editor
– From the Navigator
– Running Experiments Automatically
– Running Several Simulations
From an Editor
As already mentioned on this page, GAML editors will provide the easiest way to
launch experiments. Whenever a model that contains the definition of experiments is
validated, these experiments will appear as distinct buttons, in the order in which
they are defined in the file, in the header ribbon above the text. Simply clicking one
of these buttons launches the corresponding experiment.
181
GAMA v1.8.0 documentation
Chapter 23. Launching Experiments from the User Interface
For each of those launching buttons, you can see 2 different pictograms, showing
the type of experiment. An experiment can either be a GUI Experiment or a Batch
Experiment.
v 1.8.0 182
GAMA v1.8.0 documentation
Chapter 23. Launching Experiments from the User Interface
v 1.8.0 183
GAMA v1.8.0 documentation
Chapter 23. Launching Experiments from the User Interface
v 1.8.0 184
GAMA v1.8.0 documentation
Chapter 23. Launching Experiments from the User Interface
v 1.8.0 185
GAMA v1.8.0 documentation
Chapter 23. Launching Experiments from the User Interface
v 1.8.0 186
Chapter 24
187
GAMA v1.8.0 documentation Chapter 24. Experiments User Interface
v 1.8.0 188
Chapter 25
The simulation perspective adds on the user interface a number of new menus and
commands (i.e. buttons) that are specific to experiment-related tasks.
Table of contents
• Menus and Commands
– Experiment Menu
– Agents Menu
– General Toolbar
Experiment Menu
A menu, called “Experiment”, allows to control the current experiment. It shares
some of its commands with the general toolbar (see below).
189
GAMA v1.8.0 documentation Chapter 25. Menus and Commands
v 1.8.0 190
GAMA v1.8.0 documentation Chapter 25. Menus and Commands
• Stop at first error: if checked, the current experiment will stop running when
an error is issued. The default value can be configured in the preferences.
• Treat warnings as errors: if checked, a warning will be considered as an
error (and if the previous item is checked, will stop the experiment). The default
value can be configured in the preferences.
• Display warnings and errors: if checked, displays the errors and warnings
issued by the experiment. If not, do not display them. The default value can
be configured in the preferences.
• Force interrupt: forces the experiment to stop, whatever it is currently doing,
purges the memory from it, and switches to the modeling perspective. Use
this command with caution, as it can have undesirable effects depending
on the state of the experiment (for example, if it is reading files, or outputting
data, etc.).
Agents Menu
A second menu is added in the simulation perspective: “Agents”. This menu allows
for an easy access to the different agents that populate an experiment.
This hierarchical menu is always organized in the same way, whatever the experiment
being run. A first level is dedicated to the current simulation agent: it allows to browse
its population or to inspect the simulation agent itself. Browsing the population will
give access to the current experiment agent (the “host” of this population). A second
level lists the “micro-populations” present in the simulation agent. And the third
level will give access to each individual agent in these populations. This organization
is of course recursive: if these agents are themselves hosts of micro-populations, they
will be displayed in their individual menu.
Each agent, when selected, will reveal a similar individual menu. This menu will
contain a set of predefined actions, the commands defined by the user for this species,
if any, and then the micro-populations hosted by this agent, if any. Agents (like the
instances of “ant” below) that do not host other agents and whose species has no
user commands will have a “simple” individual menu.
These are the 4 actions that will be there most of the time:
v 1.8.0 191
GAMA v1.8.0 documentation Chapter 25. Menus and Commands
v 1.8.0 192
GAMA v1.8.0 documentation Chapter 25. Menus and Commands
• Focus: this option is not accessible if no displays are defined. Makes the current
display zoom on the selected agent (if it is displayed) so that it occupies the
whole view.
• Kill: destroys the selected agent and disposes of it. Use this command with
caution, as it can have undesirable effects if the agent is currently executing
its behavior.
If an agent hosts other agents (it is the case in multi-level architecture), you can
access to the micro-population quite easily:
If user commands are defined for a species (for example in the existing model
Features/Driving Skill/Road Traffic simple (City)), their individual menu will look
like the following:
General Toolbar
The last piece of user interface specific to the Simulation Perspective is a toolbar,
which contains controls and information displays related to the current experiment.
v 1.8.0 193
GAMA v1.8.0 documentation Chapter 25. Menus and Commands
v 1.8.0 194
GAMA v1.8.0 documentation Chapter 25. Menus and Commands
This toolbar is voluntarily minimalist, with three buttons already present in the
experiment menu (namely, “Play/Pause”, “Step by Step” and “Reload”), which don’t
need to be detailed here, and two new controls (“Experiment status” and “Cycle
Delay”), which are explained below.
While opening an experiment, the status will display some information about what’s
going on. For instance, that GAMA is busy instantiating the agents, or opening the
displays.
The orange color usually means that, although the experiment is not ready, things are
progressing without problems (a red color message is an indication that something
went wrong). When the loading of the experiment is finished, GAMA displays the
message “Simulation ready” on a green background. If the user runs the simulation,
the status changes and displays the number of cycles already elapsed in the simulation
v 1.8.0 195
GAMA v1.8.0 documentation Chapter 25. Menus and Commands
v 1.8.0 196
GAMA v1.8.0 documentation Chapter 25. Menus and Commands
v 1.8.0 197
GAMA v1.8.0 documentation Chapter 25. Menus and Commands
v 1.8.0 198
Chapter 26
Parameters View
In the case of an experiment, the modeler can define the parameters he wants to be
able to modify to explore the simulation, and thus the ones he wants to be able to
display and alter in the GUI interface.
It important to notice that all modification made in the parameters are
used for simulation reload only. Creation of a new simulation from the
model will erase the modifications.
Table of contents
• Parameters View
– Built-in parameters
– Parameters View
– Modification of parameters values
Built-in parameters
Every GUI experiment displays a pane named “Parameters” containing at least two
built-in parameters related to the random generator:
199
GAMA v1.8.0 documentation Chapter 26. Parameters View
Parameters View
The modeler can define himself parameters that can be displayed in the GUI and
that are sorted by categories. Note that the interface will depend on the data type
of the parameter: for example, for integer or float parameters, a simple text box
will be displayed whereas a color selector will be available for color parameters. The
parameters value displayed are the initial value provided to the variables associated
to the parameters in the model.
The above parameters view is generated from the following code:
global
{
int i;
float f;
string s;
list l;
matrix m;
pair p;
rgb c;
}
v 1.8.0 200
GAMA v1.8.0 documentation Chapter 26. Parameters View
v 1.8.0 201
GAMA v1.8.0 documentation Chapter 26. Parameters View
output {}
}
Click on Edit button in case of list or map parameters or the color or matrix will
open an additional window to modify the parameter value.
v 1.8.0 202
Chapter 27
GAMA offers some tools to obtain informations about one or several agents. There
are two kinds of tools:
• agent browser
• agent inspector
GAMA offers as well a tool to get the value of a specific expression: monitors.
Table of contents
• Inspectors and monitors
– Agent Browser
– Agent Inspector
– Monitor
Agent Browser
The species browser provides informations about all or a selection of agents of a
species.
The agent browser is available through the Agents menu or by right clicking on a
display (screenshots from the ).
203
GAMA v1.8.0 documentation Chapter 27. Inspectors and monitors
v 1.8.0 204
GAMA v1.8.0 documentation Chapter 27. Inspectors and monitors
It displays in a table all the values of the agent variables of the considered species;
each line corresponding to an agent. The list of attributes is displayed on the left
side of the view, and you can select the attributes you want to be displayed, simply
by clicking on it (Ctrl + Click for multi-selection).
By clicking on the right mouse button on a line, it is possible to do some action for
the corresponding agent.
Agent Inspector
The agent inspector provides information about one specific agent. It also allows
to change the values of its variables during the simulation. The agent inspector
is available from the Agents menu, by right_clicking on a display, in the species
inspector or when inspecting another agent.
It is possible to «highlight» the selected agent.
To change the color of the highlighted agent, go to Preferences/Display.
Monitor
Monitors allow to follow the value of a GAML expression. For instance, the following
monitor allows to follow the number of infected people agents during the simulation.
The monitor is updated at each simulation step.
It is possible to define a monitor inside a model (see this page). It is also possible to
define a monitor through the graphical interface.
To define a monitor, first choose Add Monitor in the Views menu (or by clicking
on the icon in the Monitor view), then define the display legend and the expression
to monitor.
In the following example, we defined a monitor with the legend “Number initial of
preys” and that has for value the global variable “nb_preys_init”.
The expression should be written with the GAML language. See this page for more
details about the GAML language.
v 1.8.0 205
GAMA v1.8.0 documentation Chapter 27. Inspectors and monitors
v 1.8.0 206
GAMA v1.8.0 documentation Chapter 27. Inspectors and monitors
v 1.8.0 207
GAMA v1.8.0 documentation Chapter 27. Inspectors and monitors
v 1.8.0 208
GAMA v1.8.0 documentation Chapter 27. Inspectors and monitors
v 1.8.0 209
GAMA v1.8.0 documentation Chapter 27. Inspectors and monitors
v 1.8.0 210
Chapter 28
Displays
• java 2D displays
• OpenGL displays
These 2 kinds of display allows the modeler to display the same objects (agents,
charts, texts . . . ). The OpenGL display offers extended features in particular in terms
of 3D visualisation. The OpenGL displays offers in addition better performance when
zooming in and out.
Table of contents
• Displays
– Classical displays (java2D)
– OpenGL displays
211
GAMA v1.8.0 documentation Chapter 28. Displays
• the mouse left press and move allows to move the camera (in 2D),
• the mouse right click opens a context menu allowing the modeler to inspect
displayed agents,
• the wheel allows the modeler to zoom in or out.
Each display provides several buttons to manipulate the display (from left to right):
The Show/Hide side bar button opens a side panel in the display allowing the modeler
to configure:
• Properties of the display: background and highlight color, display the scale
bar
• For each layer, we can configure visibility, transparency, position and size of the
layer. For grid layers, we can in addition show/hide grids. For species layers, we
can also configure the displayed aspect. For text layers, we can the expression
displayed with the color and the font.
The bottom overlay bar displays information about the way it is displayed:
v 1.8.0 212
GAMA v1.8.0 documentation Chapter 28. Displays
OpenGL displays
The OpenGL display has an additional button 3D Options providing 3D features:
v 1.8.0 213
GAMA v1.8.0 documentation Chapter 28. Displays
• Apply inertia (only with Arcball camera): in inertia mode, when the modeler
stops moving the camera, there is no straight halt but a kind of inertia.
• Rotate scene: rotate the scene around an axis orthogonal to the scene,
• Split layers/Merge layers: display each layer at a distinct height,
• Triangulate scene: display the polygon primitives.
In addition, the bottom overlay bar provides the Camera position in 3D.
Key Function
Double Click Zoom Fit
+ Zoom In
- Zoom Out
Up Move forward
Down Move backward
v 1.8.0 214
GAMA v1.8.0 documentation Chapter 28. Displays
Key Function
Left Strafe left
Right Strafe right
SHIFT+Up Look up
SHIFT+Down Look down
SHIFT+Left Look left
SHIFT+Right Look right
MOUSE Makes the camera look up, down, left and right
MouseWheel Zoom-in/out to the current target (center of the screen)
Key Function
Double Click Zoom Fit
+ Zoom In
- Zoom Out
Up Horizontal movement to the top
Down Horizontal movement to the bottom
Left Horizontal movement to the left
Right Horizontal movement to the right
SHIFT+Up Rotate the model up (decrease the phi angle of the
spherical coordinates)
SHIFT+Down Rotate the model down (increase the phi angle of the
spherical coordinates)
SHIFT+Left Rotate the model left (increase the theta angle of the
spherical coordinates)
SHIFT+Right Rotate the model right (decrease the theta angle of the
spherical coordinates)
SPACE Reset the pivot to the center of the envelope
KEYPAD 2,4,6,8 Quick rotation (increase/decrease phi/theta by 30°)
CMD+MOUSE1 Makes the camera rotate around the model
ALT+LEFT_- Enables ROI Agent Selection
MOUSE
SHIFT+LEFT_- Enables ROI Zoom
MOUSE
v 1.8.0 215
GAMA v1.8.0 documentation Chapter 28. Displays
Key Function
SCROLL Zoom-in/out to the current target (center of the
sphere)
WHEEL CLICK Reset the pivot to the center of the envelope
v 1.8.0 216
Chapter 29
Batch Specific UI
Table of contents
• Batch Specific UI
– Information bar
– Batch UI
Information bar
In batch mode, the top information bar displays 3 distinct information (instead of
only the cycle number in the GUI experiment):
217
GAMA v1.8.0 documentation Chapter 29. Batch Specific UI
Batch UI
The parameters view is also a bit different in the case of a Batch UI. The following
interface is generated given the following model part:
experiment Batch type: batch repeat: 2 keep_seed: true until: (
food_gathered = food_placed) or (time > 400) {
parameter 'Size of the grid:' var: gridsize init: 75 unit: 'width
and height';
parameter 'Number:' var: ants_number init: 200 unit: 'ants';
parameter 'Evaporation:' var: evaporation_rate among: [0.1, 0.2,
0.5, 0.8, 1.0] unit: 'rate every cycle (1.0 means 100%)';
parameter 'Diffusion:' var: diffusion_rate min: 0.1 max: 1.0 unit: '
rate every cycle (1.0 means 100%)' step: 0.3;
The interface summarizes all model parameters and the parameters given to the
exploration method:
• Environment and Population: displays all the model parameters that should
not be explored;
• Parameters to explore: the parameters to explore are the parameters defined
in the experiment with a range of values (with among facet or min, max and
step facets);
• Exploration method: it summarizes the Exploration method and the stop
condition. For exhaustive method it also evaluates the parameter space. For
other methods, it also displays the method parameters (e.g. mutation or crossover
probability. . . ). Finally the best fitness found and the last fitness found are
displayed (with the associated parameter set).
v 1.8.0 218
GAMA v1.8.0 documentation Chapter 29. Batch Specific UI
v 1.8.0 219
GAMA v1.8.0 documentation Chapter 29. Batch Specific UI
v 1.8.0 220
Chapter 30
Errors View
221
GAMA v1.8.0 documentation Chapter 30. Errors View
v 1.8.0 222
Chapter 31
Preferences
Various preferences are accessible in GAMA to allow users and modelers to personalize
their working environment. This section review the different preference tabs available
in the current version of GAMA, as well as how to access the preferences and settings
inherited by GAMA from Eclipse.
Please note that the preferences specific to GAMA will be shared, on a same machine,
and for a same user, among all the workspaces managed by GAMA. Changing
workspace will not alter them. If you happen to run several instances of GAMA, they
will also share these preferences.
Table of contents
• Preferences
– Opening Preferences
– Simulation
– Display
– Editor
– External
– Advanced Preferences
223
GAMA v1.8.0 documentation Chapter 31. Preferences
Opening Preferences
To open the preferences dialog of GAMA, either click on the small “form” button on
the top-left corner of the window or select “Preferences. . . ” from the Gama, “Help”
or “Views” menu depending on your OS.
Simulation
• Random Number Generation: all the options pertaining to generating
random numbers in simulations
v 1.8.0 224
GAMA v1.8.0 documentation Chapter 31. Preferences
v 1.8.0 225
GAMA v1.8.0 documentation Chapter 31. Preferences
UI
• Menus
– Break down agents in menu every: when inspecting a large number of
agents, how many should be displayed before the decision is made to
separate the population in sub-menus.
– Sort colors menu by
– Sort operators menu by
• Console
– Max. number of characters to display in the console (-1 means no limit)
– Max. number of characters to keep in memory when console is paused (-1
means no limit)
• Icons
– Icons and buttons dark mode (restart to see the change): Change the
highlight for the icons and the button.
– Size of icons in the UI (restart to see the change): Size of the icons in pixel
• Viewers
v 1.8.0 226
GAMA v1.8.0 documentation Chapter 31. Preferences
v 1.8.0 227
GAMA v1.8.0 documentation Chapter 31. Preferences
General
• Startup
– Display welcome page at startup: if true, and if no editors are opened, the
welcome page is displayed when opening GAMA.
v 1.8.0 228
GAMA v1.8.0 documentation Chapter 31. Preferences
Display
• Properties: various properties of displays
– Default display method: use either ‘Java2D’ or ‘OpenGL’ if nothing is
specified in the declaration of a display.
– Synchronize displays with simulations: if true, simulation cycles will wait
for the displays to have finished their rendering before passing to the next
cycle (this setting can be changed on an individual basis dynamically here).
– Show display overlay: if true, the bottom overlay is visible when opening
a display.
– Show scale bar in overlay: if true, the scale bar is displayed in the bottom
overlay.
– Apply antialiasing: if true, displays are drawn using antialiasing, which is
v 1.8.0 229
GAMA v1.8.0 documentation Chapter 31. Preferences
slower but renders a better quality of image and text (this setting can be
changed on an individual basis dynamically here).
– Default background color: indicates which color to use when none is
specified in the declaration of a display.
– Default highlight color: indicates which color to use for highlighting agents
in the displays.
– Stack displays on screen. . . : if true, the display views, in case they are
stacked on one another, will put the first display declared in the model on
top of the stack.
• Default Aspect: which aspect to use when an ‘agent’ or ‘species’ layer does
not indicate it
Editor
Most of the settings and preferences regarding editors can be found in the advanced
preferences.
• Options
v 1.8.0 230
GAMA v1.8.0 documentation Chapter 31. Preferences
v 1.8.0 231
GAMA v1.8.0 documentation Chapter 31. Preferences
External
These preferences pertain to the use of external libraries or data with GAMA.
• Paths
– Path to Spatialite: the path to the Spatialite library (http://www.gaia-
gis.it/gaia-sins/) in the system.
– Path to RScript: the path to the RScript library (http://www.r-project.org)
in the system.
v 1.8.0 232
GAMA v1.8.0 documentation Chapter 31. Preferences
v 1.8.0 233
GAMA v1.8.0 documentation Chapter 31. Preferences
Advanced Preferences
The set of preferences described above are specific to GAMA. But there are other
preferences or settings that are inherited from the Eclipse underpinnings of GAMA,
which concern either the “core” of the platform (workspace, editors, updates, etc.) or
plugins (like SVN, for instance) that are part of the distribution of GAMA.
These “advanced” preferences are accessible by clicking on the “Advanced. . . ” button
in the Preferences view.
Depending on what is installed, the second view that appears will contain a tree
of options on the left and preference pages on the right. Contrary to the first
set of preferences, please note that these preferences will be saved in the
current workspace, which means that changing workspace will revert them to their
v 1.8.0 234
GAMA v1.8.0 documentation Chapter 31. Preferences
default values. It is however possible to import them in the new workspace using of
the wizards provided in the standard “Import. . . ” command (see here).
v 1.8.0 235
GAMA v1.8.0 documentation Chapter 31. Preferences
v 1.8.0 236
Part VI
237
Chapter 32
This large progressive tutorial has been designed to help you to learn GAML (GAma
Modeling Language). It will cover the main part of the possibilities provided by
GAML, and guide you to learn some more.
239
GAMA v1.8.0 documentation Chapter 32. Learn GAML Step by Step
v 1.8.0 240
Chapter 33
Introduction
241
GAMA v1.8.0 documentation Chapter 33. Introduction
Table of contents
• Key Concepts (Under construction)
v 1.8.0 242
GAMA v1.8.0 documentation Chapter 33. Introduction
Putting this all together, writing a model in GAML then consists in defining a species
v 1.8.0 243
GAMA v1.8.0 documentation Chapter 33. Introduction
which inherits from model, in which other species, inheriting (directly or not) from
agent and representing the entities that populate this model, will be nested, and
which is itself nested in one or several experiment plans among which a user will
be able to choose which experiment he/she wants to execute.
At the operational level, i.e. when running an experiment in GAMA,
v 1.8.0 244
GAMA v1.8.0 documentation Chapter 33. Introduction
v 1.8.0 245
GAMA v1.8.0 documentation Chapter 33. Introduction
GAML Java
species class
micro-species nested class
parent species superclass
child species subclass
model program
experiment (main) class
agent object
attribute member
action method
behavior collection of methods
aspect collection of methods, mixed with the behavior
skill interface (on steroids)
statement statement
type type
parametric type generics
GAML NetLogo
species breed
micro-species -
parent species -
v 1.8.0 246
GAMA v1.8.0 documentation Chapter 33. Introduction
GAML NetLogo
child species - (only from ‘turtle’)
model model
experiment observer
agent turtle/observer
attribute ‘breed’-own
action global function applied only to one breed
behavior collection of global functions applied to one breed
aspect only one, mixed with the behavior
skill -
statement primitive
type type
parametric type -
v 1.8.0 247
GAMA v1.8.0 documentation Chapter 33. Introduction
v 1.8.0 248
Chapter 34
In this part, we will present you some basic concepts of GAML that will help you a
lot for the next pages.
You will first learn how to organize a standard model, then you will learn about
some basis about GAML, such as how to declare a variable, how to use the basic
operators, how to write a conditional structure or a loop, how to manipulate containers
and how to generate random values.
249
GAMA v1.8.0 documentation Chapter 34. Start with GAML
v 1.8.0 250
Chapter 35
Organization of a model
This conceptual structure is respected in the definition of model files, which follows a
similar pattern:
Table of contents
251
GAMA v1.8.0 documentation Chapter 35. Organization of a model
The name of the model is not necessarily the same as the name of the file. It must
conform to the general rule for naming species, i.e. be a valid identifier (beginning
with a letter, containing only letters, digits and dashes). This name will be used for
building the name of the model species, from which simulations will be instantiated.
For instance, the following declaration:
model dummy
will internally create a species called dummy_model, child of the abstract species
model, from which simulations (called dummy_model0, dummy_model1, etc.) will be
instantiated.
This declaration is followed by optional import statements that indicate which other
models this model is importing. Import statements do not end with a semi-colon.
Importing a model can take two forms. The first one, called inheritance import, is
declared as follows:
import "relative_path_to_a_model_file"
import "relative_path_to_another_model_file"
When importing models using the first form, all the declarations of the model(s)
imported will be merged with those of the current model (in the order with which
the import statements are declared, i.e. the latest definitions of global attributes
or behaviors superseding the previous ones). The second form is reserved for using
models as micro-models of the current model. This possibility is still experimental in
the current version of GAMA.
The last part of the header is the definition of the global species, which is the actual
definition of the model species itself.
v 1.8.0 252
GAMA v1.8.0 documentation Chapter 35. Organization of a model
global {
// Definition of [global attributes](GlobalSpecies#declaration), [
actions and behaviors](DefiningActionsAndBehaviors)
}
Note that neither the imports nor the definition of global are mandatory. Only the
model statement is.
Species declarations
The header is followed by the declaration of the different species of agents that
populate the model.
The special species global is the world species. You will declare here all the global
attributes/actions/behaviors. The global species does not have name, and is unique
in your model.
global {
// definition of global attributes, actions, behaviors
}
Regular species can be declared with the keyword species. You can declare several
regular species, and they all have to be named.
species nameOfSpecies {
// definition of your [species attributes](RegularSpecies#
declaration), [actions and behaviors](DefiningActionsAndBehaviors)
}
Note that the possibility to define the species after the global definition is actually
a convenience: these species are micro-species of the model species and, hence, could
be perfectly defined as nested species of global. For instance:
global {
// definition of global attributes, actions, behaviors
}
species A {...}
species B {...}
v 1.8.0 253
GAMA v1.8.0 documentation Chapter 35. Organization of a model
species A {...}
species B {...}
}
Experiment declarations
Experiments are usually declared at the end of the file. They start with the keyword
experiment. They contains the simulation parameters, and the definition of the output
(such as displays, monitors or inspectors). You can declare as much experiments as
you want.
experiment first_experiment {
// definition of parameters (intputs)
// definition of output
output {...}
}
experiment second_experiment {
// definition of parameters (inputs)
// definition of output
}
Note that you have two types of experiments: A GUI experiment allows to display
a graphical interface with input parameters and outputs. It is declared with the
following structure :
experiment gui_experiment type:gui {
[...]
}
v 1.8.0 254
GAMA v1.8.0 documentation Chapter 35. Organization of a model
experiment batch_experiment type:batch {
[...]
}
global {
// definition of [global attributes](GlobalSpecies#declaration),
actions, behaviours
}
species my_specie {
// definition of attributes, actions, behaviours
}
Don’t forget this structure ! This will be the basis for all the models you will create
from now.
v 1.8.0 255
GAMA v1.8.0 documentation Chapter 35. Organization of a model
v 1.8.0 256
Chapter 36
In this part, we will focus on the very basic structures in GAML, such as how to
declare a variable, how to use loops, or how to manipulate lists. We will overfly
quickly all those basic programming concepts, admitting that you already have some
basics in coding.
Index
• Variables
– Basic types
– The point type
– A word about dimensions
• Declare variables using facet
• Operators in GAMA
– Logical operators
– Comparison operators
– Type casting operators
– Other operators
• Conditional structures
• Loop
257
GAMA v1.8.0 documentation Chapter 36. Basic programming concepts in GAML
• Manipulate containers
• Random values
Variables
Variables are declared very easily in GAML, starting with the keyword for the type,
following by the name you want for your variable. NB: The declaration has to be
inside the global scope, or inside the species scope.
typeName myVariableName;
Basic types
All the “basic” types are present in GAML:int, float, string, bool. The operator
for the affectation in GAML is <- (the operator = is used to test the equality).
int integerVariable <- 3;
float floatVariable <- 2.5;
string stringVariable <- "test"; // you can also write simple ' : <- '
test'
bool booleanVariable <- true; // or false
To follow the behavior of variable, we can write their value in the console. Let’s go
back to our basic skeleton of a model, and let’s create a reflex in the global scope (to
be short, a reflex is a function that is executed in each step. We will come back to
this concept later). The write function works very easily, simply writing down the
keyword write and the name of the variable we want to be displayed.
model firstModel
global {
int integerVariable <- 3;
float floatVariable <- 2.5;
string stringVariable <- "test"; // you can also write simple ' :
<- 'test'
bool booleanVariable <- true; // or false
reflex writeDebug {
write integerVariable;
write floatVariable;
write stringVariable;
v 1.8.0 258
GAMA v1.8.0 documentation Chapter 36. Basic programming concepts in GAML
write booleanVariable;
}
}
experiment myExperiment
{
}
The function write is overloaded for each type of variable (even for the more complex
type, such as containers).
Note that before being initialized, a variable has the value nil.
reflex update {
string my_string;
write my_string; // this will write "nil".
int my_int;
write my_int; // this will write "0", which is the default value
for int.
}
nil is also a literal you can use to initialize your variable (you can learn more about
the concept of literal in this page).
reflex update {
string my_string <- "a string";
my_string <- nil;
write my_string; // this will write "nil".
int my_int <- 6;
my_int <- nil;
write my_int; // this will write "0", which is the default value
for int.
}
Another variable type you should know is the point variable. This type of variable is
used to describe coordinates. It is in fact a complex variable, composed of two float
variables (or three if you are working in 3D). To declare it, you have to use the curly
bracket {:
point p <- {0.2,2.4};
v 1.8.0 259
GAMA v1.8.0 documentation Chapter 36. Basic programming concepts in GAML
The first field is related to the x value, and the second, to the y value. You can easily
get this value as following:
point p <- {0.2,2.4};
write p.x; // the output will be 0.2
write p.y; // the output will be 2.4
You can’t modify directly the value. But if you want, you can do a simple operation
to get what you want:
point p <- {0.2,2.4};
p <- p + {0.0,1.0};
write p.y; // the output will be 3.4
When manipulating float values, you can specify the dimension of your value. Dimen-
sions are preceded by # or ° (exactly the same).
float a <- 5˚m;
float b <- 4#cm;
float c <- a + b; // c is equal to 5.0399999 (it's not equal to 5.04
because it is a float value, not as precise as int)
You can use the facet update if you want to change the value of your variable. For
example, to increment your integer variable each step, you can do as follow:
v 1.8.0 260
GAMA v1.8.0 documentation Chapter 36. Basic programming concepts in GAML
int integerVariable <- 3 min:0 max:10 update:integerVariable+1;
// nb: the operator "++" doesn't exist in gaml.
You can use the facet min and max to constraint the value in a specific range of values:
int integerVariable <- 3 min:0 max:10 update:integerVariable+1;
// the result will be 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 10 - 10 - ...
The facet among can also be useful (that can be seen as an enum):
string fruits <- "banana" among:["pear","apple","banana"];
Operators in GAMA
In GAML language, you can use a lot of different operators. They are all listed in
this page, but here are the most useful ones:
- Mathematical operators
The basic arithmetical operators, such as +(add), -(substract), *(multiply), /(divide),
^(power) are used this way:
Logical operators
Logical operators such as and(and), or(inclusive or) are used the same way as basic
arithmetical operators. The operator !(negation) has to be placed just before the
operand. They return a boolean result.
FirstOperand Operator SecondOperand --> ex: true or false; // return
true
NegationOperator Operand --> ex: !(true or false); // return false
v 1.8.0 261
GAMA v1.8.0 documentation Chapter 36. Basic programming concepts in GAML
Comparison operators
The comparison operators !=(different than), <(smaller than), <=(smaller of equal), =
(equal), >(bigger than), >=(bigger or equal) are used the same way as basic arithmetical
operators:
FirstOperand Operator SecondOperand --> ex: 5 < 3; // return false
Other operators
A lot of other operators exist in GAML. The standard way to use those operators is
as followed:
Operator(FirstOperand,SecondOperand,...) --> ex: rnd(1,8);
Conditional structures
You can write if/else if/else in GAML:
if (integerVariable<0) {
write "my value is negative !! The exact value is " +
integerVariable;
}
else if (integerVariable>0) {
write "my value is positive !! The exact value is " +
integerVariable;
}
else if (integerVariable=0) {
v 1.8.0 262
GAMA v1.8.0 documentation Chapter 36. Basic programming concepts in GAML
Loop
Loops in GAML are designed by the keyword loop. As for variables, a loop have
multiple facet to determine its behavior:
• The facet from / to, to repeat a set of statements while an index iterates over
a range of values with a fixed step of 1:
loop i from:0 to: 5 { // or loop name:i from:0 to:5 -> the name is also
a facet
write i;
}
// the output will be 0 - 1 - 2 - 3 - 4 - 5
v 1.8.0 263
GAMA v1.8.0 documentation Chapter 36. Basic programming concepts in GAML
• The facet from / to combine with the facet step to choose the step:
loop i from:0 to: 5 step: 2 {
write i;
}
// the output will be 0 - 2 - 4
• The facet over to browse containers, as we will see in the next part.
Nb: you can interrupt a loop at any time by using the break statement.
Manipulate containers
We saw in the previous parts “simple” types of variable. You also have a multiple
containers types, such as list, matrix, map, pair. . . In this section, we will only
focus on the container list (you can learn the other by reading the section about
datatypes).
How to declare a list?
To declare a list, you can either or not specify the type of the data of its elements:
list<int> listOfInt <- [5,4,9,8];
list listWithoutType <- [2,4.6,"oij",["hoh",0.0]];
There is an other operator, empty, that returns you a boolean telling you if the list is
empty or not.
bool isEmpty <- empty([12,13]); // will return false
bool isEmpty <- empty([]); // will return true
bool isEmpty <- empty("stuff"); // will return false
v 1.8.0 264
GAMA v1.8.0 documentation Chapter 36. Basic programming concepts in GAML
v 1.8.0 265
GAMA v1.8.0 documentation Chapter 36. Basic programming concepts in GAML
You can add 2 lists by creating a third one and browsing the 2 first one, but you can
do it much easily by using the operator + :
list<int> list_int1 <- [1,5,7,6,7];
list<int> list_int2 <- [6,9];
list<int> list_int_result <- list_int1 + list_int2;
Random values
When you will implement your model, you will have to manipulate some random
values quite often.
To get a random value in a range of value, use the operator rnd. You can use this
operator in many ways:
int var0 <- rnd (2); // var0 equals 0, 1 or 2
float var1 <- rnd (1000) / 1000; // var1 equals a float between 0
and 1 with a precision of 0.001
v 1.8.0 266
GAMA v1.8.0 documentation Chapter 36. Basic programming concepts in GAML
point var2 <- rnd ({2.0, 4.0}, {2.0, 5.0, 10.0}, 1); // var2 equals
a point with x = 2.0, y equal to 2.0, 3.0 or 4.0 and z between 0.0
and 10.0 every 1.0
float var3 <- rnd (2.0, 4.0, 0.5); // var3 equals a float number
between 2.0 and 4.0 every 0.5
float var4 <- rnd(3.4); // var4 equals a random float between 0.0
and 3.4
int var5 <- rnd (2, 12, 4); // var5 equals 2, 6 or 10
point var6 <- rnd ({2.5,3, 0.0}); // var6 equals {x,y} with x in
[0.0,2.0], y in [0.0,3.0], z = 0.0
int var7 <- rnd (2, 4); // var7 equals 2, 3 or 4
point var8 <- rnd ({2.0, 4.0}, {2.0, 5.0, 10.0}); // var8 equals a
point with x = 2.0, y between 2.0 and 4.0 and z between 0.0 and 10.0
float var9 <- rnd (2.0, 4.0); // var9 equals a float number between
2.0 and 4.0
Use the operator flip if you want to pick a boolean value with a certain probability:
bool result <- flip(0.2); // result will have 20% of chance to be true
You can use randomness in list, by using the operator shuffle, or also by using the
operator among to pick randomly one (or several) element of your list:
list TwoRandomValuesFromTheList <- 2 among [5,4,9,8];
// the list will be for example [5,9].
You can use probabilistic laws, using operators such as gauss, poisson, binomial, or
truncated_gauss (we invite you to read the documentation for those operators).
v 1.8.0 267
GAMA v1.8.0 documentation Chapter 36. Basic programming concepts in GAML
v 1.8.0 268
Chapter 37
In this chapter, we will learn how to manipulate some basic species. As you already
know, a species can be seen as the definition of a type of agent (we call agent the
instance of a species). In OOP (Object-Oriented Programming), a species can be
seen as the class. Each species is then defined by some attributes (“member” in
OOP), actions (“method” in OOP) and behavior (“method” in OOP).
In this section, we will first learn how to declare the world agent, using the global
species. We will then learn how to declare regular species which will populate
our world. The following lesson will be dedicated to learn how to define actions
and behaviors for all those species. We will then learn how agents can interact
between each other, especially with the statement ask. In the next chapter then,
we will see how to attach skills to our species, giving them new attributes and
actions. This section will be closed with a last lesson dealing with how inheritence
works in GAML.
269
GAMA v1.8.0 documentation Chapter 37. Manipulate basic species
v 1.8.0 270
Chapter 38
We will start this chapter by studying a special species: the global species. In the
global species you can define the attributes, actions and behaviors that describe the
world agent. There is one unique world agent per simulation: it is this agent that is
created when a user runs an experiment and that initializes the simulation through its
init scope. The global species is a species like other and can be manipulated as them.
In addition, the global species automatically inherits from several of built-in variables
and actions. Note that a specificity of the global species is that all its attributes can
be referred by all agents of the simulation.
Index
• Declaration
• Environment Size
• Built-in Attributes
• Built-in Actions
• The init statement
Declaration
A GAMA model contains a unique global section that defines the global species.
global {
271
GAMA v1.8.0 documentation Chapter 38. The global species
global can use facets, such as the torus facet, to make the environment a torus or
not (if it is a torus, all the agents going out of the environment will appear in the
other side. If it’s not, the agents won’t be able to go out of the environment). By
default, the environment is not a torus.
global torus:true {
// definition of global attributes, actions, behaviours
}
Other facets such as control or schedules are also available, but we will explain
them later.
Directly in the global scope, you have to declare all your global attributes (can be
seen as “static members” in Java or C++). To declare them, proceed exactly as for
v 1.8.0 272
GAMA v1.8.0 documentation Chapter 38. The global species
declaring basic variables. Those attributes are accessible wherever you want inside
the species scope.
Environment size
In the global context, you have to define a size and a shape for your environment. In
fact, an attribute already exists for the global species: it’s called shape, and its type
is a geometry. By default, shape is equal to a 100m*100m square. You can change
the geometry of the shape by affecting another value:
geometry shape <- circle(50#mm);
geometry shape <- rectangle(10#m,20#m);
geometry shape <- polygon([{1˚m,2˚m},{3˚m,50˚cm},{3.4˚m,60˚dm}]);
nb: there are just examples. Try to avoid mixing dimensions! If no dimensions are
specify, it’ll be meter by default.
Built-in attributes
Some attributes exist by default for the global species. The attribute shape is one of
them (refers to the shape of the environment). Here is the list of the other built-in
attributes:
Like the other attributes of the global species, global built-in attributes can be
accessed (and sometimes modified) by the world agent and every other agents in the
model.
world
• represents the sole instance of the model species (i.e. the one defined in the
global section). It is accessible from everywhere (including experiments) and
gives access to built-in or user-defined global attributes and actions.
v 1.8.0 273
GAMA v1.8.0 documentation Chapter 38. The global species
cycle
To learn more about time, please read the recipe about dates.
step
• float, is the length, in model time, of an interval between two cycles, in seconds.
Its default value is 1 (second). Each turn, the value of time is incremented
by the value of step. The definition of step must be coherent with that of the
agents’ variables like speed. The use of time unit is particularly relevant for its
definition.
To learn more about time, please read the recipe about dates.
global {
...
float step <- 10˚h;
...
}
time
• float, read-only, represents the current simulated time in seconds (the default
unit). It is time in the model time. Begins at zero. Basically, we have: time =
cycle * step .
global {
...
int nb_minutes function: { int(time / 60)};
...
}
To learn more about time, please read the recipe about dates.
v 1.8.0 274
GAMA v1.8.0 documentation Chapter 38. The global species
duration
• string, read-only, represents the value that is equal to the duration in real
machine time of the last cycle.
total_duration
• string, read-only, represents the sum of duration since the beginning of the
simulation.
average_duration
• string, read-only, represents the average of duration since the beginning of the
simulation.
machine_time
• float, read-only, represents the current machine time in milliseconds.
agents
• list, read-only, returns a list of all the agents of the model that are considered
as “active” (i.e. all the agents with behaviors, excluding the places). Note that
obtaining this list can be quite time consuming, as the world has to go through
all the species and get their agents before assembling the result. For instance,
instead of writing something like:
ask agents of_species my_species {
...
}
v 1.8.0 275
GAMA v1.8.0 documentation Chapter 38. The global species
Note that any agent has the agents attribute, representing the agents it contains.
So to get all the agents of the simulation, we need to access the agents of the world
using: world.agents.
Built-in Actions
The global species is provided with two specific actions.
halt
• stops the simulation.
global {
...
reflex halting when: empty (agents) {
do halt;
}
}
pause
• pauses the simulation, which can then be continued by the user.
global {
...
reflex toto when: time = 100 {
do pause;
}
}
v 1.8.0 276
Chapter 39
Regular species
Regular species are composed of attributes, actions, reflex, aspect etc. . . They
describes the behavior of our agents. You can instantiate as much as you want agents
from a regular species, and you can define as much as you want different regular
species. You can see a species as a “class” in OOP.
Index
• Declaration
• Built-in Attributes
• Built-in Actions
• The init statement
• The aspect statement
• Instantiate an agent
Declaration
The regular species declaration starts with the keyword species followed by the
name (or followed by the facet name:) :
species my_specie {
}
or:
277
GAMA v1.8.0 documentation Chapter 39. Regular species
species name:my_specie {
}
Directly in the “species” scope, you have to declare all your attributes (or “member”
in OOP). You declare them exactly the way you declare basic variables. Those
attributes are accessible wherever you want inside the species scope.
species my_specie {
int variableA;
}
Built-in attributes
As for the global species, some attributes exist already by default in a regular species.
Here is the list of built-in attributes:
• name (type: string) is used to name your agent. By default, the name is equal
to the name of your species + an incremental number. This name is the one
visible on the species inspector.
• location (type: point) is used to control the position of your agent. It refers
to the center of the envelop of the shape associated to the agent.
• shape (type: geometry) is used to describe the geometry of your agent. If you
want to use some intersection operator between agents for instance, it is this
geometry that is computed (nb : it can be totally different from the aspect you
want to display for your agent !). By default, the shape is a point.
• host (type: agent) is used when your agent is part of another agent. We will
see this concept a bit further, in the topic multi-level architecture.
All those 4 built-in attributes can be accessed in both reading and writing very easily:
species my_species {
init {
name <- "custom_name";
location <- {0,1};
shape <- rectangle(5,1);
}
}
v 1.8.0 278
GAMA v1.8.0 documentation Chapter 39. Regular species
All those built-in attributes are attributes of an agent (an instance of a species).
Species has also their own attributes, which can be accessed with the following syntax
(read only) :
name_of_your_species.attribute_you_want
Notice that the world agent is also an agent ! It has all the built-in attributes declared
above. The world agent is defined inside the global scope. From the global scope
then, you can for example access to the center of the envelop of the world shape :
global
{
init {
write location; // writes {50.0,50.0,0.0}
}
}
Built-in action
Some actions are define by default for a minimal agent. We already saw quickly the
action write, used to display a message in the console. Another very useful built-in
action is the action die, used to destroy an agent.
species my_species{
reflex being_killed {
do die;
}
}
v 1.8.0 279
GAMA v1.8.0 documentation Chapter 39. Regular species
Here is the list of the other built-in actions which you can find in the documentation:
debug, message, tell.
You can then define your aspect by using the statement draw. You can then choose
a geometry for your aspect (facet geometry), a color (facet color), an image (facet
image), a text (facet text). . . We invite you to read the documentation about the
draw statement to know more about.
species name:my_species {
aspect name:standard_aspect {
draw geometry:circle(1) color:#blue;
}
}
v 1.8.0 280
GAMA v1.8.0 documentation Chapter 39. Regular species
In the experiment scope, you have to tell the program to display a particular species
with a particular aspect (nb : you can also choose to display your species with several
aspect in the same display).
experiment my_experiment type:gui
{
output{
display my_display {
species my_species aspect:standard_aspect;
}
}
}
Now there is only one thing missing to display our agent: we have to instantiate
them.
Instantiate an agent
As already said quickly in the last session, the instantiation of the agents is most
often in the init scope of the global species (this is not mandatory of course. You can
instantiate your agents from an action / behavior of any specie). Use the statement
create to instantiate an agent. The facet species is used to specify which species you
want to instantiate. The facet number is used to tell how many instantiation you
want. The facet with is used to specify some default values for some attributes of
your instance. For example, you can specify the location.
global{
init{
create species:my_species number:1 with:(location:{0,0},vA:8);
}
}
species name:my_specie {
int vA;
}
Here is an example of model that display an agent with a circle aspect in the center
of the environment:
model display_one_agent
v 1.8.0 281
GAMA v1.8.0 documentation Chapter 39. Regular species
global{
float worldDimension <- 50#m;
geometry shape <- square(worldDimension);
init{
point center <- {(worldDimension/2),(worldDimension/2)};
create species:my_species number:1 with:(location:center);
}
}
species name:my_species {
aspect name:standard_aspect {
draw geometry:circle(1#m);
}
}
v 1.8.0 282
Chapter 40
Both actions and behaviors can be seen as methods in OOP. They can be defined in
any species.
Index
• Action
– Declare an action
– Call an action
• Behavior
• Example
Action
Declare an action
283
GAMA v1.8.0 documentation Chapter 40. Defining actions and behaviors
species my_species {
int action_with_return_value {
// statements...
return 1;
}
action action_without_return_value {
// statements...
}
}
Arguments can also be mandated in your action. You have to specify the type and
the name of the argument:
action action_without_return_value (int argA, float argB) {
// statements...
}
If you want to have some optional arguments in the list, you can give some by default
values to turn them optional. Nb: it is better to define the optional arguments at the
end of the list of argument.
action my_action (int argA, float argB <- 5.1, point argC <- {0,0}) {
// statements...
}
Call an action
To call an action, you have to use the statement do. You can use the statement do
different ways:
• With facets : after specifying the name of your action, you can specify the
values of your arguments as if the name of your arguments were facets:
do my_action argA:5 argB:5.1;
• With parenthesis : after specifying the name of your action, you can specify
the values of your arguments in the same order they were declared, between
parenthesis:
v 1.8.0 284
GAMA v1.8.0 documentation Chapter 40. Defining actions and behaviors
do my_action (5,5.1);
We incite you to promote the second writing. To catch the returned value, you can
also skip the do statement, and store the value directly in a temporary variable:
int var1 <- my_action(5,5.1);
Behavior
A behavior, or reflex, is an action which is called automatically at each time step by
an agent.
reflex my_reflex {
write ("Executing the inconditional reflex");
// statements...
}
With the facet when, this reflex is only executed when the boolean expression evaluates
to true. It is a convenient way to specify the behavior of agents.
reflex my_reflex when:flip(0.5) {
write ("Executing the conditional reflex");
// statements...
}
Reflex, unlike actions, cannot be called from another context. But a reflex can, of
course, call actions.
Nb : Init is a special reflex, that occurs only when the agent is created.
Example
To practice a bit with those notions, we will build an easy example. Let’s build a
model with a species balloon that has 2 attributes: balloon_size (float) and balloon_-
color (rgb). Each balloon has a random position and color, his aspect is a sphere.
Each step, a balloon has a probability to spawn in the environment. Once a balloon
is created, its size is 10cm, and each step, the size increases by 1cm. Once the
balloon size reaches 50cm, the balloon has a probability to burst. Once 10 balloons
v 1.8.0 285
GAMA v1.8.0 documentation Chapter 40. Defining actions and behaviors
are destroyed, the simulation stops. The volume of each balloon is displayed in the
balloon position.
Here is one of the multiple possible implementation:
model burst_the_baloon
global{
float worldDimension <- 5#m;
geometry shape <- square(worldDimension);
int nbBaloonDead <- 0;
v 1.8.0 286
GAMA v1.8.0 documentation Chapter 40. Defining actions and behaviors
species balloon {
float balloon_size;
rgb balloon_color;
init {
balloon_size <- 0.1;
balloon_color <- rgb(rnd(255),rnd(255),rnd(255));
}
reflex balloon_grow {
balloon_size <- balloon_size + 0.01;
if (balloon_size > 0.5) {
if (flip(0.2)) {
do balloon_burst;
}
}
}
action balloon_burst {
write "the baloon is dead !";
nbBaloonDead <- nbBaloonDead + 1;
do die;
}
aspect balloon_aspect {
draw circle(balloon_size) color:balloon_color;
draw text:string(balloon_volume(balloon_size)) color:#black;
}
}
v 1.8.0 287
GAMA v1.8.0 documentation Chapter 40. Defining actions and behaviors
}
}
v 1.8.0 288
Chapter 41
In this part, we will learn how interaction between agents works. We will also present
you a bunch of operators useful for your modelling.
Index
• The ask statement
• Pseudo variables
• Some useful interaction operators
• Example
• If you want to interact with one particular agent (for example, defined as an
attribute of your species):
289
GAMA v1.8.0 documentation Chapter 41. Interaction between agents
species my_species {
agent target;
reflex update {
ask target {
// statements
}
}
}
• If you want to interact with agents, as if they were instance of a certain species
(can raise an error if it’s not the case!):
species my_species {
list<agent> targets;
reflex update {
ask targets as:my_species {
// statements
}
}
}
v 1.8.0 290
GAMA v1.8.0 documentation Chapter 41. Interaction between agents
}
}
}
species other_species {
}
Note that you can use the attribute population of species if you find it more explicit:
ask other_species.population
• If you want to interact with all the agent of a particular species from a list of
agents (for example, using the global variable “agents”):
species my_specie {
reflex update {
ask species of_species my_specie {
// statements
}
}
}
Pseudo variables
Once you are in the ask scope, you can use some pseudo variables to refer to the
receiver agent (the one specify just after the ask statement) or the transmitter agent
(the agent which is asking). We use the pseudo variable self to refer to the receiver
agent, and the pseudo variable myself to refer to the transmitter agent. The pseudo
variable self can be omitted when calling actions or attributes.
species speciesA {
init {
name <- "speciesA";
}
reflex update {
ask speciesB {
write name; // output : "speciesB"
write self.name; // output : "speciesB"
write myself.name; // output : "speciesA"
}
v 1.8.0 291
GAMA v1.8.0 documentation Chapter 41. Interaction between agents
}
}
species speciesB {
init {
name <- "speciesB";
}
}
Now, if we introduce a third species, we can write an ask statement inside another.
species speciesA {
init {
name <- "speciesA";
}
reflex update {
ask speciesB {
write self.name; // output : "speciesB"
write myself.name; // output : "speciesA"
ask speciesC {
write self.name; // output : "speciesC"
write myself.name; // output : "speciesB"
}
}
}
}
species speciesB {
init {
name <- "speciesB";
}
}
species speciesC {
init {
name <- "speciesC";
}
}
Nb: try to avoid multiple imbrications of ask statements. Most of the time, there is
another way to do the same thing.
v 1.8.0 292
GAMA v1.8.0 documentation Chapter 41. Interaction between agents
The operator closest_to returns the closest agent of a position among a container.
species my_species {
reflex update {
agent agentA <- agents closest_to(self);
// agentA contains the closest agent from the caller agent.
agent agentB <- other_specie closest_to({2,3});
// agentB contains the closest instance of other_specie from
the location {2,3}.
}
}
species other_specie {
}
Example
To practice those notions, here is a short basic example. Let’s build a model with a fix
number of agents with a circle shape. They can move randomly on the environment,
and when they are close enough from another agent, a line is displayed between them.
This line is destroyed when the distance between the two agents is too important.
Hint: use the operator polyline to construct a line. List the points between angle
brackets [].
Here is one example of implementation:
model connect_the_neighbors
global{
v 1.8.0 293
GAMA v1.8.0 documentation Chapter 41. Interaction between agents
v 1.8.0 294
GAMA v1.8.0 documentation Chapter 41. Interaction between agents
species my_species {
reflex move {
location <- {location.x+rnd(-speed,speed),location.y+rnd(-speed
,speed)};
}
aspect default {
draw circle(1);
ask my_species at_distance(distance_to_intercept) {
draw polyline([self.location,myself.location]) color:#black
;
}
}
}
v 1.8.0 295
GAMA v1.8.0 documentation Chapter 41. Interaction between agents
v 1.8.0 296
Chapter 42
Attaching Skills
GAMA allows to attach skills to agents through the facet skills. Skills are built-in
modules that provide a set of related built-in attributes and built-in actions (in
addition to those already proposed by GAMA) to the species that declare them.
Index
• The moving skill
• Other skills
• Example of implementation
Skills
A declaration of skill is done by filling the skills facet in the species definition:
species my_species skills: [skill1,skill2] {
}
297
GAMA v1.8.0 documentation Chapter 42. Attaching Skills
Once your species has the moving skill, it earns automatically the following attributes:
speed, heading, destination and the following actions: move, goto, follow, wander
and wander_3D.
Attributes:
• speed (float) designs the speed of the agent, in m/s.
• heading (int) designs the heading of an agent in degrees, which means that is
the maximum angle the agent can turn around each step.
• destination (point) is the updated destination of the agent, with respect to
its speed and heading. It’s a read-only attribute, you can’t change its value.
Actions:
follow
• returns: path
• speed (float): the speed to use for this move (replaces the current value of speed)
• return_path (boolean): if true, return the path followed (by default: false)
goto
• returns: path
v 1.8.0 298
GAMA v1.8.0 documentation Chapter 42. Attaching Skills
• speed (float): the speed to use for this move (replaces the current value of speed)
• recompute_path (boolean): if false, the path is not recompute even if the graph
is modified (by default: true)
• return_path (boolean): if true, return the path followed (by default: false)
move
moves the agent forward, the distance being computed with respect to its speed and
heading. The value of the corresponding variables are used unless arguments are
passed.
• returns: path
• speed (float): the speed to use for this move (replaces the current value of speed)
• heading (int): a restriction placed on the random heading choice. The new
heading is chosen in the range (heading - amplitude/2, heading+amplitude/2)
wander
Moves the agent towards a random location at the maximum distance (with respect
to its speed). The heading of the agent is chosen randomly if no amplitude is specified.
This action changes the value of heading.
• returns: void
• speed (float): the speed to use for this move (replaces the current value of speed)
v 1.8.0 299
GAMA v1.8.0 documentation Chapter 42. Attaching Skills
• amplitude (int): a restriction placed on the random heading choice. The new
heading is chosen in the range (heading - amplitude/2, heading+amplitude/2)
wander_3D
Moves the agent towards a random location (3D point) at the maximum distance
(with respect to its speed). The heading of the agent is chosen randomly if no
amplitude is specified. This action changes the value of heading.
• returns: path
• speed (float): the speed to use for this move (replaces the current value of speed)
• amplitude (int): a restriction placed on the random heading choice. The new
heading is chosen in the range (heading - amplitude/2, heading+amplitude/2)
• z_max (int): the maximum altitude (z) the geometry can reach
Other skills
A lot of other skills are available. Some of them can be built in skills, integrated by
default in GAMA, other are linked to additional plugins.
This is the list of skills: Advanced_driving, communication, driving, GAMASQL,
graphic, grid, MDXSKILL, moving, moving3D, physical3D, skill_road, skill_road,
skill_road_node, SQLSKILL
Example
We can now build a model using the skill moving. Let’s design 2 species, one
is “species_red”, the other is “species_green”. Species_green agents are moving
v 1.8.0 300
GAMA v1.8.0 documentation Chapter 42. Attaching Skills
randomly with a certain speed and a certain heading. Species_red agents wait for
a species_green agent to be in a certain range of distance. Once it is the case, the
agent move toward the species_green agent. A line link the red_species agent and
its target.
Here is an example of implementation:
model green_and_red_species
global{
float distance_to_intercept <- 10.0;
int number_of_green_species <- 50;
int number_of_red_species <- 50;
init {
create speciesA number:number_of_green_species;
create speciesB number:number_of_red_species;
}
}
v 1.8.0 301
GAMA v1.8.0 documentation Chapter 42. Attaching Skills
v 1.8.0 302
GAMA v1.8.0 documentation Chapter 42. Attaching Skills
aspect default {
draw circle(1) color:#red;
if (target!=nil) {
draw polyline([self.location,target.location]) color:#black
;
}
}
}
v 1.8.0 303
GAMA v1.8.0 documentation Chapter 42. Attaching Skills
v 1.8.0 304
Chapter 43
Inheritance
Index
• Mother species / child species
• Virtual actions
• Get all the subspecies from a species
Thus, all the attributes, actions and reflex of the mother species are inherited to the
child species.
305
GAMA v1.8.0 documentation Chapter 43. Inheritance
species mother_species {
int attribute_A;
action action_A {}
}
If the mother species has a particular skill, its children will inherit all the attributes
and actions.
species mother_species skills:[moving] {
}
You can redefine an action or a reflex by declaring an action or a reflex with the same
name.
Virtual action
You have also the possibility to declare a virtual action in the mother species, which
means an action without implementation, by using the facet virtual:
action virtual_action virtual:true;
When you declare an action as virtual in a species, this species becomes abstract,
which means you cannot instantiate agent from it. All the children of this species has
to implement this virtual action.
v 1.8.0 306
GAMA v1.8.0 documentation Chapter 43. Inheritance
species virtual_mother_species {
action my_action virtual:true;
}
species mother {}
We remind you that “subspecies” is a built-in attribute of the agent. Using this
attribute, you can easily get all the subspecies agents of the mother species by writing
the following gaml function :
global
{
init {
create child number:2;
create mother number:1;
}
reflex update {
v 1.8.0 307
GAMA v1.8.0 documentation Chapter 43. Inheritance
species mother {}
v 1.8.0 308
Chapter 44
In the previous chapter, we saw how to declare and manipulate regular species and
the global species (as a reminder, the instance of the global species is the world
agent).
We will now see that GAMA provides you the possibility to declare some special
species, such as grids or graphs, with their own built-in attributes and their own
built-in actions. We will also see how to declare mirror species, which is a “copy”
of a regular species, in order to give it an other representation. Finally, we will
learn how to represent several agents through one unique agent, with multi-level
architecture.
309
GAMA v1.8.0 documentation Chapter 44. Defining advanced species
v 1.8.0 310
Chapter 45
Grid Species
A grid is a particular species of agents. Indeed, a grid is a set of agents that share a
grid topology (until now, we only saw species with continuous topology). As other
agents, a grid species can have attributes, attributes, behaviors, aspects However,
contrary to regular species, grid agents are created automatically at the beginning
of the simulation. It is thus not necessary to use the create statement to create
them. Moreover, in addition to classic built-in variables, grid a provided with a set of
additional built-in variables.
Index
• Declaration
• Built-in attributes
• Access to cells
• Display grid
• Grid with matrix
• Example
Declaration
Instead of using the species keyword, use the keyword grid to declare a grid species.
The grid species has exactly the same facets of the regular species, plus some others.
311
GAMA v1.8.0 documentation Chapter 45. Grid Species
To declare a grid, you have to specify the number of columns and rows first. You can
do it two different ways:
Using the two facets width: and height: to fix the number of cells (the size of each
cells will be determined thanks to the environment dimension).
grid my_grid width:8 height:10 {
// my_grid has 8 columns and 10 rows
}
Using the two facets cell_width: and cell_height: to fix the size of each cells (the
number cells will be determined thanks to the environment dimension).
grid my_grid cell_width:3 cell_height:2 {
// my_grid has cells with dimension 3m width by 2m height
}
Another facet exists for grid only, very useful. It is the neighbors facet, used to
determine how many neighbors has each cell. You can choose among 3 values: 4 (Von
Neumann), 6 (hexagon) or 8 (Moore).
A grid can also be provided with specific facets that allows to optimize the computation
time and the memory space, such as use_regular_agents, use_indivitual_shapes
and use_neighbors_cache. Please refer to the GAML Reference for more explanation
about those particular facets.
v 1.8.0 312
GAMA v1.8.0 documentation Chapter 45. Grid Species
Built-in attributes
grid_x
This variable stores the column index of a cell.
grid cell width: 10 height: 10 neighbors: 4 {
init {
write "my column index is:" + grid_x;
}
}
grid_y
This variable stores the row index of a cell.
grid cell width: 10 height: 10 neighbors: 4 {
init {
write "my row index is:" + grid_y;
}
}
agents
return the set of agents located inside the cell. Note the use of this variable is
deprecated. It is preferable to use the inside operator: //: # (keyword|operator_-
inside)
grid cell width: 10 height: 10 neighbors: 4 {
list<bug> bugs_inside -> {bug inside self};
}
color
The color built-in variable is used by the optimized grid display. Indeed, it is possible
to use for grid agents an optimized aspect by using in a display the grid keyword.
In this case, the grid will be displayed using the color defined by the color variable.
The border of the cells can be displayed with a specific color by using the lines facet.
v 1.8.0 313
GAMA v1.8.0 documentation Chapter 45. Grid Species
Here an example of the display of a grid species named cell with black border.
experiment main_xp type: gui{
output {
display map {
grid cell lines: rgb("black") ;
}
}
}
neighbors
The neighbors built-in variable returns the list of cells at a distance of 1.
grid my_grid {
reflex writeNeighbors {
write neighbors;
}
}
grid_value
The grid_value built-in variable is used when initializing a grid from grid file (see
later). It is also used for the 3D representation of DEM.
Access to a cell
there are several ways to access to a specific cell:
v 1.8.0 314
GAMA v1.8.0 documentation Chapter 45. Grid Species
• by the row and column indexes: like matrix, it is possible to directly access to
a cell from its indexes
global {
init {
write "cell [5,8] :" + cell[5,8];
}
}
grid cell width: 10 height: 10 neighbors: 4 {
}
The operator grid_at also exists to get a particular cell. You just have to specify
the index of the cell you want (in x and y):
global {
init {
agent cellAgent <- cell grid_at {5,8};
write "cell [5,8] :" + cellAgent;
}
}
grid cell width: 10 height: 10 neighbors: 4 {
}
Display Grid
You can easily display your grid in your experiment as followed :
experiment MyExperiment type: gui {
output {
display MyDisplay type: opengl {
grid MyGrid;
}
}
}
The grid will be displayed, using the color you defined for each cell (with the “color”
built-in attribute). You can also show border of each cell by using the facet “lines:”
and choosing a rgb color:
v 1.8.0 315
GAMA v1.8.0 documentation Chapter 45. Grid Species
grid MyGrid lines:#black;
An other way to display a grid will be to define an aspect in your grid agent (the
same way as for a regular species), and define your grid as a regular species then in
your experiment, choosing your aspect :
grid MyGrid {
aspect firstAspect {
draw square(1);
}
aspect secondAspect {
draw circle(1);
}
}
Beware : don’t use this second display when you have large grids : it’s much slower.
v 1.8.0 316
GAMA v1.8.0 documentation Chapter 45. Grid Species
Declaring larger matrix in GAML can be boring as you can imagine. You can load
your matrix directly from a csv file with the operator matrix (used for the contruction
of the matrix).
file my_file <- csv_file("path/file.csv","separator");
matrix my_matrix <- matrix(my_file);
global {
file my_csv_file <- csv_file("../includes/test.csv",",");
init {
matrix data <- matrix(my_csv_file);
ask my_gama_grid {
grid_value <- float(data[grid_x,grid_y]);
write data[grid_x,grid_y];
}
}
}
v 1.8.0 317
GAMA v1.8.0 documentation Chapter 45. Grid Species
}
For more complicated models, you can read some other files, such as ASCII files (asc),
DEM files. . .
Example
To practice a bit those notions, we will build a quick model. A “regular” species will
move randomly on the environment. A grid is displayed, and its cells becomes red
when an instance of the regular species is waking inside this cell, and yellow when
the regular agent is in the surrounding of this cell. If no regular agent is on the
surrounding, the cell turns green.
Here is an example of implementation:
model my_grid_model
global{
float max_range <- 5.0;
int number_of_agents <- 5;
init {
create my_species number:number_of_agents;
}
reflex update {
ask my_species {
do wander amplitude:180;
ask my_grid at_distance(max_range)
{
if(self overlaps myself)
{
self.color_value <- 2;
}
else if (self.color_value != 2)
{
self.color_value <- 1;
}
}
}
ask my_grid {
do update_color;
}
}
}
v 1.8.0 318
GAMA v1.8.0 documentation Chapter 45. Grid Species
v 1.8.0 319
GAMA v1.8.0 documentation Chapter 45. Grid Species
v 1.8.0 320
Chapter 46
Graph Species
Using a graph species enables to easily show interaction between agents of a same
species. This kind of species is particularly useful when trying to show the interaction
(especially the non-spatial one) that exist between agents.
Index
• Declaration
• Example
321
GAMA v1.8.0 documentation Chapter 46. Graph Species
Declaration
The method related_to returns a boolean, and take the agents from the current
species in argument. If the method returns true, the two agents (the current instance
and the one as argument) will be linked.
global{
int number_of_agents <- 5;
init {
create graph_agent number:number_of_agents;
}
}
v 1.8.0 322
GAMA v1.8.0 documentation Chapter 46. Graph Species
You can for example link 2 agents when they are closer than a certain distance.
Beware: The topology used in graph species is the graph topology, and not the
continuous topology. You can force the use of the continuous topology with the action
using as follow:
bool related_to(graph_agent other){
using topology:topology(world) {
return (self.location distance_to other.location < 20);
v 1.8.0 323
GAMA v1.8.0 documentation Chapter 46. Graph Species
}
}
The abstract mother species “graph_node” has an attribute “my_graph”, with the
type “graph”. The graph type represent a graph composed of vertices linked with
edges. This type has built-in attributes such as edges (the list of all the edges agents),
or vertices (the list of all the vertices agents).
v 1.8.0 324
GAMA v1.8.0 documentation Chapter 46. Graph Species
global {
file roads_shapefile <- file("../includes/road.shp");
geometry shape <- envelope(roads_shapefile);
graph road_network;
init {
create road from: roads_shapefile;
road_network <- as_edge_graph(road);
}
}
species road {
aspect geom {
draw shape color: #black;
}
}
v 1.8.0 325
GAMA v1.8.0 documentation Chapter 46. Graph Species
Using this solution, my_graph can have two types: it can be an a-spatial graph,
or a spatial graph. The spatial graph will have a proper geometry, with segments
that follow the position of your graph (you can access to the segments by using the
built-in “segments”). The a-spatial graph will not have any shape.
global
{
graph my_spatial_graph<-spatial_graph([]);
graph my_aspatial_graph<-graph([]);
init {
point node1 <- {0.0,0.0};
point node2 <- {10.0,10.0};
my_spatial_graph <- my_spatial_graph add_node(node1);
my_spatial_graph <- my_spatial_graph add_node(node2);
my_spatial_graph <- my_spatial_graph add_edge(node1::node2);
write my_spatial_graph.edges;
// the output is [polyline ([{0.0,0.0,0.0},{10.0,10.0,0.0}])]
my_aspatial_graph <- my_aspatial_graph add_node(node1);
my_aspatial_graph <- my_aspatial_graph add_node(node2);
my_aspatial_graph <- my_aspatial_graph add_edge(node1::node2);
write my_aspatial_graph.edges;
// the output is [{0.0,0.0,0.0}::{10.0,10.0,0.0}]
}
}
v 1.8.0 326
GAMA v1.8.0 documentation Chapter 46. Graph Species
Here is an example of model using those two previous concepts (a random node is
chosen each step, displayed in red, and his neighbors are displayed in yellow):
model graph_model
global
{
int number_of_agents <- 50;
init
{
create graph_agent number: number_of_agents;
}
v 1.8.0 327
GAMA v1.8.0 documentation Chapter 46. Graph Species
v 1.8.0 328
GAMA v1.8.0 documentation Chapter 46. Graph Species
reflex update {
ask graph_agent(one_of(graph_agent)) {
status <- 2;
do update_neighbors;
}
}
}
init {
int i<-0;
loop g over:graph_agent {
if (flip(0.1)) {
add i to:list_connected_index;
}
i <- i+1;
}
}
action update_neighbors {
aspect base
{
if (status = 0) {
draw circle(2) color: # green;
v 1.8.0 329
GAMA v1.8.0 documentation Chapter 46. Graph Species
}
else if (status = 1) {
draw circle(2) color: # yellow;
}
else if (status = 2) {
draw circle(2) color: # red;
}
draw text:string(my_graph degree_of self) color:# black size:4
at:point(self.location.x-1,self.location.y-2);
status <- 0;
}
}
To compute the shortest path to go from a point to another, pick a source and a
destination among the vertices you have for your graph. Store those values as point
type.
point source;
point destination;
source <- point(one_of(my_graph.vertices));
destination <- point(one_of(my_graph.vertices));
v 1.8.0 330
GAMA v1.8.0 documentation Chapter 46. Graph Species
Then, you can use the operator path_between to return the shortest path. To use
this action, you have to give the graph, then the source point, and the destination
point. This action returns a path type.
path shortest_path;
shortest_path <- path_between (my_graph, source,destination);
Another operator exists, paths_between, that returns a list of shortest paths between
two points. Please read the documentation to learn more about this operator.
Here is an example of code that show the shortest path between two points of a
graph:
model graph_model
global
{
int number_of_agents <- 50;
point source;
point target;
graph my_graph;
path shortest_path;
init
{
create graph_agent number: number_of_agents;
}
reflex pick_two_points {
if (my_graph=nil) {
ask graph_agent {
myself.my_graph <- self.my_graph;
break;
}
}
shortest_path <- nil;
loop while:shortest_path=nil {
source <- point(one_of(my_graph.vertices));
target <- point(one_of(my_graph.vertices));
if (source != target) {
shortest_path <- path_between (my_graph, source,target)
;
}
}
}
}
v 1.8.0 331
GAMA v1.8.0 documentation Chapter 46. Graph Species
v 1.8.0 332
GAMA v1.8.0 documentation Chapter 46. Graph Species
init {
int i<-0;
loop g over:graph_agent {
if (flip(0.1)) {
add i to:list_connected_index;
}
i <- i+1;
}
}
aspect base {
draw circle(2) color: # green;
}
}
v 1.8.0 333
GAMA v1.8.0 documentation Chapter 46. Graph Species
}
}
The calculation of shortest path can change according to the weight you choose for
your edges. For example, here is the result of the calculation of the shortest path
when all the edges have 1 as weight value (it is the default graph topology), and when
the edges have their length as weight.
Here is an example of implementation:
v 1.8.0 334
GAMA v1.8.0 documentation Chapter 46. Graph Species
model shortest_path_with_weight
global
{
graph my_graph<-spatial_graph([]);
path shortest_path;
list<point> nodes;
init
{
add point(10.0,10.0) to:nodes;
add point(90.0,90.0) to:nodes;
add point(40.0,20.0) to:nodes;
add point(80.0,50.0) to:nodes;
add point(90.0,20.0) to:nodes;
v 1.8.0 335
GAMA v1.8.0 documentation Chapter 46. Graph Species
v 1.8.0 336
Chapter 47
Mirror species
Index
• Declaration
• Example
Declaration
A mirror species can be defined using the mirrors keyword as following:
species B mirrors: A{
}
In this case, the species B mirrors the species A.
By default, the location of the species B will be random but in many cases, once want
to place the mirror agent at the same location of the reference species. This can be
achieved by simply adding the following lines in the mirror species :
337
GAMA v1.8.0 documentation Chapter 47. Mirror species
species B mirrors: A{
point location <- target.location update: target.location;
}
Example
To practice a bit with the mirror notion, we will now build a simple model displaying
a species A (aspect: white circle) moving randomly, and another species B (aspect:
blue sphere) with the species A location on x and y, with an upper value for the z
axis.
Here is an example of implementation for this model:
model Mirror
global {
init{
create A number:100;
}
}
species A skills:[moving]{
reflex update{
do wander;
}
aspect base{
draw circle(1) color: #white border: #black;
}
}
species B mirrors: A{
point location <- target.location update: {target.location.x,target
.location.y,target.location.z+5};
v 1.8.0 338
GAMA v1.8.0 documentation Chapter 47. Mirror species
v 1.8.0 339
GAMA v1.8.0 documentation Chapter 47. Mirror species
aspect base {
draw sphere(2) color: #blue;
}
}
v 1.8.0 340
Chapter 48
Multi-level architecture
The multi-level architecture offers the modeler the following possibilities: the declara-
tion of a species as a micro-species of another species, the representation of an entity
as different types of agent (i.e., GAML species), the dynamic migration of agents
between populations.
Index
• Declaration of micro-species
• Access to micro-agents / host agent
• Representation of an entity as different types of agent
• Dynamic migration of agents
• Example
Declaration of micro-species
A species can have other species as micro-species. The micro-species of a species is
declared inside the species’ declaration.
species macro_species {
species micro_species_in_group {
}
}
341
GAMA v1.8.0 documentation Chapter 48. Multi-level architecture
species macro_species
{
init {
create micro_species_in_group number:rnd(10);
write "the macro species named "+name+" contains "+length(
micro_species_in_group)+" micro-species.";
}
species micro_species_in_group {
}
}
In this above example, we create 5 macro-species, and each one of these macro-species
create a random number of inner micro-species. We can see that “micro_species_-
in_group” refers to the list of micro-species inside the given macro-species.
v 1.8.0 342
GAMA v1.8.0 documentation Chapter 48. Multi-level architecture
species macro_species
{
init {
create first_micro_species number:3;
create second_micro_species number:6;
write "the macro species named "+name+" contains "+length(
members)+" micro-species.";
}
species first_micro_species {
}
species second_micro_species {
}
}
The host built-in attribute is used inside the micro-agent to get the host macro-agent.
species macro_species {
micro_species_in_group micro_agent;
init {
create micro_species_in_group number:rnd(10);
write "the macro species named "+name+" contains "+length(
members)+" micro-species.";
}
species micro_species_in_group {
init {
write "the micro species named "+name+" is hosted by "+host
;
}
}
}
NB: We already said that the world agent is a particular agent, instantiated just once.
In fact, the world agent is the host of all the agents. You can try to get the host
for a regular species, you will get the world agent itself (named as you named your
model). You can also try to get the members of your world (from the global scope
for example), and you will get the list of the agents presents in the world.
global
{
init {
v 1.8.0 343
GAMA v1.8.0 documentation Chapter 48. Multi-level architecture
species macro_species
{
init {
write "the macro species named "+name+" is hosted by "+host;
}
}
species macro_species
{
species micro_species_in_group parent: micro_species {
}
}
v 1.8.0 344
GAMA v1.8.0 documentation Chapter 48. Multi-level architecture
The statement release is used by the “macro_species” to release one (or several)
“micro_species_in_group” agent(s), and turn it (them) to a “micro_species”. You
can specify which agent (or list of agents) you want to release by using the facet
target. The facet as is used to cast the agent from “micro_species_in_group” to
“micro_species”. The facet in is used to specify the new host (by default, it is the
host of the “macro_species”). You can use the facet return to get the newly released
agent(s).
release target:list(micro_species_in_group) as:micro_species in:world;
The statement migrate, less used, permits agents to migrate from one popula-
tion/species to another population/species and stay in the same host after the
migration. Read the GAML Reference to learn more about this statement.
Example:
Here is an example of micro_species that gather together in macro_species when
they are close enough.
model multilevel
global {
int release_time <- 20;
v 1.8.0 345
GAMA v1.8.0 documentation Chapter 48. Multi-level architecture
v 1.8.0 346
GAMA v1.8.0 documentation Chapter 48. Multi-level architecture
v 1.8.0 347
GAMA v1.8.0 documentation Chapter 48. Multi-level architecture
species macro_species {
geometry shape <- circle(1) update:circle(length(members));
aspect base {
draw shape;
draw text:string(length(members)) color:#black size:4;
}
}
v 1.8.0 348
Chapter 49
When you execute your simulation, you will often need to display some information.
For each simulation, you can define some inputs and outputs:
• The inputs will be composed of parameters manipulated by the user for each
simulation.
• The outputs will be composed of displays, monitors or output files. They will
be define inside the scope output.
experiment exp_name type: gui {
[input]
output {
[display statements]
[monitor statements]
[file statements]
}
}
You can define two types of experiment (through the facet type):
• gui experiments (the default type) are used to play an experiment, and interpret
its outputs.
• batch experiments are used to play an experiment several times (usually with
other input values), used for model exploration. We will come back to this
notion a bit further in the tutorial.
349
GAMA v1.8.0 documentation Chapter 49. Defining GUI Experiment
Inside experiment scope, you can access to some built-ins which can be useful, such
as minimum_cycle_duration, to force the duration of one cycle.
experiment my_experiment type: gui {
float minimum_cycle_duration <- 2.0#minute;
}
Other built-ins are available, to learn more about, go to the page experiment
built-in.
In this part, we will focus on the gui experiments. We will start with learning how
to define input parameters, then we will study the outputs, such as displays,
monitors and inspectors, and export files. We will finish this part with how to
define user commands.
v 1.8.0 350
Chapter 50
Defining Parameters
When playing simulation, you have the possibility to define input parameters, in
order to change them and replay the simulation. Defining parameters allows to make
the value of a global variable definable by the user through the user graphic interface.
Index
• Defining parameters
• Additional facets
Defining parameters
You can define parameters inside the global scope, when defining your global variables
with the facet parameter:
global
{
int my_integer_global_value <- 5 parameter: "My integer global
value";
}
When launching your experiment, the parameter will appear in your “Parameters”
panel, with the name you chose for the parameter facet.
351
GAMA v1.8.0 documentation Chapter 50. Defining Parameters
You can also define your parameter inside the experiment, using the statement
parameter. You have to specify first the name of your parameter, then the name of
the global variable through the facet var.
global
{
int my_integer_global_value <- 5;
}
experiment MyExperiment type: gui { parameter “My integer global value” var:my_-
integer_global_value; }
NB: This variable has to be initialized with a value. If you don’t want to initialize
your value on the global scope, you can initialize the value directly on the parameter
statement, using the facet init.
global
{
int my_integer_global_value;
}
v 1.8.0 352
GAMA v1.8.0 documentation Chapter 50. Defining Parameters
Additional facets
You can use some facets to arrange your parameters. For example, you can categorize
your parameters under a label, using the facet category:
global
{
int attr_1 <- 5 parameter:"attr 1" category:"category 1";
int attr_2 <- 5 parameter:"attr 2" category:"category 1";
int attr_3 <- 5 parameter:"attr 3" category:"category 2";
}
v 1.8.0 353
GAMA v1.8.0 documentation Chapter 50. Defining Parameters
You also can add some facets such as min, max or among to improve the declaration
of the parameter.
global
{
string fruit <- "none" among:["none","apple","banana"] parameter:"
fruit" category:"food";
string vegetable <- "none" among:["none","cabbage","carrot"]
parameter:"vegetable" category:"food";
int integer_variable <- 5 parameter:"integer variable" min:0 max
:100 category:"other";
}
v 1.8.0 354
Chapter 51
Index
• Displays and layers
• Organize your layers
• Example of layers
– agents layer
– species layer
– image layer
– text layer
– graphics layer
355
GAMA v1.8.0 documentation Chapter 51. Defining displays (Generalities)
}
}
}
• Use refresh if you want to refresh the display when a condition is true (to
refresh your display every number of steps, use the operator every)
display "my_display" refresh:every(10)
You can choose between two types of displays, by using the facet type:
• java2D displays will be used when you want to have 2D visualization. It is used
for example when you manipulate charts. This is the default value for the facet
type.
• opengl displays allows you to have 3D visualization.
You can save the display on the disk, as a png file, in the folder name_of_model/-
models/snapshots, by using the facet autosave. This facet takes one a boolean as
argument (to allow or not to save each frame) or a point (to define the size of your
image). By default, the resolution of the output image is 500x500px (note that when
no unit is provided, the unit is #px (pixel) ).
display my_display autosave:true type:java2D {}
is equivalent to :
display my_display autosave:{500,500} type:java2D {}
Each display can be decomposed in one or several layers. Here is a screenshot (from
the Toy Model Ant) to better understand those different notions we are about to
tackle in this session.
v 1.8.0 356
GAMA v1.8.0 documentation Chapter 51. Defining displays (Generalities)
v 1.8.0 357
GAMA v1.8.0 documentation Chapter 51. Defining displays (Generalities)
}
graphics "layer3" {
draw square(20) at:{20,20} color:#cornflowerblue;
}
}
}
}
v 1.8.0 358
GAMA v1.8.0 documentation Chapter 51. Defining displays (Generalities)
}
To specify a position and a size for your layer, you can use the position and the
size facets. The position facet is used with a point type, between {0,0} and {1,1},
which corresponds to the position of the upper left corner of your layer in percentage.
Then, if you choose the point {0.5,0.5}, the upper left corner of your layer will be
in the center of your display. By default, this value is {0,0}. The size facet is used
with a point type, between {0,0} and {1,1} also. It corresponds to the size occupied
by the layer in percentage. By default, this value is {1,1}.
experiment expe type:gui {
output {
display my_display {
graphics "layer1" position:{0,0} size:{0.5,0.8} {
draw shape color:#darkorange;
}
graphics "layer2" position:{0.3,0.1} size:{0.6,0.2} {
draw shape color:#cornflowerblue;
}
graphics "layer3" position:{0.4,0.2} size:{0.3,0.8} {
draw shape color:#gold;
}
}
}
v 1.8.0 359
GAMA v1.8.0 documentation Chapter 51. Defining displays (Generalities)
}
NB: displays can have background, while graphics can’t. If you want to put a
background for your graphics, a solution can be to draw the shape of the world
(which is, by default, a square 100m*100m).
A lot of other facets are available for the different layers. Please read the documenta-
tion of graphics for more information.
v 1.8.0 360
GAMA v1.8.0 documentation Chapter 51. Defining displays (Generalities)
Example of layers
agents layer
agents allows the modeler to display only the agents that fulfill a given condition.
Please read the documentation about agents statement if you are interested.
species layer
species allows modeler to display all the agent of a given species in the current
display. In particular, modeler can choose the aspect used to display them.
Please read the documentation about species statement if you are interested.
image layer
image allows modeler to display an image (e.g. as background of a simulation).
Please read the documentation about image statement if you are interested.
graphics layer
graphics allows the modeler to freely draw shapes/geometries/texts without having
to define a species.
Please read the documentation about graphics statement if you are interested.
v 1.8.0 361
GAMA v1.8.0 documentation Chapter 51. Defining displays (Generalities)
v 1.8.0 362
Chapter 52
Defining Charts
To visualize result and make analysis about you model, you will certainly have to use
charts. You can define 3 types of charts in GAML: histograms, pie, and series. For
each type, you will have to determine the data you want to highlight.
Index
• Define a chart
• Data definition
• Different types of charts
Define a chart
To define a chart, we have to use the chart statement. A chart has to be named
(with the name facet), and the type has to be specified (with the type facet). The
value of the type facet can be histogram, pie, series, scatter, xy. A chart has to
be defined inside a display.
experiment my_experiment type: gui {
output {
display "my_display" {
chart "my_chart" type:pie {
}
}
363
GAMA v1.8.0 documentation Chapter 52. Defining Charts
}
}
After declaring your chart, you have to define the data you want to display in your
chart.
Data definition
Data can be specified with:
The data statement is used to specify which variable will be displayed. You have to
give your data a name (that will be displayed in your chart), the value of the variable
you want to follow (using the value facet). You can add come optional facets such as
color to specify the color of your data.
global
{
int numberA <- 2 update:numberA*2;
int numberB <- 10000 update:numberB-1000;
}
(TODO_IMAGE)
The datalist statement is used several variables in one statement. Instead of giving
simple values, datalist is used with lists.
v 1.8.0 364
GAMA v1.8.0 documentation Chapter 52. Defining Charts
datalist ["numberA","numberB"] value:[numberA,numberB] color:[#red,#
blue];
[TODO] Datalist provides you some additional facets you can use. If you want to
learn more about them, please read the documentation [URL]
v 1.8.0 365
GAMA v1.8.0 documentation Chapter 52. Defining Charts
v 1.8.0 366
Chapter 53
Defining 3D Displays
Table of contents
• OpenGL display
– Position
– Size
• Camera
• Dynamic camera
– Camera position
– Camera direction (Look Position)
– Camera orientation (Up Vector)
∗ Default view
∗ First person view
∗ Third Person view
• Lighting
OpenGL display
• Define the attribute type of the display with type:opengl in the output of your
model (or use the preferences->display windows to use it by default):
367
GAMA v1.8.0 documentation Chapter 53. Defining 3D Displays
output {
display DisplayName type:opengl {
species mySpecies;
}
The opengl display share most of the feature that the java2D offers and that are
described here.
Using 3D display offers many way to represent a simulation. A layer can be positioned
and scaled in a 3D world. It is possible to superpose layer on different z value and
display different information on the model at different position on the screen.
Position
Layer can be drawn on different position (x,y and z) value using the position facet
Size
Layer can be drawn with different size (x,y and z) using the size facet
Here is an example of display using all the previous facet (experiment factice to add
to the model Incremental Model 5 ). You can also dynamically change those value by
showing the side bar in the display.
experiment expe_test type:gui {
output {
display city_display type: opengl{
species road aspect: geom refresh:false;
species building aspect: geom transparency:0.5 ;
species people aspect: sphere3D position:{0,0,0.1};
species road aspect: geom size:{0.3,0.3,0.3};
}
}
}
Camera
Arcball Camera
FreeFly Camera
v 1.8.0 368
GAMA v1.8.0 documentation Chapter 53. Defining 3D Displays
v 1.8.0 369
GAMA v1.8.0 documentation Chapter 53. Defining 3D Displays
Dynamic camera
User have the possibility to set dynamically the parameter of the camera (observer).
The basic camera properties are its position, the direction in which is pointing,
and its orientation. Those 3 parameters can be set dynamically at each iteration of
the simulation.
Camera position
The facet camera_pos(x,y,z) places the camera at the given position. The default
camera positon is (world.width/2,world/height/2,world.maxDim*1.5) to place the
camera at the middle of the environement at an altitude that enables to see the entire
environment.
The facet camera_look_pos(x,y,z) points the camera toward the given position.
The default look position is (world.width/2,world/height/2,0) to look at the center of
the environment.
Default view
display RealBoids type:opengl{
...
}
v 1.8.0 370
GAMA v1.8.0 documentation Chapter 53. Defining 3D Displays
You can set the position as a first person shooter video game using:
display FirstPerson type:opengl
camera_pos:{boids(1).location.x,-boids(1).location.y,10}
camera_look_pos:{cos(boids(1).heading)*world.shape.width,-sin(boids(1).
heading)*world.shape.height,0}
camera_up_vector:{0.0,0.0,1.0}{
...
}
You can follow an agent during a simulation by positioning the camera above it using:
display ThirdPerson type:opengl camera_pos:{boids(1).location.x,-boids
(1).location.y,250} camera_look_pos:{boids(1).location.x,-boids(1).
location.y,boids(1).location.z}{
...
}
Lighting
In a 3D scene once can define light sources. The way how light sources and 3D object
interact is called lighting. Lighting is an important factor to render realistic scenes.
In a real world, the color that we see depend on the interaction between color material
surfaces, the light sources and the position of the viewer. There are four kinds of
lighting called ambient, diffuse, specular and emissive.
Gama handle ambient and diffuse light.
• ambient_light: Allows to define the value of the ambient light either using
an int (ambient_light:(125)) or a rgb color ((ambient_light:rgb(255,255,255)).
default is rgb(125,125,125).
• diffuse_light: Allows to define the value of the diffuse light either using an int
(diffuse_light:(125)) or a rgb color ((diffuse_light:rgb(255,255,255)). default is
rgb(125,125,125).
v 1.8.0 371
GAMA v1.8.0 documentation Chapter 53. Defining 3D Displays
Here is an example using all the available facet to define a diffuse light that rotate
around the world.
display View1 type:opengl draw_diffuse_light:true ambient_light:(0)
diffuse_light:(255) diffuse_light_pos:{50+ 150*sin(time*2),50,150*
cos(time*2){
...
}
v 1.8.0 372
Chapter 54
Other outputs can be very useful to study better the behavior of your agents.
Index
• Define a monitor
• Define an inspector
Define a monitor
A monitor allows to follow the value of an arbitrary expression in GAML. It will
appear, in the User Interface, in a small window on its own and be recomputed every
time step (or according to its refresh facet).
Definition of a monitor:
monitor monitor_name value: an_expression refresh:boolean_statement;
with:
• value: mandatory, the expression whose value will be displayed by the monitor.
• refresh: bool statement, optional : the new value is computed if the bool
statement returns true.
373
GAMA v1.8.0 documentation Chapter 54. Defining monitors and inspectors
Example:
experiment my_experiment type: gui {
output {
monitor monitor_name value: cycle refresh:every(1);
}
}
NB : you can also declare monitors during the simulation, by clicking on the button
“Add new monitor”, and specifying the name of the variable you want to follow.
Define an inspector
During the simulation, the user interface of GAMA provides the user the possibility
to inspect an agent, or a group of agents. But you can also define the inspector you
want directly from your model, as an output of the experiment.
Use the statement inspect to define your inspector, in the output scope of your gui
experiment. The inspector has to be named (using the facet name), a value has to be
specified (with the value facet).
inspect name:"inspector_name" value:the_value_you_want_to_display;
Note that you can inspect any type of species (regular species, grid species, even the
world. . . ).
The optional facet type is used to specify the type of your inspector. 2 values are
possible:
• agent (default value) if you want to display the information as a regular agent
inspector. Note that if you want to inspect a large number of agents, this can
take a lot of time. In this case, prefer the other type table
• table if you want to display the information as an agent browser
The optional facet attribute is used to filter the attributes you want to be displayed
in your inspector.
Beware: only one agent inspector (type:agent) can be used for an experiment.
Beside, you can add as many agent browser (type:table) as you want for your
experiment.
Example of implementation:
v 1.8.0 374
GAMA v1.8.0 documentation Chapter 54. Defining monitors and inspectors
model new
global {
init {
create my_species number:3;
}
}
species my_species {
int int_attr <- 6;
string str_attr <- "my_value";
string str_attr_not_important <- "blabla";
}
Another statement, browse, is doing a similar thing, but preferring the table type (if
you want to browse an agent species, the default type will be the table type).
v 1.8.0 375
GAMA v1.8.0 documentation Chapter 54. Defining monitors and inspectors
v 1.8.0 376
Chapter 55
Index
• The Save Statement
• Export files in experiment
• Autosave
Facets
377
GAMA v1.8.0 documentation Chapter 55. Defining export files
• type (an identifier): an expression that evaluates to an string, the type of the
output file (it can be only “shp”, “text” or “csv”)
• with (map):
Usages
• Its simple syntax is:
save data to: output_file type: a_type_file;
• To save the values of some attributes of the current agent in csv file:
save [name, location, host] to: "save_data.csv" type: "csv";
• To save the geometries of all the agents of a species into a shapefile (with
optional attributes):
save species_of(self) to: "save_shapefile.shp" type: "shp" with: [name
::"nameAgent", location::"locationAgent"] crs: "EPSG:4326";
v 1.8.0 378
GAMA v1.8.0 documentation Chapter 55. Defining export files
Example:
file name: "results" type: text data: time + "; " + nb_preys + ";" +
nb_predators refresh:every(2);
Each time step (or according to the frequency defined in the refresh facet of the file
output), a new line will be added at the end of the file. If rewrite: false is defined
in its facets, a new file will be created for each simulation (identified by a timestamp
in its name).
Optionally, a footer and a header can also be described with the corresponding
facets (of type string).
Autosave
Image files can be exported also through the autosave facet of the display, as explained
in this previous part.
v 1.8.0 379
GAMA v1.8.0 documentation Chapter 55. Defining export files
v 1.8.0 380
Chapter 56
During the simulation, GAML provides you the possibility to define some function
the user can execute during the execution. In this chapter, we will see how to define
buttons to execute action during the simulation, how to catch click event, and how
to use the user control architecture.
Index
• Catch Mouse Event
• Define User command
381
GAMA v1.8.0 documentation Chapter 56. Defining user interaction
• name (identifier) : Specify which event do you want to trigger (among the fol-
lowing values : mouse_down, mouse_up, mouse_move, mouse_enter, mouse_exit
or any alphanumeric symbol/key of the keyboard, such as, 'a', 'b'. . . ).
• action (identifier) : Specify the name of the global action to call.
event mouse_down action: my_action;
The event statement has to be defined in the experiment/output/display scope.
Once the event is triggered, the global action linked will be called. The action linked
cannot have arguments. To get the location of the mouse click, the #user_location
can be used; to get the agents on which the mouse has clicked, you can use spatial
query (e.g. my_species overlapping #user_location).
global
{
action my_action
{
write "do action";
}
species my_species
{
}
v 1.8.0 382
GAMA v1.8.0 documentation Chapter 56. Defining user interaction
For instance:
user_command kill_myself action: die;
//or
user_command kill_myself action: some_action with: [arg1::5, arg2::3];
//or
user_command kill_myself {
do die;
}
The user command can be defined directly inside the GUI experiment scope. In that
case, the implemented action appears as a button in the top of the parameter view.
Here is a very short code example :
model quick_user_command_model
global {
action createAgent
{
create my_species;
}
}
species my_species {
aspect base {
draw circle(1) color:#blue;
}
v 1.8.0 383
GAMA v1.8.0 documentation Chapter 56. Defining user interaction
v 1.8.0 384
GAMA v1.8.0 documentation Chapter 56. Defining user interaction
model quick_user_command_model
global {
init {
create my_species number:10;
}
}
species my_species {
user_command cmd_inside_experiment action:die;
aspect base {
draw circle(1) color:#blue;
}
}
• When the agent is inspected, they appear as buttons above the agents’ attributes
v 1.8.0 385
GAMA v1.8.0 documentation Chapter 56. Defining user interaction
v 1.8.0 386
GAMA v1.8.0 documentation Chapter 56. Defining user interaction
v 1.8.0 387
GAMA v1.8.0 documentation Chapter 56. Defining user interaction
user_location
In the special case when the user_command is called from the pop-up menu (from a
right-click on an agent in a display), the location chosen by the user (translated into the
model coordinates) is passed to the execution scope under the name user_location.
Example:
global {
user_command "Create agents here" {
create my_species number: 10 with: [location::user_location];
}
}
This will allow the user to click on a display, choose the world (always present now),
and select the menu item “Create agents here”.
Note that if the world is inspected (this user_command appears thus as a button) and
the user chooses to push the button, the agent will be created at a random location.
user_input
As it is also, sometimes, necessary to ask the user for some values (not defined as
parameters), the user_input unary operator has been introduced. This operator
takes a map [string::value] as argument (the key is the name of the chosen parameter,
the value is the default value), displays a dialog asking the user for these values, and
returns the same map with the modified values (if any). You can also add a text
as first argument of the operator, which will be displayed as a title for your dialog
popup. The dialog is modal and will interrupt the execution of the simulation until
the user has either dismissed or accepted it. It can be used, for instance, in an init
section like the following one to force the user to input new values instead of relying
on the initial values of parameters.
Here is an example of implementation:
model quick_user_command_model
global {
init {
map values <- user_input("Choose a number of agent to create",["
Number" :: 100]);
create my_species number: int(values at "Number");
v 1.8.0 388
GAMA v1.8.0 documentation Chapter 56. Defining user interaction
}
}
species my_species {
aspect base {
draw circle(1) color:#blue;
}
}
When running this model, you will first have to input a number:
v 1.8.0 389
GAMA v1.8.0 documentation Chapter 56. Defining user interaction
v 1.8.0 390
Chapter 57
Exploring Models
We just learnt how to launch GUI Experiments from GAMA. A GUI Experiment will
start with a particular set of input, compute several outputs, and will stop at the
end (if asked).
In order to explore models (by automatically running the Experiment using several
configurations to analyze the outputs), a first approach is to run several simulations
from the same experiment, considering each simulation as an agent. A second
approach, much more efficient for larger explorations, is to run an other type of
experiment : the Batch Experiment.
We will start this part by learning how to run several simulations from the same
experiment. Then, we will see how batch experiments work, and we will focus
on how to use those batch experiments to explore models by using exploration
methods.
391
GAMA v1.8.0 documentation Chapter 57. Exploring Models
v 1.8.0 392
Chapter 58
To explore a model, the easiest and the most intuitive way to proceed is running
several simulations with several parameter value, and see the differences from the
output. GAMA provides you the possibility to launch several simulations from the
GUI.
Index
• Create a simulation
• Manipulate simulations
• Random seed
– Defining the seed from the model
– Defining the seed from the experiment
– Run several simulations with the same random numbers
– Change the RNG
Create a simulation
Let’s remind you that in GAMA, everything is an agent. We already saw that the
“world” agent is the agent of the model. The model is thus a species, called
modelName_model :
model toto // <- the name of the species is "toto_model"
393
GAMA v1.8.0 documentation Chapter 58. Run Several Simulations
New highlight of the day : an Experiment is also an agent ! It’s a special agent
which will instantiate automatically an agent from the model species. You can then
perfectly create agents (model agents) from your experiment, using the statement
create :
model multi_simulations // the "world" is an instance of the "
multi_simulations_model"
global {
}
This sort model will instantiate 2 simulations (two instance of the model) : one is
created automatically by the experiment, and the second one is explicitly created
through the statement create.
To simplify the syntax, you can use the built-in attribute simulation of your ex-
periment. When you have a model called “multi_simulations”, the two following
lines are strictly equal :
create multi_simulations_model;
create simulation;
As it was the case for creating regular species, you can specify the parameters of your
agent during the creation through the facet with: :
model multi_simulations
global {
rgb bgd_color;
}
v 1.8.0 394
GAMA v1.8.0 documentation Chapter 58. Run Several Simulations
}
Manipulate simulations
When you think the simulations as agents, it gives you a lot of new possibilities. You
can for example create a reflex from your experiment, asking to create simulations
during the experiment execution !
The following short model for example will create a new simulation at each 10 cycles :
model multi_simulations
global {
init {
write "new simulation created ! Its name is "+name;
}
}
You may ask, what is the purpose of such a thing ? Well, with such a short model, it
is not very interesting, for sure. But you can imagine running a simulation, and if the
simulation reaches a certain state, it can be closed, and another simulation can be
run instead with different parameters (a simulation can be closed by doing a “do die”
on itself). You can also imagine to run two simulations, and to communicate from
one to an other through the experiment, as it is shown in this easy model, where
agents can move from one simulation to another :
model smallWorld
global {
int grid_size <- 10;
bool modelleft <- true;
int id<- 0;
v 1.8.0 395
GAMA v1.8.0 documentation Chapter 58. Run Several Simulations
v 1.8.0 396
GAMA v1.8.0 documentation Chapter 58. Run Several Simulations
init {
create people number: nb_agents {
my_cell <- one_of(cell);
location <- my_cell.location;
}
if (modelleft) {
ask cell where (each.grid_x = (grid_size - 1)) {
color <- #red;
}
} else {
ask cell where (each.grid_x = 0) {
color <- #red;
}
}
}
species people {
rgb color <- rnd_color(255);
cell my_cell;
reflex move {
if (modelleft and my_cell.color = #red) {
ask smallWorld_model[1] {
do changeWorld(myself.color, {100 - myself.location.x,
myself.location.y});
}
do die;
} else {
list<cell> free_cells <- list<cell> (my_cell.neighbors)
where empty(people inside each);
if not empty(free_cells) {
my_cell <- one_of(free_cells);
location <- my_cell.location;
}
}
v 1.8.0 397
GAMA v1.8.0 documentation Chapter 58. Run Several Simulations
aspect default {
draw circle(50/grid_size) color: color;
}
}
output {
display map {
grid cell lines: #black;
species people;
}
}
}
Random seed
You can also specify the seed if you are inside the init scope of your global agent.
global {
init {
v 1.8.0 398
GAMA v1.8.0 documentation Chapter 58. Run Several Simulations
v 1.8.0 399
GAMA v1.8.0 documentation Chapter 58. Run Several Simulations
seed<-10.0;
}
}
Notice that if you affect the value of your seed built-in directly in the global scope,
the affectation of the parameters (for instance specified with the facet with of the
statement create), and the “init” will be done after will be done at the end.
The experiment agent also have a built-in attribute seed. The value of this seed is
defined in your simulation preferences. The first simulation created is created with
the seed value of the experiment.
The following sequence diagram can explain you better how the affectation of the
seed attribute works :
The affectation of an attribute is always done in this order : (1) the attribute is
affected with a specific value in the species scope. If no attribute value is specified,
the value is a default value. (2) if a value is specified for this attribute in the create
statement, then the attribute value is affected again. (3) the attribute value can be
changed again in the init scope.
v 1.8.0 400
GAMA v1.8.0 documentation Chapter 58. Run Several Simulations
global {
init {
create my_species;
}
}
global {
int number_of_speciesB <- 1;
v 1.8.0 401
GAMA v1.8.0 documentation Chapter 58. Run Several Simulations
init {
create my_speciesA;
create my_speciesB number:number_of_speciesB;
}
}
v 1.8.0 402
GAMA v1.8.0 documentation Chapter 58. Run Several Simulations
Then you run the experiment, you may find something strange. . .
Even if the first step seems ok (the greed agent and one of the two red agent is
initialized with the same location), the simulation differs completly. You should have
expected to have the same behavior for the greed agent in both of the simulation,
but it is not the case. The explaination of this behavior is that a random number
generator has generated more random numbers in the second simulation than in the
first one.
If you don’t understand, here is a short example that may help you to understand
better :
model multi_simulations
v 1.8.0 403
GAMA v1.8.0 documentation Chapter 58. Run Several Simulations
global {
int iteration_number <- 1;
reflex update {
float value;
loop times:iteration_number {
value<-rnd(10.0);
write value;
}
write "cycle "+cycle+" in experiment "+name+" : "+value;
}
}
Which means :
v 1.8.0 404
GAMA v1.8.0 documentation Chapter 58. Run Several Simulations
When writing your models, you have to be aware of this behavior. Remember that
each simulation has it’s own random number generator.
global {
init {
create my_species number:50;
}
}
v 1.8.0 405
GAMA v1.8.0 documentation Chapter 58. Run Several Simulations
v 1.8.0 406
Chapter 59
Table of contents
• The batch experiment facets
• Action _step
• Reflexes
• Permanent
407
GAMA v1.8.0 documentation Chapter 59. Defining Batch Experiments
• until: (expression) Specifies when to stop each simulation. Its value is a condition
on variables defined in the model. The run will stop when the condition is
evaluated to true. If omitted, the first simulation run will go forever, preventing
any subsequent run to take place (unless a halt command is used in the model
itself).
• repeat: (integer) A parameter configuration corresponds to a set of values
assigned to each parameter. The attribute repeat specifies the number of times
each configuration will be repeated, meaning that as many simulations will be
run with the same parameter values. Different random seeds are given to the
pseudo-random number generator. This allows to get some statistical power
from the experiments conducted. Default value is 1.
• keep_seed: (boolean) If true, the same series of random seeds will be used from
one parameter configuration to another. Default value is false.
experiment my_batch_experiment type: batch repeat: 5 keep_seed: true
until: time = 300 {
[parameter to explore]
[exploration method]
}
Action _step_
The _step_ action of an experiment is called at the end of a simulation. It is possible
to override this action to apply a specific action at the end of each simulation. Note
that at the experiment level, you have access to all the species and all the global
variables.
For instance, the following experiment runs the simulation 5 times, and, at the end
of each simulation, saves the people agents in a shapefile.
experiment 'Run 5 simulations' type: batch repeat: 5 keep_seed: true
until: ( time > 1000 ) {
int cpt <- 0;
action _step_ {
save people type:"shp" to:"people_shape" + cpt + ".shp" with: [
is_infected::"INFECTED",is_immune::"IMMUNE"];
cpt <- cpt + 1;
}
}
v 1.8.0 408
GAMA v1.8.0 documentation Chapter 59. Defining Batch Experiments
A second solution to achieve the same result is to use reflexes (see below).
Reflexes
It is possible to write reflexes inside a batch experiment. This reflex will be executed
at the end of each simulation. For instance, the following reflex writes at the end of
each simulation the value of the variable food_gathered:
reflex info_sim {
write "Running a new simulation " + simulation + " -> " +
food_gathered;
}
Permanent
The permanent section allows to define an output block that will not be re-initialized
at the beginning of each simulation but will be filled at the end of each simulation.
For instance, this permanent section will allow to display for each simulation the
end value of the food_gathered variable.
permanent {
display Ants background: rgb('white') refresh:every(1) {
chart "Food Gathered" type: series {
data "Food" value: food_gathered;
}
}
}
v 1.8.0 409
GAMA v1.8.0 documentation Chapter 59. Defining Batch Experiments
v 1.8.0 410
Chapter 60
Exploration Methods
Table of contents
• The method element
• Exhaustive exploration of the parameter space
• Hill Climbing
• Simulated Annealing
• Tabu Search
• Reactive Tabu Search
• Genetic Algorithm
411
GAMA v1.8.0 documentation Chapter 60. Exploration Methods
The order of the simulations depends on the order of the param. In our example, the
first combinations will be the followings:
v 1.8.0 412
GAMA v1.8.0 documentation Chapter 60. Exploration Methods
Note: this method can also be used for optimization by adding an method element
with maximize or a minimize attribute:
experiment Batch type: batch repeat: 2 keep_seed: true until: (
food_gathered = food_placed ) or ( time > 400 ) {
parameter 'Evaporation:' var: evaporation_rate among: [ 0.1 , 0.2 ,
0.5 , 0.8 , 1.0 ] unit: 'rate every cycle (1.0 means 100%)';
parameter 'Diffusion:' var: diffusion_rate min: 0.1 max: 1.0 unit:
'rate every cycle (1.0 means 100%)' step: 0.3;
method exhaustive maximize: food_gathered;
}
Hill Climbing
Name: hill_climbing Parameter definitions accepted: List with step and Explicit List.
Parameter type accepted: all.
This algorithm is an implementation of the Hill Climbing algorithm. See the wikipedia
article.
Algorithm:
Initialization of an initial solution s
iter = 0
While iter <= iter_max, do:
Choice of the solution s' in the neighborhood of s that maximize the
fitness function
If f(s') > f(s)
s = s'
Else
end of the search process
EndIf
iter = iter + 1
EndWhile
v 1.8.0 413
GAMA v1.8.0 documentation Chapter 60. Exploration Methods
Method parameters:
Example (models/ants/batch/ant_hill_climbing_batch.xml):
experiment Batch type: batch repeat: 2 keep_seed: true until: (
food_gathered = food_placed ) or ( time > 400 ) {
parameter 'Evaporation:' var: evaporation_rate among: [ 0.1 , 0.2 ,
0.5 , 0.8 , 1.0 ] unit: 'rate every cycle (1.0 means 100%)';
parameter 'Diffusion:' var: diffusion_rate min: 0.1 max: 1.0 unit:
'rate every cycle (1.0 means 100%)' step: 0.3;
method hill_climbing iter_max: 50 maximize : food_gathered;
}
Simulated Annealing
Name: annealing Parameter definitions accepted: List with step and Explicit List.
Parameter type accepted: all.
This algorithm is an implementation of the Simulated Annealing algorithm. See the
wikipedia article.
Algorithm:
Initialization of an initial solution s
temp = temp_init
While temp > temp_end, do:
iter = 0
While iter < nb_iter_cst_temp, do:
Random choice of a solution s2 in the neighborhood of s
df = f(s2)-f(s)
If df > 0
s = s2
Else,
rand = random number between 0 and 1
If rand < exp(df/T)
s = s2
EndIf
EndIf
iter = iter + 1
EndWhile
v 1.8.0 414
GAMA v1.8.0 documentation Chapter 60. Exploration Methods
Method parameters:
Example (models/ants/batch/ant_simulated_annealing_batch.xml):
experiment Batch type: batch repeat: 2 keep_seed: true until: (
food_gathered = food_placed ) or ( time > 400 ) {
parameter 'Evaporation:' var: evaporation_rate among: [ 0.1 , 0.2 ,
0.5 , 0.8 , 1.0 ] unit: 'rate every cycle (1.0 means 100%)';
parameter 'Diffusion:' var: diffusion_rate min: 0.1 max: 1.0 unit:
'rate every cycle (1.0 means 100%)' step: 0.3;
method annealing temp_init: 100 temp_end: 1 temp_decrease: 0.5
nb_iter_cst_temp: 5 maximize: food_gathered;
}
Tabu Search
Name: tabu Parameter definitions accepted: List with step and Explicit List. Param-
eter type accepted: all.
This algorithm is an implementation of the Tabu Search algorithm. See the wikipedia
article.
Algorithm:
Initialization of an initial solution s
tabuList = {}
iter = 0
While iter <= iter_max, do:
Choice of the solution s2 in the neighborhood of s such that:
s2 is not in tabuList
the fitness function is maximal for s2
s = s2
If size of tabuList = tabu_list_size
v 1.8.0 415
GAMA v1.8.0 documentation Chapter 60. Exploration Methods
Method parameters:
v 1.8.0 416
GAMA v1.8.0 documentation Chapter 60. Exploration Methods
Genetic Algorithm
Name: genetic Parameter definitions accepted: List with step and Explicit List.
Parameter type accepted: all.
This is a simple implementation of Genetic Algorithms (GA). See the wikipedia
article. The principle of GA is to search an optimal solution by applying evolution
operators on an initial population of solutions There are three types of evolution
operators:
v 1.8.0 417
GAMA v1.8.0 documentation Chapter 60. Exploration Methods
Initial population building: the system builds nb_prelim_gen random initial popula-
tions composed of pop_dim individual solutions. Then, the best pop_dim solutions
are selected to be part of the initial population.
Selection operator: roulette-wheel selection: the probability to choose a solution is
equal to: fitness(solution)/ Sum of the population fitness. A solution can be selected
several times. Ex: population composed of 3 solutions with fitness (that we want to
maximize) 1, 4 and 5. Their probability to be chosen is equal to 0.1, 0.4 and 0.5.
Mutation operator: The value of one parameter is modified. Ex: The solution
{Param1 = 3; Param2 = 2} can mute to {Param1 = 3; Param2 = 4}
Crossover operator: A cut point is randomly selected and two new solutions are built
by taking the half of each parent solution. Ex: let {Param1 = 4; Param2 = 1} and
{Param1 = 2; Param2 = 3} be two solutions. The crossover operator builds two new
solutions: {Param1 = 2; Param2 = 1} and {Param1 = 4; Param2 = 3}.
Method parameters:
v 1.8.0 418
Chapter 61
Optimizing Models
Now you are becoming more comfortable with GAML, it is time to think about how
the runtime works, to be able to run some more optimized models. Indeed, if you
already tried to write some models by yourself using GAML, you could have noticed
that the execution time depends a lot of how you implemented your model!
We will first present you in this part some runtime concepts (and present you the
species facet scheduler), and we will then show you some tips to optimize your
models (how to increase performances using scheduler, grids, displays and how to
choose your operators).
419
GAMA v1.8.0 documentation Chapter 61. Optimizing Models
v 1.8.0 420
Chapter 62
Runtime Concepts
When a model is being simulated, a number of algorithms are applied, for instance to
determine the order in which to run the different agents, or the order in which the
initialization of agents is performed, etc. This section details some of them, which can
be important when building models and understanding how they will be effectively
simulated.
Table of contents
• Simulation initialization
• Agents Creation
• Agents Step
• Schedule Agents
Simulation initialization
Once the user launches an experiment, GAMA starts the initialization of the simula-
tion. First it creates a world agent.
It initializes all its attributes with their init values. This includes its shape (that will
be used as environment of the simulation).
If a species of type grid exists in the model, agents of species are created.
421
GAMA v1.8.0 documentation Chapter 62. Runtime Concepts
Finally the init statement is executed. It should include the creation of all the other
agents of regular species of the simulation. After their creation and initialization,
they are added in the list members the world (that contains all the micro-agent of
the world).
Agents Creation
Except grid agents, other agents are created using the create statement. It is used
to allocate memory for each agent and to initialize all its attributes.
If no explicit initialization exists for an attribute, it will get the default value
corresponding to its type.
The initialization of an attribute can be located at several places in the code; they
are executed in the following order (which means that, if several ways are used, the
attribute will finally have the value of the last applied one):
Agents Step
When an agent is asked to step, it means that it is expected to update its variables,
run its behaviors and then step its micro-agents (if any).
step of agent agent_a
{
species_a <- agent_a.species
architecture_a <- species_a.architecture
ask architecture_a to step agent_a {
ask agent_a to update species_a.variables
ask agent_a to run architecture_a.behaviors
}
v 1.8.0 422
GAMA v1.8.0 documentation Chapter 62. Runtime Concepts
Schedule Agents
The global scheduling of agents is then simply the application of this previous step to
the experiment agent, keeping in mind that this agent has only one micro-population
(of simulation agents, each instance of the model species), and that the simulation(s)
inside this population contain(s), in turn, all the “regular” populations of agents of
the model.
To influence this schedule, then, one possible way is to change the way populations
compute their lists of agents to schedule, which can be done in a model by providing
custom definitions to the “schedules:” facet of one or several species.
A practical application of this facet is to reduce simulation artifacts created by the
default scheduling of populations, which is sequential (i.e. their agents are executed
in turn in their order of creation). To enable a pseudo-parallel scheduling based
on a random scheduling recomputed at each step, one has simply to define the
corresponding species like in the following example:
species A schedules: shuffle(A) {...}
It is important to (1) explicitly invoke the scheduling of the world (although it doesn’t
have to be the first); (2) suppress the population-based scheduling to avoid having
agent being scheduled 2 times (one time in the custom definition, one time by their
population).
Other schemes are possible. For instance, the following definition will completely
suppress the default scheduling mechanism to replace it with a custom scheduler that
v 1.8.0 423
GAMA v1.8.0 documentation Chapter 62. Runtime Concepts
will execute the world, then all agents of species A in a random way and then all
agents of species B in their order of creation:
global schedules: [world] + shuffle(A) + B {...} // explicit scheduling
in the world
Complex conditions can be used to express which agents need to be scheduled each
step. For instance, in the following definition, only agents of A that return true to a
particular condition are scheduled:
species A schedules: A where each.can_be_scheduled() {
bool can_be_scheduled() {
...
returns true_or_false;
}
}
and this one will result in an infinite loop (which will trigger a stack overflow at
some point):
global {} // The world is normally scheduled...
v 1.8.0 424
Chapter 63
Optimizing Models
This page aims at presenting some tips to optimize the memory footprint or the
execution time of a model in GAMA.
Note: since GAMA 1.6.1, some optimizations have become obsolete because they have
been included in the compiler. They have, then, been removed from this page. For
instance, writing ‘rgb(0,0,0)’ is now compiled directly as ‘#black’.
Table of contents
• machine_time
• Scheduling
• Grid
– Optimization Facets
∗ use_regular_agents
∗ use_individual_shapes
• Operators
– List operators
∗ first_with
∗ where / count
– Spatial operators
∗ container of agents in closest_to, at_distance, overlapping, inside
425
GAMA v1.8.0 documentation Chapter 63. Optimizing Models
machine_time
In order to optimize a model, it is important to exactly know which part of the model
take times. The simplest to do that is to use the machine_time built-in global
variable that gives the current time in milliseconds. Then to compute the time taken
by a statement, a possible way is to write:
float t <- machine_time;
// here a block of instructions that you consider as "critical"
// ...
write "duration of the last instructions: " + (machine_time - t);
Scheduling
If you have a species of agents that, once created, are not supposed to do anything more
(i.e. no behavior, no reflex, their actions triggered by other agents, their attributes
being simply read and written by other agents), such as a “data” grid, or agents
representing a “background” (from a shape file, etc.), consider using the schedules:
[] facet on the definition of their species. This trick allows to tell GAMA to not
schedule any of these agents.
grid my_grid height: 100 width: 100 schedules: []
{
...
}
The schedules: facet is dynamically computed (even if the agents are not scheduled),
so, if you happen to define agents that only need to be scheduled every x cycles, or
depending on a condition, you can also write schedules: to implement this. For
instance, the following species will see its instances scheduled every 10 steps and only
if a certain condition is met:
v 1.8.0 426
GAMA v1.8.0 documentation Chapter 63. Optimizing Models
species my_species schedules: (every 10) ? (condition ? my_species :
[]) : []
{
...
}
In the same way, modelers can use the frequency facet to define when the agents of
a species are going to be activated. By setting this facet to 0, the agents are never
activated.
species my_species frequency: 0
{
...
}
Grid
Optimization Facets
In this section, we present some facets that allow to optimize the use of grid (in
particular in terms of memories). Note that all these facet can be combined (see the
Life model from the Models library).
use_regular_agents
If false, then a special class of agents is used. This special class of agents used less
memories but has some limitation: the agents cannot inherit from a “normal” species,
they cannot have sub-populations, their name cannot be modified, etc.
grid cell width: 50 height: 50 use_regular_agents: false ;
use_individual_shapes
If false, then only one geometry is used for all agents. This facet allows to gain a lot
of memory, but should not be used if the geometries of the agents are often activated
(for instance, by an aspect).
v 1.8.0 427
GAMA v1.8.0 documentation Chapter 63. Optimizing Models
grid cell width: 50 height: 50 use_individual_shapes: false ;
Operators
List operators
first_with
Whereas it is often more optimized to use the shuffle operator to shuffle the list,
then the first_with operator to select the first element that verifies the condition:
bug one_big_bug <- shuffle(bug) first_with (each.size > 10);
where / count
This will however create an intermediary list before counting it, and this operation
can be time consuming if the number of elements is important. To alleviate this
problem, GAMA includes an operator called count that will count the elements that
verify the condition by iterating directly on the container (no useless list created) :
int n <- my_container count (each.size > 10);
v 1.8.0 428
GAMA v1.8.0 documentation Chapter 63. Optimizing Models
Spatial operators
But it is much faster if your container is large, as it will query the agents using a
spatial index (instead of browsing through the whole container). Note that in some
cases, when you have a small number of agents, the first syntax will be faster. The
same applies for the other operators.
Now consider a very common case: you need to restrict the agents being queried, not
to a container, but to a species (which, actually, acts as a container in most cases).
For instance, you want to know which predator is the closest to the current agent. If
we apply the pattern above, we would write:
predator closest_predator <- predator with_min_of (each distance_to
self);
or
predator closest_predator <- list(predator) closest_to self;
But these two operators can be painfully slow if your species has many instances
(even in the second form). In that case, always prefer using directly the species as
the left member:
predator closest_ predator <- predator closest_to self;
Not only is the syntax clearer, but the speed gain can be phenomenal because, in
that case, the list of instances is not used (we just check if the agent is an instance of
the left species).
v 1.8.0 429
GAMA v1.8.0 documentation Chapter 63. Optimizing Models
However, what happens if one wants to query instances belonging to 2 or more species
? If we follow our reasoning, the immediate way to write it would be (if predator 1
and predator 2 are two species):
agent closest_agent <- (list(predator1) + list(predator2)) closest_to
self;
The first syntax suffers from the same problem than the previous syntax: GAMA has
to browse through the list (created by the concatenation of the species populations)
to filter agents. The solution, then, is again to use directly the species, as GAMA
is clever enough to create a temporary “fake” population out of the concatenation
of several species, which can be used exactly like a list of agents, but provides the
advantages of a species population (no iteration made during filtering).
The closest_to operator can sometimes be slow if numerous agents are concerned by
this query. If the modeler is just interested by a small subset of agents, it is possible
to apply a first spatial filtering on the agent list by using the at_distance operator.
For example, if the modeler wants first to do a spatial filtering of 10m:
agent closest_agent <- (predator1 at_distance 10) closest_to self;
Displays
shape
It is quite common to want to display an agent as a circle or a square. A common
mistake is to mix up the shape to draw and the geometry of the agent in the model.
v 1.8.0 430
GAMA v1.8.0 documentation Chapter 63. Optimizing Models
If the modeler just wants to display a particular shape, he/she should not modify the
agent geometry (which is a point by default), but just specify the shape to draw in
the agent aspect.
species bug {
int size <- rnd(100);
aspect circle {
draw circle(2) color: ˚blue;
}
}
v 1.8.0 431
GAMA v1.8.0 documentation Chapter 63. Optimizing Models
v 1.8.0 432
433
GAMA v1.8.0 documentation Chapter 64. Multi-Paradigm Modeling
Chapter 64
Multi-Paradigm Modeling
v 1.8.0 434
GAMA v1.8.0 documentation Chapter 64. Multi-Paradigm Modeling
v 1.8.0 435
GAMA v1.8.0 documentation Chapter 64. Multi-Paradigm Modeling
v 1.8.0 436
Chapter 65
Control Architectures
For example, the given code allows to attach the fsm control architecture to the
dummy species.
species dummy control: fsm {
}
GAMA integrates several agent control architectures that can be used in addition to
the common behavior structure:
• fsm: finite state machine based behavior model. During its life cycle, the agent
can be in several states. At any given time step, it is in one single state. Such
an agent needs to have one initial state (the state in which it will be at its
initialization)
• weighted_tasks: task-based control architecture. At any given time, only the
task only the task with the maximal weight is executed.
• sorted_tasks: task-based control architecture. At any given time, the tasks are
all executed in the order specified by their weights (highest first).
437
GAMA v1.8.0 documentation Chapter 65. Control Architectures
Index
• Finite State Machine
– Declaration
– State
• Task Based
– Declaration
– Task
• User Control Architecture
– user_only, user_first, user_last
– user_panel
– user_controlled
• Other Control Architectures
v 1.8.0 438
GAMA v1.8.0 documentation Chapter 65. Control Architectures
in one single state. Such an agent needs to have one initial state (the state in which
it will be at its initialization).
At each time step, the agent will:
• first (only if he just entered in its current state) execute statement embedded
in the enter statement,
• then all the statements in the state statement
• it will evaluate the condition of each embedded transition statements. If one
condition is fulfilled, the agent execute the embedded statements
Declaration
Using the FSM architecture for a species require to use the control facet:
species dummy control: fsm {
...
}
State
Attributes
Sub Statements
v 1.8.0 439
GAMA v1.8.0 documentation Chapter 65. Control Architectures
• Obviously, only one definition of exit and enter is accepted in a given state
• Transition statements written in the middle of the state statements will only
be evaluated at the end, so, even if it evaluates to true, the remaining of
the statements found after the definition of the transition will be nevertheless
executed. So, despite the appearance, a transition written somewhere in the
sequence will “not stop” the state at that point (but only at the end).
Definition
A state can contain several statements that will be executed, at each time step, by
the agent. There are three exceptions to this rule:
1. statements enclosed in enter will only be executed when the state is entered
(after a transition, or because it is the initial state).
2. Those enclosed in exit will be executed when leaving the state as a result of a
successful transition (and before the statements enclosed in the transition).
3. Those enclosed in a transition will be executed when performing this transition
(but after the exit sequence has been executed).
v 1.8.0 440
GAMA v1.8.0 documentation Chapter 65. Control Architectures
state state2 {
write string(cycle) + ":" + name + "->" + "state2";
transition to: state1 when: flip(0.5) {
write string(cycle) + ":" + name + "->" + "transition to
state1";
}
exit {
write string(cycle) + ":" + name + "->" + "leave state2";
}
}
state state3 {
write string(cycle) + ":" + name + "->" + "state3";
transition to: state1 when: flip(0.5) {
write string(cycle) + ":" + name + "->" + "transition to
state1";
}
transition to: state2 when: flip(0.2) ;
}
}
the dummy agents start at state1. At each simulation step they have a probability of
0.5 to change their state to state2. If they do not change their state to state2, they
have a probability of 0.2 to change their state to state3. In state2, at each simulation
step, they have a probability of 0.5 to change their state to state1. At last, in step3,
at each simulation step they have a probability of 0.5 to change their state to state1.
If they do not change their state to state1, they have a probability of 0.2 to change
their state to state2.
Here a possible result that can be obtained with one dummy agent:
0:dummy0->state1
0:dummy0->transition to state1
1:dummy0->state2
2:dummy0->state2
2:dummy0->leave state2
2:dummy0->transition to state1
3:dummy0->state1
3:dummy0->transition to state1
4:dummy0->state2
5:dummy0->state2
5:dummy0->leave state2
5:dummy0->transition to state1
6:dummy0->state1
7:dummy0->state3
v 1.8.0 441
GAMA v1.8.0 documentation Chapter 65. Control Architectures
8:dummy0->state2
Task Based
GAMA integrated several task-based control architectures. Species can define any
number of tasks within their body. At any given time, only one or several tasks are
executed according to the architecture chosen:
• weighted_tasks : in this architecture, only the task with the maximal weight
is executed.
• sorted_tasks : in this architecture, the tasks are all executed in the order
specified by their weights (biggest first)
• probabilistic_tasks: this architecture uses the weights as a support for
making a weighted probabilistic choice among the different tasks. If all tasks
have the same weight, one is randomly chosen each step.
Declaration
Using the Task architectures for a species require to use the control facet:
species dummy control: weighted_tasks {
...
}
species dummy control: sorted_tasks {
...
}
species dummy control: probabilistic_tasks {
...
}
Task
Sub elements
Besides a sequence of statements like reflex, a task contains the following sub elements:
v 1.8.0 442
GAMA v1.8.0 documentation Chapter 65. Control Architectures
Definition
As reflex, a task is a sequence of statements that can be executed, at each time step,
by the agent. If an agent owns several tasks, the scheduler chooses a task to execute
based on its current priority weight value.
For example, consider the following example:
species dummy control: weighted_tasks {
task task1 weight: cycle mod 3 {
write string(cycle) + ":" + name + "->" + "task1";
}
task task2 weight: 2 {
write string(cycle) + ":" + name + "->" + "task2";
}
}
v 1.8.0 443
GAMA v1.8.0 documentation Chapter 65. Control Architectures
If the control chosen is user_first, it means that the user controlled panel is opened
first, and then the agent has a chance to run its “own” behaviors (reflexes, essentially,
or “init” in the case of a “user_init” panel). If the control chosen is user_last, it is
the contrary.
user_panel
This control architecture is a specialization of the Finite State Machine Architecture
where the “behaviors” of agents can be defined by using new constructs called
user_panel (and one user_init), mixed with “states” or “reflexes”. This user_panel
translates, in the interface, in a semi-modal view that awaits the user to choose action
buttons, change attributes of the controlled agent, etc. Each user_panel, like a
state in FSM, can have a enter and exit sections, but it is only defined in terms
of a set of user_commands which describe the different action buttons present in the
panel.
user_commands can also accept inputs, in order to create more interesting commands
for the user. This uses the user_input statement (and not operator), which is
basically the same as a temporary variable declaration whose value is asked to the
user. Example:
As user_panel is a specialization of state, the modeler has the possibility to describe
several panels and choose the one to open depending on some condition, using the
same syntax than for finite state machines : * either adding transitions to the
user_panels, * or setting the state attribute to a new value, from inside or from
another agent.
This ensures a great flexibility for the design of the user interface proposed to the
user, as it can be adapted to the different stages of the simulation, etc. . .
Follows a simple example, where, every 10 steps, and depending on the value of an
attribute called “advanced”, either the basic or the advanced panel is proposed. (The
full model is provided in the GAMA model library.)
species user control:user_only {
user_panel default initial: true {
v 1.8.0 444
GAMA v1.8.0 documentation Chapter 65. Control Architectures
The panel marked with the “initial: true” facet will be the one run first when the
agent is supposed to run. If none is marked, the first panel (in their definition order)
is chosen.
A special panel called user_init will be invoked only once when initializing the agent
if it is defined. If no panel is described or if all panels are empty (i.e. no user_-
commands), the control view is never invoked. If the control is said to be “user_only”,
the agent will then not run any of its behaviors.
v 1.8.0 445
GAMA v1.8.0 documentation Chapter 65. Control Architectures
user_controlled
Finally, each agent provided with this architecture inherits a boolean attribute called
user_controlled. If this attribute becomes false, no panels will be displayed and
the agent will run “normally” unless its species is defined with a user_only control.
v 1.8.0 446
Chapter 66
Using Equations
Introduction
ODEs (Ordinary Differential Equations) are often used in ecology or in epidemiology
to describe the macroscopic evolution over time of a population. Generally the whole
population is split into several compartments. The state of the population is described
by the number of individuals in each compartment. Each equation of the ODE system
describes the evolution of the number of individual in a compartment. In such an
approach individuals are not taken into account individually, with own features and
behaviors. In contrary they are aggregated in a compartment and reduced to a
number.
A classical example is the SIR epidemic model representing the spreading of a disease
in a population. The population is split into 3 compartments: S (Susceptible), I
(Infected), R (Recovered). (see below for the equation)
In general the ODE systems cannot be analytically solved, i.e. it is not possible to find
the equation describing the evolution of the number of S, I or R. But these systems
can be numerically integrated in order to get the evolution. A numerical integration
computes step after step the value of S, I and R. Several integration methods exist
(e.g. Euler, Runge-Kutta. . . ), each of them being a compromise between accuracy
and computation time. The length of the integration step has also a huge impact on
precision. These models are deterministic.
This approach makes a lot of strong hypotheses. The model does not take into
account space. The population is considered has infinite and homogeneously mixed,
so that any agent can interact with any other one.
447
GAMA v1.8.0 documentation Chapter 66. Using Equations
• S = 499
v 1.8.0 448
GAMA v1.8.0 documentation Chapter 66. Using Equations
• I=1
• R=0
• beta = 0.4
• gamma = 0.1
• h = 0.1
v 1.8.0 449
GAMA v1.8.0 documentation Chapter 66. Using Equations
equation
equation eqSI {
diff(S,t) = -beta * S * I / N ;
diff(I,t) = beta * S * I / N ;
}
}
This equation has to be defined in a species with t, S and I attributes. beta (and
other similar parameters) can be defined either in the specific species (if it is specific
to each agent) or in the global if it is a constant.
Note: the t attribute will be automatically updated using the solve statement; it
contains the time elapsed in the equation integration.
v 1.8.0 450
GAMA v1.8.0 documentation Chapter 66. Using Equations
• type: the identifier of the built-in system (here SI) (the list of all built-in
systems are described below),
• vars: this facet is expecting a list of variables of the species, that will be
matched with the variables of the system,
• params: this facet is expecting a list of variables of the species (of the global),
that will be matched with the parameters of the system.
equation eqBuiltInSI type: SI vars: [S,I,t] params: [N,beta] ;
v 1.8.0 451
GAMA v1.8.0 documentation Chapter 66. Using Equations
species I_agt {
float t ;
float Isize ; // number of infected
float beta ;
The interest is that the modeler can create several agents for each compartment,
which different values. For example in the SI model, the modeler can choose to create
1 agent S_agt and 2 agents I_agt. The beta attribute will have different values in
the two agents, in order to represent 2 different strains.
global {
int number_S <- 495 ; // The number of susceptible
int number_I <- 5 ; // The number of infected
int nb_I <- 2;
float gbeta <- 0.3 ; // The parameter Beta
init {
create S_agt {
Ssize <- float(number_S) ;
}
create I_agt number: nb_I {
Isize <- float(number_I) ;
self.beta <- myself.gbeta + rnd(0.5) ;
}
}
}
• number_S = 495
• number_I = 5
• nb_I = 2
• gbeta = 0.3
v 1.8.0 452
GAMA v1.8.0 documentation Chapter 66. Using Equations
• hKR4 = 0.1
solve an equation
The solve statement has been added in order to integrate numerically the equation
system. It should be added into a reflex. At each simulation step, a step of the
integration is executed, the length of the integration step is defined in the step facet.
The solve statement will update the variables used in the equation system. The
chosen integration method (defined in method) is Runge-Kutta 4 (which is very often
a good choice of integration method in terms of accuracy).
reflex solving {
solve eqSI method:rk4 step:h;
}
With a smaller integration step, the integration will be faster but less accurate.
More details
v 1.8.0 453
GAMA v1.8.0 documentation Chapter 66. Using Equations
solve eqSI ;
In order to synchronize the simulation step and the equation integration step, 2 facets
can be used:
• step: number
• cycle_length: number
cycle_length (int): length of simulation cycle which will be synchronized with step
of the integrator (default value: 1) step (float): integration step, use with most
integrator methods (default value: 1)
time_final (float): target time for the integration (can be set to a value smaller than
t0 for backward integration) time_initial (float): initial time discretizing_step (int):
number of discret beside 2 step of simulation (default value: 0) integrated_times (list):
time interval inside integration process integrated_values (list): list of variables’s
value inside integration process
Some facets are specific to the DP853 integration methods: max_step, min_step,
scalAbsoluteTolerance and scalRelativeTolerance.
The step and cycle_length facets of the integration method may have a huge
influence on the results. step has an impact on the result accuracy. In addition, it is
possible to synchronize the step of the (agent-based) simulation and the (equation)
integration step in various ways (depending on the modeler purpose) using the
cycle_length facet: e.g. cycle_length: 10 means that 10 simulation steps are
equivalent to 1 unit of time of the integration method.
v 1.8.0 454
GAMA v1.8.0 documentation Chapter 66. Using Equations
v 1.8.0 455
GAMA v1.8.0 documentation Chapter 66. Using Equations
The results are provided using the Runge-Kutta 4 method using following initial
values:
• S = 499
• I=1
• beta = 0.4
• h = 0.1
v 1.8.0 456
GAMA v1.8.0 documentation Chapter 66. Using Equations
The results are provided using the Runge-Kutta 4 method using following initial
values:
• S = 499
• I=1
• beta = 0.4
v 1.8.0 457
GAMA v1.8.0 documentation Chapter 66. Using Equations
• gamma = 0.1
• h = 0.1
v 1.8.0 458
GAMA v1.8.0 documentation Chapter 66. Using Equations
}
The results are provided using the Runge-Kutta 4 method using following initial
values:
• S = 499
• I=1
• R=0
• beta = 0.4
• gamma = 0.1
• h = 0.1
v 1.8.0 459
GAMA v1.8.0 documentation Chapter 66. Using Equations
The results are provided using the Runge-Kutta 4 method using following initial
values:
• S = 499
• I=1
• R=0
v 1.8.0 460
GAMA v1.8.0 documentation Chapter 66. Using Equations
• beta = 0.4
• gamma = 0.01
• omega = 0.05
• mu = 0.01
• h = 0.1
The results are provided using the Runge-Kutta 4 method using following initial
values:
• S = 499
• E=0
• I=1
v 1.8.0 461
GAMA v1.8.0 documentation Chapter 66. Using Equations
v 1.8.0 462
GAMA v1.8.0 documentation Chapter 66. Using Equations
• R=0
• beta = 0.4
• gamma = 0.01
• sigma = 0.05
• mu = 0.01
• h = 0.1
The results are provided using the Runge-Kutta 4 method using following initial
values:
• x=2
v 1.8.0 463
GAMA v1.8.0 documentation Chapter 66. Using Equations
v 1.8.0 464
GAMA v1.8.0 documentation Chapter 66. Using Equations
• y=2
• alpha = 0.8
• beta = 0.3
• gamma = 0.2
• delta = 0.85
• h = 0.1
v 1.8.0 465
GAMA v1.8.0 documentation Chapter 66. Using Equations
v 1.8.0 466
Part VII
Recipes
467
Chapter 67
Recipes
Understanding the structure of models in GAML and gaining some insight of the
language is required, but is usually not sufficient to build correct models or models that
need to deal with specific approaches (like equation-based modeling). This section
is intended to provide readers with practical “how to”s on various subjects, ranging
from the use of database access to the design of agent communication languages. It
is by no means exhaustive, and will progressively be extended with more “recipes” in
the future, depending on the concrete questions asked by users.
469
GAMA v1.8.0 documentation Chapter 67. Recipes
v 1.8.0 470
Chapter 68
This section will be presented as a quick tutorial, showing how to proceed to manip-
ulate OSM (Open street map) datas, and load them into GAMA. We will use the
software QGIS to change the attributes of the OSM file.
From the website openstreetmap.org, we will chose a place (in this example, we will
take a neighborhood in New York City). Directly from the website, you can export
the chosen area in the osm format.
We have now to manipulate the attributes for the exported osm file. Several software
are possible to use, but we will focus on QGIS, which is totally free and provides a
lot of possibilities in term of manipulation of data.
Once you have installed correctly QGIS, launch QGIS Desktop, and start to import
the topology from the osm file.
A message indicates that the import was successful. An output file .osm.db is created.
You have now to export the topology to SpatiaLite.
Specify the path for your DataBase file, then choose the export type (in your case,
we will choose the type “Polygons (closed ways)”), choose an output layer name. If
you want to use the open street maps attributes values, click on “Load from DB”,
and select the attributes you want to keep. Click OK then.
A message indicates that the export was successful, and you have now a new layer
created.
We will now manipulate the attributes of your datafile. Right click on the layer, and
select “Open Attribute Table”.
471
GAMA v1.8.0 documentation Chapter 68. Manipulate OSM Datas
The table of attribute appears. Select the little pencil on the top-left corner of the
window to modify the table.
We will add an attribute manually. Click on the button “new column”, choose a
name and a type (we will choose the type “text”).
A new column appears at the end of the table. Let’s fill some values (for instance
blue / red). Once you finishes, click on the “save edit” button.
Our file is now ready to be exported. Right click on the layer, and click on “Save As”.
Choose “shapefile” as format, choose a save path and click ok.
Copy passed all the .shp created in the include folder of your GAMA project. You
are now ready to write the model.
model HowToUseOpenStreetMap
global {
// Global variables related to the Management units
file shapeFile <- file('../includes/new_york.shp');
v 1.8.0 472
GAMA v1.8.0 documentation Chapter 68. Manipulate OSM Datas
v 1.8.0 473
GAMA v1.8.0 documentation Chapter 68. Manipulate OSM Datas
v 1.8.0 474
GAMA v1.8.0 documentation Chapter 68. Manipulate OSM Datas
v 1.8.0 475
GAMA v1.8.0 documentation Chapter 68. Manipulate OSM Datas
v 1.8.0 476
GAMA v1.8.0 documentation Chapter 68. Manipulate OSM Datas
v 1.8.0 477
GAMA v1.8.0 documentation Chapter 68. Manipulate OSM Datas
v 1.8.0 478
GAMA v1.8.0 documentation Chapter 68. Manipulate OSM Datas
v 1.8.0 479
GAMA v1.8.0 documentation Chapter 68. Manipulate OSM Datas
v 1.8.0 480
GAMA v1.8.0 documentation Chapter 68. Manipulate OSM Datas
v 1.8.0 481
GAMA v1.8.0 documentation Chapter 68. Manipulate OSM Datas
v 1.8.0 482
GAMA v1.8.0 documentation Chapter 68. Manipulate OSM Datas
v 1.8.0 483
GAMA v1.8.0 documentation Chapter 68. Manipulate OSM Datas
init {
//Creation of elementOfNewYork agents from the shapefile (and
reading some of the shapefile attributes)
create elementOfNewYork from: shapeFile
with: [elementId::int(read('id')), elementHeight::int(read
('height')), elementColor::string(read('attrForGama'))] ;
}
}
species elementOfNewYork{
int elementId;
int elementHeight;
string elementColor;
aspect basic{
draw shape color: (elementColor = "blue") ? #blue : ( (
elementColor = "red") ? #red : #yellow ) depth: elementHeight;
}
}
Here is the result, with a special colorization of the different elements regarding to
the value of the attribute “attrForGama”, and an elevation regarding to the value of
the attribute “height”.
v 1.8.0 484
GAMA v1.8.0 documentation Chapter 68. Manipulate OSM Datas
v 1.8.0 485
GAMA v1.8.0 documentation Chapter 68. Manipulate OSM Datas
v 1.8.0 486
Chapter 69
Implementing diffusion
GAMA provides you the possibility to represent and simulate the diffusion of a
variable through a grid topology.
Index
• Diffuse statement
• Diffusion with matrix
– Diffusion matrix
– Gradient matrix
– Compute multiple propagations at the same step
– Executing several diffusion matrix
• Diffusion with parameters
• Computation methods
– Convolution
– Dot Product
• Use mask
– Generalities
– Tips
• Pseudo code
487
GAMA v1.8.0 documentation Chapter 69. Implementing diffusion
Diffuse statement
The statement to use for the diffusion is diffuse. It has to be used in a grid species.
The diffuse uses the following facets:
• on (any type in [container, species]): the list of agents (in general cells of a
grid), on which the diffusion will occur
• avoid_mask (boolean): if true, the value will not be diffused in the masked
cells, but will be restitute to the neighboring cells, multiplied by the variation
value (no signal lost). If false, the value will be diffused in the masked cells, but
masked cells won’t diffuse the value afterward (lost of signal). (default value :
false)
• cycle_length (int): the number of diffusion operation applied in one simulation
step
• mask (matrix): a matrix masking the diffusion (matrix created from a image
for example). The cells corresponding to the values smaller than “-1” in the
mask matrix will not diffuse, and the other will diffuse.
• matrix (matrix): the diffusion matrix (“kernel” or “filter” in image processing).
Can have any size, as long as dimensions are odd values.
• method (an identifier), takes values in: {convolution, dot_product}: the diffu-
sion method
• min_value (float): if a value is smaller than this value, it will not be diffused.
By default, this value is equal to 0.0. This value cannot be smaller than 0.
• propagation (a label), takes values in: {diffusion, gradient}: represents both
the way the signal is propagated and the way to treat multiple propagation of
the same signal occurring at once from different places. If propagation equals
‘diffusion’, the intensity of a signal is shared between its neighbors with respect
to ‘proportion’, ‘variation’ and the number of neighbors of the environment
places (4, 6 or 8). I.e., for a given signal S propagated from place P, the value
transmitted to its N neighbors is : S’ = (S / N / proportion) - variation. The
intensity of S is then diminished by S * proportion on P. In a diffusion, the
different signals of the same name see their intensities added to each other
on each place. If propagation equals ‘gradient’, the original intensity is not
modified, and each neighbors receives the intensity : S / proportion - variation.
If multiple propagation occur at once, only the maximum intensity is kept on
each place. If ‘propagation’ is not defined, it is assumed that it is equal to
v 1.8.0 488
GAMA v1.8.0 documentation Chapter 69. Implementing diffusion
‘diffusion’.
• proportion (float): a diffusion rate
• radius (int): a diffusion radius (in number of cells from the center)
• variation (float): an absolute value to decrease at each neighbors
To write a diffusion, you first have to declare a grid, and declare a special attribute
for the diffusion. You will then have to write the diffuse statement in an other scope
(such as the global scope for instance), which will permit the values to be diffused
at each step. There, you will specify which variable you want to diffuse (through the
var facet), on which species or list of agents you want the diffusion (through the on
facet), and how you want this value to be diffused (through all the other facets, we
will see how it works with matrix and with special parameters just after).
Here is the template of code we will use for the next following part of this page:
global {
int size <- 64; // the size has to be a power of 2.
cells selected_cells;
// Initialize the emiter cell as the cell at the center of the word
init {
selected_cells <- location as cells;
}
// Affecting "1" to each step
reflex new_Value {
ask(selected_cells){
phero <- 1.0;
}
}
reflex diff {
// Declare a diffusion on the grid "cells" and on "quick_cells
". The diffusion declared on "quick_cells" will make 10 computations
at each step to accelerate the process.
// The value of the diffusion will be store in the new variable
"phero" of the cell.
diffuse var: phero on: cells /*HERE WRITE DOWN THE DIFFUSION
PROPERTIES*/;
}
}
v 1.8.0 489
GAMA v1.8.0 documentation Chapter 69. Implementing diffusion
This model will simulate a diffusion through a grid at each step, affecting 1 to the
center cell diffusing variable value. The diffusion will be seen during the simulation
through a color code, and through the elevation of the cell.
A first way of specifying the behavior of your diffusion is using diffusion matrix. A
diffusion matrix is a 2 dimension matrix [n][m] with float values, where both n and
m have to be pair values. The most often, diffusion matrix are square matrix, but
you can also declare rectangular matrix.
Example of matrix:
matrix<float> mat_diff <- matrix([
[1/9,1/9,1/9],
[1/9,1/9,1/9],
[1/9,1/9,1/9]]);
In the diffuse statement, you than have to specify the matrix of diffusion you want
in the facet matrix.
diffuse var: phero on: cells matrix:mat_diff;
Using the facet propagation, you can specify if you want the value to be propagated
as a diffusion or as a gratient.
v 1.8.0 490
GAMA v1.8.0 documentation Chapter 69. Implementing diffusion
Diffusion matrix
A diffusion (the default value of the facet propagation) will spread the values to the
neighbors cells according to the diffusion matrix, and all those values will be added
together, as it is the case in the following example :
Note that the sum of all the values diffused at the next step is equal to the sum of
the values that will be diffused multiply by the sum of the values of the diffusion
matrix. That means that if the sum of the values of your diffusion matrix is larger
than 1, the values will increase exponentially at each step. The sum of the value of a
diffusion matrix is usually equal to 1.
Here are some example of matrix you can use, played with the template model:
Gradient matrix
Note that unlike the diffusion propagation, the sum of your matrix can be greater
than 1 (and it is the case, most often !).
v 1.8.0 491
GAMA v1.8.0 documentation Chapter 69. Implementing diffusion
v 1.8.0 492
GAMA v1.8.0 documentation Chapter 69. Implementing diffusion
v 1.8.0 493
GAMA v1.8.0 documentation Chapter 69. Implementing diffusion
You can compute several times the propagation you want by using the facet
cycle_length. GAMA will compute for you the corresponding new matrix, and will
apply it.
Writing those two thinks are exactly equivalent (for diffusion):
matrix<float> mat_diff <- matrix([
[1/81,2/81,3/81,2/81,1/81],
[2/81,4/81,6/81,4/81,2/81],
[3/81,6/81,1/9,6/81,3/81],
[2/81,4/81,6/81,4/81,2/81],
v 1.8.0 494
GAMA v1.8.0 documentation Chapter 69. Implementing diffusion
[1/81,2/81,3/81,2/81,1/81]]);
reflex diff {
diffuse var: phero on: cells matrix:mat_diff;
matrix<float> mat_diff <- matrix([
[1/9,1/9,1/9],
[1/9,1/9,1/9],
[1/9,1/9,1/9]]);
reflex diff {
diffuse var: phero on: cells matrix:mat_diff cycle_length:2;
If you execute several times the statement diffuse with different matrix on the same
variable, their values will be added (and centered if their dimension is not equal).
Thus, the following 3 matrix will be combined to create one unique matrix:
v 1.8.0 495
GAMA v1.8.0 documentation Chapter 69. Implementing diffusion
(1) We determine the “minimale” matrix according to N (if N = 8, the matrix will
be [[P/9,P/9,P/9][P/9,1/9,P/9][P/9,P/9,P/9]]. if N = 4, the matrix will
be [[0,P/5,0][P/5,1/5,P/5][0,P/5,0]]).
v 1.8.0 496
GAMA v1.8.0 documentation Chapter 69. Implementing diffusion
v 1.8.0 497
GAMA v1.8.0 documentation Chapter 69. Implementing diffusion
Computation methods
You can compute the output matrix using two computation methods by using the
facet method : the dot product and the convolution. Note that the result of those
two methods is exactly the same (except if you use the avoid_mask facet, the results
can be slightly differents between the two computations).
Convolution
convolution is the default computation method for the diffusion. For every output
cells, we will multiply the input values and the flipped kernel together, as shown in
the following image :
Pseudo-code (k the kernel, x the input matrix, y the output matrix) :
for (i = 0 ; i < y.nbRows ; i++)
for (j = 0 ; j < y.nbCols ; j++)
for (m = 0 ; m < k.nbRows ; m++)
for (n = 0 ; n < k.nbCols ; n++)
y[i,j] += k[k.nbRows - m - 1, k.nbCols - n - 1]
* x[i - k.nbRows/2 + m, j - k.nbCols/2 + n]
v 1.8.0 498
GAMA v1.8.0 documentation Chapter 69. Implementing diffusion
Dot Product
dot_product method will compute the matrix using a simple dot product between
the matrix. For every input cells, we multiply the cell by the kernel matrix, as shown
in the following image :
Pseudo-code (k the kernel, x the input matrix, y the output matrix) :
for (i = 0 ; i < y.nbRows ; i++)
for (j = 0 ; j < y.nbCols ; j++)
for (m = 0 ; m < k.nbRows ; m++)
for (n = 0 ; n < k.nbCols ; n++)
y[i - k.nbRows/2 + m, j - k.nbCols/2 + n] += k[m, n] * x[i, j]
Using mask
Generalities
If you want to propagate some values in an heterogeneous grid, you can use some
mask to forbid some cells to propagate their values.
You can pass a matrix to the facet mask. All the values smaller than -1 will not
propagate, and all the values greater or equal to -1 will propagate.
A simple way to use mask is by loading an image :
v 1.8.0 499
GAMA v1.8.0 documentation Chapter 69. Implementing diffusion
Note that when you use the on facet for the diffuse statement, you can choose only
some cells, and not every cells. In fact, when you restrain the values to be diffuse, it
is exactly the same process as if you were defining a mask.
When your diffusion is combined with a mask, the default behavior is that the non-
masked cells will diffuse their values in all existing cells (that means, even the masked
cells !). To change this behavior, you can use the facet avoid_mask. In that case, the
value which was supposed to be affected to the masked cell will be redistributed to
the neighboring non-masked cells.
Tips
Masks can be used to simulate a lot of environments. Here are some ideas for your
models:
If you want to simulate a wall blocking a uniform diffusion, you can declare a second
diffusion matrix that will be applied only on the cells where your wall will be. This
diffusion matrix will “push” the values outside from himself, but conserving the values
(the sum of the values of the diffusion still have to be equal to 1) :
matrix<float> mat_diff <- matrix([
v 1.8.0 500
GAMA v1.8.0 documentation Chapter 69. Implementing diffusion
[1/9,1/9,1/9],
[1/9,1/9,1/9],
[1/9,1/9,1/9]]);
reflex diff {
diffuse var: phero on: (cells where(each.grid_x>30)) matrix:
mat_diff;
diffuse var: phero on: (cells where(each.grid_x=30)) matrix:
mat_diff_left_wall;
}
Note that almost the same result can be obtained by using the facet avoid_mask :
the value of all masked cells will remain at 0, and the value which was supposed to
be affected to the masked cell will be distributed to the neighboring cells. Notice
that the results can be slightly different if you are using the convolution or the
dot_product method : the algorithm of redistribution of the value to the neighboring
cells is a bit different. We advise you to use the dot_product with the avoid_mask
facet, the results are more accurates.
v 1.8.0 501
GAMA v1.8.0 documentation Chapter 69. Implementing diffusion
Let’s simulate a uniform diffusion that is pushed by a wind from “north” everywhere
in the grid. A wind from “west” as blowing at the top side of the grid. We will here
have to build 2 matrix : one for the uniform diffusion, one for the “north” wind and
one for the “west” wind. The sum of the values for the 2 matrix meant to simulate
the wind will be equal to 0 (as it will be add to the diffusion matrix).
matrix<float> mat_diff <- matrix([
[1/9,1/9,1/9],
[1/9,1/9,1/9],
[1/9,1/9,1/9]]);
v 1.8.0 502
GAMA v1.8.0 documentation Chapter 69. Implementing diffusion
reflex diff {
diffuse var: phero on: cells matrix:mat_diff;
diffuse var: phero on: cells matrix:mat_wind_from_north;
diffuse var: phero on: (cells where (each.grid_y>=32)) matrix:
mat_wind_from_west;
}
Endless world
Note that when your world is not a torus, it has the same effect as a mask, since all
the values outside from the world cannot diffuse some values back :
You can “fake” the fact that your world is endless by adding a different diffusion for
the cells with grid_x=0 to have almost the same result :
matrix<float> mat_diff <- matrix([
[1/9,1/9,1/9],
[1/9,1/9,1/9],
[1/9,1/9,1/9]]);
v 1.8.0 503
GAMA v1.8.0 documentation Chapter 69. Implementing diffusion
v 1.8.0 504
GAMA v1.8.0 documentation Chapter 69. Implementing diffusion
reflex diff {
diffuse var: phero on: (cells where(each.grid_y>0)) matrix:mat_diff
;
diffuse var: phero on: (cells where(each.grid_y=0)) matrix:
mat_diff_upper_edge;
}
Pseudo code
This section is more for a better understanding of the source code.
Here is the pseudo code for the computation of diffusion :
1) : Execute the statement diffuse, store the diffusions in a map (from class
DiffusionStatement to class GridDiffuser) :
- Get all the facet values
- Compute the "real" mask, from the facet "mask:" and the facet "on:".
- If no value for "mask:" and "on:" all the grid, the mask is equal
to null.
- Compute the matrix of diffusion
- If no value for "matrix:", compute with "nb_neighbors", "
is_gradient", "proportion", "propagation", "variation", "range".
- Then, compute the matrix of diffusion with "cycle_length".
- Store the diffusion properties in a map
- Map : ["method_diffu", "is_gradient", "matrix", "mask", "min_value"
] is value, ["var_diffu", "grid_name"] is key.
- If the key exists in the map, try to "mix" the diffusions
- If "method_diffu", "mask" and "is_gradient" equal for the 2
diffusions, mix the diffusion matrix.
v 1.8.0 505
GAMA v1.8.0 documentation Chapter 69. Implementing diffusion
- For each key of the map,
- Load the couple "var_diffu" / "grid_name"
- Build the "output" and "input" array with the dimension of the grid
.
- Initialize the "output" array with -Double.MAX_VALUE.
- For each value of the map for that key,
- Load all the properties : "method_diffu", "is_gradient", "matrix"
, "mask", "min_value"
- Compute :
- If the cell is not masked, if the value of input is > min_value
, diffuse to the neighbors.
- If the value of the cell is equal to -Double.MAX_VALUE,
remplace it by input[idx] * matDiffu[i][j].
- Else, do the computation (gradient or diffusion).
- Finish the diffusion :
- If output[idx] > -Double.MAX_VALUE, write the new value in the
cell.
v 1.8.0 506
Chapter 70
• Agents can execute SQL queries (create, Insert, select, update, drop, delete) to
various kinds of DBMS.
• Agents can execute MDX (Multidimensional Expressions) queries to select
multidimensional objects, such as cubes, and return multidimensional cellsets
that contain the cube’s data.
507
GAMA v1.8.0 documentation Chapter 70. Using Database Access
Description
• Plug-in: irit.gaml.extensions.database
• Author: TRUONG Minh Thai, Frederic AMBLARD, Benoit GAUDOU,
Christophe SIBERTIN-BLANC
Supported DBMS
The following DBMS are currently supported:
• SQLite
• MySQL Server
• PostgreSQL Server
• SQL Server
• Mondrian OLAP Server
v 1.8.0 508
GAMA v1.8.0 documentation Chapter 70. Using Database Access
Note that, other DBMSs require a dedicated server to work while SQLite on only
needs a file to be accessed. All the actions can be used independently from the chosen
DBMS. Only the connection parameters are DBMS-dependent.
SQLSKILL
Agents with such a skill can use additional actions (defined in the skill)
v 1.8.0 509
GAMA v1.8.0 documentation Chapter 70. Using Database Access
//SQLite
map <string, string> SQLITE <- [
'dbtype'::'sqlite',
'database'::'../includes/meteo.db'];
v 1.8.0 510
GAMA v1.8.0 documentation Chapter 70. Using Database Access
• Return: list < list >. If the selection succeeds, it returns a list with three
elements:
– The first element is a list of column name.
– The second element is a list of column type.
– The third element is a data set.
• Arguments:
– params: (type = map) map containing the connection parameters
v 1.8.0 511
GAMA v1.8.0 documentation Chapter 70. Using Database Access
– select: (type = string) select string. The selection string can contain
question marks.
– values: List of values that are used to replace question marks in appropriate.
This is an optional parameter.
• Exceptions: GamaRuntimeException
Example: select data from table point with question marks from table points
map <string, string> PARAMS <- ['dbtype'::'sqlite', 'database'::'../
includes/meteo.db'];
list<list> t <- list<list> (self select(params: PARAMS,
select: "SELECT temp_min
FROM points where (day>? and day<?);"
values: [10,20] ));
Syntax:
• Return: int
v 1.8.0 512
GAMA v1.8.0 documentation Chapter 70. Using Database Access
v 1.8.0 513
GAMA v1.8.0 documentation Chapter 70. Using Database Access
• Arguments:
– params: (type = map) map containing the connection parameters
– updateComm: (type = string) SQL command string. It may be commands:
create, update, delete and drop with or without question marks.
– columns: (type=list) list of column names of table.
– values: (type=list) list of values that are used to replace question marks if
appropriate. This is an optional parameter.
• Exceptions: GamaRuntimeException
// Insert into
do executeUpdate (params: PARAMS ,
updateComm: "INSERT INTO registration " +
"VALUES(100, 'Zara', 'Ali', 18);");
do insert (params: PARAMS, into: "registration",
columns: ["id", "first", "last"],
values: [103, 'Zaid tim', 'Kha']);
//update
int n <- executeUpdate (params: PARAMS,
updateComm: "UPDATE registration
SET age = 30 WHERE id IN (100, 101)" );
// delete
v 1.8.0 514
GAMA v1.8.0 documentation Chapter 70. Using Database Access
// Drop table
do executeUpdate (params: PARAMS, updateComm: "DROP TABLE registration"
);
MDXSKILL
MDXSKILL plays the role of an OLAP tool using select to query data from OLAP
server to GAMA environment and then species can use the queried data for any
analysis purposes.
}
...
Agents with such a skill can use additional actions (defined in the skill)
v 1.8.0 515
GAMA v1.8.0 documentation Chapter 70. Using Database Access
v 1.8.0 516
GAMA v1.8.0 documentation Chapter 70. Using Database Access
'port'::'8080',
'database'::'MondrianFoodMart',
'catalog'::'FoodMart',
'user'::'test',
'passwd'::'abc'];
v 1.8.0 517
GAMA v1.8.0 documentation Chapter 70. Using Database Access
• Return: list < list >. If the selection succeeds, it returns a list with three
elements:
– The first element is a list of column name.
– The second element is a list of column type.
– The third element is a data set.
• Arguments:
– params: (type = map) map containing the connection parameters
– onColumns: (type = string) declare the select string on columns. The
selection string can contain question marks.
– onRows: (type = string) declare the selection string on rows. The selection
string can contain question marks.
– from: (type = string) specify cube where data is selected. The cube_string
can contain question marks.
– where_: (type = string) specify the selection conditions. The condiction_-
string can contains question marks. This is an optional parameter. *values:
List of values that are used to replace question marks if appropriate. This
is an optional parameter.
• Exceptions:_GamaRuntimeException
Example: select data from SQL Server Analysis Service via XMLA
if (self testConnection[ params::SSAS]){
list l1 <- list(self select (params: SSAS ,
onColumns: " { [Measures].[Quantity], [Measures].[Price] }",
onRows:" { { { [Time].[Year].[All].CHILDREN } * "
+ " { [Product].[Product Category].[All].CHILDREN } * "
+"{ [Customer].[Company Name].&[Alfreds Futterkiste], "
v 1.8.0 518
GAMA v1.8.0 documentation Chapter 70. Using Database Access
Example: select data from Mondrian via XMLA with question marks in selection
if (self testConnection(params:MONDRIANXMLA)){
list<list> l2 <- list<list> (self select(params: MONDRIANXMLA,
onColumns:" {[Measures].[Unit Sales], [Measures].[Store Cost], [
Measures].[Store Sales]} ",
onRows:" Hierarchize(Union(Union(Union({([Promotion Media].[All
Media],"
+" [Product].[All Products])}, "
+" Crossjoin([Promotion Media].[All Media].Children, "
+" {[Product].[All Products]})), "
+" Crossjoin({[Promotion Media].[Daily Paper, Radio, TV]}, "
+" [Product].[All Products].Children)), "
+" Crossjoin({[Promotion Media].[Street Handout]}, "
+" [Product].[All Products].Children))) ",
from:" from [?] " ,
where :" where [Time].[?] " ,
values:["Sales",1997]));
write "result2:"+ l2;
}else {
write "Connect error";
}
AgentDB
AgentBD is a built-in species, which supports behaviors that look like actions in
SQLSKILL but differs slightly with SQLSKILL in that it uses only one connection
for several actions. It means that AgentDB makes a connection to DBMS and keeps
that connection for its later operations with DBMS.
v 1.8.0 519
GAMA v1.8.0 documentation Chapter 70. Using Database Access
Example of declaration:
species agentDB parent: AgentDB {
//insert your descriptions here
}
Connect to database
Syntax:
• Return: connection
• Arguments:
• Exceptions: GamaRuntimeException
v 1.8.0 520
GAMA v1.8.0 documentation Chapter 70. Using Database Access
• Return: null
If the current connection of species is close then the action return null value; otherwise
it throws a GamaRuntimeException.
Example:
v 1.8.0 521
GAMA v1.8.0 documentation Chapter 70. Using Database Access
ask agentDB {
if (self isConnected){
do close;
}
}
Example:
ask agentDB {
if (self isConnected){
write "the connection parameter: " +(self getParameter);
}
}
• Return: null
• Arguments:
– params: (type = map) map containing the connection parameters
v 1.8.0 522
GAMA v1.8.0 documentation Chapter 70. Using Database Access
• Exceptions: GamaRuntimeException
Example:
ask agentDB {
if (self isConnected){
do setParameter(params: MySQL);
do connect(params: (self getParameter));
}
}
Because of the connection to database of AgentDB is kept alive then AgentDB can
execute several SQL queries with only one connection. Hence AgentDB can do actions
such as select, insert, executeUpdate with the same parameters of those actions
of SQLSKILL except params parameter is always absent.
Examples:
map<string, string> PARAMS <- ['dbtype'::'sqlite', 'database'::'../../
includes/Student.db'];
ask agentDB {
do connect (params: PARAMS);
// Create table
do executeUpdate (updateComm: "CREATE TABLE registration"
+ "(id INTEGER PRIMARY KEY, "
+ " first TEXT NOT NULL, " + " last TEXT NOT NULL, "
+ " age INTEGER);");
// Insert into
do executeUpdate ( updateComm: "INSERT INTO registration "
+ "VALUES(100, 'Zara', 'Ali', 18);");
do insert (into: "registration",
columns: ["id", "first", "last"],
values: [103, 'Zaid tim', 'Kha']);
// executeUpdate with question marks
do executeUpdate (updateComm: "INSERT INTO registration VALUES(?, ?,
?, ?);",
values: [101, 'Mr', 'Mme', 45]);
//select
list<list> t <- list<list> (self select(
select:"SELECT * FROM registration;"));
//update
v 1.8.0 523
GAMA v1.8.0 documentation Chapter 70. Using Database Access
v 1.8.0 524
GAMA v1.8.0 documentation Chapter 70. Using Database Access
• Step 2: define boundary of environment by using the map object in first step.
geometry shape <- envelope(BOUNDS);
Note: We can do the same way if we work with MySQL, SQLite, or SQLServer and
we must convert Geometry format in GIS database to binary format.
If we are familiar with how to create agents from a shapefile then it becomes very
simple to create agents from select result. We can do as below:
v 1.8.0 525
GAMA v1.8.0 documentation Chapter 70. Using Database Access
species toto skills: SQLSKILL {
//insert your descriptions here
}
v 1.8.0 526
GAMA v1.8.0 documentation Chapter 70. Using Database Access
init {
create toto ;
ask toto {
if (self testConnection[ params::PARAMS]){
// create GIS database
do executeUpdate(params:PARAMS,
updateComm: "CREATE DATABASE spatial_db with
TEMPLATE = template_postgis;");
remove key: "database" from: PARAMS;
put "spatial_db" key:"database" in: PARAMS;
//create table
do executeUpdate params: PARAMS
updateComm : "CREATE TABLE buildings "+
"( " +
" name character varying(255), " +
" type character varying(255), "
+
" geom GEOMETRY " +
")";
}else {
write "Connection to MySQL can not be established ";
}
}
}
}
v 1.8.0 527
GAMA v1.8.0 documentation Chapter 70. Using Database Access
v 1.8.0 528
Chapter 71
Calling R
Introduction
R language is one of powerful data mining tools, and its community is very large in
the world (See the website: http://www.r-project.org/). Adding the R language into
GAMA is our strong endeavors to accelerate many statistical, data mining tools into
GAMA.
RCaller 2.0 package (Website: http://code.google.com/p/rcaller/) is used for GAMA
1.6.1.
Table of contents
• Introduction
– Configuration in GAMA
– Calling R from GAML
∗ Calling the built-in operators
· Example 1
∗ Calling R codes from a text file (.txt) WITHOUT the parameters
· Example 2
· Correlation.R file
∗ Output
529
GAMA v1.8.0 documentation Chapter 71. Calling R
· Example 3
· RandomForest.R file
• Load the package:
• Read data from iris:
• Build the decision tree:
• Build the random forest of 50 decision trees:
• Predict the acceptance of test set:
• Calculate the accuracy:
– Output
– Calling R codes from a text file (.R, .txt) WITH the parameters
∗ Example 4
∗ Mean.R file
– Output
∗ Example 5
∗ AddParam.R file
∗ Output
Configuration in GAMA
1) Install R language into your computer.
2) In GAMA, select menu option: Edit/Preferences.
3) In “Config RScript’s path”, browse to your “Rscript” file (R language
installed in your system).
v 1.8.0 530
GAMA v1.8.0 documentation Chapter 71. Calling R
model CallingR
global {
list X <- [2, 3, 1];
list Y <- [2, 12, 4];
list result;
init{
write corR(X, Y); // -> 0.755928946018454
write meanR(X); // -> 2.0
}
}
Example 2
model CallingR
global
{
list result;
init{
result <- R_compute("C:/YourPath/Correlation.R");
write result at 0;
}
}
Above syntax is deprecated, use following syntax with R_file instead of R_compute:
model CallingR
v 1.8.0 531
GAMA v1.8.0 documentation Chapter 71. Calling R
global
{
file result;
init{
result <- R_file("C:/YourPath/Correlation.R");
write result.contents;
}
}
Correlation.R file
x <- c(1, 2, 3)
y <- c(1, 2, 4)
Output
result::[0.981980506061966]
Example 3
model CallingR
global
{
list result;
init{
result <- R_compute("C:/YourPath/RandomForest.R");
write result at 0;
}
}
v 1.8.0 532
GAMA v1.8.0 documentation Chapter 71. Calling R
RandomForest.R file
# Load the package:
library(randomForest)
data(iris)
nrow<-length(iris[,1])
ncol<-length(iris[1,])
idx<-sample(nrow,replace=FALSE)
trainrow<-round(2*nrow/3)
trainset<-iris[idx[1:trainrow],]
trainset<-iris[idx[1:trainrow],]
testset<-iris[idx[(trainrow+1):nrow],]
acc<-sum(pred==testset[, ncol])/(nrow-trainrow)
Output
acc::[0.98]
v 1.8.0 533
GAMA v1.8.0 documentation Chapter 71. Calling R
Calling R codes from a text file (.R, .txt) WITH the param-
eters
Using R_compute_param(String RFile, List vectorParam) operator. This
operator ALLOWS to add the parameters from the GAML code.
Remarks: Don’t let any white lines at the end of R codes. R_compute_param
will return the last variable of R file, this parameter can be a basic type or a list.
Please ensure that the called packages must be installed before using.
Example 4
model CallingR
global
{
list X <- [2, 3, 1];
list result;
init{
result <- R_compute_param("C:/YourPath/Mean.R", X);
write result at 0;
}
}
Mean.R file
Output
result::[3.33333333333333]
Example 5
model CallingR
global {
v 1.8.0 534
GAMA v1.8.0 documentation Chapter 71. Calling R
init{
result <- R_compute_param("C:/YourPath/AddParam.R", X);
write result at 0;
}
}
AddParam.R file
v1 <- vectorParam[1]
v2<-vectorParam[2]
v3<-vectorParam[3]
result<-v1+v2+v3
Output
result::[10]
v 1.8.0 535
GAMA v1.8.0 documentation Chapter 71. Calling R
v 1.8.0 536
Chapter 72
The communicating skill offers some actions and built-in variables which enable agents
to communicate with each other using the FIPA interaction protocol. This document
describes the built-in variables and actions of this skill. Examples are found in the
models library bundled with GAMA.
Variables
• accept_proposals (list): A list of ‘accept_proposal’ performative messages
of the agent’s mailbox having .
• agrees (list): A list of ‘accept_proposal’ performative messages.
• cancels (list): A list of ‘cancel’ performative messages.
• cfps (list): A list of ‘cfp’ (call for proposal) performative messages.
• conversations (list): A list containing the current conversations of agent.
Ended conversations are automatically removed from this list.
• failures (list): A list of ‘failure’ performative messages.
• informs (list): A list of ‘inform’ performative messages.
• messages (list): The mailbox of the agent, a list of messages of all types of
performatives.
• proposes (list): A list of ‘propose’ performative messages .
• queries (list): A list of ‘query’ performative messages.
• refuses (list): A list of ‘propose’ performative messages.
• reject_proposals (list): A list of ‘reject_proposals’ performative messages.
• requests (list): A list of ‘request’ performative messages.
537
GAMA v1.8.0 documentation Chapter 72. Using FIPA ACL
Actions
accept_proposal
• returns: unknown
• message (message): The message to be replied
• content (list): The content of the replying message
agree
• returns: unknown
• message (message): The message to be replied
• content (list): The content of the replying message
cancel
• returns: unknown
• message (message): The message to be replied
• content (list): The content of the replying message
cfp
• returns: unknown
• message (message): The message to be replied
• content (list): The content of the replying message
v 1.8.0 538
GAMA v1.8.0 documentation Chapter 72. Using FIPA ACL
end_conversation
• returns: unknown
• message (message): The message to be replied
• content (list): The content of the replying message
failure
• returns: unknown
• message (message): The message to be replied
• content (list): The content of the replying message
inform
• returns: unknown
• message (message): The message to be replied
• content (list): The content of the replying message
propose
• returns: unknown
• message (message): The message to be replied
• content (list): The content of the replying message
v 1.8.0 539
GAMA v1.8.0 documentation Chapter 72. Using FIPA ACL
query
• returns: unknown
• message (message): The message to be replied
• content (list): The content of the replying message
refuse
• returns: unknown
• message (message): The message to be replied
• content (list): The content of the replying message
reject_proposal
• returns: unknown
• message (message): The message to be replied
• content (list): The content of the replying message
reply
Replies a message. This action should be only used to reply a message in a ‘no-
protocol’ conversation and with a ‘user defined performative’. For performatives
supported by GAMA (i.e., standard FIPA performatives), please use the ‘action’ with
the same name of ‘performative’. For example, to reply a message with a ‘request’
performative message, the modeller should use the ‘request’ action.
• returns: unknown
• message (message): The message to be replied
• performative (string): The performative of the replying message
• content (list): The content of the replying message
v 1.8.0 540
GAMA v1.8.0 documentation Chapter 72. Using FIPA ACL
request
• returns: unknown
• message (message): The message to be replied
• content (list): The content of the replying message
send
• returns: msi.gaml.extensions.fipa.Message
• receivers (list): A list of receiver agents
• content (list): The content of the message. A list of any GAML type
• performative (string): A string, representing the message performative
• protocol (string): A string representing the name of interaction protocol
start_conversation
• returns: msi.gaml.extensions.fipa.Message
• receivers (list): A list of receiver agents
• content (list): The content of the message. A list of any GAML type
• performative (string): A string, representing the message performative
• protocol (string): A string representing the name of interaction protocol
subscribe
• returns: unknown
• message (message): The message to be replied
• content (list): The content of the replying message
v 1.8.0 541
GAMA v1.8.0 documentation Chapter 72. Using FIPA ACL
v 1.8.0 542
Chapter 73
Using GAMAnalyzer
Install
Go to Git View -> Click on Import Projects Add the dependencies in ummis-
co.gama.feature.dependencies
GamAnalyzer is a tool to monitor several multi-agents simulation
The “agent_group_follower” goal is to monitor and analyze a group of agent during
several simulation. This group of agent can be chosen by the user according to criteria
chosen by the user. The monitoring process and analysis of these agents involves the
extraction, processing and visualization of their data at every step of the simulation.
The data for each simulation are pooled and treated commonly for their graphic
representation or clusters.
Built-in Variable
• varmap: All variable that can be analyzed or displayed in a graph.
• numvarmap: Numerical variable (on this variable all the aggregator numeric
are computed).
• qualivarmap: All non numerical variable. Could be used for BDI to analyze
beliefs.
543
GAMA v1.8.0 documentation Chapter 73. Using GAMAnalyzer
• lastdetailedvarvalues: store all the value (in varmap) for all the followed
agent for the last iteration.
Example
This example is based on a toy model which is only composed of wandering people.
In this example we will use GamAnalyzer to follow the agent people.
agent_group_follower peoplefollower;
create agentfollower
{
do analyse_cluster species_to_analyse:"people";
peoplefollower<-self;
}
v 1.8.0 544
GAMA v1.8.0 documentation Chapter 73. Using GAMAnalyzer
expGlobalNone
expSimGlobalNone
The agent_group_follower corresponding to the current iteration and all the already
launch experiments are displayed.
aspect simglobal{
display_mode <-"simglobal";
clustering_mode <-"none";
draw shape color: #red;
int curColor <-0;
loop geom over: allSimShape{
draw geom color:SequentialColors[curColor] at:{location.x,location.
y,curColor*10};
curColor <- curColor+1;
}
}
expCluster
The agent group follower is divided in cluster computed thanks to a dbscan algorithm.
Only the current agent_group_follower is displayed
aspect cluster {
display_mode <-"global";
clustering_mode <-"dbscan";
draw shape color: #red;
}
v 1.8.0 545
GAMA v1.8.0 documentation Chapter 73. Using GAMAnalyzer
expClusterSimGlobal
The agent_group_follower (made of different cluster) corresponding to the current
iteration and all the already launch experiments are displayed.
aspect clusterSimGlobal {
display_mode <-"simglobal";
clustering_mode <-"dbscan";
draw shape color: #red;
int curColor <-0;
loop geom over: allSimShape{
draw geom color:SequentialColors[curColor] at:{location.x,location.
y,curColor*10};
curColor <- curColor+1;
}
}
v 1.8.0 546
Chapter 74
Using BDI
Acteur Projet
This project lead to the BEN Architecture wich is a more complete version of the
BDI architecture described on this page. A detailed description of BEN may be found
here.
547
GAMA v1.8.0 documentation Chapter 74. Using BDI
Attributes
The species helicopter needs 2 attributes to represent the water value and its speed.
float waterValue;
float speed <- 10.0;
Predicates
The predicate are the structure that are used to define a belief, a desire or an intention.
In this model we choose to declare 3 different predicates.
predicate patrol_desire <- new_predicate("patrol") with_priority 1;
predicate water_predicate <- new_predicate("has water", true)
with_priority 3;
predicate no_water_predicate <- new_predicate("has water", false) ;
The new_predicate() tool creates a predicate. It needs a name (string type) and
it can contain a map of values, a priority (double type) or a truth value (boolean
v 1.8.0 548
GAMA v1.8.0 documentation Chapter 74. Using BDI
type). The with_priority tool add a priority to a predicate. The priority is used
as an argument when the agent has to choose between two predicates (to choose an
intention for example).
Initialization
The initialization consists in setting the attribute waterValue to 1 and to add one
desire. Three optional parameters are also set. The first desire added in the desire
base is the patrol_desire saying that the helicopter wants to patrol. The optional
parameters are specific to the BDI plug-in. You can specify the commitment of an
agent to his intentions and his plans with the variables intention_persistence and
plan_persistence that are floats between 0.0 (no commitment) and 1.0. The variable
probabilistic_choice is a boolean that enables the agent to use a probabilistic choice
(when true) or a deterministic choice (when false) when trying to find a plan or an
intention.
waterValue <-1.0;
do add_desire(patrol_desire);
intention_persistence <- 1.0;
plan_persistence <- 1.0;
probabilistic_choice <- false;
Perception
At each iteration, the helicopter has two perceptions to do. The first one is about
itself. The helicopter needs to perceive if it has water or not. If it has water, it adds
the belief corresponding belief and removes the belief that it does not have water.
And if it does not have water, that is the contrary.
perceive target:self{
if(waterValue>0){
do add_belief(water_predicate);
do remove_belief(no_water_predicate);
}
if(waterValue<=0){
do add_belief(no_water_predicate);
do remove_belief(water_predicate);
}
}
v 1.8.0 549
GAMA v1.8.0 documentation Chapter 74. Using BDI
The second perception is about the fires. Here, the fires are represented with the
species fireArea. The helicopter has a radius of perception of 10 meters. If it
perceives a fire, it will focus on the location of this fire. The focus tool create a belief
with the same name as the focus (here, “fireLocation”) and will store the value of the
focused variable (here, the variable location from the specie fireArea) with a priority
of 10 in this example. Once the fire is perceived, the helicopter removes its intention
of patrolling.
perceive target:fireArea in: 10{
focus fireLocation var:location priority:10;
ask myself{
do remove_intention(patrol_desire, true);
}
}
Rules
The agent can use rules to create desires from beliefs. In this example, the agent has
two rules. The first rule is to have a desire corresponding to the belief of a location of
a fire. It means that when the agent has the belief that there is a fire in a particular
location, it will have the desire to extinguish it. This permits to have the location
value in the desire base. The second rule is to create the desire to have water when
the agent has the belief that it not has water.
rule belief: new_predicate("fireLocation") new_desire:
get_belief_with_name("fireLocation");
rule belief: no_water_predicate new_desire: water_predicate;
Plan
Patrolling
This plan will be used when the agent has the intention to patrol.
plan patrolling intention: patrol_desire{
do wander;
}
v 1.8.0 550
GAMA v1.8.0 documentation Chapter 74. Using BDI
stopFire
This plan is executed when the agent has the intention to extinguish a fire.
plan stopFire intention: new_predicate("fireLocation") {
point target_fire <- point(get_current_intention().values["
location_value"] );
if(waterValue>0){
if (self distance_to target_fire <= 1) {
fireArea current_fire <- fireArea first_with (each.location
= target_fire);
if (current_fire != nil) {
waterValue <- waterValue - 1.0;
current_fire.size <- current_fire.size - 1;
if ( current_fire.size <= 0) {
ask current_fire {do die;}
do remove_belief(get_current_intention());
do remove_intention(get_current_intention(), true);
do add_desire(patrol_desire);
}
} else {
do remove_belief(get_current_intention());
do remove_intention(get_current_intention(), true);
do add_desire(patrol_desire);
}
} else {
do goto target: target_fire;
}
} else {
do add_subintention(get_current_intention(),water_predicate,
true);
do current_intention_on_hold();
}
}
gotoTakeWater
This plan is executed when the agent has the intention to have water.
plan gotoTakeWater intention: water_predicate {
waterArea wa <- first(waterArea);
do goto target: wa);
if (self distance_to wa <= 1) {
waterValue <- waterValue + 2.0;
}
}
v 1.8.0 551
GAMA v1.8.0 documentation Chapter 74. Using BDI
Plans can have other options. They can have a priority (with the facet priority), a
boolean condition to start (with the facet when) or a boolean condition to stop (with
the facet finished_when).
FireArea Species
species fireArea{
float size <-1.0;
aspect base {
draw circle(size) color: #red;
}
}
WaterArea Species
species waterArea{
float size <-10.0;
aspect base {
draw circle(size) color: #blue;
}
}
v 1.8.0 552
Chapter 75
Introduction to BEN
BEN (Behavior with Emotions and Norms) is an agent architecture providing social
agents with cognition, emotions, emotional contagion, personality, social relations,
and norms. This work has been done during the PhD of Mathieu Bourgais, funded
by the ANR ACTEUR.
The BEN architecture is accessible in GAMA through the use of the simple_bdi
architecture when defining agents. This page indicates the theoretical running of
BEN as well as the practicle way it has been implemented in GAMA.
This page features all the descriptions for the running of the BEN architecture. This
page is updated with the version of BEN implemented in GAMA. To get more details
on its implementation in GAMA, see operators related to BDI, BDI tutorials or
GAML References/build-in architecture/BDI.
553
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
v 1.8.0 554
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
are automatically computed (in blue) or which need to be manually defined by the
modeler (in pink). Some of these processes are mandatory (in solid line) and some
others are optional (in dotted line). This modularity enables each modeler to only
use components that seem pertinent to the studied situation without creating heavy
and useless computations.
The Activity diagram bellow shows the order in which each module and each process
is activated. The rest of this page explains in details how each process from each
module works and what is the difference between the theoretical architecture and its
implementation.
v 1.8.0 555
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
v 1.8.0 556
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
• M: the modality indicating the type of the cognitive mental state (e.g. a belief).
• PMEm: the object with which the cognitive mental state relates. It can be a
predicate, another cognitive mental state, or an emotion.
• Val: a real value which meaning depends on the modality.
• Li: a lifetime value indicating the time before the cognitive mental state is
forgotten.
A cognitive mental state with no particular value and no particular lifetime is writ-
ten Mi(PMEm). Val[Mi(PMEm)] represents the value attached to a particular
cognitive mental state and Li[Mi(PMEm)] represents its lifetime.
The cognitive part of BEN is based on the BDI paradigm [?] in which agents have
a belief base, a desire base and an intention base to store the cognitive mental
states about the world. In order to connect cognition with other social features, the
architecture outlines a total of 6 different modalities which are defined as follows:
• Belief : represents what the agent knows about the world. The value attached
to this mental state indicates the strength of the belief.
• Uncertainty: represents an uncertain information about the world. The value
attached to this mental state indicates the importance of the uncertainty.
• Desire: represents a state of the world the agent wants to achieve. The value
attached to this mental state indicates the priority of the desire.
• Intention: represents a state of the world the agent is committed to achieve.
The value attached to this mental state indicates the priority of the intention.
• Ideal: represents an information socially judged by the agent. The value
attached to this mental state indicates the praiseworthiness value of the ideal
about P. It can be positive (the ideal about P is praiseworthy) or negative (the
ideal about P is blameworthy).
• Obligation: represents a state of the world the agent has to achieve. The
value attached to this mental state indicates the priority of the obligation.
In GAML, mental states are manipulated thanks to add, remove and get actions
related to each modality: add_belief, remove_belief, get_belief, add_desire,
v 1.8.0 557
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
Emotions
In BEN, the definition of emotions is based on the OCC theory of emotions (Ortony,
90). According to this theory, an emotion is a valued answer to the appraisal of a
situation. Once again, as the agents are taken into consideration in the context of a
society and should act depending on it, the definition of an emotion needs to contain
the agent causing it. Thus, an emotion is represented by Emi(P,Ag,I,De) with the
following elements :
An emotion with any intensity and any decay is represented by Emi (P,Ag) and
an emotion caused by any agent is written {Emi(P). I[Emi(P,Ag)] stands for the
intensity of a particular emotion and De[Emi(P,Ag)] stands for its decay value.
In GAML, emotions are manipulated thanks to add_emotion, remove_emotion and
get_emotion actions and attributes of an emotion are manipulated with set and
get operators (set_intensity, set_about, set_decay, set_agent_cause, get_intensity,
get_about, get_decay, get_agent_cause)
Below is an exemple of code in GAML concerning cognitive mental states:
v 1.8.0 558
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
reflex testEmotion{
predicate a <- new_predicate("test");
do add_emotion("hope",a);
do add_emotion("joy",a,intesity1,decay1);
float c <- get_intensity(get_emotion(new_emotion("joy",a)));
}
Social relations
As people create social relations when living with other people and change their
behavior based on these relationships, the BEN architecture makes it possible to
describe social relations in order to use them in agents’ behavior. Based on the
research carried out by Svennevig (2000), a social relation is described by using a
finite set of variables. Svennevig identifies a minimal set of four variables : liking,
dominance, solidarity and familiarity. A trust variable is added to interact with the
enforcement of social norms. Therefore, in BEN, a social relation between agent i
and agent j is expressed as Ri,j(L,D,S,F,T) with the following elements:
With this definition, a social relation is not necessarily symmetric, which means
Ri,j(L,D,S,F,T) is not equal by definition to Ri,j(L,D,S,F,T). L[Ri,j] stands for the
v 1.8.0 559
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
liking value of the social relation between agent i and agent j, D[i,j] stands for its
dominance value, S[Ri,j] for its solidarity value, F[Ri,j] represents its familiarity
value and T[Ri,j] its trust value.
In GAML, social relations are manipulated with add_social_link, remove_social_link
and get_social_link actions. Each feature of a social link is accessible with set and
gt operators (set_agent, get_agent, set_liking, get_liking, set_dominance, etc.)
Below is an exemple of code to manipulates social relations in GAML:
reflex testSocialRelations{
do add_social_relation(new_social_relation(agentAlice));
do add_social_relation(new_social_relation(agentBob
,0.5,-0.3,0.2,0.1,0.8));
float a <- get_liking(get_social_relation(new_social_relation(
agentBob)));
set_dominance(get_social_relation(new_social_relation(agentBob))
,0.3);
}
In GAML, these variables are build-in attributes of agents using the simple_bdi control
architecture. They are called openness, conscientiousness, extroversion, agreeableness
v 1.8.0 560
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
and neurotism. To use this personality to automaticaly parametrize the other modules,
a modeler needs to indicate it as shown in the GAML example below:
species miner control:simple_bdi {
...
bool use_personality <- true;
float openness <- 0.1;
float conscientiousness <- 0.2;
float extroversion <- 0.3;
float agreeableness <- 0.4;
float neurotism <- 0.5;
...
}
With BEN, the agent has variables related to some of the social features. The idea
behind the BEN architecture is to connect these variables to the personality module
and in particular to the five dimensions of the OCEAN model in order to reduce
the number of parameters which need to be entered by the user. These additional
variables are:
With the cognition, the agent has two parameters representing the probability to
randomly remove the current plan or the current intention in order to check whether
there could be a better plan or a better intention in the current context. These two
values are connected to the consciousness components of the OCEAN model as it
describes the tendency of the agent to prepare its actions (with a high value) or act
impulsively (with a low value).
Probability Keeping Plans = C1/2
Probability Keeping Intentions = C1/2
For the emotional contagion, the process (presented later) requires charisma (Ch) and
emotional receptivity (R) to be defined for each agent. In BEN, charisma is related to
the capacity of expression, which is related to the extroversion of the OCEAN model,
while the emotional receptivity is related to the capacity to control the emotions,
which is expressed with the neurotism value of OCEAN.
v 1.8.0 561
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
Ch = E
R = 1-N
With the concept of norms, the agent has a value of obedience between 0 and 1, which
indicates its tendency to follow laws, obligations and norms. According to research in
psychology, which tried to explain the behavior of people participating in a recreation
of the Milgram’s experiment (Begue, 2015), obedience is linked with the notions of
consciousness and agreeableness which gives the following equation:
obedience = ((C+A)/2)1/2
With the same idea, all the parameters required by each process are linked to the
OCEAN model.
If a modeler wants to put a different value to one of these variables, he/she just need
to indicate a new value manualy. For the probability to keep the current plan and
the probability to keep the current intention, he/she also has to indicates it with a
particular boolean value, as shown in the GAML example below:
species miner control:simple_bdi {
...
bool use_personality <- true;
bool use_persistence <- true;
float plan_persistence <- 0.3;
float intention_persistence <- 0.4;
float obedience <- 0.2;
float charisma <- 0.3
float receptivity <- 0.6;
...
}
Perception
The first step of BEN is the perception of the environment. This module is used to
connect the environment to the knowledge of the agent, transforming information
from the world into cognitive mental states, emotions or social links but also used to
apply sanctions during the enforcement of norms from other agents.
Below is an example of code to define a perception in GAML:
perceive target:fireArea in: 10{
...
v 1.8.0 562
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
}
The first process in this perception consists in adding beliefs about the world.
During this phase, information from the environment is transformed into predicates
which are included in beliefs or uncertainties and then added to the agent’s knowledge
bases. This process enables the agent to update its knowledge about the world.
From the modeler’s point of view, it is only necessary to specify which information
is transformed into which predicate. The addition of a belief BeliefA(X) triggers
multiple processes :
In GAML, the focus statement eases the use of this process. Below is an example
that adds a belief and an uncertainty with the focus statement during a perception:
perceive target:fireArea in: 10{
focus id:"fireLocation" var:location strength:10.0;
//is equivalent to ask myself {do add_belief(new_predicate("
fireLocation",["location_value"::myself.location],10.0);}
focus id:"hazardLocation" var:location strength:1.0 is_uncertain:
true;
//is equivalent to ask myself {do add_uncertainty(new_predicate
("hazardLocation",["location_value"::myself.location],1.0);}
}
The emotional contagion enables the agent to update its emotions according to
the emotions of other agents perceived. The modeler has to indicate the emotion
triggering the contagion, the emotion created in the perceiving agent and the threshold
of this contagion; the charisma (Ch) and receptivity (R) values are automatically
computed as explained previously. The contagion from agent i to agent j occurs
only if Chi x Rj is superior or equal to the threshold, which value is 0.25 by default.
Then, the presence of the trigger emotion in the perceived agent is checked in order
to create the emotion indicated.
The intensity and decay value of the emotion acquired by contagion are automaticaly
computed.
v 1.8.0 563
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
During the perception, the agent has the possibility of creating social relations with
other perceived agents. The modeler indicates the initial value for each component of
the social link, as explained previously. By default, a neutral relation is created, with
each value of the link at 0.0. Social relations can also be defined before the start of
the simulation, to indicate that an agent has links with other agents at the start of
the simulation, like links with friends or family members.
In GAML, the socialize statement help creating dynamicaly new social relations, as
shown below:
perceive target:otherHumanAgents in: 10{
socialize;
//creates a neutral relation
socialize dominance: -0.8 familiarity:0.2 when: isBoss;
//example of a social link with precise values for some of its
dimensions in a certain context
}
Finally, the agent may apply sanctions through the norm enforcement of other
agents perceived. The modeler needs to indicate which modality is enforced and the
sanction and reward used in the process. Then, the agent checks if the norm, the
obligation, or the law, is violated, applied or not activated by the perceived agent.
v 1.8.0 564
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
Notions of norms laws and obligations and how they work are explained later in this
ocument.
A norm is considered violated when its context is verified, and yet the agent chose
another norm or another plan to execute because it decided to disobey. A law is
considered violated when its context is verified, but the agent disobeyed it, not
creating the corresponding obligation. Finally, an obligation is considered violated if
the agent did not execute the corresponding norm because it chose to disobey.
Below is an example of how to define an enforcement in GAML:
species miner skills: [moving] control:simple_bdi {
...
perceive target:miner in:viewdist {
myself.agent_perceived<-self;
enforcement norm:"share_information" sanction:"sanctionToNorm"
reward:"rewardToNorm";
}
sanction sanctionToNorm{
do change_liking(agent_perceived,-0.1);
}
sanction rewardToNorm{
do change_liking(agent_perceived,0.1);
}
}
Managing knowledges
The second step of the architecture, corresponding to the module number 2, consists
in managing the agent’s knowledge. This means updating the knowledge bases
according to the latest perceptions, adding new desires, new obligations, new emotions
or updating social relations, for example.
Modelers have to use inference rules for this purpose. Theses rules are triggered
by a new belief, a new uncertainty or a new emotion, in a certain context, and may
add or remove any cognitive mental state or emotion indicated by the user. Using
multiple inference rules helps the agent to adapt its mind to the situation perceived
without removing all its older cognitive mental states or emotions, thus enabling the
creation of a cognitive behavior. These inference rules enable to link manually the
v 1.8.0 565
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
}
Using the same idea, modelers can define laws. These laws enable the creation
of obligations in a given context based on the newest beliefs created by the agent
through its perception or its inference rules. The modelers also needs to indicate
an obedience threshold and if the agent’s obedience value is below that threshold,
the law is violated. If the law is activated, the obligation is added to the agent’s
cognitive mental state bases. The definition of laws makes it possible to create a
behavior based on obligations imposed upon the agent.
Below is an example of the definition of a law statement in GAML:
law belief: new_predicate("testA") new_obligation:new_predicate("testB"
) threshold:thresholdLaw;
Emotional engine
BEN enables the agent to get emotions about its cognitive mental states. This
addition of emotions is based on the OCC model (Ortony, 1990) and its logical
formalism (Adam, 2007), which has been proposed to integrate the OCC model in a
BDI formalism.
According to the OCC theory, emotions can be split into three groups: emotions
linked to events, emotions linked to people and actions performed by people, and
emotions linked to objects. In BEN, as the focus is on relations between social agents,
only the first two groups of emotions (emotions linked to events and people) are
considered.
v 1.8.0 566
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
The twenty emotions defined in this paper can be divided into seven groups depend-
ing on their relations with mental states: emotions about beliefs, emotions about
uncertainties, combined emotions about uncertainties, emotions about other agents
with a positive liking value, emotions about other agents with a negative liking value,
emotions about ideals and combined emotions about ideals. All the initial intensities
and decay value are computed using the OCEAN model and the value attached to
the concerned mental states.
The emotions about beliefs are joy and sadness and are expressed this way:
Their initial intensity is computed according to the following equation with N the
neurotism component from the OCEAN model:
I[Emi(P)] = V[Beliefi(P)] x V[Desirei(P)] x (1+(0,5-N))
The emotions about uncertainties are fear and hope and are defined this way:
Their initial intensity is computed according to the following equation with Em’i(P)
the emotion of fear/hope.
I[Emi(P)] = V[Beliefi(P)] x I[Em’i(P)]
On top of that, according to the logical formalism (Adam, 2007), four inference rules
are triggered by these emotions:
v 1.8.0 567
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
• The creation of fear confirmed or the creation of relief will replace the
emotion of fear.
• The creation of satisfaction or the creation of disappointment will replace
a hope emotion.
• The creation of satisfaction or relief leads to the creation of joy.
• The creation of disappointment or fear confirmed leads to the creation of
sadness.
The emotions about other agents with a positive liking value are emotions related to
emotions of other agents which are in a the social relation base with a positive liking
value on that link. They are the emotions called “happy for” and “sorry for” which
are defined this way :
Their initial intensity is computed according to the following equation with A the
agreeableness value from the OCEAN model.
I[Emi(P)] = I[Emj(P)] x L[Ri,j] x (1-(0,5-A))
Emotions about other agents with a negative liking value are close to the previous
definitions, however, they are related to the emotions of other agents which are in
the social relation base with a negative liking value. These emotions are resentment
and gloating and have the following definition:
Their initial intensity is computed according to the following equation. This equation
can be seen as the inverse of Equation (??), and means that the intensity of resentment
or gloating is greater if the agent has a low level of agreeableness contrary to the
intensity of “happy for” and “sorry for”.
I[Emi(P)] = I[Emj(P)] x |L[Ri,j]| x (1+(0,5-A))
Emotions about ideals are related to the agent’s ideal base which contains, at the start
of the simulation, all the actions about which the agent has a praiseworthiness value
to give. These ideals can be praiseworthy (their praiseworthiness value is positive)
or blameworthy (their praiseworthiness value is negative). The emotions coming
from these ideals are pride, shame, admiration and reproach and have the following
definition:
v 1.8.0 568
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
Their initial intensity is computed according to the following equation with O the
openness value from the OCEAN model:
I[Emi(P)] = V[Beliefi(P)] x |V[Ideali(P)]| x (1+(0,5-O))
Finally, combined emotions about ideals are emotions built upon pride, shame,
admiration and reproach. They appear when joy or sadness appear with an emotion
about ideals. They are gratification, remorse, gratitude and anger which are defined
as follows:
Their initial intensity is computed according to the following equation with Em’i(P)
the emotion about ideals and Em"i(P) the emotion about beliefs.
I[Emi(P)] = I[Em’i(P)] x I[Em"i(P)]
In order to keep the initial intensity of each emotion between 0 and 1, each equation
is truncated between 0 an 1 if necessary.
The initial decay value for each of these twenty emotions is computed according to
the same equation with Deltat a time step which enables to define that an emotion
does not last more than a given time:
De[Emi(P)] = N x I[Emi(P)] x Deltat
To use this automatic computation of emotion, a modeler need to activate it as shown
in the GAML example below :
species miner control:simple_bdi {
...
bool use_emotions_architecture <- true;
...
}
v 1.8.0 569
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
Social Engine
When an agent already known is perceived (i.e. there is already a social link with it),
the social relation with this agent is updated automatically by BEN. This update is
based on the work of (Ochs, 2009) and takes the agent’s cognitive mental states and
emotions into account. In this section, the automatic update of each variable
of a social link Ri,j(L,D,S,F,T) by the architecture is described in details; the trust
variable of the link is however not updated automatically.
• Liking: according to (Ortony, 1991), the degree of liking between two agents
depends on the valence (positive or negative) of the emotions induced by the
corresponding agent. In the emotional model of the architecture, joy and hope
are considered as positive emotions (satisfaction and relief automatically raise
joy with the emotional engine) while sadness and fear are considered as negative
emotions (fear confirmed and disappointment automatically raise sadness with
the emotional engine). So, if an agent i has a positive (resp. negative) emotion
caused by an agent j, this will increase (resp. decrease) the value of appreciation
in the social link from i concerning j.
Moreover, research has shown that the degree of liking is influenced by the solidarity
value [?]. This may be explained by the fact that people tend to appreciate people
similar to them.
The computation formula is described with the following equation with mPos the mean
value of all positive emotions caused by agent j, mNeg the mean value of all negative
emotions caused by agent j and aL a coefficient depending of the agent’s personality,
indicating the importance of emotions in the process, and which is described below.
L[Ri,j]=L[Ri,j]+|L[Ri,j]|(1-|L[Ri,j]|)S[Ri,j] + aL (1-|L[Ri,j]|)(mPos-mNeg)
aL = 1-N
The computation formula is described by the following equation with mSE the mean
value of all negative emotions caused by agent i to agent j, mOE the mean value of
v 1.8.0 570
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
On top of that, negative emotions tend to decrease the value of solidarity between
two people. The computation formula is described by the following equation with sim
the number of cognitive mental states similar between agent i and agent j, opp the
number of opposite cognitive mental states between agent i and agent j, NbKnow the
number of cognitive mental states in common between agent i and agent j, mNeg the
mean value of all negative emotions caused by agent j, aS1 a coefficient depending of
the agent’s personality, indicating the importance of similarities and oppositions in
the process, and aS2 a coefficient depending of the agent’s personality, indicating the
importance of emotions in the process.
S[Ri,j]=S[Ri,j] + S[Ri,j] x (1-S[Ri,j]) x (aS1 (sim-opp)/(NbKnow) - aS2 mNeg))
aS1 = 1-O
aS2 = 1-N
F[Ri,j]=F[Ri,j] x (1+L[Ri,j])
The trust value is not evolving automatically in BEN, as there is no clear and
automatic link with cognition or emotions. However, this value can evolve manually,
v 1.8.0 571
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
especially with sanctions and rewards to social norms where the modeler can indicate
a modification of the trust value during the enforcement process.
To use this automatic update of social relations, a modeler need to activate it as
shown in the GAML example below :
species miner control:simple_bdi {
...
bool use_social_architecture <- true;
...
}
Making Decision
The third part of the architecture is the only one mandatory as it is where the agent
makes a decision. A cognitive engine can be coupled with a normative engine to chose
an intention and a plan to execute. The complete engine is summed up in the figure
below:
The decision-making process can be divided into seven steps:
• Step 1: the engine checks the current intention. If it is still valid, the intention
is kept so the agent may continue to carry out its current plan.
• Step 2: the engine checks if the current plan/norm is still usable or not,
depending on its context.
• Step 3: the engine checks if the agent obeys an obligation taken from the
obligations corresponding to a norm with a valid context in the current situation
and with a threshold level lower than the agent’s obedience value as computed
in Section 4.1.
• Step 4: the obligation with the highest priority is taken as the current intention.
• Step 5: the desire with the highest priority is taken as the current intention.
• Step 6: the plan or norm with the highest priority is selected as the current
plan/norm, among the plans or norms corresponding to the current intention
with a valid context.
• Step 7: the behavior associated with the current plan/norm is executed.
v 1.8.0 572
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
v 1.8.0 573
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
Defining plans
The modeler needs to define action plans wich are used by the cognitive engine, as
explained earlier. These plans are a set of behaviors executed in a certain context
in response to an intention. In BEN, a plan owned by agent i is represented by
Pli(Int,Cont,Pr,B) with:
The context of a plan is a particular state of the world in which this plan should be
considered by the agent making a decision. This feature enables to define multiple
plans answering the same intention, but activated in various contexts.
Below is an example for the definition of two plans answering the same intention in
different contexts in GAML:
species miner control:simple_bdi {
...
plan evacuationFast intention: in_shelter emotion: fearConfirmed
priority:2 {
color <- #yellow;
speed <- 60 #km/#h;
if (target = nil or noTarget) {
target <- (shelter with_min_of (each.location distance_to
location)).location;
noTarget <- false;
v 1.8.0 574
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
}
else {
do goto target: target on: road_network move_weights:
current_weights recompute_path: false;
if (target = location) {
do die;
}
}
}
Defining norms
A normative engine may be used within the cognitive engine, as it has been explained
above. This normative engine means choosing an obligation as the current intention
and selecting a set of actions to answer this intention. Also, the concept of social
norms is modeled as a set of action answering an intention, which an agent could
disobey.
In BEN, this concept of a behavior which may be disobeyed is formally represented
by a norm possessed by agent i Noi(Int,Cont,Ob,Pr,B,Vi) with:
v 1.8.0 575
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
v 1.8.0 576
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
do remove_intention(share_information, true);
}
...
}
Dynamic knowledge
The final part of the architecture is used to create a temporal dynamic to the agent’s
behavior, useful in a simulation context. To do so, this module automatically degrades
mental states and emotions and updates the status of each norm.
The degradation of mental states consists in reducing their lifetime. When the
lifetime is null, the mental state is removed from its base. The degradation of
emotions consists in reducing the intensity of each emotion stored by its decay value.
When the intensity of an emotion is null, the emotion is removed from the emotional
base.
In GAML, if a mental state has a lifetime value or if an emotion has an intensity and
a decay value, this degradation process is done automatically.
Finally, the status of each norm is updated to indicate if the norm was activated
or not (if the context was right or wrong) and if it was violated or not (the norm was
activated but the agent disobeyed it). Also, a norm can be violated for a certain time
which is updated and if it becomes null, the norm is not violated anymore.
v 1.8.0 577
GAMA v1.8.0 documentation Chapter 75. Using BEN (simple_bdi)
These last steps enable the agent’s behavior’s components to automatically evolve
through time, leading the agents to forget a piece of knowledge after a certain amount
of time, creating dynamics in their behavior.
Conclusion
The BEN architecture is already implemented in GAMA and may be accessed by
adding the simple_bdi control architecture to the definition of a species.
A tutorial may be found with the BDI Tutorial.
v 1.8.0 578
Chapter 76
This page aims at presenting how to use the advanced driving skill in models.
Table of contents
579
GAMA v1.8.0 documentation Chapter 76. Advanced Driving Skill
It provides as well the road agents with one read only variable:$
• agents_on: list of list (of driver agents); for each lane, the list of driver agents
on the road.
v 1.8.0 580
GAMA v1.8.0 documentation Chapter 76. Advanced Driving Skill
The roadNode skill provides the road agents with several variables that will define
the road properties:
• roads_in: list of road agents; the list of road agents that have this node for
target node.
• roads_out: list of road agents; the list of road agents that have this node for
source node.
• stop: list of list of road agents; list of stop signals, and for each stop signal,
the list of concerned roads.**
It provides as well the road agents with one read only variable:
• block: map: key: driver agent, value: list of road agents; the list of driver
agents blocking the node, and for each agent, the list of concerned roads.
• final_target: point; final location that the agent wants to reach (its goal).
• vehicle_length: float; length of the vehicle.
• max_acceleration: float; maximal acceleration of the vehicle.
• max_speed: float; maximal speed of the vehicle.
• right_side_driving: boolean; do drivers drive on the right side of the road?
• speed_coef : float; coefficient that defines if the driver will try to drive above
or below the speed limits.
• security_distance_coeff: float; coefficient for the security distance. The
security distance will depend on the driver speed and on this coefficient.
• proba_lane_change_up: float; probability to change lane to a upper lane
if necessary (and if possible).
v 1.8.0 581
GAMA v1.8.0 documentation Chapter 76. Advanced Driving Skill
It provides as well the driver agents with several read only variables:
• speed: float; speed expected according to the road max_value, the car
properties, the personality of the driver and its real_speed.
• real_speed: float; real speed of the car (that takes into account the other
drivers and the traffic signals).
• current_path: path (list of roads to follow); the path that the agent is
currently following.
• current_target: point; the next target to reach (sub-goal). It corresponds to
a node.
• targets: list of points; list of locations (sub-goals) to reach the final target.
• current_index: integer; the index of the current goal the agent has to reach.
• on_linked_road: boolean; is the agent on the linked road?
Of course, the values of these variables can be modified at any time during the
simulation. For example, the probability to take a reverse road (proba_use_-
linked_road) can be increased if the driver is stucked for several minutes behind a
slow vehicle.
In addition, the advanced driving skill provides the driver agents with several actions:
v 1.8.0 582
GAMA v1.8.0 documentation Chapter 76. Advanced Driving Skill
the drive action works as follow: while the agent has the time to move (remaining_-
time > 0), it first defines the speed expected. This speed is computed from the
max_speed of the road, the current real_speed, the max_speed, the max_-
acceleration and the speed_coef of the driver (see Equation 1).
Then, the agent moves toward the current target and compute the remaining time.
During the movement, the agents can change lanes (see below). If the agent reaches
its final target, it stops; if it reaches its current target (that is not the final target), it
tests if it can cross the intersection to reach the next road of the current path. If it
is possible, it defines its new target (target node of the next road) and continues to
move.
images/drive_action.png
The function that defines if the agent crosses or not the intersection to continue to
move works as follow: first, it tests if the road is blocked by a driver at the intersection
(if the road is blocked, the agent does not cross the intersection). Then, if there is
at least one stop signal at the intersection (traffic signal, stop sign. . . ), for each of
these signals, the agent tests its probability to respect or not the signal (note that
the agent has a specific probability to respect each type of signals). If there is no
stopping signal or if the agent does not respect it, the agent checks if there is at least
one vehicle coming from a right (or left if the agent drives on the left side) road at a
distance lower than its security distance. If there is one, it tests its probability to
respect this priority. If there is no vehicle from the right roads or if it chooses to do
not respect the right priority, it tests if it is possible to cross the intersection to its
target road without blocking the intersection (i.e. if there is enough space in the target
road). If it can cross the intersection, it crosses it; otherwise, it tests its probability
to block the node: if the agent decides nevertheless to cross the intersection, then
the perpendicular roads will be blocked at the intersection level (these roads will be
unblocked when the agent is going to move).
images/stop_at_intersection.png
Concerning the movement of the driver agents on the current road, the agent moves
from a section of the road (i.e. segment composing the polyline) to another section
according to the maximal distance that the agent can moves (that will depend on the
remaining time). For each road section, the agent first computes the maximal distance
it can travel according the remaining time and its speed. Then, the agent computes
v 1.8.0 583
GAMA v1.8.0 documentation Chapter 76. Advanced Driving Skill
its security distance according to its speed and its security_distance_coeff. While
its remaining distance is not null, the agent computes the maximal distance it can
travel (and the corresponding lane), then it moves according to this distance (and
update its current lane if necessary). If the agent is not blocked by another vehicle
and can reach the end of the road section, it updates its current road section and
continues to move.
images/follow_driving.png
The computation of the maximal distance an agent can move on a road section
consists in computing for each possible lane the maximal distance the agent can move.
First, if there is a lower lane, the agent tests the probability to change its lane to
a lower one. If it decides to test the lower lane, the agent computes the distance
to the next vehicle on this lane and memorizes it. If this distance corresponds to
the maximal distance it can travel, it chooses this lane; otherwise it computes the
distance to the next vehicle on its current lane and memorizes it if it is higher than
the current memorized maximal distance. Then if the memorized distance is lower
than the maximal distance the agent can travel and if there is an upper lane, the
agents tests the probability to change its lane to a upper one. If it decides to test
the upper lane, the agent computes the distance to the next vehicle on this lane and
memorizes it if it is higher than the current memorized maximal distance. At last,
if the memorized distance is still lower than the maximal distance it can travel, if
the agent is on the highest lane and if there is a reverse road, the agent tests the
probability to use the reverse road (linked road). If it decides to use the reverse road,
the agent computes the distance to the next vehicle on the lane 0 of this road and
memorizes the distance if it is higher than the current memorized maximal distance.
images/define_max_dist.png
Application example
We propose a simple model to illustrate the driving skill. We define a driver species.
When a driver agent reaches its destination, it just chooses a new random final target.
In the same way, we did not define any specific behavior to avoid traffic jam for the
driver agents: once they compute their path (all the driver agents use for that the
same road graph with the same weights), they never re-compute it even if they are
stucked in a traffic jam. Concerning the traffic signals, we just consider the traffic
lights (without any pre-processing: we consider the raw OSM data). One step of the
simulation represents 1 second. At last, in order to clarify the explanation of the
v 1.8.0 584
GAMA v1.8.0 documentation Chapter 76. Advanced Driving Skill
model, we chose to do not present the parts of the GAML code that concern the
simulation visualization.
images//sim_snapshot.png
The following code shows the definition of species to represent the road infrastructure:
species road skills: [skill_road] {
string oneway;
}
In order to use our driving skill, we just have to add the skill_road_node to the
node species and the skill_road to the road species. In addition, we added to the
road species a variable called oneway that will be initialized from the OSM data
and that represents the traffic direction (see the OSM map features for more details).
Concerning the node, we defined 3 new attributes:
In addition, we defined for the node species a reflex (behavior) called dynamic that
will be activated only for traffic light nodes and that will increment the counter
value. If this counter is higher than time_to_change, this variable is set to 0, and
the node change the value of the stop variable: if the traffic light was green (i.e. there
is no road concerns by this stop sign), the list of block roads is set by all the roads
v 1.8.0 585
GAMA v1.8.0 documentation Chapter 76. Advanced Driving Skill
that enter the node; if the traffic light was red (i.e. there is at least one road concerns
by this stop sign), the list of block roads is set to an empty list.
The following code shows the definition of driver species:
In order to use our driving plug-in, we just have to add the advanced_driving to
the driver species. For this species, we defined two reflexes:
• time_to_go: activated when the agent has no final target. In this reflex, the
agent will randomly choose one of the nodes as its final target, and computed
the path to reach this target using the
• road_network graph. Note that it will have been possible to take into account
the knowledge that each agent has concerning the road network by defining a
new variable of type map (dictionary) containing for each road a given weight
that will reflect the driver knowledge concerning the network (for example, the
known traffic jams, its favorite roads. . . .) and to use this map for the path
computation.
• move: activated when the agent has a final target. In this reflex, the agent will
drive in direction of its final target.
v 1.8.0 586
GAMA v1.8.0 documentation Chapter 76. Advanced Driving Skill
match "no" {
create road {
lanes <- myself.lanes;
shape <- polyline(reverse
(myself.shape.points));
maxspeed <- myself.maxspeed;
linked_road <- myself;
myself.linked_road <- self;
}
}
match "-1" {
shape <- polyline(reverse(shape.points));
}
}
}
}
map general_speed_map <- road as_map
(each::(each.shape.perimeter/(each.maxspeed)));
In this code, we create the node agents from the node shapefile (while reading the
attributes contained in the shapefile), then we create in the same way the road agents.
However, for the road agents, we use the oneway variable to define if we should
or not reverse their geometry (oneway = “-1”) or create a reverse road (oneway
= “no”). Then, from the road and node agents, we create a graph (while taking
into account the maxspeed of the road for the weights of the edges). This graph is
v 1.8.0 587
GAMA v1.8.0 documentation Chapter 76. Advanced Driving Skill
the one that will be used by all agents to compute their path to their final target.
Finally, we create 1000 driver agents. At initialization, they are randomly placed
on the nodes; their vehicle has a length of 3m; the maximal acceleration of their
vehicle is randomly drawn between 0.5 and 1; the speed coefficient of the driver is
randomly drawn between 0.8 and 1.2; they are driving on the right side of the road;
their probability of changing lane for a upper lane is randomly drawn between 0 and
1.0; their probability of changing lane for a lower lane is randomly drawn between
0.5 and 1.0; the security distance coefficient is randomly drawn between 1 and 3;
their probability to respect priorities is randomly drawn between 0.8 and 1; their
probability to respect light signal is randomly drawn between 0.998 and 1; their
probability to block a node is randomly drawn between 0 and 0.003; their probability
to use the reverse road is randomly drawn between 0 and 0.01;
The complete code of the model with the data can be found here
v 1.8.0 588
Chapter 77
Manipulate Dates
• cycle (int - not modifiable): the current simulation step - this variable is
incremented by 1 at each simulation step
• step (float - can be modified): the duration of a simulation step (in seconds).
By default the duration is one second.
• time (float - not modifiable): the current time spent since the beginning of the
simulation - this variable is computed at each simulation step by: time = cycle
* step.
589
GAMA v1.8.0 documentation Chapter 77. Manipulate Dates
The value of the cycle and time variables are shown in the top left (green rectangle) of
the simulation interface. Clicking on the green rectangle allows to display either the
number cycles or the time variable. Concerning this variable, it is presented following
a years - month - days - hours - minutes - seconds format. In this presentation, every
months are considered as being composed of 30 days (the different number of days of
months are not taken into account).
Concerning the step facet, the variable can be modified by the modeler. A classic
way of doing it consists in reediting the variable in the global section:
global {
float step <- 1 #hour;
}
In this example, each simulation step will represent 1 hour. This time will be taken
into account for all actions based on time (e.g. moving actions).
Note that the value of the step variable should be given in seconds. To facilitate the
definition of the step value and of all expressions based on time, GAMA provides
different built-in constant variables accessible with the “#” symbol:
• #s : second - 1 second
• #mn : minute - 60 seconds
• #hour : hour - 60 minutes - 3600 seconds
• #day : day - 24 hours - 86400 seconds
• #month : month - 30 days - 2592000 seconds
• #year : year - 12 month - 3.1104E7
v 1.8.0 590
GAMA v1.8.0 documentation Chapter 77. Manipulate Dates
Several ways can be used to define a date. The simplest consists in using a list of
int values: [year,month of the year,day of the month, hour of the day, minute of the
hour, second of the minute]
date my_date <- date([2010,3,23,17,30,10]); // the 23th of March 2010,
at 17:30:10
Note that the current date can be access through the #now built-in variable (variable
of type date).
In addition, GAMA provides different useful operators working on dates. For instance,
it is possible to compute the duration in seconds between 2 dates using the “-” operator.
The result is given in seconds:
float d <- starting_date - my_date;
At last, it is possible to add or subtract a duration (in years, months, weeks, days,
hours, minutes, seconds) to a date:
write "my_date add_years 1: " + (my_date add_years 1);
write "my_date add_months 1: " + (my_date add_months 1);
write "my_date add_weeks 1: " + (my_date add_weeks 1);
write "my_date add_days 1: " + (my_date add_days 1);
write "my_date add_hours 1: " + (my_date add_hours 1);
write "my_date add_minutes 1: " + (my_date add_minutes 1);
write "my_date add_seconds 1: " + (my_date add_seconds 1);
v 1.8.0 591
GAMA v1.8.0 documentation Chapter 77. Manipulate Dates
By default, these variables are nil. Defining a value of the starting_date allows to
change the normal time management of the simulation by a more realistic one (using
calendar):
global {
date starting_date <- date([1979,12,17,19,45,10]);
}
v 1.8.0 592
Chapter 78
Implementing light
When using opengl display, GAMA provides you the possibility to manipulate one or
several lights, making your display more realistic. Most of the following screenshots
will be taken with the following short example gaml :
model test_light
grid cells {
aspect base {
draw square(1) at:{grid_x,grid_y} color:#white;
}
}
experiment my_experiment type:gui{
output {
display my_display type:opengl background:#darkblue {
species cells aspect:base;
graphics "my_layer" {
draw square(100) color:#white at:{50,50};
draw cube(5) color:#lightgrey at:{50,30};
draw cube(5) color:#lightgrey at:{30,35};
draw cube(5) color:#lightgrey at:{60,35};
draw sphere(5) color:#lightgrey at:{10,10,2.5};
draw sphere(5) color:#lightgrey at:{20,30,2.5};
draw sphere(5) color:#lightgrey at:{40,30,2.5};
draw sphere(5) color:#lightgrey at:{40,60,2.5};
draw cone3D(5,5) color:#lightgrey at:{55,10,0};
draw cylinder(5,5) color:#lightgrey at:{10,60,0};
}
}
}
593
GAMA v1.8.0 documentation Chapter 78. Implementing light
}
Index
• Light generalities
• Default light
• Custom lights
Light generalities
Before going deep into the code, here is a quick explanation about how light works
in opengl. First of all, you need to know that there are 3 types of lights you can
manipulate : the ambient light, the diffuse light and the specular light. Each
“light” in opengl is in fact composed of those 3 types of lights.
Ambient light
The ambient light is the light of your world without any lighting. If a face of a
cube is not stricken by the light rays for instance, this face will appear totally black
if there is no ambient light. To make your world more realistic, it is better to have
an ambient light. An ambient light has then no position or direction. It is equally
distributed to all the objects of your scene.
Here is an example of our GAML scene using only ambient light (color red) :
Diffuse light
The diffuse light can be seen as the light rays : if a face of a cube is stricken by the
diffuse light, it will take the color of this diffuse light. You have to know that the
more perpendicular the face of your object will be to the light ray, the more lightened
the face will be.
A diffuse light has then a direction. It can have also a position. Your have 2 categories
of diffuse light : the positional lights, and the directional lights.
v 1.8.0 594
GAMA v1.8.0 documentation Chapter 78. Implementing light
Positional lights
Those lights have a position in your world. It is the case of point lights and spot
lights.
• Point lights
Points lights can be seen as a candle in your world, diffusing the light equally in all
the direction.
Here is an example of our GAML scene using only diffuse light, with a point light
(color red, the light source is displayed as a red sphere) :
• Spot lights
Spot lights can be seen as a torch light in your world. It needs a position, and also a
direction and an angle.
Here is an example of our GAML scene using only diffusion light, with a spot light
(color red, the light source is displayed as a red cone) :
Positional lights, as they have a position, can also have an attenuation according
to the distance between the light source and the object. The value of positional
lights are computed with the following formula : diffuse_light = diffuse_light * ( 1
v 1.8.0 595
GAMA v1.8.0 documentation Chapter 78. Implementing light
v 1.8.0 596
GAMA v1.8.0 documentation Chapter 78. Implementing light
Here is an example of our GAML scene using only diffusion light, with a point light
with linear attenuation (color red, the light source is displayed as a red sphere):
Directional lights
Directional lights have no real “position” : they only have a direction. A directional
light will strike all the objects of your world with the same direction. An example of
directional light you have in the real world would be the light of the sun : the sun
is so far away from us that you can consider that the rays have the same direction
and the same intensity wherever they strike. Since there is no position for directional
lights, there is no attenuation either.
Here is an example of our GAML scene using only diffusion light, with a directional
light (color red) :
v 1.8.0 597
GAMA v1.8.0 documentation Chapter 78. Implementing light
Specular light
This is a more advanced concept, giving an aspect a little bit “shinny” to the objects
stricken by the specular light. It is used to simulate the interaction between the
light and a special material (ex : wood, steel, rubber. . . ). This specular light is not
implemented yet in gama, only the two others are.
Default light
In your opengl display, without specifying any light, you will have only one light,
with those following properties :
Those values have been chosen in order to have the same visual effect in both opengl
and java2D displays, when you display 2D objects, and also to have a nice “3D effect”
when using the opengl displays. We chose the following setting by default:
v 1.8.0 598
GAMA v1.8.0 documentation Chapter 78. Implementing light
Custom lights
In your opengl display, you can create up to 8 lights, giving them the properties you
want.
Ambient light
In order to keep it simple, the ambient light can be set directly when you are declaring
your display, through the facet ambient_light. You will have one only ambient light.
experiment my_experiment type:gui {
output {
display "my_display" type:opengl ambient_light:100 {
}
}
}
Note for developers : Note that this ambient light is set to the GL_LIGHT0. This
GL_LIGHT0 only contains an ambient light, and no either diffuse nor specular light.
Diffuse light
In order to add lights, or modifying the existing lights, you can use the statement
light, inside your display scope :
v 1.8.0 599
GAMA v1.8.0 documentation Chapter 78. Implementing light
experiment my_experiment type:gui {
output {
display "my_display" type:opengl {
light id:0;
}
}
}
This statement has just one non-optional facet: the facet “id”. Through this facet, you
can specify which light you want. You can control 7 lights, through an integer value
between 1 and 7. Once you are manipulating a light through the light statement,
the light is turned on. To switch off the light, you have to add the facet active, and
turn it to false. The light you are declaring through the light statement is in fact a
“diffuse” light. You can specify the color of the diffuse light through the facet color
(by default, the color will be turned to white). An other very important facet is the
type facet. This facet accepts a value among direction, point and spot.
A direction light, as explained in the first part, is a light without any position. Instead
of the facet position, you will use the facet direction, giving a 3D vector.
Example of implementation:
light id:1 type:direction direction:{1,1,1} color:rgb(255,0,0);
A point light will need a facet position, in order to give the position of the light
source.
Example of implementation of a basic point light:
light id:1 type:point position:{10,20,10} color:rgb(255,0,0);
You can add, if you want, a custom attenuation of the light, through the facets
linear_attenuation or quadratic_attenuation.
v 1.8.0 600
GAMA v1.8.0 documentation Chapter 78. Implementing light
light id:1 type:point position:{10,20,10} color:rgb(255,0,0)
linear_attenuation:0.1;
A spot light will need the facet position (a spot light is a positionnal light) and the
facet direction. A spot light will also need a special facet spot_angle to determine
the angle of the spot (by default, this value is set to 45 degree).
Example of implementation of a basic spot light:
light id:1 type:spot position:{0,0,10} direction:{1,1,1} color:rgb
(255,0,0) spot_angle:20;
Same as for point light, you can specify an attenuation for a spot light.
Example of implementation of a spot light with attenuation :
light id:1 type:spot position:{0,0,10} direction:{1,1,1} color:rgb
(255,0,0) spot_angle:20;
Note that when you are working with lights, you can display your lights through the
facet draw light to help you implementing your model. The three types of lights
are displayed differently:
• The point light is represented by a sphere with the color of the diffuse light
you specified, in the position of your light source.
• The spot light is represented by a cone with the color of the diffuse light you
specified, in the position of your light source, the orientation of your light source.
The size of the base of the cone will depend of the angle you specified.
• The direction light, as it has no real position, is represented with arrows a bit
above the world, with the direction of your direction light, and the color of the
diffuse light you specified.
Note for developers: Note that, since the GL_LIGHT0 is already reserved for the
ambient light (only !), all the other lights (from 1 to 7) are the lights from GL_LIGHT1
to GL_LIGHT7.
v 1.8.0 601
GAMA v1.8.0 documentation Chapter 78. Implementing light
v 1.8.0 602
Chapter 79
Using Comodel
Introduction
Example of a Comodel
603
GAMA v1.8.0 documentation Chapter 79. Using Comodel
to be completed. . .
The GAML language has been evolve by extend the import section. The old importa-
tion tell the compiler to merge all imported elements into as one model, but the new
one allows modellers to keep the elements come from imported models separately
with the caller model.
Defining a micro-model
v 1.8.0 604
GAMA v1.8.0 documentation Chapter 79. Using Comodel
Instantiate a micro-model
After the importation and giving an identifier, micro-model must be explicitly instan-
tiated. It could be done by create statement.
create <micro-model identifier> . <experiment name> [optional parameter
];
A micro-model can be control as the normal agent by asking the correspond identifier,
and also be destroy by the ‘o die’ statement. As fact, it can be recreate any time we
need.
ask (<micro-model identifier> . <experiment name> at <number> ) .
simulation {
...
}
Visualize micro-model
The micro-model species could display in comodel with the support of agent layer
agents "name of layer" value: (<micro-model> . <experiment name> at <
number>).<get List of agents>;
v 1.8.0 605
GAMA v1.8.0 documentation Chapter 79. Using Comodel
More details
Toy Models/Evacuation/models/continuous_move.gaml
v 1.8.0 606
GAMA v1.8.0 documentation Chapter 79. Using Comodel
v 1.8.0 607
GAMA v1.8.0 documentation Chapter 79. Using Comodel
Simulation results:
v 1.8.0 608
Chapter 80
Last version of GAMA has introduced new features to save the state of a simulation
at a given simulation cycle. This has two main applications:
Save a simulation
experiment saveSimu type: gui {
output {
display main_display {
species road aspect: geom;
species people aspect: base;
}
}
}
609
GAMA v1.8.0 documentation Chapter 80. Save and Restore simulations
Restore a simulation
experiment reloadSavedSimuOnly type: gui {
action _init_ {
create simulation from: saved_simulation_file("saveSimu.gsim");
}
output {
display main_display {
species road aspect: geom;
species people aspect: base;
}
}
}
v 1.8.0 610
Chapter 81
Using network
Introduction
GAMA provides features to allow agents to communicate with other agents (and
other applications) through network and to exchange messages of various types (from
simple number to agents). To this purpose, the network skill should be used on
agents intending to use these capabilities.
Notice that in this communication, roles are asymetric: the simulations should contain
a server and some clients to communicate. Message exchanges are made between
agents through this server. 3 protocols are supported (TCP, UDP and MQTT):
• when TCP or UDP protocols are used: one agent of the simulation is the
server and the other ones are the clients.
• when the MQTT protocol is used: all the agents are clients and the server
is an external software. A free solution (ActiveMQ) can be freely downloaded
from: http://activemq.apache.org.
In the GAMA network, 3 kinds of protocol can be used. Each of them has a particular
purpose.
611
GAMA v1.8.0 documentation Chapter 81. Using network
• MQTT: this is the default protocol that should be used to make agents of
various GAMA instances to communicate through a MQTT server (that should
be run as an external application, e.g. ActiveMQ that can be downloaded from:
http://activemq.apache.org/),
• UDP: this protocol should be limited to fast (and unsecured) exchanges of
small pieces of data from GAMA to an external application (for example, mouse
location from a Processing application to GAMA, c.f. model library),
• TCP: this protocol can be used both to communicate between GAMA applica-
tions or between GAMA and an external application.
Disclaimer
In all the models using any network communication, the server should be
launched before the clients. As a consequence, when TCP or UDP protocols
are used, a model creating a server agent should always be run first. Using MQTT
protocol, the external software server should be launched before running any model
using it.
A list exhaustive of the additional attributes and available actions provided by this
skill are described here: network skill preference page.
v 1.8.0 612
GAMA v1.8.0 documentation Chapter 81. Using network
create Networking_Client {
do connect to: "localhost" protocol: "tcp_client" port: 3001
with_name: "Client";
}
• TCP:
– protocol: the 2 possibles keywords are tcp_server or tcp_client, de-
pending on the wanted role of the agent in the communication.
– port: traditionally the port 3001 is used.
• UDP:
– protocol: the 2 possibles keywords are udp_server or udp_emitter, de-
pending on the wanted role of the agent in the communication.
– port: traditionally the port 9876 is used.
• MQTT:
– protocol: MQTT is the default protocol value (if no value is given, MQTT
will be used)
Sending messages
To send any message, the agent has to use the send action:
do send to: "send" contents: name + " " + cycle + " sent to server"
;
Receiving messages
The messages sent by other agents are received in the mailbox attribute of each agent.
So to get its new message, the agent has simply to check whether it has new messages
(with action has_more_message() ) and fetch it (that is get it and remove it from
the mailing box) with the action fetch_message().
v 1.8.0 613
GAMA v1.8.0 documentation Chapter 81. Using network
reflex fetch when: has_more_message() {
message mess <- fetch_message();
write name + " fecth this message: " + mess.contents;
}
Alternatively, the mailbox attribute can be directly accessed (notice that the mailbox
is a list of messages):
reflex receive {
if (length(mailbox) > 0) {
write mailbox;
}
}
To go further:
v 1.8.0 614
Chapter 82
Overview
This tutorial presents the headless mode usage of GAMA. We will execute the Predator-
Prey model, already presented in this tutorial. Headless mode is documented here,
with the same model as an example. Here, we focus on the definition of an experiment
plan, where the model is run several times. We only consider the shell script execution,
not the java command execution.
In headless-mode, GAMA can be seen as any shell command, whose behavior is
controlled by passing arguments to it. You must provide 2 arguments :
• an input experiment file , used to describe the execution plan of your model,
its inputs and the expected outputs.
• an ** output directory **, where the results of the execution are stored
Headless-mode is a little bit more technical to handle than the general GAMA use-case,
and the following commands and code have been solely tested on a Linux Ubuntu
15.04 machine, x86_64 architecture, with kernel 3.19.0-82-generic. Java version is
1.8.0_121 (java version “1.8.0_121”)
You may have to perform some adjustments (such as paths definition) according to
your machine, OS, java and GAMA versions and so on.
615
GAMA v1.8.0 documentation Chapter 82. Editing Headless mode for dummies
Setup
GAMA version
Headless mode is frequently updated by GAMA developers, so you have to get the very
latest build version of GAMA. You can download it here https://github.com/gama-
platform/gama/releases Be sure to pick the ** Continuous build ** version (The
name looks like GAMA1.7_Linux_64_02.26.17_da33f5b.zip) and ** not ** the major
release, e.g. GAMA1.7_Linux_64.zip. Big note on Windows OS (maybe on others),
GAMA must be placed outside of several sensible folders (Program Files, Program
Filesx64, Windows). RECOMMENED: Place GAMA in Users Folder of windows OS.
i=0
echo ${!i}
for ((i=1;i<=$#;i=$i+1))
do
if test ${!i} = "-m"
then
i=$i+1
memory=${!i}
else
PARAM=$PARAM\ ${!i}
i=$i+1
PARAM=$PARAM\ ${!i}
fi
done
v 1.8.0 616
GAMA v1.8.0 documentation Chapter 82. Editing Headless mode for dummies
echo "
******************************************************************"
echo "* GAMA version 1.7.0 V7
*"
echo "* http://gama-platform.org
*"
echo "* (c) 2007-2016 UMI 209 UMMISCO IRD/UPMC & Partners
*"
echo "
******************************************************************"
passWork=.work$RANDOM
Notice the final command of the script rm -rf $passWork. It is intended to remove the
temporary file used during the execution of the script. For now, we should comment
this commmand, in order to check the logs if an error appears: #rm -rf $passWork
v 1.8.0 617
GAMA v1.8.0 documentation Chapter 82. Editing Headless mode for dummies
</Outputs>
</Simulation>
</Experiment_plan>
As you can see, you need to define 3 things in this minimal example:
• Simulation: its id, path to the model, finalStep (or stop condition), and name
of the experiment
• Parameters name, of the model for this simulation (i.e. Simulation of id= 2)
• Outputs of the model: their id, name, type, and the rate (expressed in cycles)
at which they are logged in the results file during the simulation
id
For now, we only consider one single execution of the model, so the simulation id is
not critical, let it unchanged. Later example will include different simulations in the
same experiment file. Simulation id is a string. Don’t introduce weird symbols into
it.
sourcePath
sourcePath is the relative (or absolute) path to the model file you want to execute
headlessly.
Here we want to execute the fourth model of the Predator Prey tutorial suite, locat-
ed in ~/GAMA/plugins/msi.gama.models_1.7.0.XXXXXXXXXXXX/models/Tutorials/
Predator Prey/models (with XXXXXXXXXXXX replaced by the number of the
release you downloaded)
So we set sourcePath=“../plugins/msi.gama.models_1.7.0.201702260518/models/Tu-
torials/Predator Prey/models/Model 07.gaml” (Remember that the headless script is
located in ~/GAMA/headless/)
v 1.8.0 618
GAMA v1.8.0 documentation Chapter 82. Editing Headless mode for dummies
Depending on the directory you want to run the gama-headless.sh script, sourcePath
must me modified accordingly. Another workaround for shell more advanced users is
to define a $GAMA_PATH, $MODEL_PATH and $OUPUT_PATH in gama-headless.sh script.
Don’t forget the quotes " around your path.
finalStep
The duration, in cycles, of the simulation.
experiment
This is the name of (one of) the experiment statement at the end of the model code.
In our case there is only one, called prey_predator and it looks like this :
experiment prey_predator type: gui {
parameter "Initial number of preys: " var: nb_preys_init min: 1
max: 1000 category: "Prey" ;
parameter "Prey max energy: " var: prey_max_energy category: "
Prey" ;
parameter "Prey max transfert: " var: prey_max_transfert
category: "Prey" ;
parameter "Prey energy consumption: " var: prey_energy_consum
category: "Prey" ;
output {
display main_display {
grid vegetation_cell lines: #black ;
species prey aspect: base ;
}
monitor "Number of preys" value: nb_preys ;
}
}
N.B. the numbers after msi.gama.models (the number of your GAMA release actually)
have to be adapted to your own release of GAMA number. The path to the GAMA
installation directory has also to be adapted of course.
v 1.8.0 619
GAMA v1.8.0 documentation Chapter 82. Editing Headless mode for dummies
Any declared parameter can be set this way, yet you don’t have to set all of them,
provided they are initialized with a default value in the model (see the global statement
part of the model code).
v 1.8.0 620
GAMA v1.8.0 documentation Chapter 82. Editing Headless mode for dummies
• framerate is the rate at which the output is written in the result file. It’s a
number of cycle of simulation (integer). In this example the display is saved
every 10 cycle
• name is either the “title” of the corresponding monitor. In our case, the second
output’s is the title of the monitor "Number of preys", i.e. “Number of preys”
We also save a display output, that is an image of the simulation graphical display
named main_display in the code of the model. Theses images is what you would
have seen if you had run the model in the traditional GUI mode.
Execution
We have to launch the gama-headless.sh script and provide two arguments : the
experiment file we just completed and the path of a directory where the results will
be written.
** Warning ** In this example ,we are lazy and define the source path as the absolute
path to the model we want to execute. If you want to use a relative path, note that
it has to be define relatively to the location of your ** ExperimentFile.xml location
** (and the location where you launched the script)
In a terminal, position yourself in the headless directory : ‘~/GAMA/headless/’.
Then type the following command :
bash gama-headless.sh -v ~/a/path/to/MyExperimentFile.xml /path/to/the/de-
sired/output/directory
And replace paths by the location of your ExperimentFile and output directory
You should obtain the following output in the terminal :
v 1.8.0 621
GAMA v1.8.0 documentation Chapter 82. Editing Headless mode for dummies
– http://gama-platform.org *
– (c) 2007-2016 UMI 209 UMMISCO IRD/UPMC & Partners
*****************************************************************
>GAMA plugin loaded in 2927 ms: msi.gama.core >GAMA plu-
gin loaded in 67 ms: ummisco.gama.network >GAMA plugin
loaded in 56 ms: simtools.gaml.extensions.traffic >GAMA plu-
gin loaded in 75 ms: simtools.gaml.extensions.physics >GAMA
plugin loaded in 1 ms: irit.gaml.extensions.test >GAMA plug-
in loaded in 75 ms: ummisco.gaml.extensions.maths >GAMA
plugin loaded in 47 ms: msi.gaml.extensions.fipa >GAMA plu-
gin loaded in 92 ms: ummisco.gama.serialize >GAMA plugin
loaded in 49 ms: irit.gaml.extensions.database >GAMA plugin
loaded in 2 ms: msi.gama.lang.gaml >GAMA plugin loaded
in 1 ms: msi.gama.headless >GAMA plugin loaded in 103 ms:
ummisco.gama.java2d >GAMA plugin loaded in 189 ms: m-
si.gaml.architecture.simplebdi >GAMA plugin loaded in 129 ms:
ummisco.gama.opengl >GAMA building GAML artefacts>GAMA
total load time 4502 ms. in 714 ms cpus :8 Simulation is running. . .
...................................................................................
Simulation duration: 7089ms
Results
The results are stored in the output directory you provided as the second argument
of the script.
3 items have appeared:
The values of the monitor “Number of preys” are stored in the xml file simulation-
outputXX.xml
v 1.8.0 622
GAMA v1.8.0 documentation Chapter 82. Editing Headless mode for dummies
Going further
v 1.8.0 623
GAMA v1.8.0 documentation Chapter 82. Editing Headless mode for dummies
v 1.8.0 624
Chapter 83
The graphical editor that allows defining a GAMA model through a graphical interface
(gadl files). It is based on the Graphiti Eclipse plugin. It allows as well to produce a
graphical model (diagram) from a gaml model.
Table of contents
• The Graphical Editor
625
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
v 1.8.0 626
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
∗ experiment
· GUI experiment
· display
· batch experiment
∗ BDI Architecture
· plan
· rule
· perception
∗ Finite State Machine
· state
∗ Tasked-based Architecture
· task
– Pictogram color modification
– GAML Model generation
v 1.8.0 627
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
v 1.8.0 628
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
v 1.8.0 629
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
v 1.8.0 630
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
In the next Wizard dialog, select the type of diagram (Empty, Skeleton or Example)
then the name of the file and the author.
Skeleton and Example diagram types allow to add to the diagram some basic features.
Similarly to GAML editor, the graphical editor proposes a live display of errors
and model statuses. A graphical model can actually be in three different states,
which are visually accessible above the editing area: Functional (orange color),
Experimentable (green color) and InError (red color). See the section on model
validation for more precise information about these statuses.
In its initial state, a model is always in the Functional state, which means it compiles
without problems, but cannot be used to launch experiments. The InError state
occurs when the file contains errors (syntactic or semantic ones).
Reaching the Experimentable state requires that all errors are eliminated and that
at least one experiment is defined in the model. The experiment is immediately
displayed as a button in the toolbar, and clicking on it will allow the modeler to
launch this experiment on your model.
Experiment buttons are updated in real-time to reflect what’s in your code. If more
than one experiment is defined, corresponding buttons will be displayed in addition
to the first one.
v 1.8.0 631
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
v 1.8.0 632
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
Features
agents
species
The species feature allows the modeler to define a species with a continuous topology.
A species is always a micro-species of another species. The top-level (macro-species
of all species) is the world species.
grid
The grid feature allows the modeler to define a species with a grid topology. A grid
is always a micro-species of another species.
Inheriting link
The inheriting link feature allows the modeler to define an inheriting link between
two species.
world
When a model is created, a world species is always defined. It represents the global
part of the model. The world species, which is unique, is the top-level species. All
other species are micro-species of the world species.
v 1.8.0 633
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
v 1.8.0 634
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
v 1.8.0 635
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
v 1.8.0 636
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
agent features
action
The action feature allows the modeler to define an action for a species.
– target: -
v 1.8.0 637
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
reflex
The reflex feature allows the modeler to define a reflex for a species.
– target: -
aspect
The aspect feature allows the modeler to define an aspect for a species.
– target: -
equation
The equation feature allows the modeler to define an equation for a species.
– target: -
v 1.8.0 638
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
v 1.8.0 639
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
v 1.8.0 640
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
resources/images/graphicalEditor/equation.png
resources/images/graphicalEditor/Frame_Equation.pn
v 1.8.0 641
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
experiment
GUI experiment
The GUI Experiment feature allows the modeler to define a GUI experiment.
display
v 1.8.0 642
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
v 1.8.0 643
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
v 1.8.0 644
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
resources/images/graphicalEditor/plan.png
batch experiment
The Batch Experiment feature allows the modeler to define a Batch experiment.
BDI Architecture
Plan
The Plan feature allows the modeler to define a plan for a BDI species, i.e. a sequence
of statements that will be executed in order to fulfill a particular intention.
Rule
The Rule feature allows the modeler to define a rule for a BDI species, i.e. a function
executed at each iteration to infer new desires or beliefs from the agent’s current
beliefs and desires.
v 1.8.0 645
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
resources/images/graphicalEditor/Frame_plan.p
resources/images/graphicalEditor/rule.png
Perception
The Perception feature allows the modeler to define a perception for a BDI species,
i.e. a function executed at each iteration that updates the agent’s Belief base according
to the agent perception.
resources/images/graphicalEditor/Frame_rule.p
v 1.8.0 646
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
resources/images/graphicalEditor/perception.png
resources/images/graphicalEditor/Frame_perception.
State
The State feature allows the modeler to define a state for a FSM species, i.e. sequence
of statements that will be executed if the agent is in this state (an agent has a unique
state at a time).
– target: -
resources/images/graphicalEditor/state.png
v 1.8.0 647
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
resources/images/graphicalEditor/Frame_state.
resources/images/graphicalEditor/task.png
Task-based Architecture
Task
The Task feature allows the modeler to define a task for a Tasked-based species,
i.e. sequence of statements that can be executed, at each time step, by the agent.
If an agent owns several tasks, the scheduler chooses a task to execute based on its
current priority weight value.
– target: -
resources/images/graphicalEditor/Frame_task.p
v 1.8.0 648
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
v 1.8.0 649
GAMA v1.8.0 documentation Chapter 83. The Graphical Editor
v 1.8.0 650
Chapter 84
651
GAMA v1.8.0 documentation Chapter 84. FAQ (Frequently Asked Questions)
v 1.8.0 652
Chapter 85
Known issues
653
GAMA v1.8.0 documentation Chapter 85. Known issues
v 1.8.0 654
GAMA v1.8.0 documentation Chapter 85. Known issues
v 1.8.0 655
GAMA v1.8.0 documentation Chapter 85. Known issues
v 1.8.0 656
Part VIII
GAML References
657
Chapter 86
GAML References
The GAML references describe in details all the keywords of the GAML language. In
particular, they detail all the expressions (operators, units, literals. . . ), statements,
data types, file types, skills, architectures, built-in species. . .
Index of keywords
The Index page contains the exhaustive list of the GAML keywords, with a link to a
detailed description of each of them.
659
GAMA v1.8.0 documentation Chapter 86. GAML References
v 1.8.0 660
Chapter 87
Built-in Species
This file is automatically generated from java files. Do Not Edit It.
It is possible to use in the models a set of built-in agents. These agents allow to
directly use some advance features like clustering, multi-criteria analysis, etc. The
creation of these agents are similar as for other kinds of agents:
create species: my_built_in_agent returns: the_agent;
Table of Contents
agent, AgentDB, base_edge, experiment, graph_edge, graph_node, physical_world,
661
GAMA v1.8.0 documentation Chapter 87. Built-in Species
agent
Variables
• host (-29): Returns the agent that hosts the population of the receiver agent
• name (string): Returns the name of the agent (not necessarily unique in its
population)
• peers (list): Returns the population of agents of the same species, in the
same host, minus the receiver agent
Actions
_init_
• returns: unknown
_step_
• returns: unknown
AgentDB
Variables
• agents (list): Returns the list of agents for the population(s) of which the
receiver agent is a direct or undirect host
v 1.8.0 662
GAMA v1.8.0 documentation Chapter 87. Built-in Species
• members (list): Returns the list of agents for the population(s) of which the
receiver agent is a direct host
Actions
close
• returns: unknown
connect
• returns: unknown
executeUpdate
• returns: int
• values (list): List of values that are used to replace question mark
getParameter
• returns: unknown
insert
• returns: int
v 1.8.0 663
GAMA v1.8.0 documentation Chapter 87. Built-in Species
• values (list): List of values that are used to insert into table. Columns and
values must have same size
isConnected
• returns: bool
select
• returns: list
• values (list): List of values that are used to replace question marks
setParameter
• returns: unknown
testConnection
• returns: bool
timeStamp
• returns: float
v 1.8.0 664
GAMA v1.8.0 documentation Chapter 87. Built-in Species
base_edge
Variables
Actions
experiment
Experiments that declare a graphical user interface
Variables
• model_path (string): Contains the absolute path to the folder in which the
current model is located
• rng (string): The random number generator to use for this simulation. Three
different ones are at the disposal of the modeler: mersenne represents the
default generator, based on the Mersenne-Twister algorithm. Very reliable;
cellular is a cellular automaton based generator that should be a bit faster, but
less reliable; and java invokes the standard Java generator
v 1.8.0 665
GAMA v1.8.0 documentation Chapter 87. Built-in Species
• rng_usage (int): Returns the number of times the random number generator
of the experiment has been drawn
Actions
compact_memory
• returns: unknown
update_outputs
• returns: unknown
v 1.8.0 666
GAMA v1.8.0 documentation Chapter 87. Built-in Species
graph_edge
Variables
• source (agent): The source agent of this edge
Actions
graph_node
Variables
• my_graph (graph): A reference to the graph containing the agent
Actions
related_to
• returns: bool
physical_world
The base species for agents that act as a 3D physical world
v 1.8.0 667
GAMA v1.8.0 documentation Chapter 87. Built-in Species
Variables
• agents (list): The list of agents registered in this physical world
Actions
compute_forces
• returns: unknown
• step (float): allows to define the time step considered for the physical world
agent. If not defined, the physical world agent will use the step global variable.
v 1.8.0 668
Chapter 88
agent attributes
agent defines several attributes, which form the minimal set of knowledge any agent
will have in a model. *
agent actions
669
GAMA v1.8.0 documentation
Chapter 88. The ‘agent’ built-in species (Under Construction)
v 1.8.0 670
Chapter 89
model attributes
model defines several attributes, which, in addition to the attributes inherited from
agent, form the minimal set of knowledge a model can manipulate. *
model actions
671
GAMA v1.8.0 documentation
Chapter 89. The ‘model’ built-in species (Under Construction)
v 1.8.0 672
Chapter 90
experiment attributes
experiment defines several attributes, which, in addition to the attributes inherited
from agent, form the minimal set of knowledge any experiment will have access to.
experiment actions
673
GAMA v1.8.0 documentation
Chapter 90. The ‘experiment’ built-in species (Under Construction)
v 1.8.0 674
Chapter 91
Built-in Skills
This file is automatically generated from java files. Do Not Edit It.
Introduction
Skills are built-in modules, written in Java, that provide a set of related built-in
variables and built-in actions (in addition to those already provided by GAMA) to the
species that declare them. A declaration of skill is done by filling the skills attribute
in the species definition:
species my_species skills: [skill1, skill2] {
...
}
Skills have been designed to be mutually compatible so that any combination of them
will result in a functional species. An example of skill is the moving skill.
So, for instance, if a species is declared as:
species foo skills: [moving]{
...
}
675
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
Its agents will automatically be provided with the following variables : speed, heading,
destination and the following actions: move, goto, wander, follow in addition to
those built-in in species and declared by the modeller. Most of these variables, except
the ones marked read-only, can be customized and modified like normal variables
by the modeller. For instance, one could want to set a maximum for the speed; this
would be done by redeclaring it like this:
float speed max:100 min:0;
Table of Contents
advanced_driving, driving, fipa, MDXSKILL, messaging, moving, moving3D, network,
physics, skill_road, skill_road_node, SQLSKILL,
advanced_driving
Variables
• current_index (int): the current index of the agent target (according to the
targets list)
v 1.8.0 676
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
v 1.8.0 677
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
• speed_coeff (float): speed coefficient for the speed that the driver want to
reach (according to the max speed of the road)
• targets (list): the current list of points that the agent has to reach (path)
Actions
advanced_follow_driving
moves the agent towards along the path passed in the arguments while considering
the other agents in the network (only for graph topology)
• returns: float
v 1.8.0 678
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
• speed (float): the speed to use for this move (replaces the current value of speed)
compute_path
• returns: path
• source (agent): the source node (optional, if not defined, closest node to the
agent location)
drive
• returns: void
drive_random
• returns: void
• proba_roads (map): a map containing for each road (key), the probability to
be selected as next road (value)
v 1.8.0 679
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
external_factor_impact
action that allows to define how the remaining time is impacted by external factor
• returns: float
is_ready_next_road
action to test if the driver can take the given road at the given lane
• returns: bool
lane_choice
• returns: int
path_from_nodes
• returns: path
v 1.8.0 680
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
speed_choice
• returns: float
test_next_road
• returns: bool
driving
Variables
• lanes_attribute (string): the name of the attribut of the road agent that
determine the number of road lanes
• living_space (float): the min distance between the agent and an obstacle
(in meter)
• tolerance (float): the tolerance distance used for the computation (in meter)
v 1.8.0 681
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
Actions
follow_driving
moves the agent along a given path passed in the arguments while considering the
other agents in the network.
• returns: path
• speed (float): the speed to use for this move (replaces the current value of speed)
• return_path (boolean): if true, return the path followed (by default: false)
• living_space (float): min distance between the agent and an obstacle (replaces
the current value of living_space)
• tolerance (float): tolerance distance used for the computation (replaces the
current value of tolerance)
• lanes_attribute (string): the name of the attribut of the road agent that
determine the number of road lanes (replaces the current value of lanes_-
attribute)
goto_driving
moves the agent towards the target passed in the arguments while considering the
other agents in the network (only for graph topology)
• returns: path
• speed (float): the speed to use for this move (replaces the current value of speed)
v 1.8.0 682
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
• on (any type): list, agent, graph, geometry that restrains this move (the agent
moves inside this geometry)
• return_path (boolean): if true, return the path followed (by default: false)
• living_space (float): min distance between the agent and an obstacle (replaces
the current value of living_space)
• tolerance (float): tolerance distance used for the computation (replaces the
current value of tolerance)
• lanes_attribute (string): the name of the attribut of the road agent that
determine the number of road lanes (replaces the current value of lanes_-
attribute)
fipa
The fipa skill offers some primitives and built-in variables which enable agent to
communicate with each other using the FIPA interaction protocol.
Variables
v 1.8.0 683
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
Actions
accept_proposal
• returns: unknown
agree
v 1.8.0 684
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
• returns: unknown
cancel
• returns: unknown
cfp
• returns: unknown
end_conversation
• returns: unknown
v 1.8.0 685
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
failure
• returns: unknown
inform
• returns: unknown
propose
• returns: unknown
query
• returns: unknown
v 1.8.0 686
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
refuse
• returns: unknown
reject_proposal
• returns: unknown
reply
Replies a message. This action should be only used to reply a message in a ‘no-
protocol’ conversation and with a ‘user defined performative’. For performatives
supported by GAMA (i.e., standard FIPA performatives), please use the ‘action’ with
the same name of ‘performative’. For example, to reply a message with a ‘request’
performative message, the modeller should use the ‘request’ action.
• returns: unknown
v 1.8.0 687
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
request
• returns: unknown
send
• returns: msi.gaml.extensions.fipa.FIPAMessage
• contents (list): The content of the message. A list of any GAML type
start_conversation
• returns: msi.gaml.extensions.fipa.FIPAMessage
v 1.8.0 688
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
• contents (list): The content of the message. A list of any GAML type
subscribe
• returns: unknown
MDXSKILL
This skill allows agents to be provided with actions and attributes in order to connect
to MDX databases
Variables
Actions
select
• returns: list
v 1.8.0 689
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
• onRows (list): List of values that are used to replace question marks
• from (list): List of values that are used to replace question marks
• where (list): List of values that are used to replace question marks
• values (list): List of values that are used to replace question marks
testConnection
• returns: bool
timeStamp
• returns: float
messaging
A simple skill that provides agents with a mailbox than can be filled with messages
Variables
• mailbox (list): The list of messages that can be consulted by the agent
Actions
send
• returns: msi.gama.extensions.messaging.GamaMessage
v 1.8.0 690
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
• to (any type): The agent, or server, to which this message will be sent to
moving
The moving skill is intended to define the minimal set of behaviours required for
agents that are able to move on different topologies
Variables
• current_edge (geometry): Represents the agent/geometry on which the agent
is located (only used with a graph)
• destination (point): Represents the next location of the agent if it keeps its
current speed and heading (read-only). ** Only correct in continuous topologies
and may return nil values if the destination is outside the environment **
• real_speed (float): Represents the actual speed of the agent (in meter/second)
Actions
follow
v 1.8.0 691
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
• returns: path
• speed (float): the speed to use for this move (replaces the current value of speed)
• return_path (boolean): if true, return the path followed (by default: false)
goto
• returns: path
• speed (float): the speed to use for this move (replaces the current value of speed)
• recompute_path (boolean): if false, the path is not recompute even if the graph
is modified (by default: true)
• return_path (boolean): if true, return the path followed (by default: false)
move
moves the agent forward, the distance being computed with respect to its speed and
heading. The value of the corresponding variables are used unless arguments are
passed.
• returns: path
v 1.8.0 692
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
• speed (float): the speed to use for this move (replaces the current value of speed)
• bounds (geometry): the geometry (the localized entity geometry) that restrains
this move (the agent moves inside this geometry
wander
Moves the agent towards a random location at the maximum distance (with respect
to its speed). The heading of the agent is chosen randomly if no amplitude is specified.
This action changes the value of heading.
• returns: void
• speed (float): the speed to use for this move (replaces the current value of speed)
• amplitude (float): a restriction placed on the random heading choice. The new
heading is chosen in the range (heading - amplitude/2, heading+amplitude/2)
• bounds (geometry): the geometry (the localized entity geometry) that restrains
this move (the agent moves inside this geometry)
• on (graph): the graph that restrains this move (the agent moves on the graph
moving3D
The moving skill 3D is intended to define the minimal set of behaviours required for
agents that are able to move on different topologies
v 1.8.0 693
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
Variables
• heading (float): the absolute heading of the agent in degrees (in the range
0-359)
• pitch (float): the absolute pitch of the agent in degrees (in the range 0-359)
• roll (float): the absolute roll of the agent in degrees (in the range 0-359)
Actions
move
moves the agent forward, the distance being computed with respect to its speed and
heading. The value of the corresponding variables are used unless arguments are
passed.
• returns: path
• speed (float): the speed to use for this move (replaces the current value of speed)
• heading (int): int, optional, the direction to take for this move (replaces the
current value of heading)
• pitch (int): int, optional, the direction to take for this move (replaces the
current value of pitch)
• heading (int): int, optional, the direction to take for this move (replaces the
current value of roll)
• bounds (geometry): the geometry (the localized entity geometry) that restrains
this move (the agent moves inside this geometry
v 1.8.0 694
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
network
The network skill provides new features to let agents exchange message through
network.
Variables
• network_server (list): The list of all the servers to which the agent is con-
nected
Actions
connect
• returns: void
• protocol (string): protocol type (MQTT (by default), TCP, UDP): the
possible value ares ‘udp_server’, ‘udp_emitter’, ‘tcp_server’, ‘tcp_client’,
otherwise the MQTT protocol is used.
v 1.8.0 695
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
execute
• returns: string
fetch_message
• returns: msi.gama.extensions.messaging.GamaMessage
has_more_message
• returns: bool
join_group
• returns: void
leave_group
leave a group of agents. The leaving agent will not receive any message from the
group. Overwhise, it can send messages to the left group
v 1.8.0 696
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
• returns: void
simulate_step
Simulate a step to test the skill. It must be used for Gama-platform test only
• returns: void
physics
Variables
• ang_damping (float): angular dampling
• collisionBound (map): map describing the shape of the agent. format for
sphere: [‘shape’::‘sphere’, ‘radius’::10.0]; for floor: [‘shape’::‘floor’, ‘x’::100.0,
‘y’::100.0, ‘z’::2.0]; if not defined, the shape attribute of the agent is used.
Actions
v 1.8.0 697
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
skill_road
Variables
• agents_on (list): for each lane of the road, the list of agents for each segment
• linked_road (-199): the linked road: the lanes of this linked road will be
usable by drivers on the road
Actions
register
• returns: void
• lane (int): the lane index on which to register; if lane index >= number of
lanes, then register on the linked road
unregister
v 1.8.0 698
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
• returns: void
skill_road_node
Variables
• block (map): define the list of agents blocking the node, and for each agent,
the list of concerned roads
• stop (list): define for each type of stop, the list of concerned roads
Actions
SQLSKILL
This skill allows agents to be provided with actions and attributes in order to connect
to SQL databases
v 1.8.0 699
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
Variables
Actions
executeUpdate
• returns: int
• values (list): List of values that are used to replace question mark
getCurrentDateTime
• returns: string
getDateOffset
• returns: string
insert
• returns: int
v 1.8.0 700
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
• values (list): List of values that are used to insert into table. Columns and
values must have same size
list2Matrix
• returns: matrix
select
• returns: list
• values (list): List of values that are used to replace question marks
testConnection
• returns: bool
v 1.8.0 701
GAMA v1.8.0 documentation Chapter 91. Built-in Skills
timeStamp
• returns: float
v 1.8.0 702
Chapter 92
Built-in Architectures
This file is automatically generated from java files. Do Not Edit It.
INTRODUCTION
Table of Contents
703
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
fsm
Variables
• states (list): Returns the list of all possible states the agents can be in
Actions
parallel_bdi
Variables
Actions
probabilistic_tasks
Variables
Actions
v 1.8.0 704
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
reflex
Variables
Actions
rules
Variables
Actions
simple_bdi
this architecture enables to define a behaviour using BDI. It is an implementation of
the BEN architecture (Behaviour with Emotions and Norms)
Variables
v 1.8.0 705
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
v 1.8.0 706
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
Actions
add_belief
• returns: bool
add_belief_emotion
v 1.8.0 707
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
• returns: bool
add_belief_mental_state
• returns: bool
add_desire
• returns: bool
add_desire_emotion
v 1.8.0 708
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
• returns: bool
add_desire_mental_state
• returns: bool
add_directly_belief
• returns: bool
add_directly_desire
v 1.8.0 709
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
• returns: bool
add_directly_ideal
• returns: bool
add_directly_uncertainty
• returns: bool
add_emotion
• returns: bool
add_ideal
• returns: bool
v 1.8.0 710
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
add_ideal_emotion
• returns: bool
add_ideal_mental_state
• returns: bool
add_intention
• returns: bool
v 1.8.0 711
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
add_intention_emotion
• returns: bool
add_intention_mental_state
• returns: bool
add_obligation
• returns: bool
v 1.8.0 712
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
add_social_link
• returns: bool
add_subintention
• returns: bool
add_uncertainty
• returns: bool
v 1.8.0 713
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
add_uncertainty_emotion
• returns: bool
add_uncertainty_mental_state
• returns: bool
change_dominance
changes the dominance value of the social relation with the agent specified.
• returns: bool
v 1.8.0 714
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
change_familiarity
changes the familiarity value of the social relation with the agent specified.
• returns: bool
change_liking
changes the liking value of the social relation with the agent specified.
• returns: bool
change_solidarity
changes the solidarity value of the social relation with the agent specified.
• returns: bool
change_trust
changes the trust value of the social relation with the agent specified.
• returns: bool
v 1.8.0 715
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
clear_beliefs
• returns: bool
clear_desires
• returns: bool
clear_emotions
• returns: bool
clear_ideals
• returns: bool
clear_intentions
• returns: bool
v 1.8.0 716
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
clear_obligations
• returns: bool
clear_social_links
• returns: bool
clear_uncertainties
• returns: bool
current_intention_on_hold
puts the current intention on hold until the specified condition is reached or all
subintentions are reached (not in desire base anymore).
• returns: bool
• until (any type): the current intention is put on hold (fited plan are not
considered) until specific condition is reached. Can be an expression (which
will be tested), a list (of subintentions), or nil (by default the condition will be
the current list of subintentions of the intention)
get_belief
return the belief about the predicate in the belief base (if several, returns the first
one).
• returns: mental_state
v 1.8.0 717
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
get_belief_emotion
return the belief about the emotion in the belief base (if several, returns the first
one).
• returns: mental_state
get_belief_mental_state
return the belief about the mental state in the belief base (if several, returns the first
one).
• returns: mental_state
get_belief_with_name
get the predicates is in the belief base (if several, returns the first one).
• returns: mental_state
get_beliefs
• returns: list
v 1.8.0 718
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
get_beliefs_metal_state
get the list of bliefs in the belief base containing the mental state
• returns: list
get_beliefs_with_name
get the list of predicates is in the belief base with the given name.
• returns: list
get_current_intention
• returns: mental_state
get_current_plan
• returns: BDIPlan
get_desire
get the predicates is in the desire base (if several, returns the first one).
• returns: mental_state
v 1.8.0 719
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
get_desire_mental_state
get the mental state is in the desire base (if several, returns the first one).
• returns: mental_state
get_desire_with_name
get the predicates is in the belief base (if several, returns the first one).
• returns: mental_state
get_desires
• returns: list
get_desires_mental_state
• returns: list
v 1.8.0 720
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
get_desires_with_name
get the list of predicates is in the belief base with the given name.
• returns: list
get_emotion
get the emotion in the emotion base (if several, returns the first one).
• returns: emotion
get_emotion_with_name
get the emotion is in the emotion base (if several, returns the first one).
• returns: emotion
get_ideal
get the ideal about the predicate in the ideal base (if several, returns the first one).
• returns: mental_state
v 1.8.0 721
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
get_ideal_mental_state
get the mental state in the ideal base (if several, returns the first one).
• returns: mental_state
get_intention
get the predicates in the intention base (if several, returns the first one).
• returns: mental_state
get_intention_mental_state
get the mental state is in the intention base (if several, returns the first one).
• returns: mental_state
get_intention_with_name
get the predicates is in the belief base (if several, returns the first one).
• returns: mental_state
v 1.8.0 722
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
get_intentions
• returns: list
get_intentions_mental_state
• returns: list
get_intentions_with_name
get the list of predicates is in the belief base with the given name.
• returns: list
get_obligation
get the predicates in the obligation base (if several, returns the first one).
• returns: mental_state
v 1.8.0 723
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
get_plan
• returns: BDIPlan
get_plans
• returns: list
get_social_link
get the social link (if several, returns the first one).
• returns: social_link
get_social_link_with_agent
get the social link with the agent concerned (if several, returns the first one).
• returns: social_link
get_uncertainty
get the predicates is in the uncertainty base (if several, returns the first one).
• returns: mental_state
v 1.8.0 724
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
get_uncertainty_mental_state
get the mental state is in the uncertainty base (if several, returns the first one).
• returns: mental_state
has_belief
• returns: bool
has_belief_mental_state
• returns: bool
has_belief_with_name
• returns: bool
v 1.8.0 725
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
has_desire
• returns: bool
has_desire_mental_state
• returns: bool
has_desire_with_name
• returns: bool
has_emotion
• returns: bool
v 1.8.0 726
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
has_emotion_with_name
• returns: bool
has_ideal
• returns: bool
has_ideal_mental_state
• returns: bool
has_ideal_with_name
• returns: bool
v 1.8.0 727
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
has_obligation
• returns: bool
has_social_link
• returns: bool
has_social_link_with_agent
• returns: bool
• agent (agent): an agent with who I want to check if I have a social link
has_uncertainty
• returns: bool
v 1.8.0 728
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
has_uncertainty_mental_state
• returns: bool
has_uncertainty_with_name
• returns: bool
is_current_intention
check if the predicates is the current intention (last entry of intention base).
• returns: bool
is_current_intention_mental_state
check if the mental state is the current intention (last entry of intention base).
• returns: bool
v 1.8.0 729
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
is_current_plan
• returns: bool
remove_all_beliefs
• returns: bool
remove_belief
• returns: bool
remove_belief_mental_state
• returns: bool
v 1.8.0 730
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
remove_desire
• returns: bool
remove_desire_mental_state
• returns: bool
remove_emotion
• returns: bool
remove_ideal
• returns: bool
v 1.8.0 731
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
remove_ideal_mental_state
• returns: bool
remove_intention
• returns: bool
remove_intention_mental_state
• returns: bool
remove_obligation
• returns: bool
v 1.8.0 732
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
remove_social_link
• returns: bool
remove_social_link_with_agent
• returns: bool
• agent (agent): an agent with who I get the social link to remove
remove_uncertainty
• returns: bool
remove_uncertainty_mental_state
• returns: bool
v 1.8.0 733
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
replace_belief
• returns: bool
sorted_tasks
Variables
Actions
user_first
Variables
Actions
v 1.8.0 734
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
user_last
Variables
Actions
user_only
Variables
Actions
weighted_tasks
Variables
Actions
v 1.8.0 735
GAMA v1.8.0 documentation Chapter 92. Built-in Architectures
v 1.8.0 736
Chapter 93
Statements
This file is automatically generated from java files. Do Not Edit It.
Table of Contents
=, action, add, agents, annealing, ask, aspect, assert, benchmark, break, camera, cap-
ture, catch, chart, conscious_contagion, coping, create, data, datalist, default, diffuse,
display, display_grid, display_population, do, draw, else, emotional_contagion, en-
forcement, enter, equation, error, event, exhaustive, exit, experiment, focus, focus_on,
genetic, graphics, highlight, hill_climbing, if, image, inspect, law, layout, let, light,
loop, match, migrate, monitor, norm, output, output_file, overlay, parameter, per-
ceive, permanent, plan, put, reactive_tabu, reflex, release, remove, return, rule, rule,
run, sanction, save, set, setup, simulate, socialize, solve, species, start_simulation,
state, status, switch, tabu, task, test, trace, transition, try, unconscious_conta-
gion, user_command, user_init, user_input, user_panel, using, Variable_container,
Variable_number, Variable_regular, warn, write,
Statements by kinds
• Batch method
737
GAMA v1.8.0 documentation Chapter 93. Statements
• Behavior
– aspect, coping, norm, plan, reflex, rule, sanction, state, task, test,
user_init, user_panel,
• Behavior
– aspect, coping, norm, plan, reflex, rule, sanction, state, task, test,
user_init, user_panel,
• Experiment
– experiment,
• Layer
– agents, camera, chart, display_grid, display_population, event, graphics,
image, light, overlay,
• Output
– display, inspect, layout, monitor, output, output_file, permanent,
• Parameter
– parameter,
v 1.8.0 738
GAMA v1.8.0 documentation Chapter 93. Statements
• Single statement
– =, add, assert, break, conscious_contagion, data, datalist, diffuse, do,
draw, emotional_contagion, enforcement, error, focus, focus_on, highlight,
law, let, put, remove, return, rule, save, set, simulate, socialize, solve,
status, unconscious_contagion, user_input, warn, write,
• Single statement
– =, add, assert, break, conscious_contagion, data, datalist, diffuse, do,
draw, emotional_contagion, enforcement, error, focus, focus_on, highlight,
law, let, put, remove, return, rule, save, set, simulate, socialize, solve,
status, unconscious_contagion, user_input, warn, write,
• Single statement
– =, add, assert, break, conscious_contagion, data, datalist, diffuse, do,
draw, emotional_contagion, enforcement, error, focus, focus_on, highlight,
law, let, put, remove, return, rule, save, set, simulate, socialize, solve,
status, unconscious_contagion, user_input, warn, write,
• Single statement
v 1.8.0 739
GAMA v1.8.0 documentation Chapter 93. Statements
• Species
– species,
• Variable (container)
– Variable_container,
• Variable (number)
– Variable_number,
• Variable (regular)
– Variable_regular,
Statements by embedment
• Behavior
• Environment
– species,
• Experiment
v 1.8.0 740
GAMA v1.8.0 documentation Chapter 93. Statements
v 1.8.0 741
GAMA v1.8.0 documentation Chapter 93. Statements
– add, ask, data, datalist, do, put, remove, set, simulate, using,
• display
– agents, camera, chart, display_grid, display_population, event, graphics,
image, light, overlay,
• display_population
– display_population,
• equation
– =,
• fsm
– state, user_panel,
• if
– else,
• output
– display, inspect, layout, monitor, output_file,
• parallel_bdi
– coping, rule,
• permanent
– display, inspect, monitor, output_file,
• probabilistic_tasks
– task,
• rules
– rule,
• simple_bdi
– coping, rule,
• sorted_tasks
– task,
v 1.8.0 742
GAMA v1.8.0 documentation Chapter 93. Statements
• state
– enter, exit,
• switch
– default, match,
• test
– assert,
• try
– catch,
• user_command
– user_input,
• user_first
– user_panel,
• user_init
– user_panel,
• user_last
– user_panel,
• user_only
– user_panel,
• user_panel
– user_command,
• weighted_tasks
– task,
v 1.8.0 743
GAMA v1.8.0 documentation Chapter 93. Statements
General syntax
A statement represents either a declaration or an imperative command. It consists in
a keyword, followed by specific facets, some of them mandatory (in bold), some of
them optional. One of the facet names can be omitted (the one denoted as omissible).
It has to be the first one.
statement_keyword expression1 facet2: expression2 ... ;
or
statement_keyword facet1: expression1 facet2: expression2 ...;
=
Definition
Facets
• right (float), (omissible) : the right part of the equation (it is mandatory that
it can be evaluated as a float
• left (any type): the left part of the equation (it should be a variable or a call
to the diff() or diff2() operators)
v 1.8.0 744
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
• The syntax of the = statement is a bit different from the other statements. It
has to be used as follows (in an equation):
float t;
float S;
float I;
equation SI {
diff(S,t) = (- 0.3 * S * I / 100);
diff(I,t) = (0.3 * S * I / 100);
}
Embedments
action
Definition
Allows to define in a species, model or experiment a new action that can be called
elsewhere.
Facets
v 1.8.0 745
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
• The simplest syntax to define an action that does not take any parameter and
does not return anything is:
action simple_action {
// [set of statements]
}
• If the action needs some parameters, they can be specified betwee, braquets
after the identifier of the action:
action action_parameters(int i, string s){
// [set of statements using i and s]
}
• If the action returns any value, the returned type should be used instead of the
“action” keyword. A return statement inside the body of the action statement
is mandatory.
int action_return_val(int i, string s){
// [set of statements using i and s]
return i + i;
}
• If virtual: is true, then the action is abstract, which means that the action
is defined without body. A species containing at least one abstract action is
abstract. Agents of this species cannot be created. The common use of an
abstract action is to define an action that can be used by all its sub-species,
which should redefine all abstract actions and implements its body.
species parent_species {
int virtual_action(int i, string s);
}
v 1.8.0 746
GAMA v1.8.0 documentation Chapter 93. Statements
Embedments
add
Definition
Allows to add, i.e. to insert, a new element in a container (a list, matrix, map,
. . . ).Incorrect use: The addition of a new element at a position out of the bounds
of the container will produce a warning and let the container unmodified. If all: is
specified, it has no effect if its argument is not a container, or if its argument is ‘true’
and the item to add is not a container. In that latter case
Facets
Usages
• The new element can be added either at the end of the container or at a
particular position.
add expr to: expr_container; // Add at the end
add expr at: expr to: expr_container; // Add at position expr
v 1.8.0 747
GAMA v1.8.0 documentation Chapter 93. Statements
list<int> workingList <- [];add 0 at: 0 to: workingList ;//workingList
equals [0]add 10 at: 0 to: workingList ;//workingList equals [10,0]
add 20 at: 2 to: workingList ;//workingList equals [10,0,20]add 50
to: workingList;//workingList equals [10,0,20,50]add [60,70] all:
true to: workingList;//workingList equals [10,0,20,50,60,70]
• Notice that, as the key should be unique, the addition of an item at an existing
position (i.e. existing key) will only modify the value associated with the given
key.
• On a map, the all facet will add all value of a container in the map (so as pair
val_cont::val_cont)
v 1.8.0 748
GAMA v1.8.0 documentation Chapter 93. Statements
• In case of a graph, we can use the facets node, edge and weight to add a node,
an edge or weights to the graph. However, these facets are now considered as
deprecated, and it is advised to use the various edge(), node(), edges(), nodes()
operators, which can build the correct objects to add to the graph
graph g <- as_edge_graph([{1,5}::{12,45}]);
add edge: {1,5}::{2,3} to: g;
list var <- g.vertices; // var equals [{1,5},{12,45},{2,3}]
list var <- g.edges; // var equals [polyline({1.0,5.0}::{12.0,45.0}),
polyline({1.0,5.0}::{2.0,3.0})]
add node: {5,5} to: g;
list var <- g.vertices; // var equals
[{1.0,5.0},{12.0,45.0},{2.0,3.0},{5.0,5.0}]
list var <- g.edges; // var equals [polyline({1.0,5.0}::{12.0,45.0}),
polyline({1.0,5.0}::{2.0,3.0})]
• Case of a matrix: this statement can not be used on matrix. Please refer to the
statement put.
Embedments
agents
Definition
agents allows the modeler to display only the agents that fulfill a given condition.
v 1.8.0 749
GAMA v1.8.0 documentation Chapter 93. Statements
Facets
Usages
v 1.8.0 750
GAMA v1.8.0 documentation Chapter 93. Statements
}
• For instance, in a segregation model, agents will only display unhappy agents:
display Segregation {
agents agentDisappear value: people as list where (each.is_happy =
false) aspect: with_group_color;
}
• See also: display, chart, event, graphics, display_grid, image, overlay, display_-
population,
Embedments
annealing
Definition
Facets
• name (an identifier), (omissible) : The name of the method. For internal use
only
• aggregation (a label), takes values in: {min, max}: the agregation method
• maximize (float): the value the algorithm tries to maximize
• minimize (float): the value the algorithm tries to minimize
• nb_iter_cst_temp (int): number of iterations per level of temperature
• temp_decrease (float): temperature decrease coefficient
• temp_end (float): final temperature
• temp_init (float): initial temperature
v 1.8.0 751
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
• As other batch methods, the basic syntax of the annealing statement uses
method annealing instead of the expected annealing name: id :
method annealing [facet: value];
• For example:
method annealing temp_init: 100 temp_end: 1 temp_decrease: 0.5
nb_iter_cst_temp: 5 maximize: food_gathered;
Embedments
ask
Definition
Allows an agent, the sender agent (that can be the GlobalSpecies), to ask another (or
other) agent(s) to perform a set of statements. If the value of the target facet is nil
or empty, the statement is ignored.
Facets
v 1.8.0 752
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
• Ask one agent to perform a block of statements. The block is evaluated in the
context of the agent’s species
ask ${one_agent} {
${cursor}
}
• To ask a set of agents to do something only if they belong to a given species, the
of_species operator can be used. If none of the agents belong to the species,
nothing happens
ask ${receiver_agents} of_species ${species_name} {
${cursor}
}
• Any statement can be declared in the block statements. All the statements
will be evaluated in the context of the receiver agent(s), as if they were defined
in their species, which means that an expression like self will represent the
receiver agent and not the sender. If the sender needs to refer to itself, some of
its own attributes (or temporary variables) within the block statements, it has
to use the keyword myself.
v 1.8.0 753
GAMA v1.8.0 documentation Chapter 93. Statements
species animal {
float energy <- rnd (1000) min: 0.0;
reflex when: energy > 500 { // executed when the energy is above
the given threshold
list<animal> others <- (animal at_distance 5); // find all the
neighboring animals in a radius of 5 meters
float shared_energy <- (energy - 500) / length (others); //
compute the amount of energy to share with each of them
ask others { // no need to cast, since others has already been
filtered to only include animals
if (energy < 500) { // refers to the energy of each
animal in others
energy <- energy + myself.shared_energy; //
increases the energy of each animal
myself.energy <- myself.energy - myself.
shared_energy; // decreases the energy of the sender
}
}
}
}
Embedments
aspect
Definition
Aspect statement is used to define a way to draw the current agent. Several aspects
can be defined in one species. It can use attributes to customize each agent’s aspect.
v 1.8.0 754
GAMA v1.8.0 documentation Chapter 93. Statements
The aspect is evaluate for each agent each time it has to be displayed.
Facets
• name (an identifier), (omissible) : identifier of the aspect (it can be used in a
display to identify which aspect should be used for the given species). Two
special names can also be used: ‘default’ will allow this aspect to be used as
a replacement for the default aspect defined in preferences; ‘highlighted’ will
allow the aspect to be used when the agent is highlighted as a replacement for
the default (application of a color)
Usages
Embedments
assert
Definition
Allows to check if the evaluation of a given expression returns true. If not, an error
(or a warning) is raised. If the statement is used inside a test, the error is not
v 1.8.0 755
GAMA v1.8.0 documentation Chapter 93. Statements
propagagated but invalidates the test (in case of a warning, it partially invalidates
it). Otherwise, it is normally propagated
Facets
Usages
• if the ‘warn:’ facet is set to true, the statement emits a warning (instead of an
error) in case the expression is false
assert 'abc' is string warning: true
Embedments
v 1.8.0 756
GAMA v1.8.0 documentation Chapter 93. Statements
benchmark
Definition
Displays in the console the duration in ms of the execution of the statements included
in the block. It is possible to indicate, with the ‘repeat’ facet, how many times the
sequence should be run
Facets
Usages
Embedments
break
Definition
v 1.8.0 757
GAMA v1.8.0 documentation Chapter 93. Statements
Facets
Usages
Embedments
camera
Definition
cameraallows the modeler to define a camera. The display will then be able to choose
among the camera defined (either within this statement or globally in GAMA) in a
dynamic way.
Facets
Usages
• See also: display, agents, chart, event, graphics, display_grid, image, display_-
population,
Embedments
v 1.8.0 758
GAMA v1.8.0 documentation Chapter 93. Statements
capture
Definition
Facets
Usages
• To capture all “A” agents as “C” agents, we can ask an “B” agent to execute
the following statement:
v 1.8.0 759
GAMA v1.8.0 documentation Chapter 93. Statements
capture list(B) as: C;
• Deprecated writing:
capture target: list (B) as: C;
Embedments
catch
Definition
Facets
Usages
Embedments
v 1.8.0 760
GAMA v1.8.0 documentation Chapter 93. Statements
chart
Definition
chart allows modeler to display a chart: this enables to display specific values of the
model at each iteration. GAMA can display various chart types: time series (series),
pie charts (pie) and histograms (histogram).
Facets
v 1.8.0 761
GAMA v1.8.0 documentation Chapter 93. Statements
• size (point): the layer resize factor: {1,1} refers to the original size whereas
{0.5,0.5} divides by 2 the height and the width of the layer. In case of a 3D layer,
a 3D point can be used (note that {1,1} is equivalent to {1,1,0}, so a resize of
a layer containing 3D objects with a 2D points will remove the elevation)
• style (an identifier), takes values in: {line, whisker, area, bar, dot, step, spline,
stack, 3d, ring, exploded, default}: The sub-style style, also default style for
the series.
• tick_font (string): Tick font face
• tick_font_size (int): Tick font size
• tick_font_style (an identifier), takes values in: {plain, bold, italic}: the style
used to display ticks
• tick_line_color (rgb): the tick lines color
• title_font (string): Title font face
• title_font_size (int): Title font size
• title_font_style (an identifier), takes values in: {plain, bold, italic}: the
style used to display titles
• title_visible (boolean): chart title visible
• type (an identifier), takes values in: {xy, scatter, histogram, series, pie, radar,
heatmap, box_whisker}: the type of chart. It could be histogram, series, xy,
pie, radar, heatmap or box whisker. The difference between series and xy is
that the former adds an implicit x-axis that refers to the numbers of cycles,
while the latter considers the first declaration of data to be its x-axis.
• x_label (string): the title for the X axis
• x_log_scale (boolean): use Log Scale for X axis
• x_range (any type in [float, int, point, list]): range of the x-axis. Can be a
number (which will set the axis total range) or a point (which will set the min
and max of the axis).
• x_serie (any type in [list, float, int]): for series charts, change the default
common x serie (simulation cycle) for an other value (list or numerical).
• x_serie_labels (any type in [list, float, int, a label]): change the default
common x series labels (replace x value or categories) for an other value (string
or numerical).
• x_tick_line_visible (boolean): X tick line visible
• x_tick_unit (float): the tick unit for the y-axis (distance between horyzontal
lines and values on the left of the axis).
• x_tick_values_visible (boolean): X tick values visible
• y_label (string): the title for the Y axis
• y_log_scale (boolean): use Log Scale for Y axis
v 1.8.0 762
GAMA v1.8.0 documentation Chapter 93. Statements
• y_range (any type in [float, int, point, list]): range of the y-axis. Can be a
number (which will set the axis total range) or a point (which will set the min
and max of the axis).
• y_serie_labels (any type in [list, float, int, a label]): for heatmaps/3d charts,
change the default y serie for an other value (string or numerical in a list or
cumulative).
• y_tick_line_visible (boolean): Y tick line visible
• y_tick_unit (float): the tick unit for the x-axis (distance between vertical lines
and values bellow the axis).
• y_tick_unit (float): the tick unit for the x-axis (distance between vertical lines
and values bellow the axis).
• y_tick_values_visible (boolean): Y tick values visible
• y2_label (string): the title for the second Y axis
• y2_log_scale (boolean): use Log Scale for second Y axis
• y2_range (any type in [float, int, point, list]): range of the second y-axis. Can
be a number (which will set the axis total range) or a point (which will set the
min and max of the axis).
Usages
• See also: display, agents, event, graphics, display_grid, image, overlay, quadtree,
display_population, text,
Embedments
v 1.8.0 763
GAMA v1.8.0 documentation Chapter 93. Statements
conscious_contagion
Definition
enables to directly add an emotion of a perceived specie if the perceived agent ges a
patricular emotion.
Facets
• emotion_created (546706): the emotion that will be created with the contagion
Usages
Embedments
v 1.8.0 764
GAMA v1.8.0 documentation Chapter 93. Statements
coping
Definition
enables to add or remove mantal states depending on the emotions of the agent, after
the emotional engine and before the cognitive or normative engine.
Facets
v 1.8.0 765
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
coping emotion: new_emotion("fear") when: flip(0.5) new_desire:
new_predicate("test")
Embedments
v 1.8.0 766
GAMA v1.8.0 documentation Chapter 93. Statements
create
Definition
Allows an agent to create number agents of species species, to create agents of species
species from a shapefile or to create agents of species species from one or several
localized entities (discretization of the localized entity geometries).
Facets
Usages
v 1.8.0 767
GAMA v1.8.0 documentation Chapter 93. Statements
create a_species from: the_shapefile with: [type:: read('TYPE_OCC'),
nature::read('NATURE')];
• In order to create agents from a .csv file, facet header can be used to specified
whether we can use columns header:
create toto from: "toto.csv" header: true with:[att1::read("NAME"),
att2::read("TYPE")];
or
create toto from: "toto.csv" with:[att1::read(0), att2::read(1)]; //
with read(int), the index of the column
• Similarly to the creation from shapefile, modelers can create agents from a set
of geometries. In this case, one agent per geometry will be created (with the
geometry as shape)
create species_of(self) from: [square(4),circle(4)]; // 2 agents
have been created, with shapes respectively square(4) and circle(4)
• Created agents are initialized following the rules of their species. If one wants
to refer to them after the statement is executed, the returns keyword has to be
defined: the agents created will then be referred to by the temporary variable
it declares. For instance, the following statement creates 0 to 4 agents of the
same species as the sender, and puts them in the temporary variable children
for later use.
create species (self) number: rnd (4) returns: children;
ask children {
// ...
}
• If one wants to specify a special initialization sequence for the agents created,
create provides the same possibilities as ask. This extended syntax is:
v 1.8.0 768
GAMA v1.8.0 documentation Chapter 93. Statements
create a_species number: an_int {
[statements]
}
• The same rules as in ask apply. The only difference is that, for the agents
created, the assignments of variables will bypass the initialization defined in
species. For instance:
create species(self) number: rnd (4) returns: children {
set location <- myself.location + {rnd (2), rnd (2)}; // tells the
children to be initially located close to me
set parent <- myself; // tells the children that their parent is
me (provided the variable parent is declared in this species)
}
• Desprecated uses:
// Simple syntax
create species: a_species number: an_int;
Embedments
data
Definition
This statement allows to describe the values that will be displayed on the chart.
v 1.8.0 769
GAMA v1.8.0 documentation Chapter 93. Statements
Facets
• value (any type in [float, point, list]): The value to output on the chart
• accumulate_values (boolean): Force to replace values at each step (false) or
accumulate with previous steps (true)
• color (any type in [rgb, list]): color of the serie, for heatmap can be a list to
specify [minColor,maxColor] or [minColor,medColor,maxColor]
• fill (boolean): Marker filled (true) or not (false)
• line_visible (boolean): Whether lines are visible or not
• marker (boolean): marker visible or not
• marker_shape (an identifier), takes values in: {marker_empty, marker_square,
marker_circle, marker_up_triangle, marker_diamond, marker_hor_rectangle,
marker_down_triangle, marker_hor_ellipse, marker_right_triangle, marker_-
vert_rectangle, marker_left_triangle}: Shape of the marker
• marker_size (float): Size in pixels of the marker
• style (an identifier), takes values in: {line, whisker, area, bar, dot, step, spline,
stack, 3d, ring, exploded}: Style for the serie (if not the default one sepecified
on chart statement)
• thickness (float): The thickness of the lines to draw
• use_second_y_axis (boolean): Use second y axis for this serie
• x_err_values (any type in [float, list]): the X Error bar values to display. Has
to be a List. Each element can be a number or a list with two values (low and
high value)
• y_err_values (any type in [float, list]): the Y Error bar values to display. Has
to be a List. Each element can be a number or a list with two values (low and
high value)
• y_minmax_values (list): the Y MinMax bar values to display (BW charts). Has
to be a List. Each element can be a number or a list with two values (low and
high value)
Usages
Embedments
v 1.8.0 770
GAMA v1.8.0 documentation Chapter 93. Statements
datalist
Definition
add a list of series to a chart. The number of series can be dynamic (the size of the
list changes each step). See Ant Foraging (Charts) model in ChartTest for examples.
Facets
• value (list): the values to display. Has to be a matrix, a list or a List of List.
Each element can be a number (series/histogram) or a list with two values (XY
chart)
• legend (list), (omissible) : the name of the series: a list of strings (can be a
variable with dynamic names)
• accumulate_values (boolean): Force to replace values at each step (false) or
accumulate with previous steps (true)
• color (list): list of colors, for heatmaps can be a list of [minColor,maxColor] or
[minColor,medColor,maxColor]
• fill (boolean): Marker filled (true) or not (false), same for all series.
• line_visible (boolean): Line visible or not (same for all series)
• marker (boolean): marker visible or not
• marker_shape (an identifier), takes values in: {marker_empty, marker_square,
marker_circle, marker_up_triangle, marker_diamond, marker_hor_rectangle,
marker_down_triangle, marker_hor_ellipse, marker_right_triangle, marker_-
vert_rectangle, marker_left_triangle}: Shape of the marker. Same one for all
series.
• marker_size (list): the marker sizes to display. Can be a list of numbers (same
size for each marker of the series) or a list of list (different sizes by point)
• style (an identifier), takes values in: {line, whisker, area, bar, dot, step, spline,
stack, 3d, ring, exploded}: Style for the serie (if not the default one sepecified
on chart statement)
v 1.8.0 771
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
Embedments
default
Definition
Used in a switch match structure, the block prefixed by default is executed only if no
other block has matched (otherwise it is not).
Facets
• value (any type), (omissible) : The value or values this statement tries to
match
Usages
v 1.8.0 772
GAMA v1.8.0 documentation Chapter 93. Statements
Embedments
diffuse
Definition
Facets
• on (any type in [container, species]): the list of agents (in general cells of a
grid), on which the diffusion will occur
• avoid_mask (boolean): if true, the value will not be diffused in the masked
cells, but will be restitute to the neighboring cells, multiplied by the proportion
value (no signal lost). If false, the value will be diffused in the masked cells, but
masked cells won’t diffuse the value afterward (lost of signal). (default value :
false)
• cycle_length (int): the number of diffusion operation applied in one simulation
step
• mask (matrix): a matrix masking the diffusion (matrix created from a image
for example). The cells corresponding to the values smaller than “-1” in the
mask matrix will not diffuse, and the other will diffuse.
• matrix (matrix): the diffusion matrix (“kernel” or “filter” in image processing).
Can have any size, as long as dimensions are odd values.
• method (an identifier), takes values in: {convolution, dot_product}: the diffu-
sion method
• min_value (float): if a value is smaller than this value, it will not be diffused.
By default, this value is equal to 0.0. This value cannot be smaller than 0.
v 1.8.0 773
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
• A basic example of diffusion of the variable phero defined in the species cells,
given a diffusion matrix math_diff is:
matrix<float> math_diff <- matrix
([[1/9,1/9,1/9],[1/9,1/9,1/9],[1/9,1/9,1/9]]);
diffuse var: phero on: cells matrix: math_diff;
v 1.8.0 774
GAMA v1.8.0 documentation Chapter 93. Statements
Embedments
display
Definition
A display refers to a independent and mobile part of the interface that can display
species, images, texts or charts.
Facets
v 1.8.0 775
GAMA v1.8.0 documentation Chapter 93. Statements
v 1.8.0 776
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
Embedments
display_grid
Definition
display_grid is used using the grid keyword. It allows the modeler to display in
an optimized way all cell agents of a grid (i.e. all agents of a species having a grid
topology).
Facets
v 1.8.0 777
GAMA v1.8.0 documentation Chapter 93. Statements
• elevation (any type in [matrix, float, int, boolean]): Allows to specify the
elevation of each cell, if any. Can be a matrix of float (provided it has the same
size than the grid), an int or float variable of the grid species, or simply true
(in which case, the variable called ‘grid_value’ is used to compute the elevation
of each cell)
• grayscale (boolean): if true, givse a grey value to each polygon depending on
its elevation (false by default)
• hexagonal (boolean):
• lines (rgb): the color to draw lines (borders of cells)
• position (point): position of the upper-left corner of the layer. Note that if
coordinates are in [0,1[, the position is relative to the size of the environment
(e.g. {0.5,0.5} refers to the middle of the display) whereas it is absolute when
coordinates are greater than 1 for x and y. The z-ordinate can only be defined
between 0 and 1. The position can only be a 3D point {0.5, 0.5, 0.5}, the last
coordinate specifying the elevation of the layer.
• refresh (boolean): (openGL only) specify whether the display of the species is
refreshed. (true by default, usefull in case of agents that do not move)
• selectable (boolean): Indicates whether the agents present on this layer are
selectable by the user. Default is true
• size (point): extent of the layer in the screen from its position. Coordinates
in [0,1[ are treated as percentages of the total surface, while coordinates > 1
are treated as absolute sizes in model units (i.e. considering the model occupies
the entire view). Like in ‘position’, an elevation can be provided with the z
coordinate, allowing to scale the layer in the 3 directions
• text (boolean): specify whether the attribute used to compute the elevation is
displayed on each cells (false by default)
• texture (file): Either file containing the texture image to be applied on the
grid or, if not specified, the use of the image composed by the colors of the cells
• transparency (float): the transparency rate of the agents (between 0 and 1, 1
means no transparency)
• triangulation (boolean): specifies whther the cells will be triangulated: if it is
false, they will be displayed as horizontal squares at a given elevation, whereas
if it is true, cells will be triangulated and linked to neighbors in order to have a
continuous surface (false by default)
Usages
v 1.8.0 778
GAMA v1.8.0 documentation Chapter 93. Statements
display my_display {
grid ant_grid lines: #black position: { 0.5, 0 } size: {0.5,0.5};
}
• See also: display, agents, chart, event, graphics, image, overlay, display_-
population,
Embedments
display_population
Definition
Facets
v 1.8.0 779
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
• Species can be superposed on the same plan (be careful with the order, the last
one will be above all the others):
display my_display {
species agent1 aspect: base;
v 1.8.0 780
GAMA v1.8.0 documentation Chapter 93. Statements
• Each species layer can be placed at a different z value using the opengl display.
position:{0,0,0} means the layer will be placed on the ground and position:{0,0,1}
means it will be placed at an height equal to the maximum size of the environ-
ment.
display my_display type: opengl{
species agent1 aspect: base ;
species agent2 aspect: base position:{0,0,0.5};
species agent3 aspect: base position:{0,0,1};
}
• See also: display, agents, chart, event, graphics, display_grid, image, overlay,
Embedments
do
Definition
Allows the agent to execute an (built-in or defined by the modeler) action. For a list of
built-in actions available in every species, see RegularSpecies#built-in-actions; for the
built-in action available in the world agent, see the GlobalSpecies#built-in-actions;
for the actions defined by the different skills, see this BuiltInSkills. Finally, see
DefiningActionsAndBehaviors#action.
v 1.8.0 781
GAMA v1.8.0 documentation Chapter 93. Statements
Facets
Usages
• The simple syntax (when the action does not expect any argument and the
result is not to be kept) is:
do name_of_action_or_primitive;
• In case the action expects one or more arguments to be passed, they are defined
by using facets (enclosed tags or a map are now deprecated):
do name_of_action_or_primitive arg1: expression1 arg2: expression2;
• In case the result of the action needs to be made available to the agent, the
action can be called with the agent calling the action (self when the agent itself
calls the action) instead of do; the result should be assigned to a temporary
variable:
type_returned_by_action result <- self name_of_action_or_primitive [];
• Deprecated uses: following uses of the do statement (still accepted) are now
deprecated:
v 1.8.0 782
GAMA v1.8.0 documentation Chapter 93. Statements
// Simple syntax:
do action: name_of_action_or_primitive;
or
do name_of_action_or_primitive {
arg arg1 value: expression1;
arg arg2 value: expression2;
...
}
Embedments
v 1.8.0 783
GAMA v1.8.0 documentation Chapter 93. Statements
draw
Definition
draw is used in an aspect block to express how agents of the species will be drawn. It
is evaluated each time the agent has to be drawn. It can also be used in the graphics
block.
Facets
• geometry (any type), (omissible) : any type of data (it can be geometry, image,
text)
• anchor (point): Only used when perspective: true in OpenGL. The anchor
point of the location with respect to the envelope of the text to draw, can take
one of the following values: #center, #top_left, #left_center, #bottom_left,
#bottom_center, #bottom_right, #right_center, #top_right, #top_center;
or any point between {0,0} (#bottom_left) and {1,1} (#top_right)
• at (point): location where the shape/text/icon is drawn
• begin_arrow (any type in [int, float]): the size of the arrow, located at the
beginning of the drawn geometry
• border (any type in [rgb, boolean]): if used with a color, represents the color of
the geometry border. If set to false, expresses that no border should be drawn.
If not set, the borders will be drawn using the color of the geometry.
• color (any type in [rgb, container]): the color to use to display the object. In
case of images, will try to colorize it. You can also pass a list of colors: in that
case, each color will be matched to its corresponding vertex.
• depth (float): (only if the display type is opengl) Add an artificial depth to the
geometry previously defined (a line becomes a plan, a circle becomes a cylinder,
a square becomes a cube, a polygon becomes a polyhedron with height equal to
the depth value). Note: This only works if the geometry is not a point
• empty (boolean): a condition specifying whether the geometry is empty or full
• end_arrow (any type in [int, float]): the size of the arrow, located at the end of
the drawn geometry
• font (any type in [19, string]): the font used to draw the text, if any. Applying
this facet to geometries or images has no effect. You can construct here your
font with the operator “font”. ex : font: font("Helvetica", 20 , #plain)
• lighted (boolean): Whether the object should be lighted or not (only applicable
in the context of opengl displays)
v 1.8.0 784
GAMA v1.8.0 documentation Chapter 93. Statements
• material (25): Set a particular material to the object (only if you use it in an
“opengl2” display).
• perspective (boolean): Whether to render the text in perspective or facing
the user. Default is true.
• rotate (any type in [float, int, pair]): orientation of the shape/text/icon; can
be either an int/float (angle) or a pair float::point (angle::rotation axis). The
rotation axis, when expressed as an angle, is by defaut {0,0,1}
• size (any type in [float, point]): Size of the shape/icon/image to draw, expressed
as a bounding box (width, height, depth; if expressed as a float, represents
the box as a cube). Does not apply to texts: use a font with the required size
instead
• texture (any type in [string, list, file]): the texture(s) that should be applied
to the geometry. Either a path to a file or a list of paths
• width (float): The line width to use for drawing this object
Usages
• Any kind of geometry as any location can be drawn when displaying an agent
(independently of his shape)
aspect geometryAspect {
draw circle(1.0) empty: !hasFood color: #orange ;
}
• Arrows can be drawn with any kind of geometry, using begin_arrow and end_-
arrow facets, combined with the empty: facet to specify whether it is plain or
empty
v 1.8.0 785
GAMA v1.8.0 documentation Chapter 93. Statements
aspect arrowAspect {
draw line([{20, 20}, {40, 40}]) color: #black begin_arrow:5;
draw line([{10, 10},{20, 50}, {40, 70}]) color: #green end_arrow: 2
begin_arrow: 2 empty: true;
draw square(10) at: {80,20} color: #purple begin_arrow: 2 empty:
true;
}
Embedments
else
Definition
Facets
Usages
Embedments
v 1.8.0 786
GAMA v1.8.0 documentation Chapter 93. Statements
emotional_contagion
Definition
Facets
Usages
Embedments
v 1.8.0 787
GAMA v1.8.0 documentation Chapter 93. Statements
enforcement
Definition
applay a sanction if the norm specified is violated, or a reward if the norm is applied
by the perceived agent
Facets
Usages
focus var:speed /*where speed is a variable from a species that is
being perceived*/
Embedments
v 1.8.0 788
GAMA v1.8.0 documentation Chapter 93. Statements
enter
Definition
Facets
Usages
• In the following example, at the step it enters into the state s_init, the message
‘Enter in s_init’ is displayed followed by the display of the state name:
state s_init {
enter { write "Enter in" + state; }
write "Enter in" + state;
}
write state;
}
Embedments
equation
Definition
The equation statement is used to create an equation system from several single
equations.
v 1.8.0 789
GAMA v1.8.0 documentation Chapter 93. Statements
Facets
Usages
• If the type: facet is used, a predefined equation system is defined using variables
vars: and parameters params: in the right order. All possible predefined
equation systems are the following ones (see Equations for precise definition of
each classical equation system):
equation eqSI type: SI vars: [S,I,t] params: [N,beta];
equation eqSIS type: SIS vars: [S,I,t] params: [N,beta,gamma];
equation eqSIR type:SIR vars:[S,I,R,t] params:[N,beta,gamma];
equation eqSIRS type: SIRS vars: [S,I,R,t] params: [N,beta,gamma,omega,
mu];
equation eqSEIR type: SEIR vars: [S,E,I,R,t] params: [N,beta,gamma,
sigma,mu];
equation eqLV type: LV vars: [x,y,t] params: [alpha,beta,delta,gamma] ;
• If the simultaneously: facet is used, system of all the agents will be solved
simultaneously.
v 1.8.0 790
GAMA v1.8.0 documentation Chapter 93. Statements
Embedments
error
Definition
The statement makes the agent output an error dialog (if the simulation contains a
user interface). Otherwise displays the error in the console.
Facets
Usages
• Throwing an error
error 'This is an error raised by ' + self;
Embedments
v 1.8.0 791
GAMA v1.8.0 documentation Chapter 93. Statements
event
Definition
event allows to interact with the simulation by capturing mouse or key events
and doing an action. This action needs to be defined in ‘global’ or in the current
experiment, without any arguments. The location of the mouse in the world can be
retrieved in this action with the pseudo-constant #user_location
Facets
Usages
event [event_type] action: myAction;
• For instance:
v 1.8.0 792
GAMA v1.8.0 documentation Chapter 93. Statements
global {
// ...
action myAction () {
point loc <- #user_location; // contains the location of the
mouse in the world
list<agent> selected_agents <- agents inside (10#m around loc);
// contains agents clicked by the event
• See also: display, agents, chart, graphics, display_grid, image, overlay, display_-
population,
Embedments
exhaustive
Definition
This is the standard batch method. The exhaustive mode is defined by default
when there is no method element present in the batch section. It explores all the
combination of parameter values in a sequential way. See BatchExperiments.
v 1.8.0 793
GAMA v1.8.0 documentation Chapter 93. Statements
Facets
• name (an identifier), (omissible) : The name of the method. For internal use
only
• aggregation (a label), takes values in: {min, max}: The aggregation method
to use (either min or max)
• maximize (float): the value the algorithm tries to maximize
• minimize (float): the value the algorithm tries to minimize
Usages
• As other batch methods, the basic syntax of the exhaustive statement uses
method exhaustive instead of the expected exhaustive name: id :
method exhaustive [facet: value];
• For example:
method exhaustive maximize: food_gathered;
Embedments
exit
Definition
v 1.8.0 794
GAMA v1.8.0 documentation Chapter 93. Statements
Facets
Usages
• In the following example, at the state it leaves the state s_init, he will display
the message ‘EXIT from s_init’:
state s_init initial: true {
write state;
transition to: s1 when: (cycle > 2) {
write "transition s_init -> s1";
}
exit {
write "EXIT from "+state;
}
}
Embedments
experiment
Definition
Facets
v 1.8.0 795
GAMA v1.8.0 documentation Chapter 93. Statements
• title (a label):
• type (a label), takes values in: {batch, memorize, gui, test, headless}: the type
of the experiment (either ‘gui’ or ‘batch’
• autorun (boolean): whether this experiment should be run automatically when
launched (false by default)
• benchmark (boolean): If true, make GAMA record the number of invocations
and running time of the statements and operators of the simulations launched
in this experiment. The results are automatically saved in a csv file in a folder
called ‘benchmarks’ when the experiment is closed
• control (an identifier):
• frequency (int): the execution frequence of the experiment (default value: 1).
If frequency: 10, the experiment is executed only each 10 steps.
• keep_seed (boolean): Allows to keep the same seed between simulations. Mainly
useful for batch experiments
• keep_simulations (boolean): In the case of a batch experiment, specifies
whether or not the simulations should be kept in memory for further analysis
or immediately discarded with only their fitness kept in memory
• parallel (any type in [boolean, int]): When set to true, use multiple threads
to run its simulations. Setting it to n will set the numbers of threads to use
• parent (an identifier): the parent experiment (in case of inheritance between
experiments)
• repeat (int): In the case of a batch experiment, expresses hom many times the
simulations must be repeated
• schedules (container): A container of agents (a species, a dynamic list, or a
combination of species and containers) , which represents which agents will be
actually scheduled when the population is scheduled for execution. For instance,
‘species a schedules: (10 among a)’ will result in a population that schedules
only 10 of its own agents every cycle. ‘species b schedules: []’ will prevent the
agents of ‘b’ to be scheduled. Note that the scope of agents covered here can be
larger than the population, which allows to build complex scheduling controls;
for instance, defining ‘global schedules: [] {. . . } species b schedules: []; species
c schedules: b + world;’ allows to simulate a model where the agents of b are
scheduled first, followed by the world, without even having to create an instance
of c.
• skills (list):
• until (boolean): In the case of a batch experiment, an expression that will be
evaluated to know when a simulation should be terminated
v 1.8.0 796
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
Embedments
focus
Definition
Facets
• agent_cause (agent): the agentCause value of the created belief (can be nil
• belief (546704): The predicate to focus on the beliefs of the other agent
• desire (546704): The predicate to focus on the desires of the other agent
• emotion (546706): The emotion to focus on the emotions of the other agent
• expression (any type): an expression that will be the value kept in the belief
• id (string): the identifier of the focus
• ideal (546704): The predicate to focus on the ideals of the other agent
• is_uncertain (boolean): a boolean to indicate if the mental state created is
an uncertainty
• lifetime (int): the lifetime value of the created belief
• strength (any type in [float, int]): The priority of the created predicate
• truth (boolean): the truth value of the created belief
• uncertainty (546704): The predicate to focus on the uncertainties of the other
agent
• var (any type in [any type, list, container]): the variable of the perceived agent
you want to add to your beliefs
v 1.8.0 797
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
Embedments
focus_on
Definition
Allows to focus on the passed parameter in all available displays. Passing ‘nil’ for the
parameter will make all screens return to their normal zoom
Facets
• value (any type), (omissible) : The agent, list of agents, geometry to focus on
Usages
v 1.8.0 798
GAMA v1.8.0 documentation Chapter 93. Statements
Embedments
genetic
Definition
This is a simple implementation of Genetic Algorithms (GA). See the wikipedia article
and BatchExperiments. The principle of the GA is to search an optimal solution by
applying evolution operators on an initial population of solutions. There are three
types of evolution operators: crossover, mutation and selection. Different techniques
can be applied for this selection. Most of them are based on the solution quality
(fitness).
Facets
• name (an identifier), (omissible) : The name of this method. For internal use
only
• aggregation (a label), takes values in: {min, max}: the agregation method
• crossover_prob (float): crossover probability between two individual solutions
• improve_sol (boolean): if true, use a hill climbing algorithm to improve the
solutions at each generation
• max_gen (int): number of generations
• maximize (float): the value the algorithm tries to maximize
• minimize (float): the value the algorithm tries to minimize
• mutation_prob (float): mutation probability for an individual solution
• nb_prelim_gen (int): number of random populations used to build the initial
population
• pop_dim (int): size of the population (number of individual solutions)
• stochastic_sel (boolean): if true, use a stochastic selection algorithm
(roulette) rather a determistic one (keep the best solutions)
v 1.8.0 799
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
• As other batch methods, the basic syntax of the genetic statement uses method
genetic instead of the expected genetic name: id :
method genetic [facet: value];
• For example:
method genetic maximize: food_gathered pop_dim: 5 crossover_prob: 0.7
mutation_prob: 0.1 nb_prelim_gen: 1 max_gen: 20;
Embedments
graphics
Definition
Facets
v 1.8.0 800
GAMA v1.8.0 documentation Chapter 93. Statements
• position (point): position of the upper-left corner of the layer. Note that if
coordinates are in [0,1[, the position is relative to the size of the environment
(e.g. {0.5,0.5} refers to the middle of the display) whereas it is absolute when
coordinates are greater than 1 for x and y. The z-ordinate can only be defined
between 0 and 1. The position can only be a 3D point {0.5, 0.5, 0.5}, the last
coordinate specifying the elevation of the layer.
• refresh (boolean): (openGL only) specify whether the display of the species is
refreshed. (true by default, usefull in case of agents that do not move)
• size (point): extent of the layer in the screen from its position. Coordinates
in [0,1[ are treated as percentages of the total surface, while coordinates > 1
are treated as absolute sizes in model units (i.e. considering the model occupies
the entire view). Like in ‘position’, an elevation can be provided with the z
coordinate, allowing to scale the layer in the 3 directions
• trace (any type in [boolean, int]): Allows to aggregate the visualization at each
timestep on the display. Default is false. If set to an int value, only the last
n-th steps will be visualized. If set to true, no limit of timesteps is applied.
• transparency (float): the transparency rate of the agents (between 0 and 1, 1
means no transparency)
Usages
• See also: display, agents, chart, event, graphics, display_grid, image, overlay,
display_population,
Embedments
v 1.8.0 801
GAMA v1.8.0 documentation Chapter 93. Statements
highlight
Definition
Allows to highlight the agent passed in parameter in all available displays, optionaly
setting a color. Passing ‘nil’ for the agent will remove the current highlight
Facets
Usages
• Highlighting an agent
highlight my_species(0) color: #blue;
Embedments
v 1.8.0 802
GAMA v1.8.0 documentation Chapter 93. Statements
hill_climbing
Definition
This algorithm is an implementation of the Hill Climbing algorithm. See the wikipedia
article and BatchExperiments.
Facets
• name (an identifier), (omissible) : The name of the method. For internal use
only
• aggregation (a label), takes values in: {min, max}: the agregation method
• iter_max (int): number of iterations
• maximize (float): the value the algorithm tries to maximize
• minimize (float): the value the algorithm tries to minimize
Usages
• As other batch methods, the basic syntax of the hill_climbing statement uses
method hill_climbing instead of the expected hill_climbing name: id :
method hill_climbing [facet: value];
• For example:
method hill_climbing iter_max: 50 maximize : food_gathered;
Embedments
v 1.8.0 803
GAMA v1.8.0 documentation Chapter 93. Statements
if
Definition
Allows the agent to execute a sequence of statements if and only if the condition
evaluates to true.
Facets
Usages
• Optionally, the statements to execute when the condition evaluates to false can
be defined in a following statement else. The syntax then becomes:
if bool_expr {
[statements]
}
else {
[statements]
}
string valTrue <- "";
if true {
valTrue <- "true";
}
else {
valTrue <- "false";
}//valTrue equals "true"
string valFalse <- "";
if false {
valFalse <- "true";
v 1.8.0 804
GAMA v1.8.0 documentation Chapter 93. Statements
}
else {
valFalse <- "false";
}//valFalse equals "false"
if bool_expr {
[statements]
}
else if bool_expr2 {
[statements]
}
else {
[statements]
}
Embedments
image
Definition
v 1.8.0 805
GAMA v1.8.0 documentation Chapter 93. Statements
Facets
• name (any type in [string, file]), (omissible) : Human readable title of the image
layer
• color (rgb): in the case of a shapefile, this the color used to fill in geometries
of the shapefile. In the case of an image, it is used to tint the image
• file (any type in [string, file]): the name/path of the image (in the case of a
raster image)
• gis (any type in [file, string]): the name/path of the shape file (to display a
shapefile as background, without creating agents from it)
• position (point): position of the upper-left corner of the layer. Note that if
coordinates are in [0,1[, the position is relative to the size of the environment
(e.g. {0.5,0.5} refers to the middle of the display) whereas it is absolute when
coordinates are greater than 1 for x and y. The z-ordinate can only be defined
between 0 and 1. The position can only be a 3D point {0.5, 0.5, 0.5}, the last
coordinate specifying the elevation of the layer.
• refresh (boolean): (openGL only) specify whether the image display is refreshed
or not. (false by default, true should be used in cases of images that are modified
over the simulation)
• size (point): extent of the layer in the screen from its position. Coordinates
in [0,1[ are treated as percentages of the total surface, while coordinates > 1
are treated as absolute sizes in model units (i.e. considering the model occupies
the entire view). Like in ‘position’, an elevation can be provided with the z
coordinate, allowing to scale the layer in the 3 directions
• transparency (float): the transparency rate of the agents (between 0 and 1, 1
means no transparency)
Usages
v 1.8.0 806
GAMA v1.8.0 documentation Chapter 93. Statements
display my_display {
image background file:"../images/my_backgound.jpg";
}
• It is also possible to superpose images on different layers in the same way as for
species using opengl display:
display my_display {
image image1 file:"../images/image1.jpg";
image image2 file:"../images/image2.jpg";
image image3 file:"../images/image3.jpg" position: {0,0,0.5};
}
• See also: display, agents, chart, event, graphics, display_grid, overlay, display_-
population,
Embedments
inspect
Definition
inspect (and browse) statements allows modeler to inspect a set of agents, in a table
with agents and all their attributes or an agent inspector per agent, depending on
the type: chosen. Modeler can choose which attributes to display. When browse is
used, type: default value is table, whereas wheninspect is used, type: default value
is agent.
v 1.8.0 807
GAMA v1.8.0 documentation Chapter 93. Statements
Facets
Usages
Embedments
law
Definition
v 1.8.0 808
GAMA v1.8.0 documentation Chapter 93. Statements
Facets
Usages
Embedments
layout
Definition
v 1.8.0 809
GAMA v1.8.0 documentation Chapter 93. Statements
Facets
• value (any type), (omissible) : Either #none, to indicate that no layout will
be imposed, or one of the four possible predefined layouts: #stack, #split,
#horizontal or #vertical. This layout will be applied to both experiment and
simulation display views. In addition, it is possible to define a custom layout
using the horizontal() and vertical() operators
• consoles (boolean): Whether the consoles are visible or not (true by default)
• controls (boolean): Whether the experiment should show its control toolbar
on top or not
• editors (boolean): Whether the editors should initially be visible or not
• navigator (boolean): Whether the navigator view is visible or not (true by
default)
• parameters (boolean): Whether the parameters view is visible or not (true by
default)
• tabs (boolean): Whether the displays should show their tab or not
• toolbars (boolean): Whether the displays should show their toolbar or not
• tray (boolean): Whether the bottom tray is visible or not (true by default)
Usages
• For instance, this layout statement will allow to split the screen occupied by
displays in four equal parts, with no tabs. Pairs of display::weight represent the
number of the display in their order of definition and their respective weight
within a horizontal and vertical section
layout horizontal([vertical([0::5000,1::5000])::5000,vertical
([2::5000,3::5000])::5000]) tabs: false;
Embedments
v 1.8.0 810
GAMA v1.8.0 documentation Chapter 93. Statements
let
Definition
Allows to declare a temporary variable of the specified type and to initialize it with a
value
Facets
Usages
Embedments
light
Definition
v 1.8.0 811
GAMA v1.8.0 documentation Chapter 93. Statements
Facets
Usages
light 1 type:point position:{20,20,20} color:255, linear_attenuation
:0.01 quadratic_attenuation:0.0001 draw_light:true update:false
light 2 type:spot position:{20,20,20} direction:{0,0,-1} color:255
spot_angle:25 linear_attenuation:0.01 quadratic_attenuation:0.0001
draw_light:true update:false
light 3 type:point direction:{1,1,-1} color:255 draw_light:true update:
false
v 1.8.0 812
GAMA v1.8.0 documentation Chapter 93. Statements
Embedments
loop
Definition
Allows the agent to perform the same set of statements either a fixed number of
times, or while a condition is true, or by progressing in a collection of elements or
along an interval of integers. Be aware that there are no prevention of infinite loops.
As a consequence, open loops should be used with caution, as one agent may block
the execution of the whole model.
Facets
Usages
• The basic syntax for repeating a fixed number of times a set of statements is:
loop times: an_int_expression {
// [statements]
}
v 1.8.0 813
GAMA v1.8.0 documentation Chapter 93. Statements
• The basic syntax for repeating a set of statements while a condition holds is:
loop while: a_bool_expression {
// [statements]
}
• The basic syntax for repeating a set of statements by progressing over a container
of a point is:
loop a_temp_var over: a_collection_expression {
// [statements]
}
• The basic syntax for repeating a set of statements while an index iterates over
a range of values with a fixed step of 1 is:
loop a_temp_var from: int_expression_1 to: int_expression_2 {
// [statements]
}
• In these latter three cases, the name facet designates the name of a temporary
variable, whose scope is the loop, and that takes, in turn, the value of each of
the element of the list (or each value in the interval). For example, in the first
instance of the “loop over” syntax :
int a <- 0;
loop i over: [10, 20, 30] {
a <- a + i;
} // a now equals 60
v 1.8.0 814
GAMA v1.8.0 documentation Chapter 93. Statements
• The second (quite common) case of the loop syntax allows one to use an interval
of integers. The from and to facets take an integer expression as arguments, with
the first (resp. the last) specifying the beginning (resp. end) of the inclusive
interval (i.e. [to, from]). If the step is not defined, it is assumed to be equal to
1 or -1, depending on the direction of the range. If it is defined, its sign will be
respected, so that a positive step will never allow the loop to enter a loop from
i to j where i is greater than j
list the_list <-list (species_of (self));
loop i from: 0 to: length (the_list) - 1 {
ask the_list at i {
// ...
}
} // every agent of the list is asked to do something
Embedments
match
Definition
In a switch. . . match structure, the value of each match block is compared to the
value in the switch. If they match, the embedded statement set is executed. Three
kinds of match can be used
Facets
• value (any type), (omissible) : The value or values this statement tries to
match
v 1.8.0 815
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
• match block is executed if the switch value is equals to the value of the match:
switch 3 {
match 1 {write "Match 1"; }
match 3 {write "Match 2"; }
}
• match_one block is executed if the switch value is equals to one of the values
of the match_one:
switch 3 {
match_one [0,1,2] {write "Match OK with one of [0,1,2]"; }
match_between [2,3,4,5] {write "Match OK with one of [2,3,4,5]"; }
}
Embedments
v 1.8.0 816
GAMA v1.8.0 documentation Chapter 93. Statements
migrate
Definition
Facets
Usages
Embedments
v 1.8.0 817
GAMA v1.8.0 documentation Chapter 93. Statements
monitor
Definition
Facets
Usages
Embedments
norm
Definition
a norm indicates what action the agent has to do in a certain context and with and
obedience value higher than the threshold
v 1.8.0 818
GAMA v1.8.0 documentation Chapter 93. Statements
Facets
Usages
Embedments
output
Definition
output blocks define how to visualize a simulation (with one or more display blocks
that define separate windows). It will include a set of displays, monitors and files
statements. It will be taken into account only if the experiment type is gui.
Facets
Usages
v 1.8.0 819
GAMA v1.8.0 documentation Chapter 93. Statements
experiment exp_name type: gui {
// [inputs]
output {
// [display, file, inspect, layout or monitor statements]
}
}
Embedments
output_file
Definition
Facets
• name (an identifier), (omissible) : The name of the file where you want to
export the data
v 1.8.0 820
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
Embedments
overlay
Definition
overlay allows the modeler to display a line to the already existing bottom overlay,
where the results of ‘left’, ‘center’ and ‘right’ facets, when they are defined, are
displayed with the corresponding color if defined.
Facets
• background (rgb): the background color of the overlay displayed inside the view
(the bottom overlay remains black)
• border (rgb): Color to apply to the border of the rectangular shape of the
overlay. Nil by default
• center (any type): an expression that will be evaluated and displayed in the
center section of the bottom overlay
• color (any type in [list, rgb]): the color(s) used to display the expressions given
in the ‘left’, ‘center’ and ‘right’ facets
• left (any type): an expression that will be evaluated and displayed in the left
section of the bottom overlay
• position (point): position of the upper-left corner of the layer. Note that if
coordinates are in [0,1[, the position is relative to the size of the environment
(e.g. {0.5,0.5} refers to the middle of the display) whereas it is absolute when
coordinates are greater than 1 for x and y. The z-ordinate can only be defined
between 0 and 1. The position can only be a 3D point {0.5, 0.5, 0.5}, the last
coordinate specifying the elevation of the layer.
v 1.8.0 821
GAMA v1.8.0 documentation Chapter 93. Statements
• right (any type): an expression that will be evaluated and displayed in the
right section of the bottom overlay
• rounded (boolean): Whether or not the rectangular shape of the overlay should
be rounded. True by default
• size (point): extent of the layer in the view from its position. Coordinates in
[0,1[ are treated as percentages of the total surface of the view, while coordinates
> 1 are treated as absolute sizes in model units (i.e. considering the model
occupies the entire view). Unlike ‘position’, no elevation can be provided with
the z coordinate
• transparency (float): the transparency rate of the overlay (between 0 and 1,
1 means no transparency) when it is displayed inside the view. The bottom
overlay will remain at 0.75
Usages
• See also: display, agents, chart, event, graphics, display_grid, image, display_-
population,
Embedments
parameter
Definition
The parameter statement specifies which global attributes (i) will change through
the successive simulations (in batch experiments), (ii) can be modified by user via
v 1.8.0 822
GAMA v1.8.0 documentation Chapter 93. Statements
the interface (in gui experiments). In GUI experiments, parameters are displayed
depending on their type.
Facets
• var (an identifier): the name of the variable (that should be declared in the
global)
• name (a label), (omissible) : The message displayed in the interface
• among (list): the list of possible values
• category (a label): a category label, used to group parameters in the interface
• colors (list): The colors of the control in the UI. An empty list has no effects.
Only used for sliders and switches so far. For sliders, 3 colors will allow to
specify the color of the left section, the thumb and the right section (in this
order); 2 colors will define the left and right sections only (thumb will be dark
green); 1 color will define the left section and the thumb. For switches, 2
colors will define the background for respectively the left ‘true’ and right ‘false’
sections. 1 color will define both backgrounds
• disables (list): a list of global variables whose parameter editors will be
disabled when this parameter value is set to true (they are otherwise enabled)
• enables (list): a list of global variables whose parameter editors will be enabled
when this parameter value is set to true (they are otherwise disabled)
• init (any type): the init value
• max (any type): the maximum value
• min (any type): the minimum value
• on_change (any type): Provides a block of statements that will be executed
whenever the value of the parameter changes
• slider (boolean): Whether or not to display a slider for entering an int or float
value. Default is true when max and min values are defined, false otherwise. If
no max or min value is defined, setting this facet to true will have no effect
• step (float): the increment step (mainly used in batch mode to express the
variation step between simulation)
• type (a datatype identifier): the variable type
• unit (a label): the variable unit
Usages
v 1.8.0 823
GAMA v1.8.0 documentation Chapter 93. Statements
parameter title var: global_var category: cat;
• In batch experiment, the two following syntaxes can be used to describe the
possible values of a parameter:
parameter 'Value of toto:' var: toto among: [1, 3, 7, 15, 100];
parameter 'Value of titi:' var: titi min: 1 max: 100 step: 2;
Embedments
perceive
Definition
Facets
• target (any type in [container, agent]): the list of the agent you want to
perceive
• name (an identifier), (omissible) : the name of the perception
• as (species): an expression that evaluates to a species
• emotion (546706): The emotion needed to do the perception
• in (any type in [float, geometry]): a float or a geometry. If it is a float, it’s
a radius of a detection area. If it is a geometry, it is the area of detection of
others species.
v 1.8.0 824
GAMA v1.8.0 documentation Chapter 93. Statements
• parallel (any type in [boolean, int]): setting this facet to ‘true’ will allow
‘perceive’ to use concurrency with a parallel_bdi architecture; setting it to an
integer will set the threshold under which they will be run sequentially (the
default is initially 20, but can be fixed in the preferences). This facet is true by
default.
• threshold (float): Threshold linked to the emotion.
• when (boolean): a boolean to tell when does the perceive is active
Usages
perceive name_of-perception target: the_agents_you_want_to_perceive in:
a_distance when: a_certain_condition {
Here you are in the context of the perceived agents. To refer to the
agent who does the perception, use myself.
If you want to make an action (such as adding a belief for example),
use ask myself{ do the_action}
}
Embedments
permanent
Definition
Represents the outputs of the experiment itself. In a batch experiment, the permanent
section allows to define an output block that will NOT be re-initialized at the beginning
of each simulation but will be filled at the end of each simulation.
v 1.8.0 825
GAMA v1.8.0 documentation Chapter 93. Statements
Facets
• tabs (boolean): Whether the displays should show their tab or not
• toolbars (boolean): Whether the displays should show their toolbar or not
Usages
• For instance, this permanent section will allow to display for each simulation
the end value of the food_gathered variable:
permanent {
display Ants background: rgb('white') refresh_every: 1 {
chart "Food Gathered" type: series {
data "Food" value: food_gathered;
}
}
}
Embedments
plan
Definition
v 1.8.0 826
GAMA v1.8.0 documentation Chapter 93. Statements
Facets
Usages
Embedments
put
Definition
Allows the agent to replace a value in a container at a given position (in a list or
a map) or for a given key (in a map). Note that the behavior and the type of the
attributes depends on the specific kind of container.
Facets
v 1.8.0 827
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
put expr at: expr in: expr_container;
put all: expr in: expr_container;
• In the case of a list, the position should an integer in the bound of the list. The
facet all: is used to replace all the elements of the list by the given value.
putList <- [1,2,3,4,5]; //putList equals [1,2,3,4,5]put -10 at: 1 in:
putList;//putList equals [1,-10,3,4,5]put 10 all: true in: putList
;//putList equals [10,10,10,10,10]
• In the case of a matrix, the position should be a point in the bound of the
matrix. The facet all: is used to replace all the elements of the matrix by the
given value.
putMatrix <- matrix([[0,1],[2,3]]); //putMatrix equals matrix
([[0,1],[2,3]])put -10 at: {1,1} in: putMatrix;//putMatrix equals
matrix([[0,1],[2,-10]])put 10 all: true in: putMatrix;//putMatrix
equals matrix([[10,10],[10,10]])
• In the case of a map, the position should be one of the key values of the map.
Notice that if the given key value does not exist in the map, the given pair
key::value will be added to the map. The facet all is used to replace the value
of all the pairs of the map.
putMap <- ["x"::4,"y"::7]; //putMap equals ["x"::4,"y"::7]put -10 key:
"y" in: putMap;//putMap equals ["x"::4,"y"::-10]put -20 key: "z" in:
putMap;//putMap equals ["x"::4,"y"::-10, "z"::-20]put -30 all: true
in: putMap;//putMap equals ["x"::-30,"y"::-30, "z"::-30]
v 1.8.0 828
GAMA v1.8.0 documentation Chapter 93. Statements
Embedments
reactive_tabu
Definition
Facets
v 1.8.0 829
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
• As other batch methods, the basic syntax of the reactive_tabu statement uses
method reactive_tabu instead of the expected reactive_tabu name: id :
method reactive_tabu [facet: value];
• For example:
method reactive_tabu iter_max: 50 tabu_list_size_init: 5
tabu_list_size_min: 2 tabu_list_size_max: 10 nb_tests_wthout_col_max
: 20 cycle_size_min: 2 cycle_size_max: 20 maximize: food_gathered;
Embedments
reflex
Definition
Reflexes are sequences of statements that can be executed by the agent. Reflexes
prefixed by the ‘reflex’ keyword are executed continuously. Reflexes prefixed by ‘init’
are executed only immediately after the agent has been created. Reflexes prefixed by
‘abort’ just before the agent is killed. If a facet when: is defined, a reflex is executed
only if the boolean expression evaluates to true.
v 1.8.0 830
GAMA v1.8.0 documentation Chapter 93. Statements
Facets
Usages
• Example:
reflex my_reflex when: flip (0.5){ //Only executed when flip
returns true
write "Executing the unconditional reflex";
}
Embedments
release
Definition
Allows an agent to release its micro-agent(s). The preliminary for an agent to release
its micro-agents is that species of these micro-agents are sub-species of other species
(cf. MultiLevelArchitecture#declaration-of-micro-species). The released agents won’t
be micro-agents of the calling agent anymore. Being released from a macro-agent,
the micro-agents will change their species and host (macro-agent).
v 1.8.0 831
GAMA v1.8.0 documentation Chapter 93. Statements
Facets
• target (any type in [agent, list, 27]), (omissible) : an expression that is evaluated
as an agent/a list of the agents to be released or an agent saved as a map
• as (species): an expression that is evaluated as a species in which the micro-agent
will be released
• in (agent): an expression that is evaluated as an agent that will be the macro-
agent in which micro-agent will be released, i.e. their new host
• returns (a new identifier): a new variable containing a list of the newly released
agent(s)
Usages
• We consider the following species. Agents of “C” species can be released from a
“B” agent to become agents of “A” species. Agents of “D” species cannot be
released from the “A” agent because species “D” has no parent species.
species A {
...
}
species B {
...
species C parent: A {
...
}
species D {
...
}
...
}
• To release all “C” agents from a “B” agent, agent “C” has to execute the following
statement. The “C” agent will change to “A” agent. The won’t consider “B”
agent as their macro-agent (host) anymore. Their host (macro-agent) will the
be the host (macro-agent) of the “B” agent.
release list(C);
v 1.8.0 832
GAMA v1.8.0 documentation Chapter 93. Statements
• The modeler can specify the new host and the new species of the released
agents:
release list (C) as: new_species in: new host;
Embedments
remove
Definition
Allows the agent to remove an element from a container (a list, matrix, map. . . ).
Facets
v 1.8.0 833
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
• This statement should be used in the following ways, depending on the kind of
container used and the expected action on it:
remove expr from: expr_container;
remove index: expr from: expr_container;
remove key: expr from: expr_container;
remove all: expr from: expr_container;
• In the case of list, the facet item: is used to remove the first occurence of a
given expression, whereas all is used to remove all the occurrences of the given
expression.
list<int> removeList <- [3,2,1,2,3];remove 2 from: removeList;//
removeList equals [3,1,2,3]remove 3 all: true from: removeList;//
removeList equals [1,2]remove index: 1 from: removeList;//removeList
equals [1]
• In the case of map, the facet key: is used to remove the pair identified by the
given key.
map<string,int> removeMap <- ["x"::5, "y"::7, "z"::7];remove key: "x"
from: removeMap;//removeMap equals ["y"::7, "z"::7]remove 7 all:
true from: removeMap;//removeMap equals map([])
• In addition, a map a be managed as a list with pair key as index. Given that,
facets item:, all: and index: can be used in the same way:
map<string,int> removeMapList <- ["x"::5, "y"::7, "z"::7, "t"::5];
remove 7 from: removeMapList;//removeMapList equals ["x"::5, "z"::7,
"t"::5]remove [5,7] all: true from: removeMapList;//removeMapList
equals ["t"::5]remove index: "t" from: removeMapList;//removeMapList
equals map([])
• In the case of a graph, both edges and nodes can be removes using node: and
edge facets. If a node is removed, all edges to and from this node are also
removed.
v 1.8.0 834
GAMA v1.8.0 documentation Chapter 93. Statements
graph removeGraph <- as_edge_graph([{1,2}::{3,4},{3,4}::{5,6}]);
remove node: {1,2} from: removeGraph;
remove node(1,2) from: removeGraph;
list var <- removeGraph.vertices; // var equals [{3,4},{5,6}]
list var <- removeGraph.edges; // var equals [polyline({3,4}::{5,6})]
remove edge: {3,4}::{5,6} from: removeGraph;
remove edge({3,4},{5,6}) from: removeGraph;
list var <- removeGraph.vertices; // var equals [{3,4},{5,6}]
list var <- removeGraph.edges; // var equals []
species speciesRemove {
int a <- 100;
}
Embedments
v 1.8.0 835
GAMA v1.8.0 documentation Chapter 93. Statements
return
Definition
Allows to immediately stop and tell which value to return from the evaluation of
the surrounding action or top-level statement (reflex, init, etc.). Usually used
within the declaration of an action. For more details about actions, see the following
DefiningActionsAndBehaviors#action.
Facets
Usages
• Example:
string foo {
return "foo";
}
reflex {
string foo_result <- foo(); // foos_result is now equals to "
foo"
}
• In the specific case one wants an agent to ask another agent to execute a
statement with a return, it can be done similarly to:
// In Species A:
string foo_different {
return "foo_not_same";
}
/// ....
// In Species B:
reflex writing {
string temp <- some_agent_A.foo_different []; // temp is now
equals to "foo_not_same"
}
v 1.8.0 836
GAMA v1.8.0 documentation Chapter 93. Statements
Embedments
rule
Definition
Facets
Usages
Embedments
v 1.8.0 837
GAMA v1.8.0 documentation Chapter 93. Statements
rule
Definition
Facets
v 1.8.0 838
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
rule belief: new_predicate("test") when: flip(0.5) new_desire:
new_predicate("test")
Embedments
v 1.8.0 839
GAMA v1.8.0 documentation Chapter 93. Statements
run
Facets
• of (string):
• core (int):
• end_cycle (int):
• seed (int):
• with_output (map):
• with_param (map):
Embedments
sanction
Definition
declare the actions an agent execute when enforcing norms of others during a percep-
tion
Facets
v 1.8.0 840
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
Embedments
save
Definition
Allows to save data in a file. The type of file can be “shp”, “asc”, “geotiff”, “text” or
“csv”.
Facets
• data (any type), (omissible) : any expression, that will be saved in the file
• attributes (map): Allows to specify the attributes of a shape file where agents
are saved. Must be expressed as a literal map. The keys of the map are the
names of the attributes that will be present in the file, the values are whatever
expressions neeeded to define their value
• crs (any type): the name of the projection, e.g. crs:“EPSG:4326” or it-
s EPSG id, e.g. crs:4326. Here a list of the CRS codes (and EPSG id):
http://spatialreference.org
• header (boolean): an expression that evaluates to a boolean, specifying whether
the save will write a header if the file does not exist
• rewrite (boolean): an expression that evaluates to a boolean, specifying whether
the save will ecrase the file or append data at the end of it. Default is true
• to (string): an expression that evaluates to an string, the path to the file, or
directly to a file
• type (an identifier), takes values in: {shp, text, csv, asc, geotiff, image, kml,
kmz, json}: an expression that evaluates to an string, the type of the output
file (it can be only “shp”, “asc”, “geotiff”, “image”, “text” or “csv”)
v 1.8.0 841
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
• To save the values of some attributes of the current agent in csv file:
save [name, location, host] to: "save_data.csv" type: "csv";
• To save the values of all attributes of all the agents of a species into a csv (with
optional attributes):
save species_of(self) to: "save_csvfile.csv" type: "csv" header: false;
• To save the geometries of all the agents of a species into a shapefile (with
optional attributes):
save species_of(self) to: "save_shapefile.shp" type: "shp" with: [name
::"nameAgent", location::"locationAgent"] crs: "EPSG:4326";
• To save the grid_value attributes of all the cells of a grid into an ESRI ASCII
Raster file:
save grid to: "save_grid.asc" type: "asc";
• To save the grid_value attributes of all the cells of a grid into geotiff:
v 1.8.0 842
GAMA v1.8.0 documentation Chapter 93. Statements
save grid to: "save_grid.tif" type: "geotiff";
• To save the grid_value attributes of all the cells of a grid into png (with a
worldfile):
save grid to: "save_grid.png" type: "image";
• The save statement can be use in an init block, a reflex, an action or in a user
command. Do not use it in experiments.
Embedments
set
Definition
Facets
v 1.8.0 843
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
Embedments
setup
Definition
The setup statement is used to define the set of instructions that will be executed
before every #test.
Facets
Usages
• As every test should be independent from the others, the setup will mainly
contain initialization of variables that will be used in each test.
species Tester {
int val_to_test;
setup {
val_to_test <- 0;
}
test t1 {
// [set of instructions, including asserts]
}
}
v 1.8.0 844
GAMA v1.8.0 documentation Chapter 93. Statements
Embedments
simulate
Definition
Allows an agent, the sender agent (that can be the GlobalSpecies), to ask another (or
other) agent(s) to perform a set of statements. It obeys the following syntax, where
the target attribute denotes the receiver agent(s):
Facets
Usages
v 1.8.0 845
GAMA v1.8.0 documentation Chapter 93. Statements
Embedments
socialize
Definition
Facets
Usages
socialize;
v 1.8.0 846
GAMA v1.8.0 documentation Chapter 93. Statements
Embedments
solve
Definition
Solves all equations which matched the given name, with all systems of agents that
should solved simultaneously.
Facets
v 1.8.0 847
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
Embedments
species
Definition
The species statement allows modelers to define new species in the model. global
and grid are speciel cases of species: global being the definition of the global agent
(which has automatically one instance, world) and grid being a species with a grid
topology.
v 1.8.0 848
GAMA v1.8.0 documentation Chapter 93. Statements
Facets
v 1.8.0 849
GAMA v1.8.0 documentation Chapter 93. Statements
‘species a schedules: (10 among a)’ will result in a population that schedules
only 10 of its own agents every cycle. ‘species b schedules: []’ will prevent the
agents of ‘b’ to be scheduled. Note that the scope of agents covered here can be
larger than the population, which allows to build complex scheduling controls;
for instance, defining ‘global schedules: [] {. . . } species b schedules: []; species
c schedules: b + world;’ allows to simulate a model where the agents of b are
scheduled first, followed by the world, without even having to create an instance
of c.
• skills (list): The list of skills that will be made available to the instances of
this species. Each new skill provides attributes and actions that will be added
to the ones defined in this species
• topology (topology): The topology of the population of agents defined by
this species. In case of nested species, it can for example be the shape of the
macro-agent. In case of grid or graph species, the topology is automatically
computed and cannot be redefined
• torus (boolean): is the topology toric (defaut: false). Needs to be defined on
the global species.
• use_individual_shapes (boolean): (grid only),(true by default). Allows to
specify whether or not the agents of the grid will have distinct geometries. If
set to false, they will all have simpler proxy geometries
• use_neighbors_cache (boolean): (grid only),(true by default). Allows to turn
on or off the use of the neighbors cache used for grids. Note that if a diffusion
of variable occurs, GAMA will emit a warning and automatically switch to a
caching version
• use_regular_agents (boolean): (grid only),(true by default). Allows to specify
if the agents of the grid are regular agents (like those of any other species) or
minimal ones (which can’t have sub-populations, can’t inherit from a regular
species, etc.)
• virtual (boolean): whether the species is virtual (cannot be instantiated, but
only used as a parent) (false by default)
• width (int): (grid only), the width of the grid (in terms of agent number)
Usages
v 1.8.0 850
GAMA v1.8.0 documentation Chapter 93. Statements
• The definition of the single grid of a model will automatically create gridwidth
x gridheight agents:
grid ant_grid width: gridwidth height: gridheight file: grid_file
neighbors: 8 use_regular_agents: false {
Embedments
start_simulation
Facets
• of (string):
• seed (int):
• with_param (map):
v 1.8.0 851
GAMA v1.8.0 documentation Chapter 93. Statements
Embedments
state
Definition
A state, like a reflex, can contains several statements that can be executed at each
time step by the agent.
Facets
Usages
• Here is an exemple integrating 2 states and the statements in the FSM archi-
tecture:
state s_init initial: true {
enter { write "Enter in" + state; }
write "Enter in" + state;
}
write state;
v 1.8.0 852
GAMA v1.8.0 documentation Chapter 93. Statements
exit {
write "EXIT from "+state;
}
}
state s1 {
write state;
Embedments
status
Definition
The statement makes the agent output an arbitrary message in the status box.
Facets
v 1.8.0 853
GAMA v1.8.0 documentation Chapter 93. Statements
can be specified. The message will remain in place until it is replaced by another
one or by nil, in which case the standard status (number of cycles) will be
displayed again
• color (rgb): The color used for displaying the background of the status message
Usages
• Outputting a message
status ('This is my status ' + self) color: #yellow;
Embedments
switch
Definition
The “switch. . . match” statement is a powerful replacement for imbricated “if . . . else
. . . ” constructs. All the blocks that match are executed in the order they are defined.
The block prefixed by default is executed only if none have matched (otherwise it is
not).
Facets
v 1.8.0 854
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
• Example:
switch 3 {
match 1 {write "Match 1"; }
match 2 {write "Match 2"; }
match 3 {write "Match 3"; }
match_one [4,4,6,3,7] {write "Match one_of"; }
match_between [2, 4] {write "Match between"; }
default {write "Match Default"; }
}
Embedments
tabu
Definition
This algorithm is an implementation of the Tabu Search algorithm. See the wikipedia
article and BatchExperiments.
v 1.8.0 855
GAMA v1.8.0 documentation Chapter 93. Statements
Facets
• name (an identifier), (omissible) : The name of the method. For internal use
only
• aggregation (a label), takes values in: {min, max}: the agregation method
• iter_max (int): number of iterations
• maximize (float): the value the algorithm tries to maximize
• minimize (float): the value the algorithm tries to minimize
• tabu_list_size (int): size of the tabu list
Usages
• As other batch methods, the basic syntax of the tabu statement uses method
tabu instead of the expected tabu name: id :
method tabu [facet: value];
• For example:
method tabu iter_max: 50 tabu_list_size: 5 maximize: food_gathered;
Embedments
task
Definition
As reflex, a task is a sequence of statements that can be executed, at each time step,
by the agent. If an agent owns several tasks, the scheduler chooses a task to execute
based on its current priority weight value.
v 1.8.0 856
GAMA v1.8.0 documentation Chapter 93. Statements
Facets
Usages
Embedments
test
Definition
The test statement allows modeler to define a set of assertions that will be tested.
Before the execution of the embedded set of instructions, if a setup is defined in
the species, model or experiment, it is executed. In a test, if one assertion fails, the
evaluation of other assertions continue.
Facets
Usages
• An example of use:
v 1.8.0 857
GAMA v1.8.0 documentation Chapter 93. Statements
species Tester {
// set of attributes that will be used in test
setup {
// [set of instructions... in particular initializations]
}
test t1 {
// [set of instructions, including asserts]
}
}
Embedments
trace
Definition
All the statements executed in the trace statement are displayed in the console.
Facets
Usages
Embedments
v 1.8.0 858
GAMA v1.8.0 documentation Chapter 93. Statements
transition
Definition
In an FSM architecture, transition specifies the next state of the life cycle. The
transition occurs when the condition is fulfilled. The embedded statements are
executed when the transition is triggered.
Facets
Usages
Embedments
v 1.8.0 859
GAMA v1.8.0 documentation Chapter 93. Statements
try
Definition
Allows the agent to execute a sequence of statements and to catch any runtime error
that might happen in a subsequent catch block, either to ignore it (not a good idea,
usually) or to safely stop the model
Facets
Usages
try {
[statements]
}
try {
[statements]
}
catch {
[statements]
}
v 1.8.0 860
GAMA v1.8.0 documentation Chapter 93. Statements
Embedments
unconscious_contagion
Definition
Facets
• emotion (546706): the emotion that will be copied with the contagion
• name (an identifier), (omissible) : the identifier of the unconscious contagion
• charisma (float): The charisma value of the perceived agent (between 0 and 1)
• decay (float): The decay value of the emotion added to the agent
• receptivity (float): The receptivity value of the current agent (between 0 and
1)
• threshold (float): The threshold value to make the contagion
• when (boolean): A boolean value to get the emotion only with a certain condition
Usages
unconscious_contagion emotion:fearConfirmed;
unconscious_contagion emotion:fearConfirmed charisma: 0.5 receptivity:
0.5;
v 1.8.0 861
GAMA v1.8.0 documentation Chapter 93. Statements
Embedments
user_command
Definition
Facets
v 1.8.0 862
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
Embedments
user_init
Definition
Used in the user control architecture, user_init is executed only once when the agent
is created. It opens a special panel (if it contains user_commands statements). It is
the equivalent to the init block in the basic agent architecture.
Facets
Usages
v 1.8.0 863
GAMA v1.8.0 documentation Chapter 93. Statements
Embedments
user_input
Definition
Facets
• returns (a new identifier): a new local variable containing the value given by
the user
• name (a label), (omissible) : the displayed name
• among (list): the set of acceptable values for the variable
• init (any type): the init value
• max (float): the maximum value
• min (float): the minimum value
• slider (boolean): Whether to display a slider or not when applicable
• type (a datatype identifier): the variable type
Usages
v 1.8.0 864
GAMA v1.8.0 documentation Chapter 93. Statements
Embedments
user_panel
Definition
It is the basic behavior of the user control architecture (it is similar to state for the
FSM architecture). This user_panel translates, in the interface, in a semi-modal view
that awaits the user to choose action buttons, change attributes of the controlled
agent, etc. Each user_panel, like a state in FSM, can have a enter and exit sections,
but it is only defined in terms of a set of user_commands which describe the different
action buttons present in the panel.
Facets
Usages
v 1.8.0 865
GAMA v1.8.0 documentation Chapter 93. Statements
Embedments
using
Definition
using is a statement that allows to set the topology to use by its sub-statements.
They can gather it by asking the scope to provide it.
Facets
Usages
• All the spatial operations are topology-dependent (e.g. neighbors are not the
same in a continuous and in a grid topology). So using statement allows
modelers to specify the topology in which the spatial operation will be computed.
float dist <- 0.0;
using topology(grid_ant) {
d (self.location distance_to target.location);
}
v 1.8.0 866
GAMA v1.8.0 documentation Chapter 93. Statements
Embedments
Variable_container
Definition
Facets
v 1.8.0 867
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
Embedments
Variable_number
Definition
Facets
v 1.8.0 868
GAMA v1.8.0 documentation Chapter 93. Statements
• step (int): A discrete step (used in conjunction with min and max) that
constrains the values this variable can take
• type (a datatype identifier): The type of the attribute, either ‘int’ or ‘float’
• update (any type in [int, float]): An expression that will be evaluated each
cycle to compute a new value for the attribute
Usages
Embedments
Variable_regular
Definition
Facets
v 1.8.0 869
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
Embedments
warn
Definition
The statement makes the agent output an arbitrary message in the error view as a
warning.
Facets
v 1.8.0 870
GAMA v1.8.0 documentation Chapter 93. Statements
Usages
• Emmitting a warning
warn 'This is a warning from ' + self;
Embedments
write
Definition
The statement makes the agent output an arbitrary message in the console.
Facets
• message (any type), (omissible) : the message to display. Modelers can add
some formatting characters to the message (carriage returns, tabs, or Unicode
characters), which will be used accordingly in the console.
• color (rgb): The color with wich the message will be displayed. Note that
different simulations will have different (default) colors to use for this purpose
if this facet is not specified
Usages
• Outputting a message
write 'This is a message from ' + self;
v 1.8.0 871
GAMA v1.8.0 documentation Chapter 93. Statements
Embedments
v 1.8.0 872
Chapter 94
Types
A variable’s or expression’s type (or data type) determines the values it can take, plus
the operations that can be performed on or with it. GAML is a statically-typed
language, which means that the type of an expression is always known at compile
time, and is even enforced with casting operations. There are 4 categories of types:
The hierarchy of types in GAML (only primitive and complex types are displayed
here, of course, as the other ones are model-dependent) is the following:
Table of contents
• Types (Under Construction)
– Primitive built-in types
∗ bool
∗ float
873
GAMA v1.8.0 documentation Chapter 94. Types
v 1.8.0 874
GAMA v1.8.0 documentation Chapter 94. Types
∗ int
∗ string
– Complex built-in types
∗ agent
∗ container
∗ file
∗ geometry
∗ graph
∗ list
∗ map
∗ matrix
∗ pair
∗ path
∗ point
∗ rgb
∗ species
∗ Species names as types
∗ topology
– Defining custom types
bool
bool (0) -> false
v 1.8.0 875
GAMA v1.8.0 documentation Chapter 94. Types
float
• Definition: primitive datatype holding floating point values, its absolute value
is comprised between 4.9E-324 and 1.8E308.
• Comments: this datatype is internally backed up by the Java double datatype.
• Litteral declaration: decimal notation 123.45 or exponential notation 123e45
are supported.
• Other declarations: expressions that require an integer operand often directly
apply a casting to float to their operand. Using it is a way to obtain a float
constant.
float (12) -> 12.0
int
• Definition: primitive datatype holding integer values comprised between -
2147483648 and 2147483647 (i.e. between -2^31 and 2^31 - 1.
• Comments: this datatype is internally backed up by the Java int datatype.
• Litteral declaration: decimal notation like 1, 256790 or hexadecimal notation
like #1209FF are automatically interpreted.
• Other declarations: expressions that require an integer operand often directly
apply a casting to int to their operand. Using it is a way to obtain an integer
constant.
int (234.5) -> 234.
string
• Definition: a datatype holding a sequence of characters.
• Comments: this datatype is internally backed up by the Java String class.
However, contrary to Java, strings are considered as a primitive type, which
means they do not contain character objects. This can be seen when casting
a string to a list using the list operator: the result is a list of one-character
strings, not a list of characters.
v 1.8.0 876
GAMA v1.8.0 documentation Chapter 94. Types
Contrarily to primitive built-in types, complex types have often various attributes.
They can be accessed in the same way as attributes of agents:
complex_type nom_var <- init_var;
ltype_attr attr_var <- nom_var.attr_name;
For example:
file fileText <- file("../data/cell.Data");
bool fileTextReadable <- fileText.readable;
agent
v 1.8.0 877
GAMA v1.8.0 documentation Chapter 94. Types
container
• Definition: a generic datatype that represents a collection of data.
• Comments: a container variable can be a list, a matrix, a map. . . Conversely,
each list, matrix, and map is a kind of container. In consequence, every container
can be used in container-related operators.
• See also: Container operators
• Declaration:
container c <- [1,2,3];
container c <- matrix [[1,2,3],[4,5,6]];
container c <- map ["x"::5, "y"::12];
container c <- list species1;
file
• Definition: a datatype that represents a file.
• Built-in attributes:
– name (type = string): the name of the represented file (with its extension)
– extension(type = string): the extension of the file
– path (type = string): the absolute path of the file
∗ readable (type = bool, read-only): a flag expressing whether the file
is readable
∗ writable (type = bool, read-only): a flag expressing whether the file is
writable
∗ exists (type = bool, read-only): a flag expressing whether the file
exists
∗ is_folder (type = bool, read-only): a flag expressing whether the file
is folder
∗ contents (type = container): a container storing the content of the file
• Comments: a variable with the file type can handle any kind of file (text,
image or shape files. . . ). The type of the content attribute will depend on the
kind of file. Note that the allowed kinds of file are the followings:
– text files: files with the extensions .txt, .data, .csv, .text, .tsv, .asc. The
content is by default a list of string.
v 1.8.0 878
GAMA v1.8.0 documentation Chapter 94. Types
– image files: files with the extensions .pgm, .tif, .tiff, .jpg, .jpeg, .png, .gif,
.pict, .bmp. The content is by default a matrix of int.
– shapefiles: files with the extension .shp. The content is by default a list
of geometry.
– properties files: files with the extension .properties. The content is by
default a map of string::string.
– folders. The content is by default a list of string.
• Remark: Files are also a particular kind of container and can thus be read,
written or iterated using the container operators and commands.
• See also: File operators
• Declaration: a file can be created using the generic file (that opens a file in
read only mode and tries to determine its contents), folder or the new_folder
(to open an existing folder or create a new one) unary operators. But things
can be specialized with the combination of the read/write and image/text
/shapefile/properties unary operators.
folder(a_string) // returns a file managing a existing folder
file(a_string) // returns any kind of file in read-only mode
read(text(a_string)) // returns a text file in read-only mode
read(image(a_string)) // does the same with an image file.
write(properties(a_string)) // returns a property file which is
available for writing
// (if it exists, contents will be appended
unless it is cleared
// using the standard container operations)
.
geometry
v 1.8.0 879
GAMA v1.8.0 documentation Chapter 94. Types
– holes (type = list of geometry): the list of the hole inside the given
geometry
– contour (type = geometry): the exterior ring of the given geometry and of
his holes
– envelope (type = geometry): the geometry bounding box
– width (type = float): the width of the bounding box
– height (type = float): the height of the bounding box
– points (type = list of point): the set of the points composing the geometry
geometry varGeom <- circle(5);
geometry polygonGeom <- polygon([{3,5}, {5,6},{1,4}]);
graph
v 1.8.0 880
GAMA v1.8.0 documentation Chapter 94. Types
list
• Definition: a composite datatype holding an ordered collection of values.
v 1.8.0 881
GAMA v1.8.0 documentation Chapter 94. Types
map
v 1.8.0 882
GAMA v1.8.0 documentation Chapter 94. Types
map (1) -> [1::1]
map ({1,5}) -> [x::1, y::5]
[] // empty map
matrix
//builds a one-dimension matrix, of size 5
matrix mat1 <- matrix ([10, 20, 30, 40, 50]);
// builds a two-dimensions matrix with 10 columns and 5 rows, where
each cell is initialized to 0.0
matrix mat2 <- 0.0 as_matrix({10,5});
// builds a two-dimensions matrix with 2 columns and 3 rows, with
initialized cells
matrix mat3 <- matrix([["c11","c12","c13"],["c21","c22","c23"]]);
-> c11;c21
c12;c22
c13;c23
v 1.8.0 883
GAMA v1.8.0 documentation Chapter 94. Types
pair
path
v 1.8.0 884
GAMA v1.8.0 documentation Chapter 94. Types
point
• Definition: a datatype normally holding two positive float values. Represents
the absolute coordinates of agents in the model.
v 1.8.0 885
GAMA v1.8.0 documentation Chapter 94. Types
• Built-in attributes:
– x (type = float): coordinate of the point on the x-axis
– y (type = float): coordinate of the point on the y-axis
• Comments: point coordinates should be positive, if a negative value is used
in its declaration, the point is built with the absolute value.
• Remark: points are particular cases of geometries and containers. Thus they
have also all the built-in attributes of both the geometry and the container
datatypes and can be used with every kind of operator or command admitting
geometry and container.
• Litteral declaration: two numbers, separated by a comma, enclosed in braces,
like {12.3, 14.5}
• Other declarations: points can be built literally from a list, or from an integer
or float value by using the point casting operator.
point ([12,123.45]) -> {12.0, 123.45}
point (2) -> {2.0, 2.0}
rgb
• Definition: a datatype that represents a color in the RGB space.
• Built-in attributes:
– red(type = int): the red component of the color
– green(type = int): the green component of the color
– blue(type = int): the blue component of the color
– darker(type = rgb): a new color that is a darker version of this color
– brighter(type = rgb): a new color that is a brighter version of this color
• Remark: rgb is also a particular kind of container and can thus be manipulated
using the container operators and commands.
• Litteral declaration: there exist a lot of ways to declare a color. We use the
rgb casting operator applied to:
– a string. The allowed color names are the constants defined in the Color
Java class, i.e.: black, blue, cyan, darkGray, lightGray, gray, green, magenta,
orange, pink, red, white, yellow.
v 1.8.0 886
GAMA v1.8.0 documentation Chapter 94. Types
– a list. The integer value associated to the three first elements of the list
are used to define the three red (element 0 of the list), green (element 1 of
the list) and blue (element 2 of the list) components of the color.
– a map. The red, green, blue components take the value associated to the
keys “r”, “g”, “b” in the map.
– an integer <- the decimal integer is translated into a hexadecimal <-
OxRRGGBB. The red (resp. green, blue) component of the color takes
the value RR (resp. GG, BB) translated in decimal.
– Since GAMA 1.6.1, colors can be directly obtained like units, by using the
° or # symbol followed by the name in lowercase of one of the 147 CSS
colors (see http://www.cssportal.com/css3-color-names/).
• Declaration:
rgb cssRed <- #red; // Since 1.6.1
rgb testColor <- rgb('white'); // rgb [255,255,255]
rgb test <- rgb(3,5,67); // rgb [3,5,67]
rgb te <- rgb(340); // rgb [0,1,84]
rgb tete <- rgb(["r"::34, "g"::56, "b"::345]); // rgb [34,56,255]
species
v 1.8.0 887
GAMA v1.8.0 documentation Chapter 94. Types
In the simple following example, we create a set of “humans” and initialize a random
“friendship network” among them. See how the name of the species, human, is used
in the create command, as an argument to the list casting operator, and as the type
of the variable named friend.
global {
init {
create human number: 10;
ask human {
friend <- one_of (human - self);
}
}
}
entities {
species human {
human friend <- nil;
}
}
topology
• Definition: a topology is basically on neighborhoods, distance,. . . structures
in which agents evolves. It is the environment or the context in which all
these values are computed. It also provides the access to the spatial index
shared by all the agents. And it maintains a (eventually dynamic) link with
the ‘environment’ which is a geometrical border.
• Built-in attributes:
v 1.8.0 888
GAMA v1.8.0 documentation Chapter 94. Types
v 1.8.0 889
GAMA v1.8.0 documentation Chapter 94. Types
And how to use bottles as any other agent in a species (a drinker owns a bottle; when
he gets thirsty, it drinks a random quantity from it; when it is empty, it refills it):
species drinker {
...
bottle my_bottle<- nil;
float quantity <- rnd (100) / 100;
bool thirsty <- false update: flip (0.1);
...
action drink {
if condition: ! bottle.is_empty {
bottle.volume <-bottle.volume - quantity;
thirsty <- false;
}
}
...
init {
create bottle return: created_bottle;
volume <- 0.5;
}
my_bottle <- first(created_bottle);
}
...
reflex filling_bottle when: bottle.is_empty {
ask my_bottle {
do fill;
}
}
...
reflex drinking when: thirsty {
do drink;
}
}
v 1.8.0 890
Chapter 95
File Types
GAMA provides modelers with a generic type for files called file. It is possible to
load a file using the file operator:
file my_file <- file("../includes/data.csv");
However, internally, GAMA makes the difference between the different types of files.
Indeed, for instance:
global {
init {
file my_file <- file("../includes/data.csv");
loop el over: my_file {
write el;
}
}
}
will give:
sepallength
sepalwidth
petallength
petalwidth
type
5.1
3.5
1.4
0.2
Iris-setosa
891
GAMA v1.8.0 documentation Chapter 95. File Types
4.9
3.0
1.4
0.2
Iris-setosa
...
Indeed, the content of CSV file is a matrix: each row of the matrix is a line of the
file; each column of the matrix is value delimited by the separator (by default “,”).
In contrary:
global {
init {
file my_file <- file("../includes/data.shp");
loop el over: my_file {
write el;
}
}
}
will give:
Polygon
Polygon
Polygon
Polygon
Polygon
Polygon
Polygon
In order to know how to load a file, GAMA analyzes its extension. For instance for a
file with a “.csv” extension, GAMA knows that the file is a csv one and will try to
split each line with the , separator. However, if the modeler wants to split each line
with a different separator (for instance ;) or load it as a text file, he/she will have to
use a specific file operator.
v 1.8.0 892
GAMA v1.8.0 documentation Chapter 95. File Types
Table of contents
• File Types
– Text File
∗ Extensions
∗ Content
∗ Operators
– CSV File
∗ Extensions
∗ Content
∗ Operators
– Shapefile
∗ Extensions
∗ Content
∗ Operators
– OSM File
∗ Extensions
∗ Content
∗ Operators
– Grid File
∗ Extensions
∗ Content
∗ Operators
– Image File
∗ Extensions
∗ Content
∗ Operators
– SVG File
∗ Extensions
∗ Content
∗ Operators
– Property File
∗ Extensions
∗ Content
v 1.8.0 893
GAMA v1.8.0 documentation Chapter 95. File Types
∗ Operators
– R File
∗ Extensions
∗ Content
∗ Operators
– 3DS File
∗ Extensions
∗ Content
∗ Operators
– OBJ File
∗ Extensions
∗ Content
∗ Operators
Text File
Extensions
Here the list of possible extensions for text file: * “txt” * “data” * “csv” * “text” *
“tsv” * “xml”
Note that when trying to define the type of a file with the default file loading operator
(file), GAMA will first try to test the other type of file. For example, for files with
“.csv” extension, GAMA will cast them as csv file and not as text file.
Content
The content of a text file is a list of string corresponding to each line of the text file.
For example:
global {
init {
file my_file <- text_file("../includes/data.txt");
loop el over: my_file {
write el;
}
}
}
v 1.8.0 894
GAMA v1.8.0 documentation Chapter 95. File Types
will give:
sepallength,sepalwidth,petallength,petalwidth,type
5.1,3.5,1.4,0.2,Iris-setosa
4.9,3.0,1.4,0.2,Iris-setosa
4.7,3.2,1.3,0.2,Iris-setosa
Operators
List of operators related to text files: * text_file(string path): load a file (with an
authorized extension) as a text file. * text_file(string path, list content): load
a file (with an authorized extension) as a text file and fill it with the given content. *
is_text(op): tests whether the operand is a text file
CSV File
Extensions
Here the list of possible extensions for csv file: * “csv” * “tsv”
Content
The content of a csv file is a matrix of string: each row of the matrix is a line of the
file; each column of the matrix is value delimited by the separator (by default “,”).
For example:
global {
init {
file my_file <- csv_file("../includes/data.csv");
loop el over: my_file {
write el;
}
}
}
will give:
v 1.8.0 895
GAMA v1.8.0 documentation Chapter 95. File Types
sepallength
sepalwidth
petallength
petalwidth
type
5.1
3.5
1.4
0.2
Iris-setosa
4.9
3.0
1.4
0.2
Iris-setosa
...
Operators
List of operators related to csv files: * csv_file(string path): load a file (with an
authorized extension) as a csv file with default separator (“,”). * csv_file(string
path, string separator): load a file (with an authorized extension) as a csv file
with the given separator.
file my_file <- csv_file("../includes/data.csv", ";");
Shapefile
Shapefiles are classical GIS data files. A shapefile is not simple file, but a set of
several files (source: wikipedia): * Mandatory files : * .shp — shape format; the
feature geometry itself * .shx — shape index format; a positional index of the feature
geometry to allow seeking forwards and backwards quickly * .dbf — attribute format;
columnar attributes for each shape, in dBase IV format
v 1.8.0 896
GAMA v1.8.0 documentation Chapter 95. File Types
• Optional files :
Extensions
Content
will give:
v 1.8.0 897
GAMA v1.8.0 documentation Chapter 95. File Types
Polygon
Polygon
Polygon
Polygon
Polygon
Polygon
Polygon
...
Note that the attributes of each object of the shapefile is stored in their corresponding
GAMA geometry. The operator “get” (or “read”) allows to get the value of a
corresponding attributes.
For example:
file my_file <- shape_file("../includes/data.shp");
write "my_file: " + my_file.contents;
loop el over: my_file {
write (el get "TYPE");
}
Operators
v 1.8.0 898
GAMA v1.8.0 documentation Chapter 95. File Types
OSM File
OSM (Open Street Map) is a collaborative project to create a free editable map
of the world. The data produced in this project (OSM File) represent physical
features on the ground (e.g., roads or buildings) using tags attached to its basic
data structures (its nodes, ways, and relations). Each tag describes a geographic
attribute of the feature being shown by that specific node, way or relation (source:
openstreetmap.org).
More details about OSM data can be found here.
Extensions
Here the list of possible extension for shapefile: * “osm” * “pbf” * “bz2” * “gz”
Content
The content of a OSM data is a list of geometries corresponding to the objects of the
OSM file. For example:
global {
init {
file my_file <- osm_file("../includes/data.gz");
loop el over: my_file {
write el;
}
}
}
will give:
Point
Point
Point
Point
Point
LineString
LineString
Polygon
Polygon
Polygon
...
v 1.8.0 899
GAMA v1.8.0 documentation Chapter 95. File Types
Note that like for shapefiles, the attributes of each object of the osm file is stored in
their corresponding GAMA geometry. The operator “get” (or “read”) allows to get
the value of a corresponding attributes.
Operators
List of operators related to osm file: * osm_file(string path): load a file (with an
authorized extension) as a osm file with default projection (if a prj file is defined, use
it, otherwise use the default projection defined in the preference). In this case, all
the nodes and ways of the OSM file will becomes a geometry. * osm_file(string
path, string code): load a file (with an authorized extension) as a osm file with
the given projection (GAMA will automatically decode the code. For a list of the
possible projections see: http://spatialreference.org/ref/). In this case, all the nodes
and ways of the OSM file will becomes a geometry. * osm_file(string path, int
EPSG_ID): load a file (with an authorized extension) as a osm file with the given
projection (GAMA will automatically decode the epsg code. For a list of the possible
projections see: http://spatialreference.org/ref/). In this case, all the nodes and ways
of the OSM file will becomes a geometry.
file my_file <- osm_file("../includes/data.gz", "EPSG:32601");
v 1.8.0 900
GAMA v1.8.0 documentation Chapter 95. File Types
automatically decode the code. For a list of the possible projections see:
http://spatialreference.org/ref/). In this case, only the elements with the
defined values are loaded from the file.
– osm_file(string path, map filter, int EPSG_ID): load a file (with
an authorized extension) as a osm file with the given projection (GAMA will
automatically decode the epsg code. For a list of the possible projections
see: http://spatialreference.org/ref/). In this case, only the elements with
the defined values are loaded from the file.
– is_osm(op): tests whether the operand is a osm file
Grid File
Esri ASCII Grid files are classic text raster GIS data.
More details about Esri ASCII grid file can be found here.
Note that grid files can be used to initialize a grid species. The number of rows and
columns will be read from the file. Similarly, the values of each cell contained in the
grid file will be accessible through the grid_value attribute.
grid cell file: grid_file {
}
Extensions
Here the list of possible extension for grid file: * “asc”
Content
The content of a grid file is a list of geometries corresponding to the cells of the grid.
For example:
global {
init {
file my_file <- grid_file("../includes/data.asc");
loop el over: my_file {
write el;
}
v 1.8.0 901
GAMA v1.8.0 documentation Chapter 95. File Types
}
}
will give:
Polygon
Polygon
Polygon
Polygon
Polygon
Polygon
Polygon
...
Note that the values of each cell of the grid file is stored in their corresponding GAMA
geometry (grid_value attribute). The operator “get” (or “read”) allows to get the
value of this attribute.
For example:
file my_file <- grid_file("../includes/data.asc");
write "my_file: " + my_file.contents;
loop el over: my_file {
write el get "grid_value";
}
Operators
List of operators related to shapefiles: * grid_file(string path): load a file (with an
authorized extension) as a grid file with default projection (if a prj file is defined, use
it, otherwise use the default projection defined in the preference). * grid_file(string
path, string code): load a file (with an authorized extension) as a grid file with
the given projection (GAMA will automatically decode the code. For a list of the
possible projections see: http://spatialreference.org/ref/) * grid_file(string path,
int EPSG_ID): load a file (with an authorized extension) as a grid file with the
given projection (GAMA will automatically decode the epsg code. For a list of the
possible projections see: http://spatialreference.org/ref/)
file my_file <- grid_file("../includes/data.shp", "EPSG:32601");
v 1.8.0 902
GAMA v1.8.0 documentation Chapter 95. File Types
Image File
Extensions
Here the list of possible extensions for image file: * “tif” * “tiff” * “jpg” * “jpeg” *
“png” * “gif” * “pict” * “bmp”
Content
The content of an image file is a matrix of int: each pixel is a value in the matrix.
For example:
global {
init {
file my_file <- image_file("../includes/DEM.png");
loop el over: my_file {
write el;
}
}
}
will give:
-9671572
-9671572
-9671572
-9671572
-9934744
-9934744
-9868951
-9868951
-10000537
-10000537
...
Operators
List of operators related to csv files: * image_file(string path): load a file (with
an authorized extension) as an image file. * image_file(string path, matrix
v 1.8.0 903
GAMA v1.8.0 documentation Chapter 95. File Types
content): load a file (with an authorized extension) as an image file and fill it with
the given content. * is_image(op): tests whether the operand is an image file
SVG File
Scalable Vector Graphics (SVG) is an XML-based vector image format for two-
dimensional graphics with support for interactivity and animation. Note that interac-
tivity and animation features are not supported in GAMA.
More details about SVG file can be found here.
Extensions
Here the list of possible extension for SVG file: * “svg”
Content
The content of a SVG file is a list of geometries. For example:
global {
init {
file my_file <- svg_file("../includes/data.svg");
loop el over: my_file {
write el;
}
}
}
will give:
Polygon
Operators
List of operators related to svg files: * shape_file(string path): load a file (with
an authorized extension) as a SVG file. * shape_file(string path, point size):
load a file (with an authorized extension) as a SVG file with the given size:
v 1.8.0 904
GAMA v1.8.0 documentation Chapter 95. File Types
file my_file <- svg_file("../includes/data.svg", {5.0,5.0});
Property File
Extensions
Here the list of possible extensions for property file: * “properties”
Content
The content of a property file is a map of string corresponding to the content of the
file. For example:
global {
init {
file my_file <- property_file("../includes/data.properties");
loop el over: my_file {
write el;
}
}
}
will give:
3.0
4.0
5.0
Iris-setosa
2.5
v 1.8.0 905
GAMA v1.8.0 documentation Chapter 95. File Types
Operators
List of operators related to text files: * property_file(string path): load a file
(with an authorized extension) as a property file. * is_property(op): tests whether
the operand is a property file
R File
R is a free software environment for statistical computing and graphics. GAMA
allows to execute R script (if R is installed on the computer).
More details about R can be found here.
Note that GAMA also integrates some operators to manage R scripts: * R_compute
* R_compute_param
Extensions
Here the list of possible extensions for R file: * “r”
Content
The content of a R file corresponds to the results of the application of the script
contained in the file.
For example:
global {
init {
file my_file <- R_file("../includes/data.r");
loop el over: my_file {
write el;
}
}
}
will give:
3.0
v 1.8.0 906
GAMA v1.8.0 documentation Chapter 95. File Types
Operators
List of operators related to R files: * R_file(string path): load a file (with an
authorized extension) as a R file. * is_R(op): tests whether the operand is a R file.
3DS File
3DS is one of the file formats used by the Autodesk 3ds Max 3D modeling, animation
and rendering software. 3DS files can be used in GAMA to load 3D geometries.
More details about 3DS file can be found here.
Extensions
Here the list of possible extension for 3DS file: * “3ds” * “max”
Content
The content of a 3DS file is a list of geometries. For example:
global {
init {
file my_file <- threeds_file("../includes/data.3ds");
loop el over: my_file {
write el;
}
}
}
will give:
Polygon
Operators
List of operators related to 3ds files: * threeds_file(string path): load a file (with
an authorized extension) as a 3ds file. * is_threeds(op): tests whether the operand
is a 3DS file
v 1.8.0 907
GAMA v1.8.0 documentation Chapter 95. File Types
OBJ File
OBJ file is a geometry definition file format first developed by Wavefront Technologies
for its Advanced Visualizer animation package. The file format is open and has been
adopted by other 3D graphics application vendors.
More details about Obj file can be found here.
Extensions
Here the list of possible extension for OBJ files: * “obj”
Content
The content of a OBJ file is a list of geometries. For example:
global {
init {
file my_file <- obj_file("../includes/data.obj");
loop el over: my_file {
write el;
}
}
}
will give:
Polygon
Operators
List of operators related to obj files: * obj_file(string path): load a file (with an
authorized extension) as a obj file. * is_obj(op): tests whether the operand is a
OBJ file
v 1.8.0 908
Chapter 96
Expressions
Expressions in GAML are the value part of the statements’ facets. They represent or
compute data that will be used as the value of the facet when the statement will be
executed.
An expression can be either a literal, a unit, a constant, a variable, an attribute or
the application of one or several operators to compose a complex expression.
909
GAMA v1.8.0 documentation Chapter 96. Expressions
v 1.8.0 910
Chapter 97
Literals
Table of contents
• Literals
– Simple Types
– Literal Constructors
– Universal Literal
Simple Types
Values of simple (i.e. not composed) types can all be expressed using literal expressions.
Namely:
911
GAMA v1.8.0 documentation Chapter 97. Literals
• float: the value in plain digits, using '.' for the decimal point (e.g. 123.297)
• string: a sequence of characters enclosed between quotes ('my string') or
double quotes ("my string")
Literal Constructors
Although they are not strictly literals in the sense given above, some special constructs
(called literal constructors) allow the modeler to declare constants of other data types.
They are actually operators but can be thought of literals when used with constant
operands.
Universal Literal
Finally, a special literal, of type unknown, is shared between the data types and all
the agent types (aka species). Only bool, int and float, which do not derive from
unknown, do not accept this literal. All the others will accept it (e.g. string s <-
nil; is ok).
v 1.8.0 912
Chapter 98
This file is automatically generated from java files. Do Not Edit It.
Introduction
Units can be used to qualify the values of numeric variables. By default, unqualified
values are considered as:
913
GAMA v1.8.0 documentation Chapter 98. Units and constants
float foo <- 1 ˚centimeter;
or
float foo <- 1 #centimeter;
In that case, the numeric value of foo will be automatically translated to 0.01
(meter). It is recommended to always use float as the type of the variables that might
be qualified by units (otherwise, for example in the previous case, they might be
truncated to 0). Several units names are allowed as qualifiers of numeric variables.
These units represent the basic metric and US units. Composed and derived units
(like velocity, acceleration, special volumes or surfaces) can be obtained by combining
these units using the * and / operators. For instance:
float one_kmh <- 1 ˚km / ˚h const: true;
float one_millisecond <-1 ˚sec / 1000;
float one_cubic_inch <- 1 ˚sqin * 1 ˚inch;
... etc ...
Table of Contents
Constants
• #AdamsBashforth, value= AdamsBashforth, Comment: AdamsBashforth solver
• #current_error, value= , Comment: The text of the last error thrown during
the current execution
v 1.8.0 914
GAMA v1.8.0 documentation Chapter 98. Units and constants
v 1.8.0 915
GAMA v1.8.0 documentation Chapter 98. Units and constants
Graphics units
• #bold, value= 1, Comment: This constant allows to build a font with a bold
face. Can be combined with #italic
• #flat, value= 2, Comment: This constant represents a flat line buffer end cap
style
v 1.8.0 916
GAMA v1.8.0 documentation Chapter 98. Units and constants
• #pixels (#px), value= 1.0, Comment: This unit, only available when running
aspects or declaring displays, returns a dynamic value instead of a fixed one.
px (or pixels), returns the value of one pixel on the current view in terms of
model units.
• #plain, value= 0, Comment: This constant allows to build a font with a plain
face
• #round, value= 1, Comment: This constant represents a round line buffer end
cap style
• #split, value= 2, Comment: This constant represents a layout where all display
views are split in a grid-like structure
• #square, value= 3, Comment: This constant represents a square line buffer end
cap style
• #stack, value= 1, Comment: This constant represents a layout where all display
views are stacked
v 1.8.0 917
GAMA v1.8.0 documentation Chapter 98. Units and constants
• #zoom, value= 1.0, Comment: This unit, only available when running aspects
or declaring displays, returns the current zoom level of the display as a positive
float, where 1.0 represent the neutral zoom (100%)
Length units
• #µm (#micrometer,#micrometers), value= 1.0E-6, Comment: micrometer unit
v 1.8.0 918
GAMA v1.8.0 documentation Chapter 98. Units and constants
Surface units
• #m2, value= 1.0, Comment: square meter: the basic unit for surfaces
Time units
• #custom, value= CUSTOM, Comment: custom: a custom date/time pattern
that can be defined in the preferences of GAMA and reused in models
• #day (#days), value= 86400.0, Comment: day time unit: defines an exact
duration of 24 hours
• #epoch, value= No Default Value, Comment: The epoch default starting date
as defined by the ISO format (1970-01-01T00:00Z)
v 1.8.0 919
GAMA v1.8.0 documentation Chapter 98. Units and constants
Volume units
• #cl (#centiliter,#centiliters), value= 1.0E-5, Comment: centiliter unit
• #dl (#deciliter,#deciliters), value= 1.0E-4, Comment: deciliter unit
• #hl (#hectoliter,#hectoliters), value= 0.1, Comment: hectoliter unit
• #l (#liter,#liters,#dm3), value= 0.001, Comment: liter unit
• #m3, value= 1.0, Comment: cube meter: the basic unit for volumes
v 1.8.0 920
GAMA v1.8.0 documentation Chapter 98. Units and constants
Weight units
• #gram (#grams), value= 0.001, Comment: gram unit
Colors
In addition to the previous units, GAML provides a direct access to the 147 named
colors defined in CSS (see http://www.cssportal.com/css3-color-names/). E.g,
rgb my_color <- ˚teal;
v 1.8.0 921
GAMA v1.8.0 documentation Chapter 98. Units and constants
v 1.8.0 922
GAMA v1.8.0 documentation Chapter 98. Units and constants
v 1.8.0 923
GAMA v1.8.0 documentation Chapter 98. Units and constants
v 1.8.0 924
GAMA v1.8.0 documentation Chapter 98. Units and constants
v 1.8.0 925
GAMA v1.8.0 documentation Chapter 98. Units and constants
v 1.8.0 926
GAMA v1.8.0 documentation Chapter 98. Units and constants
v 1.8.0 927
GAMA v1.8.0 documentation Chapter 98. Units and constants
v 1.8.0 928
Chapter 99
Pseudo-variables
The expressions known as pseudo-variables are special read-only variables that are
not declared anywhere (at least not in a species), and which represent a value that
changes depending on the context of execution.
Table of contents
• Pseudo-variables
– self
– myself
– each
– super
self
The pseudo-variable self always holds a reference to the agent executing the current
statement.
• Example (sets the friend attribute of another random agent of the same species
to self and conversely):
929
GAMA v1.8.0 documentation Chapter 99. Pseudo-variables
friend potential_friend <- one_of (species(self) - self);
if potential_friend != nil {
potential_friend.friend <- self;
friend <- potential_friend;
}
super
The pseudo-variable super behaves exactly in the same way as self except when
calling an action, in which case it represents an indirection to the parent species. It is
mainly used for allowing to call inherited actions within redefined ones. For instance:
species parent {
}
myself
myself plays the same role as self but in remotely-executed code (ask, create,
capture and release statements), where it represents the calling agent when the
code is executed by the remote agent.
• Example (asks the first agent of my species to set its color to my color):
v 1.8.0 930
GAMA v1.8.0 documentation Chapter 99. Pseudo-variables
ask first (species (self)){
color <- myself.color;
}
• Example (create 10 new agents of the species of my species, share the energy
between them, turn them towards me, and make them move 4 times to get
closer to me):
create species (self) number: 10 {
energy <- myself.energy / 10.0;
loop times: 4 {
heading <- towards (myself);
do move;
}
}
each
each is available only in the right-hand argument of iterators. It is a pseudo-variable
that represents, in turn, each of the elements of the left-hand container. It can then
take any type depending on the context.
• Example:
list<string> names <- my_species collect each.name; // each is of
type my_species
int max <- max(['aa', 'bbb', 'cccc'] collect length(each)); // each
is of type string
v 1.8.0 931
GAMA v1.8.0 documentation Chapter 99. Pseudo-variables
v 1.8.0 932
Chapter 100
Variables and attributes represent named data that can be used in an expression.
They can be accessed depending on their scope:
• the scope of attributes declared in a species is itself, its child species and its
micro-species.
• the scope of temporary variables is the one in which they have been declared,
and all its sub-scopes. Outside its scope of validity, an expression cannot use a
variable or an attribute directly. However, attributes can be used in a remote
fashion by using a dotted notation on a given agent (see here).
Table of contents
• Variables and Attributes
– Direct Access
– Remote Access
Direct Access
When an agent wants to use either one of the variables declared locally, one of the
attributes declared in its species (or parent species), one of the attributes declared in
the macro-species of its species, it can directly invoke its name and the compiler will
933
GAMA v1.8.0 documentation Chapter 100. Variables and Attributes
do the rest (i.e. finding the variable or attribute in the right scope). For instance, we
can have a look at the following example:
species animal {
float energy <- 1000 min: 0 max: 2000 update: energy - 0.001;
int age_in_years <- 1 update: age_in_years + int (time / 365);
reflex feed {
int food_found <- rnd(100);
do eat (amount: food_found);
}
}
Species declaration
Everywhere in the species declaration, we are able to directly name and use: * time,
a global built-in variable, * energy and age_in_years, the two species attributes.
Nevertheless, in the species declaration, but outside of the action eat and the reflex
feed, we cannot name the variables:
v 1.8.0 934
GAMA v1.8.0 documentation Chapter 100. Variables and Attributes
Remote Access
When an expression needs to get access to the attribute of an agent which does not
belong to its scope of execution, a special notation (similar to that used in Java) has
to be used:
remote_agent.variable
v 1.8.0 935
GAMA v1.8.0 documentation Chapter 100. Variables and Attributes
v 1.8.0 936
Chapter 101
Operators
This file is automatically generated from java files. Do Not Edit It.
Definition
Operators in the GAML language are used to compose complex expressions. An
operator performs a function on one, two, or n operands (which are other expressions
and thus may be themselves composed of operators) and returns the result of this
function.
Most of them use a classical prefixed functional syntax (i.e. operator_name(operand1
, operand2, operand3), see below), with the exception of arithmetic (e.g. +, /),
logical (and, or), comparison (e.g. >, <), access (., [..]) and pair (::) operators,
which require an infixed notation (i.e. operand1 operator_symbol operand1).
The ternary functional if-else operator, ? :, uses a special infixed syntax composed
with two symbols (e.g. operand1 ? operand2 : operand3). Two unary operators (-
and !) use a traditional prefixed syntax that does not require parentheses unless the
operand is itself a complex expression (e.g. - 10, ! (operand1 or operand2)).
Finally, special constructor operators ({...} for constructing points, [...] for con-
structing lists and maps) will require their operands to be placed between their two
937
GAMA v1.8.0 documentation Chapter 101. Operators
With the exception of these special cases above, the following rules apply to the
syntax of operators:
• if they only have one operand, the functional prefixed syntax is mandatory
(e.g. operator_name(operand1))
• if they have two arguments, either the functional prefixed syn-
tax (e.g. operator_name(operand1, operand2)) or the infixed syntax
(e.g. operand1 operator_name operand2) can be used.
• if they have more than two arguments, either the functional prefixed syn-
tax (e.g. operator_name(operand1, operand2, ..., operand)) or a special
infixed syntax with the first operand on the left-hand side of the operator name
(e.g. operand1 operator_name(operand2, ..., operand)) can be used.
• the constructor operators, like ::, used to compose pairs of operands, have
the lowest priority of all operators (e.g. a > b :: b > c will return a pair of
boolean values, which means that the two comparisons are evaluated before
the operator applies. Similarly, [a > 10, b > 5] will return a list of boolean
values.
v 1.8.0 938
GAMA v1.8.0 documentation Chapter 101. Operators
Any agent instance of spec1 can use min as an operator (if the action conflicts with
an existing operator, a warning will be emitted). For instance, in the same model,
the following line is perfectly acceptable:
global {
init {
create spec1;
spec1 my_agent <- spec1[0];
int the_min <- my_agent min(10,20); // or min(my_agent,
10, 20);
}
}
v 1.8.0 939
GAMA v1.8.0 documentation Chapter 101. Operators
If the action doesn’t have any operands, the syntax to use is my_agent the_action().
Finally, if it does not return a value, it might still be used but is considering as
returning a value of type unknown (e.g. unknown result <- my_agent the_action(
op1, op2);).
Note that due to the fact that actions are written by modelers, the general functional
contract is not respected in that case: actions might perfectly have side effects on
their operands (including the agent).
Table of Contents
Operators by categories
3D
box, cone3D, cube, cylinder, dem, hexagon, pyramid, set_z, sphere, teapot,
Arithmetic operators
-, /, [](OperatorsAA# ), *, +, abs, acos, asin, atan, atan2, ceil, cos, cos_rad, div, even,
exp, fact, floor, hypot, is_finite, is_number, ln, log, mod, round, signum, sin, sin_rad,
sqrt, tan, tan_rad, tanh, with_precision,
v 1.8.0 940
GAMA v1.8.0 documentation Chapter 101. Operators
BDI
add_values, and, eval_when, get_about, get_agent, get_agent_cause, get_be-
lief_op, get_belief_with_name_op, get_beliefs_op, get_beliefs_with_name_op,
get_current_intention_op, get_decay, get_desire_op, get_desire_with_name_op,
get_desires_op, get_desires_with_name_op, get_dominance, get_familiarity, get_-
ideal_op, get_ideal_with_name_op, get_ideals_op, get_ideals_with_name_op,
get_intensity, get_intention_op, get_intention_with_name_op, get_intentions_op,
get_intentions_with_name_op, get_lifetime, get_liking, get_modality, get_obli-
gation_op, get_obligation_with_name_op, get_obligations_op, get_obligations_-
with_name_op, get_plan_name, get_predicate, get_solidarity, get_strength, get_-
super_intention, get_trust, get_truth, get_uncertainties_op, get_uncertainties_-
with_name_op, get_uncertainty_op, get_uncertainty_with_name_op, get_val-
ues, has_belief_op, has_belief_with_name_op, has_desire_op, has_desire_with_-
name_op, has_ideal_op, has_ideal_with_name_op, has_intention_op, has_inten-
tion_with_name_op, has_obligation_op, has_obligation_with_name_op, has_un-
certainty_op, has_uncertainty_with_name_op, new_emotion, new_mental_state,
new_predicate, new_social_link, not, or, set_about, set_agent, set_agent_cause,
set_decay, set_dominance, set_familiarity, set_intensity, set_lifetime, set_liking,
set_modality, set_predicate, set_solidarity, set_strength, set_trust, set_truth,
with_values,
Casting operators
as, as_int, as_matrix, font, is, is_skill, list_with, matrix_with, species, to_gaml,
topology,
Color-related operators
-, /, *, +, blend, brewer_colors, brewer_palettes, grayscale, hsb, mean, median, rgb,
rnd_color, sum,
v 1.8.0 941
GAMA v1.8.0 documentation Chapter 101. Operators
Comparison operators
!=, <, <=, =, >, >=, between,
Containers-related operators
-, ::, +, accumulate, all_match, among, at, collect, contains, contains_all, contains_-
any, contains_key, count, distinct, empty, every, first, first_with, get, group_by, in,
index_by, inter, interleave, internal_at, internal_integrated_value, last, last_with,
length, max, max_of, mean, mean_of, median, min, min_of, mul, none_matches,
one_matches, one_of, product_of, range, reverse, shuffle, sort_by, split, split_in,
split_using, sum, sum_of, union, variance_of, where, with_max_of, with_min_of,
Date-related operators
-, !=, +, <, <=, =, >, >=, after, before, between, every, milliseconds_between,
minus_days, minus_hours, minus_minutes, minus_months, minus_ms, minus_-
weeks, minus_years, months_between, plus_days, plus_hours, plus_minutes, plus_-
months, plus_ms, plus_weeks, plus_years, since, to, until, years_between,
Dates
Displays
horizontal, stack, vertical,
v 1.8.0 942
GAMA v1.8.0 documentation Chapter 101. Operators
Driving operators
as_driving_graph,
edge
edge_between, strahler,
EDP-related operators
diff, diff2,
Files-related operators
crs, csv_file, dxf_file, evaluate_sub_model, file, file_exists, folder, gaml_file, geo-
json_file, get, gif_file, gml_file, grid_file, image_file, is_csv, is_dxf, is_gaml,
is_geojson, is_gif, is_gml, is_grid, is_image, is_json, is_obj, is_osm, is_pgm,
is_property, is_R, is_saved_simulation, is_shape, is_svg, is_text, is_threeds, is_-
xml, json_file, new_folder, obj_file, osm_file, pgm_file, property_file, R_file, read,
saved_simulation_file, shape_file, step_sub_model, svg_file, text_file, threeds_file,
writable, xml_file,
FIPA-related operators
conversation, message,
v 1.8.0 943
GAMA v1.8.0 documentation Chapter 101. Operators
GamaMetaType
type_of,
Graphs-related operators
add_edge, add_node, adjacency, agent_from_geometry, all_pairs_shortest_path,
alpha_index, as_distance_graph, as_edge_graph, as_intersection_graph, as_path,
beta_index, betweenness_centrality, biggest_cliques_of, connected_components_-
of, connectivity_index, contains_edge, contains_vertex, degree_of, directed, edge,
edge_between, edge_betweenness, edges, gamma_index, generate_barabasi_albert,
generate_complete_graph, generate_watts_strogatz, grid_cells_to_graph, in_de-
gree_of, in_edges_of, layout_circle, layout_force, layout_grid, load_graph_from_-
file, load_shortest_paths, main_connected_component, max_flow_between, maxi-
mal_cliques_of, nb_cycles, neighbors_of, node, nodes, out_degree_of, out_edges_-
of, path_between, paths_between, predecessors_of, remove_node_from, rewire_n,
source_of, spatial_graph, strahler, successors_of, sum, target_of, undirected, use_-
cache, weight_of, with_optimizer_type, with_weights,
Grid-related operators
as_4_grid, as_grid, as_hexagonal_grid, grid_at, path_between,
Iterator operators
accumulate, all_match, as_map, collect, count, create_map, first_with, frequency_-
of, group_by, index_by, last_with, max_of, mean_of, min_of, none_matches,
one_matches, product_of, sort_by, sum_of, variance_of, where, with_max_of,
with_min_of,
v 1.8.0 944
GAMA v1.8.0 documentation Chapter 101. Operators
List-related operators
copy_between, index_of, last_index_of,
Logical operators
:, !, ?, add_3Dmodel, add_geometry, add_icon, and, or, xor,
Map-related operators
as_map, create_map, index_of, last_index_of,
Material
material,
Matrix-related operators
-, /, ., *, +, append_horizontally, append_vertically, column_at, columns_list,
determinant, eigenvalues, index_of, inverse, last_index_of, row_at, rows_list, shuffle,
trace, transpose,
v 1.8.0 945
GAMA v1.8.0 documentation Chapter 101. Operators
multicriteria operators
electre_DM, evidence_theory_DM, fuzzy_choquet_DM, promethee_DM, weight-
ed_means_DM,
Path-related operators
agent_from_geometry, all_pairs_shortest_path, as_path, load_shortest_paths,
max_flow_between, path_between, path_to, paths_between, use_cache,
Points-related operators
-, /, *, +, <, <=, >, >=, add_point, angle_between, any_location_in, centroid,
closest_points_with, farthest_point_to, grid_at, norm, points_along, points_at,
points_on,
Random operators
binomial, flip, gauss, open_simplex_generator, poisson, rnd, rnd_choice, sample,
shuffle, simplex_generator, skew_gauss, truncated_gauss,
ReverseOperators
restore_simulation, restore_simulation_from_file, save_agent, save_simulation, se-
rialize, serialize_agent,
v 1.8.0 946
GAMA v1.8.0 documentation Chapter 101. Operators
Shape
arc, box, circle, cone, cone3D, cross, cube, curve, cylinder, ellipse, envelope, geome-
try_collection, hexagon, line, link, plan, polygon, polyhedron, pyramid, rectangle,
sphere, square, squircle, teapot, triangle,
Spatial operators
v 1.8.0 947
GAMA v1.8.0 documentation Chapter 101. Operators
Species-related operators
index_of, last_index_of, of_generic_species, of_species,
v 1.8.0 948
GAMA v1.8.0 documentation Chapter 101. Operators
Statistical operators
auto_correlation, beta, binomial_coeff, binomial_complemented, binomial_sum,
build, chi_square, chi_square_complemented, corR, correlation, covariance, db-
scan, distribution_of, distribution2d_of, dtw, durbin_watson, frequency_of, gamma,
gamma_distribution, gamma_distribution_complemented, gamma_rnd, geometric_-
mean, gini, harmonic_mean, hierarchical_clustering, incomplete_beta, incomplete_-
gamma, incomplete_gamma_complement, kmeans, kurtosis, kurtosis, log_gamma,
max, mean, mean_deviation, meanR, median, min, moment, moran, mul, normal_-
area, normal_density, normal_inverse, predict, pValue_for_fStat, pValue_for_tStat,
quantile, quantile_inverse, rank_interpolated, rms, simple_clustering_by_distance,
skew, skewness, split, split_in, split_using, standard_deviation, student_area, stu-
dent_t_inverse, sum, variance, variance,
Strings-related operators
+, <, <=, >, >=, at, char, contains, contains_all, contains_any, copy_between,
date, empty, first, in, indented_by, index_of, is_number, last, last_index_of, length,
lower_case, replace, replace_regex, reverse, sample, shuffle, split_with, string, up-
per_case,
SubModel
load_sub_model,
System
., command, copy, copy_to_clipboard, dead, eval_gaml, every, is_error, is_warning,
user_input,
v 1.8.0 949
GAMA v1.8.0 documentation Chapter 101. Operators
Time-related operators
date, string,
Types-related operators
action, agent, attributes, BDIPlan, bool, container, emotion, file, float, gaml_type,
geometry, graph, int, kml, list, map, material, matrix, mental_state, Norm, pair,
path, point, predicate, regression, rgb, Sanction, skill, social_link, topology, unknown,
Operators
-
Possible uses:
v 1.8.0 950
GAMA v1.8.0 documentation Chapter 101. Operators
v 1.8.0 951
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
If it is used as an unary operator, it returns the opposite of the operand. Returns the
difference of the two operands.
Comment:
Special cases:
• if the left operand is a species and the right operand is an agent of the species,
- returns a list containing all the agents of the species minus this agent
• if both operands are containers and the right operand is empty, - returns the
left operand
• if one operand is a color and the other an integer, returns a new color resulting
from the subtraction of each component of the color with the right operand
rgb var18 <- rgb([255, 128, 32]) - 3; // var18 equals rgb([252,125,29])
• if both operands are colors, returns a new color resulting from the subtraction
of the two operands, component by component
v 1.8.0 952
GAMA v1.8.0 documentation Chapter 101. Operators
rgb var19 <- rgb([255, 128, 32]) - rgb('red'); // var19 equals rgb
([0,128,32])
• if the left operand is a list and the right operand is an object of any type (except
list), - returns a list containing the elements of the left operand minus all the
occurrences of this object
list<int> var21 <- [1,2,3,4,5,6] - 2; // var21 equals [1,3,4,5,6]
list<int> var22 <- [1,2,3,4,5,6] - 0; // var22 equals [1,2,3,4,5,6]
• if one operand is a matrix and the other a number (float or int), performs a
normal arithmetic difference of the number with each element of the matrix
(results are float if the number is a float.
matrix var24 <- 3.5 - matrix([[2,5],[3,4]]); // var24 equals matrix
([[1.5,-1.5],[0.5,-0.5]])
• if both operands are dates, returns the duration in seconds between date2 and
date1. To obtain a more precise duration, in milliseconds, use milliseconds_-
between(date1, date2)
v 1.8.0 953
GAMA v1.8.0 documentation Chapter 101. Operators
float var25 <- date('2000-01-02') - date('2000-01-01'); // var25 equals
86400
• if both operands are points, returns their difference (coordinates per coordi-
nates).
point var26 <- {1, 2} - {4, 5}; // var26 equals {-3.0, -3.0}
• if one of the operands is a date and the other a number, returns a date
corresponding to the date minus the given number as duration (in seconds)
date var27 <- date('2000-01-01') - 86400; // var27 equals date
('1999-12-31')
• if both operands are containers, returns a new list in which all the elements of
the right operand have been removed from the left one
list<int> var29 <- [1,2,3,4,5,6] - [2,4,9]; // var29 equals [1,3,5,6]
list<int> var30 <- [1,2,3,4,5,6] - [0,8]; // var30 equals [1,2,3,4,5,6]
v 1.8.0 954
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
matrix var0 <- (10.0 - (3.0 as_matrix({2,3}))); // var0 equals matrix
([[7.0,7.0,7.0],[7.0,7.0,7.0]])
point var1 <- -{3.0,5.0}; // var1 equals {-3.0,-5.0}
point var2 <- -{1.0,6.0,7.0}; // var2 equals {-1.0,-6.0,-7.0}
point var3 <- {2.0,3.0,4.0} - 1; // var3 equals {1.0,2.0,3.0}
float var4 <- 1.0 - 1.0; // var4 equals 0.0
float var5 <- 3.7 - 1.2; // var5 equals 2.5
float var6 <- 3.0 - 1.2; // var6 equals 1.8
map var7 <- ['a'::1,'b'::2] - ['b'::2]; // var7 equals ['a'::1]
map var8 <- ['a'::1,'b'::2] - ['b'::2,'c'::3]; // var8 equals ['a'::1]
date var9 <- date('2000-01-01') - 86400; // var9 equals date
('1999-12-31')
float var10 <- 1 - 1.0; // var10 equals 0.0
float var11 <- 3 - 1.2; // var11 equals 1.8
float var12 <- 1.0 - 1; // var12 equals 0.0
float var13 <- 3.7 - 1; // var13 equals 2.7
float var14 <- 3.0 - 1; // var14 equals 2.0
int var15 <- - (-56); // var15 equals 56
map var16 <- ['a'::1,'b'::2] - ('b'::2); // var16 equals ['a'::1]
map var17 <- ['a'::1,'b'::2] - ('c'::3); // var17 equals ['a'::1,'b
'::2]
See also:
-, milliseconds_between, +, *, /,
Possible uses:
v 1.8.0 955
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Examples:
list<string> var0 <- [10, 19, 43, 12, 7, 22] collect ((each > 20) ? '
above' : 'below'); // var0 equals ['below', 'below', 'above', 'below
', 'below', 'above']
See also:
?,
::
Possible uses:
Result:
produces a new pair combining the left and the right operands
Special cases:
v 1.8.0 956
GAMA v1.8.0 documentation Chapter 101. Operators
!
Possible uses:
Result:
Special cases:
Examples:
bool var0 <- ! (true); // var0 equals false
See also:
!=
Possible uses:
v 1.8.0 957
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Examples:
bool var0 <- 3.0 != 3; // var0 equals false
bool var1 <- 4.7 != 4; // var1 equals true
bool var2 <- #now != #now minus_hours 1; // var2 equals true
bool var3 <- 3.0 != 3.0; // var3 equals false
bool var4 <- 4.0 != 4.7; // var4 equals true
bool var5 <- [2,3] != [2,3]; // var5 equals false
bool var6 <- [2,4] != [2,3]; // var6 equals true
bool var7 <- 3 != 3.0; // var7 equals false
bool var8 <- 4 != 4.7; // var8 equals true
See also:
?
Possible uses:
Result:
v 1.8.0 958
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
Examples:
list<string> var0 <- [10, 19, 43, 12, 7, 22] collect ((each > 20) ? '
above' : 'below'); // var0 equals ['below', 'below', 'above', 'below
', 'below', 'above']
rgb col <- (flip(0.3) ? #red : (flip(0.9) ? #blue : #green));
See also:
:,
/
Possible uses:
v 1.8.0 959
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Special cases:
• if one operand is a color and the other a double, returns a new color resulting
from the division of each component of the color by the right operand. The
result on each component is then truncated.
rgb var0 <- rgb([255, 128, 32]) / 2.5; // var0 equals rgb([102,51,13])
• if the left operand is a point, returns a new point with coordinates divided by
the right operand
point var2 <- {5, 7.5} / 2.5; // var2 equals {2, 3}
point var3 <- {2,5} / 4; // var3 equals {0.5,1.25}
• if one operand is a color and the other an integer, returns a new color resulting
from the division of each component of the color by the right operand
rgb var4 <- rgb([255, 128, 32]) / 2; // var4 equals rgb([127,64,16])
v 1.8.0 960
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
*, +, -,
.
Possible uses:
Result:
It has two different uses: it can be the dot product between 2 matrices or return an
evaluation of the expression (right-hand operand) in the scope the given agent.
Special cases:
v 1.8.0 961
GAMA v1.8.0 documentation Chapter 101. Operators
ˆ
Possible uses:
Result:
Returns the value (always a float) of the left operand raised to the power of the right
operand.
Special cases:
Examples:
float var0 <- 4.84 ^ 0.5; // var0 equals 2.2
See also:
*, sqrt,
v 1.8.0 962
GAMA v1.8.0 documentation Chapter 101. Operators
Same signification as at
*
Possible uses:
v 1.8.0 963
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Special cases:
• if one operand is a matrix and the other a number (float or int), performs
a normal arithmetic product of the number with each element of the matrix
(results are float if the number is a float.
matrix var1 <- 2 * matrix([[2,5],[3,4]]); // var1 equals matrix
([[4,10],[6,8]])
• if one operand is a color and the other an integer, returns a new color resulting
from the product of each component of the color with the right operand (with
a maximum value at 255)
rgb var3 <- rgb([255, 128, 32]) * 2; // var3 equals rgb([255,255,64])
v 1.8.0 964
GAMA v1.8.0 documentation Chapter 101. Operators
geometry var5 <- circle(10) * 2; // var5 equals circle(20)
geometry var6 <- (circle(10) * 2).location with_precision 9; // var6
equals (circle(20)).location with_precision 9
float var7 <- (circle(10) * 2).height with_precision 9; // var7 equals
(circle(20)).height with_precision 9
float var8 <- {2,5} * {4.5, 5}; // var8 equals 34.0
• if the left-hand operator is a point and the right-hand a number, returns a point
with coordinates multiplied by the number
point var9 <- {2,5} * 4; // var9 equals {8.0, 20.0}
point var10 <- {2, 4} * 2.5; // var10 equals {5.0, 10.0}
Examples:
float var0 <- 2.5 * 2; // var0 equals 5.0
See also:
/, +, -,
v 1.8.0 965
GAMA v1.8.0 documentation Chapter 101. Operators
Possible uses:
v 1.8.0 966
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Special cases:
• if both operands are species, returns a special type of list called meta-population
point var0 <- {1, 2} + {4, 5}; // var0 equals {5.0, 7.0}
v 1.8.0 967
GAMA v1.8.0 documentation Chapter 101. Operators
to the left-hand operand (geometry, agent, point) enlarged by the first right-
hand operand (distance), using a number of segments equal to the second
right-hand operand and a flat, square or round end cap style
geometry var1 <- circle(5) + (5,32,#round); // var1 equals circle(10)
• if the left-hand and right-hand operand are a string, returns the concatenation
of the two operands
string var4 <- "hello " + "World"; // var4 equals "hello World"
• if the left-hand operand is a point and the right-hand a number, returns a new
point with each coordinate as the sum of the operand coordinate with this
number.
v 1.8.0 968
GAMA v1.8.0 documentation Chapter 101. Operators
point var8 <- {1, 2} + 4.5; // var8 equals {5.5, 6.5,4.5}
• if the left-hand operand is a string, returns the concatenation of the two operands
(the left-hand one beind casted into a string)
string var10 <- "hello " + 12; // var10 equals "hello 12"
• if both operands are colors, returns a new color resulting from the sum of the
two operands, component by component
rgb var11 <- rgb([255, 128, 32]) + rgb('red'); // var11 equals rgb
([255,128,32])
• if both operands are numbers (float or int), performs a normal arithmetic sum
and returns a float if one of them is a float.
int var13 <- 1 + 1; // var13 equals 2
• if one operand is a color and the other an integer, returns a new color resulting
from the sum of each component of the color with the right operand
v 1.8.0 969
GAMA v1.8.0 documentation Chapter 101. Operators
rgb var14 <- rgb([255, 128, 32]) + 3; // var14 equals rgb([255,131,35])
• if one of the operands is a date and the other a number, returns a date
corresponding to the date plus the given number as duration (in seconds)
date var15 <- date('2000-01-01') + 86400; // var15 equals date
('2000-01-02')
• if one operand is a matrix and the other a number (float or int), performs a
normal arithmetic sum of the number with each element of the matrix (results
are float if the number is a float.
matrix var16 <- 3.5 + matrix([[2,5],[3,4]]); // var16 equals matrix
([[5.5,8.5],[6.5,7.5]])
Examples:
map var17 <- ['a'::1,'b'::2] + ['c'::3]; // var17 equals ['a'::1,'b
'::2,'c'::3]
map var18 <- ['a'::1,'b'::2] + [5::3.0]; // var18 equals ['a'::1,'b
'::2,5::3.0]
map var19 <- ['a'::1,'b'::2] + ('c'::3); // var19 equals ['a'::1,'b
'::2,'c'::3]
map var20 <- ['a'::1,'b'::2] + ('c'::3); // var20 equals ['a'::1,'b
'::2,'c'::3]
point var21 <- {1, 2} + 4; // var21 equals {5.0, 6.0,4.0}
date var22 <- date('2016-01-01 00:00:01') + 86400; // var22 equals date
('2016-01-02 00:00:01')
float var23 <- 1.0 + 1; // var23 equals 2.0
float var24 <- 1.0 + 2.5; // var24 equals 3.5
string var25 <- date('2000-01-01 00:00:00') + '_Test'; // var25 equals
'2000-01-01 00:00:00_Test'
See also:
-, /, *,
v 1.8.0 970
GAMA v1.8.0 documentation Chapter 101. Operators
<
Possible uses:
Result:
true if the left-hand operand is less than the right-hand operand, false otherwise.
Special cases:
• if both operands are points, returns true if and only if the left component (x)
of the left operand if less than or equal to x of the right one and if the right
component (y) of the left operand is greater than or equal to y of the right one.
bool var1 <- {5,7} < {4,6}; // var1 equals false
bool var2 <- {5,7} < {4,8}; // var2 equals false
v 1.8.0 971
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
bool var3 <- 3.5 < 7; // var3 equals true
bool var4 <- #now < #now minus_hours 1; // var4 equals false
bool var5 <- 3 < 7; // var5 equals true
bool var6 <- 3 < 2.5; // var6 equals false
bool var7 <- 3.5 < 7.6; // var7 equals true
See also:
<=
Possible uses:
Result:
true if the left-hand operand is less or equal than the right-hand operand, false
otherwise.
v 1.8.0 972
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
• if both operands are points, returns true if and only if the left component (x)
of the left operand if less than or equal to x of the right one and if the right
component (y) of the left operand is greater than or equal to y of the right one.
bool var1 <- {5,7} <= {4,6}; // var1 equals false
bool var2 <- {5,7} <= {4,8}; // var2 equals false
Examples:
bool var3 <- 3 <= 7; // var3 equals true
bool var4 <- 3.5 <= 3.5; // var4 equals true
bool var5 <- (#now <= (#now minus_hours 1)); // var5 equals false
bool var6 <- 7.0 <= 7; // var6 equals true
bool var7 <- 3 <= 2.5; // var7 equals false
See also:
=
Possible uses:
v 1.8.0 973
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
returns true if both operands are equal, false otherwise returns true if both operands
are equal, false otherwise
Special cases:
• if both operands are any kind of objects, returns true if they are identical (i.e.,
the same object) or equal (comparisons between nil values are permitted)
bool var0 <- [2,3] = [2,3]; // var0 equals true
Examples:
bool var1 <- 4 = 5; // var1 equals false
bool var2 <- 4.5 = 4.7; // var2 equals false
bool var3 <- #now = #now minus_hours 1; // var3 equals false
bool var4 <- 4.7 = 4; // var4 equals false
bool var5 <- 3 = 3.0; // var5 equals true
bool var6 <- 4 = 4.7; // var6 equals false
See also:
v 1.8.0 974
GAMA v1.8.0 documentation Chapter 101. Operators
>
Possible uses:
Result:
true if the left-hand operand is greater than the right-hand operand, false otherwise.
Special cases:
• if both operands are points, returns true if and only if the left component (x)
of the left operand if greater than x of the right one and if the right component
(y) of the left operand is greater than y of the right one.
bool var1 <- {5,7} > {4,6}; // var1 equals true
bool var2 <- {5,7} > {4,8}; // var2 equals false
v 1.8.0 975
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
bool var3 <- 3 > 2.5; // var3 equals true
bool var4 <- 3.5 > 7.6; // var4 equals false
bool var5 <- (#now > (#now minus_hours 1)); // var5 equals true
bool var6 <- 13.0 > 7.0; // var6 equals true
bool var7 <- 3.5 > 7; // var7 equals false
See also:
>=
Possible uses:
Result:
true if the left-hand operand is greater or equal than the right-hand operand, false
otherwise.
v 1.8.0 976
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
• if both operands are points, returns true if and only if the left component (x)
of the left operand if greater or equal than x of the right one and if the right
component (y) of the left operand is greater than or equal to y of the right one.
bool var0 <- {5,7} >= {4,6}; // var0 equals true
bool var1 <- {5,7} >= {4,8}; // var1 equals false
• if both operands are string, uses a lexicographic comparison of the two strings
bool var2 <- 'abc' >= 'aeb'; // var2 equals false
bool var3 <- 'abc' >= 'abc'; // var3 equals true
Examples:
bool var4 <- 3 >= 7; // var4 equals false
bool var5 <- 3 >= 2.5; // var5 equals true
bool var6 <- #now >= #now minus_hours 1; // var6 equals true
bool var7 <- 3.5 >= 3.5; // var7 equals true
bool var8 <- 3.5 >= 7; // var8 equals false
See also:
abs
Possible uses:
v 1.8.0 977
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Returns the absolute value of the operand (so a positive int or float depending on
the type of the operand).
Examples:
float var0 <- abs (200 * -1 + 0.5); // var0 equals 199.5
int var1 <- abs (-10); // var1 equals 10
int var2 <- abs (10); // var2 equals 10
accumulate
Possible uses:
Result:
returns a new flat list, in which each element is the evaluation of the right-hand
operand. If this evaluation returns a list, the elements of this result are added directly
to the list returned
Comment:
v 1.8.0 978
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
list var0 <- [a1,a2,a3] accumulate (each neighbors_at 10); // var0
equals a flat list of all the neighbors of these three agents
list<int> var1 <- [1,2,4] accumulate ([2,4]); // var1 equals
[2,4,2,4,2,4]
list<int> var2 <- [1,2,4] accumulate (each * 2); // var2 equals [2,4,8]
See also:
collect,
acos
Possible uses:
Result:
Returns the value (in the interval [0,180], in decimal degrees) of the arccos of the
operand (which should be in [-1,1]).
Special cases:
Examples:
float var0 <- acos (0); // var0 equals 90.0
v 1.8.0 979
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
action
Possible uses:
add_3Dmodel
Possible uses:
Result:
the kml export manager with new 3D model: take the following argument: (kml,
location (point),orientation (float), scale (float), file_path (string)) the kml ex-
port manager with new 3D model: take the following argument: (kml, location
(point),orientation (float), scale (float), file_path (string), begin date, end date)
See also:
v 1.8.0 980
GAMA v1.8.0 documentation Chapter 101. Operators
add_days
add_edge
Possible uses:
Result:
add an edge between a source vertex and a target vertex (resp. the left and the right
element of the pair operand)
Comment:
WARNING / side effect: this operator modifies the operand and does not create a
new graph. If the edge already exists, the graph is unchanged
Examples:
graph <- graph add_edge (source::target);
See also:
add_node, graph,
v 1.8.0 981
GAMA v1.8.0 documentation Chapter 101. Operators
add_geometry
Possible uses:
Result:
the kml export manager with new geometry: take the following argument: (kml,
geometry,linewidth, linecolor,fillcolor) the kml export manager with new geometry:
take the following argument: (kml, geometry,linewidth, linecolor,fillcolor, begin date,
end date) the kml export manager with new geometry: take the following argument:
(kml, geometry,linewidth, color) the kml export manager with new geometry: take the
following argument: (kml, geometry,linewidth, linecolor,fillcolor, end date) the kml
export manager with new geometry: take the following argument: (kml, geometry,
linecolor,fillcolor)
See also:
add_hours
v 1.8.0 982
GAMA v1.8.0 documentation Chapter 101. Operators
add_icon
Possible uses:
Result:
the kml export manager with new icons: take the following argument: (kml, location
(point),orientation (float), scale (float), file_path (string)) the kml export manager
with new icons: take the following argument: (kml, location (point),orientation (float),
scale (float), file_path (string), begin date, end date)
See also:
add_geometry, add_icon,
add_minutes
Same signification as plus_minutes
add_months
Same signification as plus_months
add_ms
Same signification as plus_ms
v 1.8.0 983
GAMA v1.8.0 documentation Chapter 101. Operators
add_node
Possible uses:
Result:
Comment:
WARNING / side effect: this operator modifies the operand and does not create a
new graph
Examples:
graph var0 <- graph add_node node(0) ; // var0 equals the graph, to
which node(0) has been added
See also:
add_edge, graph,
add_point
Possible uses:
v 1.8.0 984
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
A new geometry resulting from the addition of the right point (coordinate) to the
left-hand geometry. Note that adding a point to a line or polyline will always return
a closed contour. Also note that the position at which the added point will appear
in the geometry is not necessarily the last one, as points are always ordered in a
clockwise fashion in geometries
Examples:
geometry var0 <- polygon([{10,10},{10,20},{20,20}]) add_point {20,10};
// var0 equals polygon([{10,10},{10,20},{20,20},{20,10}])
add_seconds
Same signification as +
add_values
Possible uses:
Result:
v 1.8.0 985
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
predicate add_values ["time"::10]
add_weeks
add_years
adjacency
Possible uses:
Result:
v 1.8.0 986
GAMA v1.8.0 documentation Chapter 101. Operators
after
Possible uses:
Result:
Returns true if the current_date of the model is strictly after the date passed in
argument. Synonym of ‘current_date > argument’. Can be used in its composed form
with 2 arguments to express the lower boundary for the computation of a frequency.
Note that only dates strictly after this one will be tested against the frequency
Examples:
reflex when: after(starting_date) {} // this reflex will always be
run after the first step
reflex when: false after(starting date + #10days) {} // This reflex
will not be run after this date. Better to use 'until' or 'before'
in that case
every(2#days) after (starting_date + 1#day) // the computation will
return true every two days (using the starting_date of the model as
the starting point) only for the dates strictly after this
starting_date + 1#day
agent
Possible uses:
v 1.8.0 987
GAMA v1.8.0 documentation Chapter 101. Operators
agent_closest_to
Possible uses:
Result:
Comment:
the distance is computed in the topology of the calling agent (the agent in which this
operator is used), with the distance algorithm specific to the topology.
Examples:
agent var0 <- agent_closest_to(self); // var0 equals the closest agent
to the agent applying the operator.
See also:
agent_farthest_to
Possible uses:
Result:
v 1.8.0 988
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
the distance is computed in the topology of the calling agent (the agent in which this
operator is used), with the distance algorithm specific to the topology.
Examples:
agent var0 <- agent_farthest_to(self); // var0 equals the farthest
agent to the agent applying the operator.
See also:
agent_from_geometry
Possible uses:
Result:
returns the agent corresponding to given geometry (right-hand operand) in the given
path (left-hand operand).
Special cases:
v 1.8.0 989
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
geometry line <- one_of(path_followed.segments);
road ag <- road(path_followed agent_from_geometry line);
See also:
path,
agents_at_distance
Possible uses:
Result:
Examples:
list var0 <- agents_at_distance(20); // var0 equals all the agents (
excluding the caller) which distance to the caller is lower than 20
See also:
v 1.8.0 990
GAMA v1.8.0 documentation Chapter 101. Operators
agents_inside
Possible uses:
Result:
Examples:
list<agent> var0 <- agents_inside(self); // var0 equals the agents that
are covered by the shape of the agent applying the operator.
See also:
agents_overlapping
Possible uses:
Result:
Examples:
list<agent> var0 <- agents_overlapping(self); // var0 equals the agents
that overlap the shape of the agent applying the operator.
v 1.8.0 991
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
all_match
Possible uses:
Result:
Returns true if all the elements of the left-hand operand make the right-hand operand
evaluate to true. Returns true if the left-hand operand is empty. ‘c all_match
each.property’ is strictly equivalent to ‘(c count each.property) = length(c)’ but faster
in most cases (as it is a shortcircuited operator)
Comment:
in the right-hand operand, the keyword each can be used to represent, in turn, each
of the elements.
Special cases:
Examples:
bool var0 <- [1,2,3,4,5,6,7,8] all_match (each > 3); // var0 equals
false
bool var1 <- [1::2, 3::4, 5::6] all_match (each > 4); // var1 equals
false
v 1.8.0 992
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
all_pairs_shortest_path
Possible uses:
Result:
returns the successor matrix of shortest paths between all node pairs (rows: source,
columns: target): a cell (i,j) will thus contains the next node in the shortest path
between i and j.
Examples:
matrix<int> var0 <- all_pairs_shortest_paths(my_graph); // var0 equals
shortest_paths_matrix will contain all pairs of shortest paths
all_verify
Same signification as all_match
alpha_index
Possible uses:
v 1.8.0 993
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
returns the alpha index of the graph (measure of connectivity which evaluates the
number of cycles in a graph in comparison with the maximum number of cycles. The
higher the alpha index, the more a network is connected: alpha = nb_cycles / (2*S-5)
- planar graph)
Examples:
float var1 <- alpha_index(graphEpidemio); // var1 equals the alpha
index of the graph
See also:
among
Possible uses:
Result:
Returns a list of length the value of the left-hand operand, containing random elements
from the right-hand operand. As of GAMA 1.6, the order in which the elements
are returned can be different than the order in which they appear in the right-hand
container
v 1.8.0 994
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
• if the right-hand operand is empty, among returns a new empty list. If it is nil,
it throws an error.
• if the left-hand operand is greater than the length of the right-hand operand,
among returns the right-hand operand (converted as a list). If it is smaller or
equal to zero, it returns an empty list
Examples:
list<int> var0 <- 3 among [1,2,4,3,5,7,6,8]; // var0 equals [1,2,8] (
for example)
list var1 <- 3 among g2; // var1 equals [node6,node11,node7]
list var2 <- 3 among list(node); // var2 equals [node1,node11,node4]
list<int> var3 <- 1 among [1::2,3::4]; // var3 equals 2 or 4
and
Possible uses:
Result:
a bool value, equal to the logical and between the left-hand operand and the right-hand
operand.
Comment:
both operands are always casted to bool before applying the operator. Thus, an
expression like (1 and 0) is accepted and returns false.
v 1.8.0 995
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
bool var0 <- true and false; // var0 equals false
bool var1 <- false and false; // var1 equals false
bool var2 <- false and true; // var2 equals false
bool var3 <- true and true; // var3 equals true
int a <-3 ; int b <- 4; int c <- 7;
bool var5 <- ((a+b) = c ) and ((a+b) > c ); // var5 equals false
See also:
bool, or, !,
and
Possible uses:
Result:
Examples:
predicate1 and predicate2
angle_between
Possible uses:
v 1.8.0 996
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
the angle between vectors P0P1 and P0P2 (P0, P1, P2 being the three point operands)
Examples:
float var0 <- angle_between({5,5},{10,5},{5,10}); // var0 equals 90
any
any_location_in
Possible uses:
Result:
Examples:
point var0 <- any_location_in(square(5)); // var0 equals a point in the
square, for example : {3,4.6}.
v 1.8.0 997
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
any_point_in
Same signification as any_location_in
append_horizontally
Possible uses:
Result:
A matrix resulting from the concatenation of the rows of the two given matrices. A
matrix resulting from the concatenation of the rows of the two given matrices. If not
both numerical or both object matrices, returns the first matrix.
Examples:
matrix var0 <- matrix([[1.0,2.0],[3.0,4.0]]) append_horizontally matrix
([[1,2],[3,4]]); // var0 equals matrix
([[1.0,2.0],[3.0,4.0],[1.0,2.0],[3.0,4.0]])
matrix var1 <- matrix([[1.0,2.0],[3.0,4.0]]) append_horizontally matrix
([[1,2],[3,4]]); // var1 equals matrix
([[1.0,2.0],[3.0,4.0],[1.0,2.0],[3.0,4.0]])
v 1.8.0 998
GAMA v1.8.0 documentation Chapter 101. Operators
append_vertically
Possible uses:
Result:
A matrix resulting from the concatenation of the columns of the two given matrices.
A matrix resulting from the concatenation of the columns of the two given matrices.
If not both numerical or both object matrices, returns the first matrix.
Examples:
matrix var0 <- matrix([[1,2],[3,4]]) append_vertically matrix
([[1,2],[3,4]]); // var0 equals matrix([[1,2,1,2],[3,4,3,4]])
matrix var1 <- matrix([[1,2],[3,4]]) append_vertically matrix
([[1,2],[3,4]]); // var1 equals matrix([[1,2,1,2],[3,4,3,4]])
arc
Possible uses:
Result:
An arc, which radius is equal to the first operand, heading to the second, amplitude
to the third and a boolean indicating whether to return a linestring or a polygon to
the fourth An arc, which radius is equal to the first operand, heading to the second
and amplitude the third
v 1.8.0 999
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
the center of the arc is by default the location of the current agent in which has been
called this operator.the center of the arc is by default the location of the current agent
in which has been called this operator. This operator returns a polygon by default.
Special cases:
Examples:
geometry var0 <- arc(4,45,90, false); // var0 equals a geometry as an
arc of radius 4, in a direction of 45˚ and an amplitude of 90˚,
which only contains the points on the arc
geometry var1 <- arc(4,45,90); // var1 equals a geometry as an arc of
radius 4, in a direction of 45˚ and an amplitude of 90˚
See also:
around, cone, line, link, norm, point, polygon, polyline, super_ellipse, rectangle,
square, circle, ellipse, triangle,
around
Possible uses:
v 1.8.0 1000
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
A geometry resulting from the difference between a buffer around the right-operand
casted in geometry at a distance left-operand (right-operand buffer left-operand) and
the right-operand casted as geometry.
Special cases:
Examples:
geometry var0 <- 10 around circle(5); // var0 equals the ring geometry
between 5 and 10.
See also:
circle, cone, line, link, norm, point, polygon, polyline, rectangle, square, triangle,
as
Possible uses:
Result:
Comment:
v 1.8.0 1001
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
int var0 <- 3.5 as int; // var0 equals int(3.5)
as_4_grid
Possible uses:
Result:
Examples:
matrix var0 <- self as_4_grid {10, 5}; // var0 equals the matrix of
square geometries (grid with 4-neighborhood) with 10 columns and 5
lines corresponding to the square tessellation of the geometry of
the agent applying the operator.
See also:
as_grid, as_hexagonal_grid,
v 1.8.0 1002
GAMA v1.8.0 documentation Chapter 101. Operators
as_distance_graph
Possible uses:
Result:
creates a graph from a list of vertices (left-hand operand). An edge is created between
each pair of vertices close enough (less than a distance, right-hand operand).
Comment:
Examples:
list(ant) as_distance_graph 3.0
See also:
as_intersection_graph, as_edge_graph,
as_driving_graph
Possible uses:
v 1.8.0 1003
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
creates a graph from the list/map of edges given as operand and connect the node to
the edge
Examples:
as_driving_graph(road,node) --: build a graph while using the road
agents as edges and the node agents as nodes
See also:
as_edge_graph
Possible uses:
Result:
Special cases:
• if the operand is a list, the graph will be built with elements of the list as edges
graph var0 <- as_edge_graph([line([{1,5},{12,45}]),line
([{12,45},{34,56}])]); // var0 equals a graph with two edges and
three vertices
v 1.8.0 1004
GAMA v1.8.0 documentation Chapter 101. Operators
• if the operand is a map, the graph will be built by creating edges from pairs of
the map
graph var1 <- as_edge_graph([{1,5}::{12,45},{12,45}::{34,56}]); // var1
equals a graph with these three vertices and two edges
See also:
as_intersection_graph, as_distance_graph,
as_grid
Possible uses:
Result:
v 1.8.0 1005
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
matrix var0 <- self as_grid {10, 5}; // var0 equals a matrix of square
geometries (grid with 8-neighborhood) with 10 columns and 5 lines
corresponding to the square tessellation of the geometry of the
agent applying the operator.
See also:
as_4_grid, as_hexagonal_grid,
as_hexagonal_grid
Possible uses:
Result:
Examples:
list<geometry> var0 <- self as_hexagonal_grid {10, 5}; // var0 equals
list of geometries (hexagonal) corresponding to the hexagonal
tesselation of the first operand geometry
See also:
as_4_grid, as_grid,
v 1.8.0 1006
GAMA v1.8.0 documentation Chapter 101. Operators
as_int
Possible uses:
Result:
parses the string argument as a signed integer in the radix specified by the second
argument.
Special cases:
• if the left operand does not represent an integer in the specified radix, as_int
throws an exception
Examples:
int var0 <- '20' as_int 10; // var0 equals 20
int var1 <- '20' as_int 8; // var1 equals 16
int var2 <- '20' as_int 16; // var2 equals 32
int var3 <- '1F' as_int 16; // var3 equals 31
int var4 <- 'hello' as_int 32; // var4 equals 18306744
See also:
int,
v 1.8.0 1007
GAMA v1.8.0 documentation Chapter 101. Operators
as_intersection_graph
Possible uses:
Result:
creates a graph from a list of vertices (left-hand operand). An edge is created between
each pair of vertices with an intersection (with a given tolerance).
Comment:
Examples:
list(ant) as_intersection_graph 0.5
See also:
as_distance_graph, as_edge_graph,
as_map
Possible uses:
v 1.8.0 1008
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
produces a new map from the evaluation of the right-hand operand for each element
of the left-hand operand
Comment:
Special cases:
Examples:
map<int,int> var0 <- [1,2,3,4,5,6,7,8] as_map (each::(each * 2)); //
var0 equals [1::2, 2::4, 3::6, 4::8, 5::10, 6::12, 7::14, 8::16]
map<int,int> var1 <- [1::2,3::4,5::6] as_map (each::(each * 2)); //
var1 equals [2::4, 4::8, 6::12]
as_matrix
Possible uses:
Result:
casts the left operand into a matrix with right operand as preferred size
v 1.8.0 1009
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
This operator is very useful to cast a file containing raster data into a matrix.Note
that both components of the right operand point should be positive, otherwise an
exception is raised.The operator as_matrix creates a matrix of preferred size. It fills
in it with elements of the left operand until the matrix is full If the size is to short,
some elements will be omitted. Matrix remaining elements will be filled in by nil.
Special cases:
See also:
matrix,
as_path
Possible uses:
Result:
Examples:
path var0 <- [road1,road2,road3] as_path my_graph; // var0 equals a
path road1->road2->road3 of my_graph
v 1.8.0 1010
GAMA v1.8.0 documentation Chapter 101. Operators
asin
Possible uses:
Result:
Special cases:
Examples:
float var0 <- asin (90); // var0 equals #nan
float var1 <- asin (0); // var1 equals 0.0
See also:
at
Possible uses:
v 1.8.0 1011
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Comment:
The first element of the container is located at the index 0. In addition, if the user
tries to get the element at an index higher or equals than the length of the container,
he will get an IndexOutOfBoundException.The at operator behavior depends on the
nature of the operand
Special cases:
• if it is a file, at returns the element of the file content at the index specified by
the right operand
• if it is a graph and if the right operand is a node, at returns the in and out
edges corresponding to that node
Examples:
string var0 <- 'abcdef' at 0; // var0 equals 'a'
v 1.8.0 1012
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
contains_all, contains_any,
at_distance
Possible uses:
Result:
A list of agents or geometries among the left-operand list that are located at a distance
<= the right operand from the caller agent (in its topology)
Examples:
list<geometry> var0 <- [ag1, ag2, ag3] at_distance 20; // var0 equals
the agents of the list located at a distance <= 20 from the caller
agent (in the same order).
See also:
at_location
Possible uses:
v 1.8.0 1013
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
A geometry resulting from the tran of a translation to the right-hand operand point
of the left-hand operand (geometry, agent, point)
Examples:
geometry var0 <- self at_location {10, 20}; // var0 equals the geometry
resulting from a translation to the location {10, 20} of the left-
hand geometry (or agent).
float var1 <- (box({10, 10 , 5}) at_location point(50,50,0)).location.
x; // var1 equals 50.0
atan
Possible uses:
Result:
Returns the value (in the interval [-90,90], in decimal degrees) of the arctan of the
operand (which can be any real number).
Examples:
float var0 <- atan (1); // var0 equals 45.0
See also:
v 1.8.0 1014
GAMA v1.8.0 documentation Chapter 101. Operators
atan2
Possible uses:
Result:
Comment:
The function atan2 is the arctangent function with two arguments. The purpose
of using two arguments instead of one is to gather information on the signs of the
inputs in order to return the appropriate quadrant of the computed angle, which is
not possible for the single-argument arctangent function.
Examples:
float var0 <- atan2 (0,0); // var0 equals 0.0
See also:
attributes
Possible uses:
v 1.8.0 1015
GAMA v1.8.0 documentation Chapter 101. Operators
auto_correlation
Possible uses:
Result:
Examples:
float var0 <- auto_correlation([1,0,1,0,1,0],2); // var0 equals 1
float var1 <- auto_correlation([1,0,1,0,1,0],1); // var1 equals -1
BDIPlan
Possible uses:
Result:
before
Possible uses:
v 1.8.0 1016
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Returns true if the current_date of the model is strictly before the date passed in
argument. Synonym of ‘current_date < argument’
Examples:
reflex when: before(starting_date) {} // this reflex will never be
run
beta
Possible uses:
Result:
Comment:
Checked on R. beta(4,5)
Examples:
float var0 <- beta(4,5) with_precision(4); // var0 equals 0.0036
v 1.8.0 1017
GAMA v1.8.0 documentation Chapter 101. Operators
beta_index
Possible uses:
Result:
returns the beta index of the graph (Measures the level of connectivity in a graph
and is expressed by the relationship between the number of links (e) over the number
of nodes (v) : beta = e/v.
Examples:
graph graphEpidemio <- graph([]);
float var1 <- beta_index(graphEpidemio); // var1 equals the beta index
of the graph
See also:
between
Possible uses:
v 1.8.0 1018
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
returns true the first integer operand is bigger than the second integer operand and
smaller than the third integer operand
returns true if the first float operand is bigger than the second float operand and
smaller than the third float operand
Special cases:
• returns true if the first operand is between the two dates passed in arguments
(both exclusive). Can be combined with ‘every’ to express a frequency between
two dates
bool var0 <- (date('2016-01-01') between(date('2000-01-01'), date
('2020-02-02'))); // var0 equals true
// will return true every new day between these two dates, taking the
first one as the starting point
every(#day between(date('2000-01-01'), date('2020-02-02')))
• returns true if the first operand is between the two dates passed in arguments
(both exclusive). The version with 2 arguments compares the current_date
with the 2 others
bool var3 <- (date('2016-01-01') between(date('2000-01-01'), date
('2020-02-02'))); // var3 equals true
// // will return true if the current_date of the model is in_between
the 2
between(date('2000-01-01'), date('2020-02-02'))
Examples:
bool var6 <- between(5, 1, 10); // var6 equals true
bool var7 <- between(5.0, 1.0, 10.0); // var7 equals true
v 1.8.0 1019
GAMA v1.8.0 documentation Chapter 101. Operators
betweenness_centrality
Possible uses:
Result:
returns a map containing for each vertex (key), its betweenness centrality (value):
number of shortest paths passing through each vertex
Examples:
graph graphEpidemio <- graph([]);
map var1 <- betweenness_centrality(graphEpidemio); // var1 equals the
betweenness centrality index of the graph
biggest_cliques_of
Possible uses:
Result:
returns the biggest cliques of a graph using the Bron-Kerbosch clique detection
algorithm
Examples:
graph my_graph <- graph([]);
list<list> var1 <- biggest_cliques_of (my_graph); // var1 equals the
list of the biggest cliques as list
v 1.8.0 1020
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
maximal_cliques_of,
binomial
Possible uses:
Result:
Comment:
Examples:
int var0 <- binomial(15,0.6); // var0 equals a random positive integer
See also:
poisson, gauss,
v 1.8.0 1021
GAMA v1.8.0 documentation Chapter 101. Operators
binomial_coeff
Possible uses:
Result:
Returns n choose k as a double. Note the integerization of the double return value.
Examples:
float var0 <- binomial_coeff(10,2); // var0 equals 45
binomial_complemented
Possible uses:
Result:
Returns the sum of the terms k+1 through n of the Binomial probability density,
where n is the number of trials and P is the probability of success in the range 0 to 1.
Examples:
float var0 <- binomial_complemented(10,5,0.5) with_precision(2); //
var0 equals 0.38
v 1.8.0 1022
GAMA v1.8.0 documentation Chapter 101. Operators
binomial_sum
Possible uses:
Result:
Returns the sum of the terms 0 through k of the Binomial probability density, where
n is the number of trials and p is the probability of success in the range 0 to 1.
Examples:
float var0 <- binomial_sum(5,10,0.5) with_precision(2); // var0 equals
0.62
blend
Possible uses:
Result:
Blend two colors with an optional ratio (c1 * r + c2 * (1 - r)) between 0 and 1
Special cases:
v 1.8.0 1023
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
rgb var3 <- blend(#red, #blue, 0.3); // var3 equals to a color between
the purple and the blue
See also:
rgb, hsb,
bool
Possible uses:
Result:
box
Possible uses:
Result:
v 1.8.0 1024
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
the center of the box is by default the location of the current agent in which has been
called this operator.the center of the box is by default the location of the current
agent in which has been called this operator.
Special cases:
Examples:
geometry var0 <- box(10, 5 , 5); // var0 equals a geometry as a
rectangle with width = 10, height = 5 depth= 5.
geometry var1 <- box({10, 5 , 5}); // var1 equals a geometry as a
rectangle with width = 10, height = 5 depth= 5.
float var2 <- (box({10, 10 , 5}) at_location point(50,50,0)).location.
y; // var2 equals 50.0
See also:
around, circle, sphere, cone, line, link, norm, point, polygon, polyline, square, cube,
triangle,
brewer_colors
Possible uses:
v 1.8.0 1025
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Build a list of colors of a given type (see website http://colorbrewer2.org/). The list
of palettes can be obtained by calling brewer_palettes Build a list of colors of a given
type (see website http://colorbrewer2.org/) with a given number of classes
Examples:
list<rgb> var0 <- list<rgb> colors <- brewer_colors("OrRd");; // var0
equals a list of 6 blue colors
list<rgb> var1 <- list<rgb> colors <- brewer_colors("Pastel1", 5);; //
var1 equals a list of 5 sequential colors in the palette named '
Pastel1'. The list of palettes can be obtained by calling
brewer_palettes
See also:
brewer_palettes,
brewer_palettes
Possible uses:
Result:
returns the list a palette with a given min number of classes) returns the list a palette
with a given min number of classes and max number of classes)
v 1.8.0 1026
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
list<string> var0 <- list<string> palettes <- brewer_palettes(3);; //
var0 equals a list of palettes that are composed of a min of 3
colors
list<string> var1 <- list<string> palettes <- brewer_palettes(5,10);;
// var1 equals a list of palettes that are composed of a min of 5
colors and a max of 10 colors
See also:
brewer_colors,
buffer
Same signification as +
build
Possible uses:
Result:
returns the regression build from the matrix data (a row = an instance, the last
value of each line is the y value) while using the given ordinary least squares method.
Usage: build(data)
v 1.8.0 1027
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
build(matrix([[1.0,2.0,3.0,4.0],[2.0,3.0,4.0,2.0]]))
ceil
Possible uses:
Result:
Maps the operand to the smallest following integer, i.e. the smallest integer not less
than x.
Examples:
float var0 <- ceil(3); // var0 equals 3.0
float var1 <- ceil(3.5); // var1 equals 4.0
float var2 <- ceil(-4.7); // var2 equals -4.0
See also:
floor, round,
centroid
Possible uses:
v 1.8.0 1028
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Centroid (weighted sum of the centroids of a decomposition of the area into triangles)
of the operand-geometry. Can be different to the location of the geometry
Examples:
point var0 <- centroid(world); // var0 equals the centroid of the
square, for example : {50.0,50.0}.
See also:
char
Possible uses:
Special cases:
chi_square
Possible uses:
v 1.8.0 1029
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Returns the area under the left hand tail (from 0 to x) of the Chi square probability
density function with df degrees of freedom.
Examples:
float var0 <- chi_square(20.0,10) with_precision(3); // var0 equals
0.971
chi_square_complemented
Possible uses:
Result:
Returns the area under the right hand tail (from x to infinity) of the Chi square
probability density function with df degrees of freedom.
Examples:
float var0 <- chi_square_complemented(2,10) with_precision(3); // var0
equals 0.996
v 1.8.0 1030
GAMA v1.8.0 documentation Chapter 101. Operators
circle
Possible uses:
Result:
A circle geometry which radius is equal to the first operand, and the center has the
location equal to the second operand. A circle geometry which radius is equal to the
operand.
Comment:
the center of the circle is by default the location of the current agent in which has
been called this operator.
Special cases:
Examples:
geometry var0 <- circle(10,{80,30}); // var0 equals a geometry as a
circle of radius 10, the center will be in the location {80,30}.
geometry var1 <- circle(10); // var1 equals a geometry as a circle of
radius 10.
See also:
around, cone, line, link, norm, point, polygon, polyline, rectangle, square, triangle,
v 1.8.0 1031
GAMA v1.8.0 documentation Chapter 101. Operators
clean
Possible uses:
Result:
Comment:
Examples:
geometry var0 <- clean(self); // var0 equals returns the geometry
resulting from the cleaning of the geometry of the agent applying
the operator.
clean_network
Possible uses:
Result:
A list of polylines corresponding to the cleaning of the first operand (list of polyline
geometry or agents), considering the tolerance distance given by the second operand;
the third operator is used to define if the operator should as well split the lines at
their intersections(true to split the lines); the last operandis used to specify if the
operator should as well keep only the main connected component of the network.
Usage: clean_network(lines:list of geometries or agents, tolerance: float, split_lines:
bool, keepMainConnectedComponent: bool)
v 1.8.0 1032
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
Examples:
list<geometry> var0 <- clean_network(my_road_shapefile.contents, 1.0,
true, false); // var0 equals returns the list of polulines resulting
from the cleaning of the geometry of the agent applying the
operator with a tolerance of 1m, and splitting the lines at their
intersections.
closest_points_with
Possible uses:
Result:
Examples:
list<point> var0 <- geom1 closest_points_with(geom2); // var0 equals [
pt1, pt2] with pt1 the closest point of geom1 to geom2 and pt1 the
closest point of geom2 to geom1
See also:
v 1.8.0 1033
GAMA v1.8.0 documentation Chapter 101. Operators
closest_to
Possible uses:
Result:
The N agents or geometries among the left-operand list of agents, species or meta-
population (addition of species), that are the closest to the operand (casted as a
geometry). An agent or a geometry among the left-operand list of agents, species
or meta-population (addition of species), the closest to the operand (casted as a
geometry).
Comment:
the distance is computed in the topology of the calling agent (the agent in which this
operator is used), with the distance algorithm specific to the topology.the distance is
computed in the topology of the calling agent (the agent in which this operator is
used), with the distance algorithm specific to the topology.
Examples:
list<geometry> var0 <- [ag1, ag2, ag3] closest_to(self, 2); // var0
equals return the 2 closest agents among ag1, ag2 and ag3 to the
agent applying the operator.
(species1 + species2) closest_to (self, 5)
geometry var2 <- [ag1, ag2, ag3] closest_to(self); // var2 equals
return the closest agent among ag1, ag2 and ag3 to the agent
applying the operator.
(species1 + species2) closest_to self
v 1.8.0 1034
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
collect
Possible uses:
Result:
returns a new list, in which each element is the evaluation of the right-hand operand.
Comment:
collect is similar to accumulate except that accumulate always produces flat lists
if the right-hand operand returns a list.In addition, collect can be applied to any
container.
Special cases:
Examples:
list var0 <- [1,2,4] collect (each *2); // var0 equals [2,4,8]
list var1 <- [1,2,4] collect ([2,4]); // var1 equals
[[2,4],[2,4],[2,4]]
list var2 <- [1::2, 3::4, 5::6] collect (each + 2); // var2 equals
[4,6,8]
list var3 <- (list(node) collect (node(each).location.x * 2); // var3
equals the list of nodes with their x multiplied by 2
v 1.8.0 1035
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
accumulate,
column_at
Possible uses:
Result:
Examples:
list<unknown> var0 <- matrix([["el11","el12","el13"],["el21","el22","
el23"],["el31","el32","el33"]]) column_at 2; // var0 equals ["el31
","el32","el33"]
See also:
row_at, rows_list,
columns_list
Possible uses:
v 1.8.0 1036
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
returns a list of the columns of the matrix, with each column as a list of elements
Examples:
list<list<unknown>> var0 <- columns_list(matrix([["el11","el12","el13"
],["el21","el22","el23"],["el31","el32","el33"]])); // var0 equals
[["el11","el12","el13"],["el21","el22","el23"],["el31","el32","el33
"]]
See also:
rows_list,
command
Possible uses:
Result:
command allows GAMA to issue a system command using the system terminal
or shell and to receive a string containing the outcome of the command or script
executed. By default, commands are blocking the agent calling them, unless the
sequence ’ &’ is used at the end. In this case, the result of the operator is an empty
string. The basic form with only one string in argument uses the directory of the
model and does not set any environment variables. Two other forms (with a directory
and a map<string, string> of environment variables) are available. command allows
GAMA to issue a system command using the system terminal or shell and to receive
v 1.8.0 1037
GAMA v1.8.0 documentation Chapter 101. Operators
cone
Possible uses:
Result:
A cone geometry which min and max angles are given by the operands. A cone
geometry which min and max angles are given by the operands.
Comment:
the center of the cone is by default the location of the current agent in which has been
called this operator.the center of the cone is by default the location of the current
agent in which has been called this operator.
Special cases:
v 1.8.0 1038
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
geometry var0 <- cone({0, 45}); // var0 equals a geometry as a cone
with min angle is 0 and max angle is 45.
geometry var1 <- cone(0, 45); // var1 equals a geometry as a cone with
min angle is 0 and max angle is 45.
See also:
around, circle, line, link, norm, point, polygon, polyline, rectangle, square, triangle,
cone3D
Possible uses:
Result:
A cone geometry which base radius size is equal to the first operand, and which the
height is equal to the second operand.
Comment:
the center of the cone is by default the location of the current agent in which has
been called this operator.
Special cases:
v 1.8.0 1039
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
geometry var0 <- cone3D(10.0,5.0); // var0 equals a geometry as a cone
with a base circle of radius 10 and a height of 5.
See also:
around, cone, line, link, norm, point, polygon, polyline, rectangle, square, triangle,
connected_components_of
Possible uses:
Result:
returns the connected components of a graph, i.e. the list of all edges (if the boolean
is true) or vertices (if the boolean is false) that are in the connected components.
returns the connected components of a graph, i.e. the list of all vertices that are in
the maximally connected component together with the specified vertex.
Examples:
graph my_graph2 <- graph([]);
list<list> var1 <- connected_components_of (my_graph2, true); // var1
equals the list of all the components as list
graph my_graph <- graph([]);
list<list> var3 <- connected_components_of (my_graph); // var3 equals
the list of all the components as list
v 1.8.0 1040
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
connectivity_index
Possible uses:
Result:
returns a simple connectivity index. This number is estimated through the number
of nodes (v) and of sub-graphs (p) : IC = (v - p) /(v - 1).
Examples:
graph graphEpidemio <- graph([]);
float var1 <- connectivity_index(graphEpidemio); // var1 equals the
connectivity index of the graph
See also:
container
Possible uses:
v 1.8.0 1041
GAMA v1.8.0 documentation Chapter 101. Operators
contains
Possible uses:
Result:
true, if the container contains the right operand, false otherwise. ‘contains’ can also
be written ‘contains_value’. On graphs, it is equivalent to calling ‘contains_edge’
Comment:
Special cases:
• if both operands are strings, returns true if the right-hand operand contains
the right-hand pattern;
• if it is a file, contains returns true it the operand is contained in the file content
v 1.8.0 1042
GAMA v1.8.0 documentation Chapter 101. Operators
• if it is a list or a matrix, contains returns true if the list or matrix contains the
right operand
bool var1 <- [1, 2, 3] contains 2; // var1 equals true
bool var2 <- [{1,2}, {3,4}, {5,6}] contains {3,4}; // var2 equals true
Examples:
bool var0 <- 'abcded' contains 'bc'; // var0 equals true
See also:
contains_all
Possible uses:
Result:
true if the left operand contains all the elements of the right operand, false otherwise
Comment:
v 1.8.0 1043
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
• if the left-operand is a string, test whether the string contains all the element
of the list;
bool var4 <- "abcabcabc" contains_all ["ca","xy"]; // var4 equals false
Examples:
bool var0 <- [1,2,3,4,5,6] contains_all [2,4]; // var0 equals true
bool var1 <- [1,2,3,4,5,6] contains_all [2,8]; // var1 equals false
bool var2 <- [1::2, 3::4, 5::6] contains_all [1,3]; // var2 equals
false
bool var3 <- [1::2, 3::4, 5::6] contains_all [2,4]; // var3 equals true
See also:
contains, contains_any,
contains_any
Possible uses:
Result:
true if the left operand contains one of the elements of the right operand, false
otherwise
v 1.8.0 1044
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
Special cases:
Examples:
bool var0 <- [1,2,3,4,5,6] contains_any [2,4]; // var0 equals true
bool var1 <- [1,2,3,4,5,6] contains_any [2,8]; // var1 equals true
bool var2 <- [1::2, 3::4, 5::6] contains_any [1,3]; // var2 equals
false
bool var3 <- [1::2, 3::4, 5::6] contains_any [2,4]; // var3 equals true
bool var4 <- "abcabcabc" contains_any ["ca","xy"]; // var4 equals true
See also:
contains, contains_all,
contains_edge
Possible uses:
Result:
returns true if the graph(left-hand operand) contains the given edge (righ-hand
operand), false otherwise
v 1.8.0 1045
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
• if the right-hand operand is a pair, returns true if it exists an edge between the
two elements of the pair in the graph
bool var0 <- graphEpidemio contains_edge (node(0)::node(3)); // var0
equals true
Examples:
graph graphFromMap <- as_edge_graph([{1,5}::{12,45},{12,45}::{34,56}])
;
bool var2 <- graphFromMap contains_edge link({1,5},{12,45}); // var2
equals true
See also:
contains_vertex,
contains_key
Possible uses:
Result:
true, if the left-hand operand – the container – contains a key – or an index – equal
to the right-hand operand, false otherwise. On graphs, ‘contains_key’ is equivalent
to calling ‘contains_vertex’
v 1.8.0 1046
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
Special cases:
See also:
contains_node
Same signification as contains_key
v 1.8.0 1047
GAMA v1.8.0 documentation Chapter 101. Operators
contains_value
contains_vertex
Possible uses:
Result:
returns true if the graph(left-hand operand) contains the given vertex (righ-hand
operand), false otherwise
Special cases:
Examples:
graph graphFromMap<- as_edge_graph([{1,5}::{12,45},{12,45}::{34,56}]);
bool var1 <- graphFromMap contains_vertex {1,5}; // var1 equals true
See also:
contains_edge,
v 1.8.0 1048
GAMA v1.8.0 documentation Chapter 101. Operators
conversation
Possible uses:
convex_hull
Possible uses:
Result:
Examples:
geometry var0 <- convex_hull(self); // var0 equals the convex hull of
the geometry of the agent applying the operator
copy
Possible uses:
Result:
v 1.8.0 1049
GAMA v1.8.0 documentation Chapter 101. Operators
copy_between
Possible uses:
Result:
Returns a copy of the first operand between the indexes determined by the second
(inclusive) and third operands (exclusive)
Special cases:
• If the first operand is empty, returns an empty object of the same type
• If the second operand is greater than or equal to the third operand, return an
empty object of the same type
Examples:
list var0 <- copy_between ([4, 1, 6, 9 ,7], 1, 3); // var0 equals [1,
6]
string var1 <- copy_between("abcabcabc", 2,6); // var1 equals "cabc"
copy_to_clipboard
Possible uses:
v 1.8.0 1050
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Tries to copy the text in parameter to the clipboard and returns whether it has been
correctly copied or not (for instance it might be impossible in a headless environment)
Examples:
bool copied <- copy_to_clipboard('text to copy');
corR
Possible uses:
Result:
returns the Pearson correlation coefficient of two given vectors (right-hand operands)
in given variable (left-hand operand).
Special cases:
Examples:
list X <- [1, 2, 3];
list Y <- [1, 2, 4];
unknown var2 <- corR(X, Y); // var2 equals 0.981980506061966
v 1.8.0 1051
GAMA v1.8.0 documentation Chapter 101. Operators
correlation
Possible uses:
Result:
Returns the correlation of two data sequences (having the same size)
Examples:
float var0 <- correlation([1,2,1,3,1,2], [1,2,1,3,1,2]) with_precision
(4); // var0 equals 1.2
float var1 <- correlation([13,2,1,4,1,2], [1,2,1,3,1,2]) with_precision
(2); // var1 equals -0.21
cos
Possible uses:
Result:
Returns the value (in [-1,1]) of the cosinus of the operand (in decimal degrees). The
argument is casted to an int before being evaluated.
Special cases:
v 1.8.0 1052
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
float var0 <- cos (0); // var0 equals 1.0
float var1 <- cos(360); // var1 equals 1.0
float var2 <- cos(-720); // var2 equals 1.0
float var3 <- cos (0.0); // var3 equals 1.0
float var4 <- cos(360.0); // var4 equals 1.0
float var5 <- cos(-720.0); // var5 equals 1.0
See also:
sin, tan,
cos_rad
Possible uses:
Result:
Returns the value (in [-1,1]) of the cosinus of the operand (in radians).
Special cases:
Examples:
float var0 <- cos_rad(0.0); // var0 equals 1.0
float var1 <- cos_rad(#pi); // var1 equals -1.0
v 1.8.0 1053
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
sin, tan,
count
Possible uses:
Result:
returns an int, equal to the number of elements of the left-hand operand that make
the right-hand operand evaluate to true.
Comment:
in the right-hand operand, the keyword each can be used to represent, in turn, each
of the elements.
Special cases:
Examples:
int var0 <- [1,2,3,4,5,6,7,8] count (each > 3); // var0 equals 5
// Number of nodes of graph g2 without any out edge
graph g2 <- graph([]);
int var3 <- g2 count (length(g2 out_edges_of each) = 0 ) ; // var3
equals the total number of out edges
// Number of agents node with x > 32
int n <- (list(node) count (round(node(each).location.x) > 32);
int var6 <- [1::2, 3::4, 5::6] count (each > 4); // var6 equals 1
v 1.8.0 1054
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
group_by,
covariance
Possible uses:
Result:
Examples:
float var0 <- covariance([13,2,1,4,1,2], [1,2,1,3,1,2]) with_precision
(2); // var0 equals -0.67
covers
Possible uses:
Result:
A boolean, equal to true if the left-geometry (or agent/point) covers the right-geometry
(or agent/point).
v 1.8.0 1055
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
Examples:
bool var0 <- square(5) covers square(2); // var0 equals true
See also:
create_map
Possible uses:
Result:
returns a new map using the left operand as keys for the right operand
Special cases:
• if both operands have different lengths, choose the minimum length between
the two operandsfor the size of the map
v 1.8.0 1056
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
map<int,string> var0 <- create_map([0,1,2],['a','b','c']); // var0
equals [0::'a',1::'b',2::'c']
map<int,float> var1 <- create_map([0,1],[0.1,0.2,0.3]); // var1 equals
[0::0.1,1::0.2]
map<string,float> var2 <- create_map(['a','b','c','d'],[1.0,2.0,3.0]);
// var2 equals ['a'::1.0,'b'::2.0,'c'::3.0]
cross
Possible uses:
Result:
A cross, which radius is equal to the first operand and the width of the lines for the
second A cross, which radius is equal to the first operand
Examples:
geometry var0 <- cross(10,2); // var0 equals a geometry as a cross of
radius 10, and with a width of 2 for the lines
geometry var1 <- cross(10); // var1 equals a geometry as a cross of
radius 10
See also:
around, cone, line, link, norm, point, polygon, polyline, super_ellipse, rectangle,
square, circle, ellipse, triangle,
v 1.8.0 1057
GAMA v1.8.0 documentation Chapter 101. Operators
crosses
Possible uses:
Result:
A boolean, equal to true if the left-geometry (or agent/point) crosses the right-
geometry (or agent/point).
Special cases:
Examples:
bool var0 <- polyline([{10,10},{20,20}]) crosses polyline
([{10,20},{20,10}]); // var0 equals true
bool var1 <- polyline([{10,10},{20,20}]) crosses {15,15}; // var1
equals true
bool var2 <- polyline([{0,0},{25,25}]) crosses polygon
([{10,10},{10,20},{20,20},{20,10}]); // var2 equals true
See also:
v 1.8.0 1058
GAMA v1.8.0 documentation Chapter 101. Operators
crs
Possible uses:
Result:
Examples:
string var0 <- crs(my_shapefile); // var0 equals the crs of the
shapefile
CRS_transform
Possible uses:
Special cases:
v 1.8.0 1059
GAMA v1.8.0 documentation Chapter 101. Operators
csv_file
Possible uses:
Result:
Constructs a file of type csv. Allowed extensions are limited to csv, tsv
Special cases:
• csv_file(string): This file constructor allows to read a CSV file with the default
separator (coma), no header, and no assumption on the type of data. No text
qualifier will be used
v 1.8.0 1060
GAMA v1.8.0 documentation Chapter 101. Operators
csv_file f <- csv_file("file.csv");
• csv_file(string,bool): This file constructor allows to read a CSV file with the
default separator (coma), with specifying if the model has a header or not
(boolean), and no assumption on the type of data. No text qualifier will be used
csv_file f <- csv_file("file.csv",true);
v 1.8.0 1061
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
is_csv,
cube
Possible uses:
v 1.8.0 1062
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Comment:
the center of the cube is by default the location of the current agent in which has
been called this operator.
Special cases:
Examples:
geometry var0 <- cube(10); // var0 equals a geometry as a square of
side size 10.
See also:
around, circle, cone, line, link, norm, point, polygon, polyline, rectangle, triangle,
curve
Possible uses:
v 1.8.0 1063
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
A cubic Bezier curve geometry built from the two given points with the given coefficient
for the radius and composed of the given number of points, considering the given
rotation angle (90 = along the z axis). A cubic Bezier curve geometry built from the
four given points composed of 10 points. A cubic Bezier curve geometry built from
the four given points composed of a given number of points. A cubic Bezier curve
geometry built from the two given points with the given coefficient for the radius
and composed of the given number of points - the boolean is used to specified if it is
the right side. A cubic Bezier curve geometry built from the two given points with
the given coefficient for the radius and composed of the given number of points -
the boolean is used to specified if it is the right side and the last value to indicate
where is the inflection point (between 0.0 and 1.0 - default 0.5). A quadratic Bezier
curve geometry built from the three given points composed of a given numnber of
points. A cubic Bezier curve geometry built from the two given points with the given
coefficient for the radius and composed of the given number of points, considering
the given inflection point (between 0.0 and 1.0 - default 0.5), and the given rotation
angle (90 = along the z axis). A cubic Bezier curve geometry built from the two
given points with the given coefficient for the radius and composed of 10 points. A
cubic Bezier curve geometry built from the two given points with the given coefficient
for the radius considering the given rotation angle (90 = along the z axis). A cubic
Bezier curve geometry built from the two given points with the given coefficient for
the radius and composed of 10 points - the last boolean is used to specified if it is
the right side. A quadratic Bezier curve geometry built from the three given points
composed of 10 points.
Special cases:
v 1.8.0 1064
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
geometry var0 <- curve({0,0},{10,10}, 0.5, 100, 90); // var0 equals a
cubic Bezier curve geometry composed of 100 points from p0 to p1 at
the right side.
geometry var1 <- curve({0,0}, {0,10}, {10,10}); // var1 equals a cubic
Bezier curve geometry composed of 10 points from p0 to p3.
geometry var2 <- curve({0,0}, {0,10}, {10,10}); // var2 equals a cubic
Bezier curve geometry composed of 10 points from p0 to p3.
geometry var3 <- curve({0,0},{10,10}, 0.5, false, 100); // var3 equals
a cubic Bezier curve geometry composed of 100 points from p0 to p1
at the right side.
geometry var4 <- curve({0,0},{10,10}, 0.5, false, 100, 0.8); // var4
equals a cubic Bezier curve geometry composed of 100 points from p0
to p1 at the right side.
geometry var5 <- curve({0,0}, {0,10}, {10,10}, 20); // var5 equals a
quadratic Bezier curve geometry composed of 20 points from p0 to p2.
geometry var6 <- curve({0,0},{10,10}, 0.5, 100, 0.8, 90); // var6
equals a cubic Bezier curve geometry composed of 100 points from p0
v 1.8.0 1065
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
around, circle, cone, link, norm, point, polygone, rectangle, square, triangle, line,
cylinder
Possible uses:
Result:
Comment:
the center of the cylinder is by default the location of the current agent in which has
been called this operator.
Special cases:
v 1.8.0 1066
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
geometry var0 <- cylinder(10,10); // var0 equals a geometry as a circle
of radius 10.
See also:
around, cone, line, link, norm, point, polygon, polyline, rectangle, square, triangle,
date
Possible uses:
Result:
converts a string to a date following a custom pattern and a specific locale (e.g. ‘fr’,
‘en’. . . ). The pattern can use “%Y %M %N %D %E %h %m %s %z” for parsing years,
months, name of month, days, name of days, hours, minutes, seconds and the time-
zone. A null or empty pattern will parse the date using one of the ISO date & time
formats (similar to date(‘. . . ’) in that case). The pattern can also follow the pattern
definition found here, which gives much more control over what will be parsed: http-
s://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#patterns.
Different patterns are available by default as constant: #iso_local, #iso_simple,
#iso_offset, #iso_zoned and #custom, which can be changed in the preferences
converts a string to a date following a custom pattern. The pattern can use
“%Y %M %N %D %E %h %m %s %z” for outputting years, months, name of
month, days, name of days, hours, minutes, seconds and the time-zone. A null
or empty pattern will parse the date using one of the ISO date & time formats
(similar to date(‘. . . ’) in that case). The pattern can also follow the pattern
v 1.8.0 1067
GAMA v1.8.0 documentation Chapter 101. Operators
definition found here, which gives much more control over what will be parsed: http-
s://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#patterns.
Different patterns are available by default as constant: #iso_local, #iso_simple,
#iso_offset, #iso_zoned and #custom, which can be changed in the preferences
Examples:
date d <- date("1999-january-30", 'yyyy-MMMM-dd', 'en');
date den <- date("1999-12-30", 'yyyy-MM-dd');
dbscan
Possible uses:
Result:
returns the list of clusters (list of instance indices) computed with the dbscan (density-
based spatial clustering of applications with noise) algorithm from the first operand
data according to the maximum radius of the neighborhood to be considered (eps)
and the minimum number of points needed for a cluster (minPts). Usage: db-
scan(data,eps,minPoints)
Special cases:
Examples:
list<list> var0 <- dbscan ([[2,4,5], [3,8,2], [1,1,3], [4,3,4]],10,2);
// var0 equals [[0,1,2,3]]
v 1.8.0 1068
GAMA v1.8.0 documentation Chapter 101. Operators
dead
Possible uses:
Result:
Examples:
bool var0 <- dead(agent_A); // var0 equals true or false
degree_of
Possible uses:
Result:
returns the degree (in+out) of a vertex (right-hand operand) in the graph given as
left-hand operand.
Examples:
int var1 <- graphFromMap degree_of (node(3)); // var1 equals 3
v 1.8.0 1069
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
in_degree_of, out_degree_of,
dem
Possible uses:
Result:
Examples:
geometry var0 <- dem(dem); // var0 equals returns a geometry as a
rectangle of width and height equal to the texture.
geometry var1 <- dem(dem,texture,z_factor); // var1 equals a geometry
as a rectangle of width and height equal to the texture.
geometry var2 <- dem(dem,z_factor); // var2 equals a geometry as a
rectangle of weight and height equal to the texture.
geometry var3 <- dem(dem,texture); // var3 equals a geometry as a
rectangle of weight and height equal to the texture.
v 1.8.0 1070
GAMA v1.8.0 documentation Chapter 101. Operators
det
Same signification as determinant
determinant
Possible uses:
Result:
Examples:
float var0 <- determinant(matrix([[1,2],[3,4]])); // var0 equals -2
diff
Possible uses:
Result:
v 1.8.0 1071
GAMA v1.8.0 documentation Chapter 101. Operators
diff2
Possible uses:
Result:
directed
Possible uses:
Result:
Comment:
WARNING / side effect: this operator modifies the operand and does not create a
new graph.
See also:
undirected,
v 1.8.0 1072
GAMA v1.8.0 documentation Chapter 101. Operators
direction_between
Possible uses:
Result:
A direction (in degree) between a list of two geometries (geometries, agents, points)
considering a topology.
Examples:
float var0 <- my_topology direction_between [ag1, ag2]; // var0 equals
the direction between ag1 and ag2 considering the topology
my_topology
See also:
direction_to
Same signification as towards
disjoint_from
Possible uses:
v 1.8.0 1073
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
A boolean, equal to true if the left-geometry (or agent/point) is disjoints from the
right-geometry (or agent/point).
Special cases:
• if one operand is a point, returns false if the point is included in the geometry.
Examples:
bool var0 <- polyline([{10,10},{20,20}]) disjoint_from polyline
([{15,15},{25,25}]); // var0 equals false
bool var1 <- polygon([{10,10},{10,20},{20,20},{20,10}]) disjoint_from
polygon([{15,15},{15,25},{25,25},{25,15}]); // var1 equals false
bool var2 <- polygon([{10,10},{10,20},{20,20},{20,10}]) disjoint_from
{15,15}; // var2 equals false
bool var3 <- polygon([{10,10},{10,20},{20,20},{20,10}]) disjoint_from
{25,25}; // var3 equals true
bool var4 <- polygon([{10,10},{10,20},{20,20},{20,10}]) disjoint_from
polygon([{35,35},{35,45},{45,45},{45,35}]); // var4 equals true
See also:
distance_between
Possible uses:
v 1.8.0 1074
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Examples:
float var0 <- my_topology distance_between [ag1, ag2, ag3]; // var0
equals the distance between ag1, ag2 and ag3 considering the
topology my_topology
See also:
distance_to
Possible uses:
Result:
Examples:
float var0 <- ag1 distance_to ag2; // var0 equals the distance between
ag1 and ag2 considering the topology of the agent applying the
operator
v 1.8.0 1075
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
distinct
Possible uses:
Result:
produces a set from the elements of the operand (i.e. a list without duplicated
elements)
Special cases:
v 1.8.0 1076
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
list var0 <- remove_duplicates([3,2,5,1,2,3,5,5,5]); // var0 equals
[3,2,5,1]
distribution_of
Possible uses:
Result:
Discretize a list of values into n bins (computes the bins from a numerical variable
into n (default 10) bins. Returns a distribution map with the values (values key), the
interval legends (legend key), the distribution parameters (params keys, for cumulative
charts). Parameters can be (list), (list, nbbins) or (list,nbbins,valmin,valmax)
Examples:
map var0 <- distribution_of([1,1,2,12.5]); // var0 equals map(['values
'::[2,1,0,0,0,0,1,0,0,0],'legend
'::['[0.0:2.0]','[2.0:4.0]','[4.0:6.0]','[6.0:8.0]','[8.0:10.0]','[10.0:12.0]','[12.0:1
parlist'::[1,0]])
map var1 <- distribution_of([1,1,2,12.5],10); // var1 equals map(['
values'::[2,1,0,0,0,0,1,0,0,0],'legend
'::['[0.0:2.0]','[2.0:4.0]','[4.0:6.0]','[6.0:8.0]','[8.0:10.0]','[10.0:12.0]','[12.0:1
parlist'::[1,0]])
map var2 <- distribution_of([1,1,2,12.5]); // var2 equals map(['values
'::[2,1,0,0,0,0,1,0,0,0],'legend
'::['[0.0:2.0]','[2.0:4.0]','[4.0:6.0]','[6.0:8.0]','[8.0:10.0]','[10.0:12.0]','[12.0:1
parlist'::[1,0]])
v 1.8.0 1077
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
as_map,
distribution2d_of
Possible uses:
Result:
Discretize two lists of values into n bins (computes the bins from a numerical variable
into n (default 10) bins. Returns a distribution map with the values (values key), the
interval legends (legend key), the distribution parameters (params keys, for cumulative
charts). Parameters can be (list), (list, nbbins) or (list,nbbins,valmin,valmax)
Examples:
map var0 <- distribution2d_of([1,1,2,12.5],10); // var0 equals map(['
values'::[2,1,0,0,0,0,1,0,0,0],'legend
'::['[0.0:2.0]','[2.0:4.0]','[4.0:6.0]','[6.0:8.0]','[8.0:10.0]','[10.0:12.0]','[
parlist'::[1,0]])
map var1 <- distribution2d_of([1,1,2,12.5]); // var1 equals map(['
values'::[2,1,0,0,0,0,1,0,0,0],'legend
'::['[0.0:2.0]','[2.0:4.0]','[4.0:6.0]','[6.0:8.0]','[8.0:10.0]','[10.0:12.0]','[
parlist'::[1,0]])
map var2 <- distribution2d_of([1,1,2,12.5],10); // var2 equals map(['
values'::[2,1,0,0,0,0,1,0,0,0],'legend
'::['[0.0:2.0]','[2.0:4.0]','[4.0:6.0]','[6.0:8.0]','[8.0:10.0]','[10.0:12.0]','[
parlist'::[1,0]])
v 1.8.0 1078
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
as_map,
div
Possible uses:
Result:
Returns the truncation of the division of the left-hand operand by the right-hand
operand.
Special cases:
Examples:
v 1.8.0 1079
GAMA v1.8.0 documentation Chapter 101. Operators
int var0 <- 40 div 4.1; // var0 equals 9
int var1 <- 40.5 div 3; // var1 equals 13
int var2 <- 40.1 div 4.5; // var2 equals 8
int var3 <- 40 div 3; // var3 equals 13
See also:
mod,
dnorm
dtw
Possible uses:
Result:
returns the dynamic time warping between the two series of values (step pattern
used: symetric1) returns the dynamic time warping between the two series of values
(step pattern used: symetric1) with Sakoe-Chiba band (radius: the window width of
Sakoe-Chiba band)
v 1.8.0 1080
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
float var0 <- dtw([32.0,5.0,1.0,3.0],[1.0,10.0,5.0,1.0]); // var0
equals 38.0
float var1 <- dtw([10.0,5.0,1.0, 3.0],[1.0,10.0,5.0,1.0], 2); // var1
equals 11.0
durbin_watson
Possible uses:
Result:
Durbin-Watson computation
Examples:
float var0 <- durbin_watson([13,2,1,4,1,2]) with_precision(4); // var0
equals 0.7231
dxf_file
Possible uses:
v 1.8.0 1081
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Special cases:
• dxf_file(string,float): This file constructor allows to read a dxf (.dxf) file and
specify the unit (meter by default)
file f <- dxf_file("file.dxf",#m);
See also:
is_dxf,
edge
Possible uses:
v 1.8.0 1082
GAMA v1.8.0 documentation Chapter 101. Operators
edge_between
Possible uses:
Result:
Examples:
unknown var0 <- graphFromMap edge_between node1::node2; // var0 equals
edge1
See also:
out_edges_of, in_edges_of,
v 1.8.0 1083
GAMA v1.8.0 documentation Chapter 101. Operators
edge_betweenness
Possible uses:
Result:
returns a map containing for each edge (key), its betweenness centrality (value):
number of shortest paths passing through each edge
Examples:
graph graphEpidemio <- graph([]);
map var1 <- edge_betweenness(graphEpidemio); // var1 equals the edge
betweenness index of the graph
edges
Possible uses:
eigenvalues
Possible uses:
Result:
v 1.8.0 1084
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
list<float> var0 <- eigenvalues(matrix([[5,-3],[6,-4]])); // var0
equals [2.0000000000000004,-0.9999999999999998]
electre_DM
Possible uses:
Result:
The index of the best candidate according to a method based on the ELECTRE
methods. The principle of the ELECTRE methods is to compare the possible
candidates by pair. These methods analyses the possible outranking relation existing
between two candidates. An candidate outranks another if this one is at least as
good as the other one. The ELECTRE methods are based on two concepts: the
concordance and the discordance. The concordance characterizes the fact that,
for an outranking relation to be validated, a sufficient majority of criteria should
be in favor of this assertion. The discordance characterizes the fact that, for an
outranking relation to be validated, none of the criteria in the minority should oppose
too strongly this assertion. These two conditions must be true for validating the
outranking assertion. More information about the ELECTRE methods can be found
in [http://www.springerlink.com/content/g367r44322876223/ Figueira, J., Mousseau,
V., Roy, B.: ELECTRE Methods. In: Figueira, J., Greco, S., and Ehrgott, M., (Eds.),
Multiple Criteria Decision Analysis: State of the Art Surveys, Springer, New York,
133–162 (2005)]. The first operand is the list of candidates (a candidate is a list of
criterion values); the second operand the list of criterion: A criterion is a map that
contains fives elements: a name, a weight, a preference value (p), an indifference value
(q) and a veto value (v). The preference value represents the threshold from which
the difference between two criterion values allows to prefer one vector of values over
another. The indifference value represents the threshold from which the difference
between two criterion values is considered significant. The veto value represents
the threshold from which the difference between two criterion values disqualifies the
candidate that obtained the smaller value; the last operand is the fuzzy cut.
v 1.8.0 1085
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
Examples:
int var0 <- electre_DM([[1.0, 7.0],[4.0,2.0],[3.0, 3.0]], [["name"::"
utility", "weight" :: 2.0,"p"::0.5, "q"::0.0, "s"::1.0, "maximize"
:: true],["name"::"price", "weight" :: 1.0,"p"::0.5, "q"::0.0, "s"
::1.0, "maximize" :: false]],0.7); // var0 equals 0
See also:
ellipse
Possible uses:
Result:
An ellipse geometry which x-radius is equal to the first operand and y-radius is equal
to the second operand
Comment:
the center of the ellipse is by default the location of the current agent in which has
been called this operator.
v 1.8.0 1086
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
• returns a point if both operands are lower or equal to 0, a line if only one is.
Examples:
geometry var0 <- ellipse(10, 10); // var0 equals a geometry as an
ellipse of width 10 and height 10.
See also:
around, cone, line, link, norm, point, polygon, polyline, rectangle, square, circle,
squircle, triangle,
emotion
Possible uses:
Result:
empty
Possible uses:
v 1.8.0 1087
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Comment:
Special cases:
• if it is a file, empty returns true if the content of the file (that is also a
container) is empty, and false otherwise
• if it is a matrix of int, float or object, it will return true if all elements are
respectively 0, 0.0 or null, and false otherwise
• if it is a string, empty returns true if the string does not contain any character,
and false otherwise
bool var0 <- empty ('abced'); // var0 equals false
• if it is a list, empty returns true if there is no element in the list, and false
otherwise
v 1.8.0 1088
GAMA v1.8.0 documentation Chapter 101. Operators
bool var1 <- empty([]); // var1 equals true
enlarged_by
Same signification as +
envelope
Possible uses:
Result:
A 3D geometry that represents the box that surrounds the geometries or the surface
described by the arguments. More general than geometry(arguments).envelope, as it
allows to pass int, double, point, image files, shape files, asc files, or any list combining
these arguments, in which case the envelope will be correctly expanded. If an envelope
cannot be determined from the arguments, a default one of dimensions (0,100, 0, 100,
0, 100) is returned
Special cases:
Examples:
v 1.8.0 1089
GAMA v1.8.0 documentation Chapter 101. Operators
file road_shapefile <- file("../includes/roads.shp");
geometry shape <- envelope(road_shapefile);
// shape is the system variable of the environment
geometry var3 <- polygon([{0,0}, {20,0}, {10,10}, {10,0}]); // var3
equals create a polygon to get the envolpe
float var4 <- envelope(polygon([{0,0}, {20,0}, {10,10}, {10,0}])).area;
// var4 equals 200.0
eval_gaml
Possible uses:
Result:
Examples:
unknown var0 <- eval_gaml("2+3"); // var0 equals 5
eval_when
Possible uses:
Result:
v 1.8.0 1090
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
eval_when(plan1)
evaluate_sub_model
Possible uses:
Result:
Load a submodel
Comment:
loaded submodel
even
Possible uses:
Result:
v 1.8.0 1091
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
Examples:
bool var0 <- even (3); // var0 equals false
bool var1 <- even(-12); // var1 equals true
every
Possible uses:
Result:
true every operand * cycle, false otherwise expects a frequency (expressed in seconds
of simulated time) as argument. Will return true every time the current_date matches
with this frequency Retrieves elements from the first argument every step (second
argument) elements. Raises an error if the step is negative or equal to zero applies a
step to an interval of dates defined by ‘date1 to date2’
Comment:
the value of the every operator depends on the cycle. It can be used to do something
every x cycle.Used to do something at regular intervals of time. Can be used in
v 1.8.0 1092
GAMA v1.8.0 documentation Chapter 101. Operators
conjunction with ‘since’, ‘after’, ‘before’, ‘until’ or ‘between’, so that this computation
only takes place in the temporal segment defined by these operators. In all cases, the
starting_date of the model is used as a reference starting point
Examples:
if every(2#cycle) {write "the cycle number is even";}
else {write "the cycle number is odd";}
reflex when: every(2#days) since date('2000-01-01') { .. }
state a { transition to: b when: every(2#mn);} state b { transition to:
a when: every(30#s);} // This oscillatory behavior will use the
starting_date of the model as its starting point in time
(date('2000-01-01') to date('2010-01-01')) every (#month) // builds an
interval between these two dates which contains all the monthly
dates starting from the beginning of the interval
See also:
every_cycle
Same signification as every
evidence_theory_DM
Possible uses:
v 1.8.0 1093
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Special cases:
• if the operator is used with only 2 operands (the candidates and the criteria),
the last parameter (use simple method) is set to true
Examples:
int var0 <- evidence_theory_DM([[1.0, 7.0],[4.0,2.0],[3.0, 3.0]], [["
name"::"utility", "s1" :: 0.0,"s2"::1.0, "v1p"::0.0, "v2p"::1.0, "
v1c"::0.0, "v2c"::0.0, "maximize" :: true],["name"::"price", "s1"
:: 0.0,"s2"::1.0, "v1p"::0.0, "v2p"::1.0, "v1c"::0.0, "v2c"::0.0, "
maximize" :: true]], false); // var0 equals 0
int var1 <- evidence_theory_DM([[1.0, 7.0],[4.0,2.0],[3.0, 3.0]], [["
name"::"utility", "s1" :: 0.0,"s2"::1.0, "v1p"::0.0, "v2p"::1.0, "
v1c"::0.0, "v2c"::0.0, "maximize" :: true],["name"::"price", "s1"
:: 0.0,"s2"::1.0, "v1p"::0.0, "v2p"::1.0, "v1c"::0.0, "v2c"::0.0, "
maximize" :: true]]); // var1 equals 0
v 1.8.0 1094
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
weighted_means_DM, electre_DM,
exp
Possible uses:
Result:
Special cases:
Examples:
float var0 <- exp (0.0); // var0 equals 1.0
See also:
ln,
v 1.8.0 1095
GAMA v1.8.0 documentation Chapter 101. Operators
fact
Possible uses:
Result:
Special cases:
Examples:
float var0 <- fact(4); // var0 equals 24
farthest_point_to
Possible uses:
Result:
Examples:
point var0 <- geom farthest_point_to(pt); // var0 equals the farthest
point of geom to pt
v 1.8.0 1096
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
farthest_to
Possible uses:
Result:
Comment:
the distance is computed in the topology of the calling agent (the agent in which this
operator is used), with the distance algorithm specific to the topology.
Examples:
geometry var0 <- [ag1, ag2, ag3] closest_to(self); // var0 equals
return the farthest agent among ag1, ag2 and ag3 to the agent
applying the operator.
(species1 + species2) closest_to self
See also:
v 1.8.0 1097
GAMA v1.8.0 documentation Chapter 101. Operators
file
Possible uses:
Result:
Creates a file in read/write mode, setting its contents to the container passed in
parameter opens a file in read only mode, creates a GAML file object, and tries to
determine and store the file content in the contents attribute.
Comment:
The type of container to pass will depend on the type of file (see the management
of files in the documentation). Can be used to copy files since files are considered
as containers. For example: save file(‘image_copy.png’, file(‘image.png’)); will copy
image.png to image_copy.pngThe file should have a supported extension, see file type
definition for supported file extensions.
Special cases:
• If the specified string does not refer to an existing file, an exception is risen
when the variable is used.
Examples:
let fileT type: file value: file("../includes/Stupid_Cell.Data");
// fileT represents the file "../includes/Stupid_Cell.Data"
// fileT.contents here contains a matrix storing all the
data of the text file
v 1.8.0 1098
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
folder, new_folder,
file
Possible uses:
file_exists
Possible uses:
Result:
Examples:
string file_name <-"../includes/buildings.shp";
if file_exists(file_name){
write "File exists in the computer";
}
v 1.8.0 1099
GAMA v1.8.0 documentation Chapter 101. Operators
first
Possible uses:
Result:
Comment:
Special cases:
• if it is a map, first returns the first value of the first pair (in insertion order)
• if it is a file, first returns the first element of the content of the file (that is also
a container)
• for a matrix of object or geometry, it will return nil if the matrix is empty
v 1.8.0 1100
GAMA v1.8.0 documentation Chapter 101. Operators
• if it is a list, first returns the first element of the list, or nil if the list is empty
int var1 <- first ([1, 2, 3]); // var1 equals 1
See also:
last,
first_of
first_with
Possible uses:
Result:
the first element of the left-hand operand that makes the right-hand operand evaluate
to true.
Comment:
in the right-hand operand, the keyword each can be used to represent, in turn, each
of the right-hand operand elements.
v 1.8.0 1101
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
• if the left-operand is a map, the keyword each will contain each value
unknown var4 <- [1::2, 3::4, 5::6] first_with (each >= 4); // var4
equals 4
unknown var5 <- [1::2, 3::4, 5::6].pairs first_with (each.value >= 4);
// var5 equals (3::4)
Examples:
unknown var0 <- [1,2,3,4,5,6,7,8] first_with (each > 3); // var0 equals
4
unknown var2 <- g2 first_with (length(g2 out_edges_of each) = 0); //
var2 equals node9
unknown var3 <- (list(node) first_with (round(node(each).location.x) >
32); // var3 equals node2
See also:
flip
Possible uses:
Result:
v 1.8.0 1102
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
Examples:
bool var0 <- flip (0.66666); // var0 equals 2/3 chances to return true.
See also:
rnd,
float
Possible uses:
floor
Possible uses:
Result:
Maps the operand to the largest previous following integer, i.e. the largest integer
not greater than x.
v 1.8.0 1103
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
float var0 <- floor(3); // var0 equals 3.0
float var1 <- floor(3.5); // var1 equals 3.0
float var2 <- floor(-4.7); // var2 equals -5.0
See also:
ceil, round,
folder
Possible uses:
Result:
Special cases:
Examples:
file dirT <- folder("../includes/");
// dirT represents the repository "../includes/"
// dirT.contents here contains the list of the names of
included files
v 1.8.0 1104
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
file, new_folder,
font
Possible uses:
Result:
Creates a new font, by specifying its name (either a font face name like ‘Lucida
Grande Bold’ or ‘Helvetica’, or a logical name like ‘Dialog’, ‘SansSerif’, ‘Serif’, etc.), a
size in points and a style, either #bold, #italic or #plain or a combination (addition)
of them.
Examples:
font var0 <- font ('Helvetica Neue',12, #bold + #italic); // var0
equals a bold and italic face of the Helvetica Neue family
frequency_of
Possible uses:
v 1.8.0 1105
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Returns a map with keys equal to the application of the right-hand argument (like
collect) and values equal to the frequency of this key (i.e. how many times it has been
obtained)
Examples:
map var0 <- [1, 2, 3, 3, 4, 4, 5, 3, 3, 4] frequency_of each; // var0
equals map([1::1,2::1,3::4,4::3,5::1])
from
Same signification as since
fuzzy_choquet_DM
Possible uses:
Result:
The index of the candidate that maximizes the Fuzzy Choquet Integral value. The
first operand is the list of candidates (a candidate is a list of criterion values); the
second operand the list of criterion (list of string); the third operand the weights of
each sub-set of criteria (map with list for key and float for value)
Special cases:
v 1.8.0 1106
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
int var0 <- fuzzy_choquet_DM([[1.0, 7.0],[4.0,2.0],[3.0, 3.0]], ["
utility", "price", "size"],[["utility"]::0.5,["size"]::0.1,["price"
]::0.4,["utility", "price"]::0.55]); // var0 equals 0
See also:
fuzzy_kappa
Possible uses:
Result:
Examples:
v 1.8.0 1107
GAMA v1.8.0 documentation Chapter 101. Operators
fuzzy_kappa([ag1, ag2, ag3, ag4, ag5],[cat1,cat1,cat2,cat3,cat2],[cat2,
cat1,cat2,cat1,cat2], similarity_per_agents,[cat1,cat2,cat3
],[[1,0,0],[0,1,0],[0,0,1]], 2)
fuzzy_kappa([ag1, ag2, ag3, ag4, ag5],[cat1,cat1,cat2,cat3,cat2],[cat2,
cat1,cat2,cat1,cat2], similarity_per_agents,[cat1,cat2,cat3
],[[1,0,0],[0,1,0],[0,0,1]], 2, [1.0,3.0,2.0,2.0,4.0])
fuzzy_kappa_sim
Possible uses:
Result:
Examples:
v 1.8.0 1108
GAMA v1.8.0 documentation Chapter 101. Operators
fuzzy_kappa_sim([ag1, ag2, ag3, ag4, ag5], [cat1,cat1,cat2,cat3,cat2],[
cat2,cat1,cat2,cat1,cat2], similarity_per_agents,[cat1,cat2,cat3
],[[1,0,0,0,0,0,0,0,0],[0,1,0,0,0,0,0,0,0],[0,0,1,0,0,0,0,0,0],[0,0,0,1,0,0,0,0,0],[0,0
2,[1.0,3.0,2.0,2.0,4.0])
fuzzy_kappa_sim([ag1, ag2, ag3, ag4, ag5], [cat1,cat1,cat2,cat3,cat2],[
cat2,cat1,cat2,cat1,cat2], similarity_per_agents,[cat1,cat2,cat3
],[[1,0,0,0,0,0,0,0,0],[0,1,0,0,0,0,0,0,0],[0,0,1,0,0,0,0,0,0],[0,0,0,1,0,0,0,0,0],[0,0
2)
gaml_file
Possible uses:
Result:
Constructs a file of type gaml. Allowed extensions are limited to gaml, experiment
Special cases:
v 1.8.0 1109
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
is_gaml,
gaml_type
Possible uses:
gamma
Possible uses:
Result:
Examples:
float var0 <- gamma(5); // var0 equals 24.0
gamma_distribution
Possible uses:
v 1.8.0 1110
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Returns the integral from zero to x of the gamma probability density function.
Comment:
Examples:
float var0 <- gamma_distribution(2,3,0.9) with_precision(3); // var0
equals 0.269
gamma_distribution_complemented
Possible uses:
Result:
Returns the integral from x to infinity of the gamma probability density function.
Examples:
float var0 <- gamma_distribution_complemented(2,3,0.9) with_precision
(3); // var0 equals 0.731
v 1.8.0 1111
GAMA v1.8.0 documentation Chapter 101. Operators
gamma_index
Possible uses:
Result:
returns the gamma index of the graph (A measure of connectivity that considers the
relationship between the number of observed links and the number of possible links:
gamma = e/(3 * (v - 2)) - for planar graph.
Examples:
graph graphEpidemio <- graph([]);
float var1 <- gamma_index(graphEpidemio); // var1 equals the gamma
index of the graph
See also:
gamma_rnd
Possible uses:
Result:
returns a random value from a gamma distribution with specified values of the shape
and scale parameters
v 1.8.0 1112
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
float var0 <- gamma_distribution_complemented(2,3,0.9) with_precision
(3); // var0 equals 0.731
gauss
Possible uses:
Result:
A value from a normally distributed random variable with expected value (mean as
first operand) and variance (standardDeviation as second operand). The probability
density function of such a variable is a Gaussian. The operator can be used with an
operand of type point {meand,standardDeviation}.
Special cases:
Examples:
float var0 <- gauss(0,0.3); // var0 equals 0.22354
float var1 <- gauss({0,0.3}); // var1 equals 0.22354
v 1.8.0 1113
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
generate_barabasi_albert
Possible uses:
Result:
Comment:
v 1.8.0 1114
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
• “synchronized”: is the graph and the species of vertices and edges synchronized?
• “synchronized”: is the graph and the species of vertices and edges synchronized?
Examples:
graph<yourNodeSpecy,yourEdgeSpecy> graphEpidemio <-
generate_barabasi_albert(
yourListOfNodes,
yourEdgeSpecy,
3,
5,
true);
graph<yourNodeSpecy,yourEdgeSpecy> graphEpidemio <-
generate_barabasi_albert(
yourNodeSpecy,
yourEdgeSpecy,
3,
5,
true);
v 1.8.0 1115
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
generate_watts_strogatz,
generate_complete_graph
Possible uses:
Result:
returns a fully connected graph. returns a fully connected graph. returns a fully
connected graph. returns a fully connected graph.
Comment:
Special cases:
• “synchronized”: is the graph and the species of vertices and edges synchronized?
v 1.8.0 1116
GAMA v1.8.0 documentation Chapter 101. Operators
• “synchronized”: is the graph and the species of vertices and edges synchronized?
• “synchronized”: is the graph and the species of vertices and edges synchronized?
• “synchronized”: is the graph and the species of vertices and edges synchronized?
Examples:
graph<myVertexSpecy,myEdgeSpecy> myGraph <- generate_complete_graph(
myListOfNodes,
myEdgeSpecy,
true);
graph<myVertexSpecy,myEdgeSpecy> myGraph <- generate_complete_graph(
myVertexSpecy,
myEdgeSpecy,
10,
true);
v 1.8.0 1117
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
generate_barabasi_albert, generate_watts_strogatz,
generate_watts_strogatz
Possible uses:
Result:
Comment:
The Watts-Strogatz model is a random graph generation model that produces graphs
with small-world properties, including short average path lengths and high clustering.A
small-world network is a type of graph in which most nodes are not neighbors of
one another, but most nodes can be reached from every other by a small number of
v 1.8.0 1118
GAMA v1.8.0 documentation Chapter 101. Operators
hops or steps. [From Wikipedia article]The map operand should includes following
elements:The Watts-Strogatz model is a random graph generation model that produces
graphs with small-world properties, including short average path lengths and high
clustering.A small-world network is a type of graph in which most nodes are not
neighbors of one another, but most nodes can be reached from every other by a small
number of hops or steps. [From Wikipedia article]The map operand should includes
following elements:
Special cases:
• “size”: the graph will contain (size + 1) nodes. Size must be greater than k.
• “k”: the base degree of each node. k must be greater than 2 and even.
• “synchronized”: is the graph and the species of vertices and edges synchronized?
• “k”: the base degree of each node. k must be greater than 2 and even.
• “synchronized”: is the graph and the species of vertices and edges synchronized?
Examples:
graph<myVertexSpecy,myEdgeSpecy> myGraph <- generate_watts_strogatz(
v 1.8.0 1119
GAMA v1.8.0 documentation Chapter 101. Operators
myVertexSpecy,
myEdgeSpecy,
2,
0.3,
2,
true);
graph<myVertexSpecy,myEdgeSpecy> myGraph <- generate_watts_strogatz(
myListOfNodes,
myEdgeSpecy,
0.3,
2,
true);
See also:
generate_barabasi_albert,
geojson_file
Possible uses:
Result:
Constructs a file of type geojson. Allowed extensions are limited to json, geojson,
geo.json
v 1.8.0 1120
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
v 1.8.0 1121
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
is_geojson,
geometric_mean
Possible uses:
Result:
the geometric mean of the elements of the operand. See Geometric_mean for more
details.
Comment:
The operator casts all the numerical element of the list into float. The elements that
are not numerical are discarded.
Examples:
float var0 <- geometric_mean ([4.5, 3.5, 5.5, 7.0]); // var0 equals
4.962326343467649
See also:
v 1.8.0 1122
GAMA v1.8.0 documentation Chapter 101. Operators
geometry
Possible uses:
geometry_collection
Possible uses:
Result:
Special cases:
Examples:
geometry var0 <- geometry_collection([{0,0}, {0,10}, {10,10}, {10,0}]);
// var0 equals a geometry composed of the 4 points (multi-point).
See also:
around, circle, cone, link, norm, point, polygone, rectangle, square, triangle, line,
v 1.8.0 1123
GAMA v1.8.0 documentation Chapter 101. Operators
get
Possible uses:
Result:
Reads an attribute of the specified geometry (left operand). The attribute name
is specified by the right operand. Reads an attribute of the specified agent (left
operand). The attribute name is specified by the right operand.
Special cases:
get_about
Possible uses:
v 1.8.0 1124
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Examples:
get_about(emotion)
get_agent
Possible uses:
Result:
Examples:
get_agent(social_link1)
get_agent_cause
Possible uses:
v 1.8.0 1125
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
get the agent cause value of the given emotion evaluate the agent_cause value of a
predicate
Examples:
get_agent_cause(emotion)
get_agent_cause(pred1)
get_belief_op
Possible uses:
Result:
get the belief in the belief base with the given predicate.
Examples:
mental_state var0 <- get_belief_op(self,predicate("has_water")); //
var0 equals nil
get_belief_with_name_op
Possible uses:
v 1.8.0 1126
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
get the belief in the belief base with the given name.
Examples:
mental_state var0 <- get_belief_with_name_op(self,"has_water"); // var0
equals nil
get_beliefs_op
Possible uses:
Result:
get the beliefs in the belief base with the given predicate.
Examples:
get_beliefs_op(self,predicate("has_water"))
get_beliefs_with_name_op
Possible uses:
v 1.8.0 1127
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
get the list of beliefs in the belief base which predicate has the given name.
Examples:
get_beliefs_with_name_op(self,"has_water")
get_current_intention_op
Possible uses:
Result:
Examples:
mental_state var0 <- get_current_intention_op(self); // var0 equals nil
get_decay
Possible uses:
v 1.8.0 1128
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Examples:
get_decay(emotion)
get_desire_op
Possible uses:
Result:
get the desire in the desire base with the given predicate.
Examples:
mental_state var0 <- get_belief_op(self,predicate("has_water")); //
var0 equals nil
get_desire_with_name_op
Possible uses:
v 1.8.0 1129
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
get the desire in the desire base with the given name.
Examples:
mental_state var0 <- get_desire_with_name_op(self,"has_water"); // var0
equals nil
get_desires_op
Possible uses:
Result:
get the desires in the desire base with the given predicate.
Examples:
get_desires_op(self,predicate("has_water"))
get_desires_with_name_op
Possible uses:
v 1.8.0 1130
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
get the list of desires in the desire base which predicate has the given name.
Examples:
get_desires_with_name_op(self,"has_water")
get_dominance
Possible uses:
Result:
Examples:
get_dominance(social_link1)
get_familiarity
Possible uses:
v 1.8.0 1131
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Examples:
get_familiarity(social_link1)
get_ideal_op
Possible uses:
Result:
get the ideal in the ideal base with the given name.
Examples:
mental_state var0 <- get_ideal_op(self,predicate("has_water")); // var0
equals nil
get_ideal_with_name_op
Possible uses:
v 1.8.0 1132
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
get the ideal in the ideal base with the given name.
Examples:
mental_state var0 <- get_ideal_with_name_op(self,"has_water"); // var0
equals nil
get_ideals_op
Possible uses:
Result:
get the ideal in the ideal base with the given name.
Examples:
get_ideals_op(self,predicate("has_water"))
get_ideals_with_name_op
Possible uses:
v 1.8.0 1133
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
get the list of ideals in the ideal base which predicate has the given name.
Examples:
get_ideals_with_name_op(self,"has_water")
get_intensity
Possible uses:
Result:
Examples:
get_intensity(emo1)
get_intention_op
Possible uses:
v 1.8.0 1134
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
get the intention in the intention base with the given predicate.
Examples:
get_intention_op(self,predicate("has_water"))
get_intention_with_name_op
Possible uses:
Result:
get the intention in the intention base with the given name.
Examples:
get_intention_with_name_op(self,"has_water")
get_intentions_op
Possible uses:
v 1.8.0 1135
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
get the intentions in the intention base with the given predicate.
Examples:
get_intentions_op(self,predicate("has_water"))
get_intentions_with_name_op
Possible uses:
Result:
get the list of intentions in the intention base which predicate has the given name.
Examples:
get_intentions_with_name_op(self,"has_water")
get_lifetime
Possible uses:
v 1.8.0 1136
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Examples:
get_lifetime(mental_state1)
get_liking
Possible uses:
Result:
Examples:
get_liking(social_link1)
get_modality
Possible uses:
v 1.8.0 1137
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Examples:
get_modality(mental_state1)
get_obligation_op
Possible uses:
Result:
get the obligation in the obligation base with the given predicate.
Examples:
mental_state var0 <- get_obligation_op(self,predicate("has_water")); //
var0 equals nil
get_obligation_with_name_op
Possible uses:
v 1.8.0 1138
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
get the obligation in the obligation base with the given name.
Examples:
mental_state var0 <- get_obligation_with_name_op(self,"has_water"); //
var0 equals nil
get_obligations_op
Possible uses:
Result:
get the obligations in the obligation base with the given predicate.
Examples:
get_obligations_op(self,predicate("has_water"))
get_obligations_with_name_op
Possible uses:
v 1.8.0 1139
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
get the list of obligations in the obligation base which predicate has the given name.
Examples:
get_obligations_with_name_op(self,"has_water")
get_plan_name
Possible uses:
Result:
Examples:
get_plan_name(agent.current_plan)
get_predicate
Possible uses:
v 1.8.0 1140
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Examples:
get_predicate(mental_state1)
get_solidarity
Possible uses:
Result:
Examples:
get_solidarity(social_link1)
get_strength
Possible uses:
v 1.8.0 1141
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Examples:
get_strength(mental_state1)
get_super_intention
Possible uses:
Result:
Examples:
get_super_intention(get_belief(pred1))
get_trust
Possible uses:
v 1.8.0 1142
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Examples:
get_familiarity(social_link1)
get_truth
Possible uses:
Result:
Examples:
get_truth(pred1)
get_uncertainties_op
Possible uses:
v 1.8.0 1143
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
get the uncertainties in the uncertainty base with the given predicate.
Examples:
get_uncertainties_op(self,predicate("has_water"))
get_uncertainties_with_name_op
Possible uses:
Result:
get the list of uncertainties in the uncertainty base which predicate has the given
name.
Examples:
get_uncertainties_with_name_op(self,"has_water")
get_uncertainty_op
Possible uses:
v 1.8.0 1144
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
get the uncertainty in the uncertainty base with the given predicate.
Examples:
mental_state var0 <- get_uncertainty_op(self,predicate("has_water"));
// var0 equals nil
get_uncertainty_with_name_op
Possible uses:
Result:
get the uncertainty in the uncertainty base with the given name.
Examples:
mental_state var0 <- get_uncertainty_with_name_op(self,"has_water"); //
var0 equals nil
get_values
Possible uses:
v 1.8.0 1145
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Examples:
get_values(pred1)
gif_file
Possible uses:
Result:
Special cases:
v 1.8.0 1146
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
is_gif,
gini
Possible uses:
Special cases:
• return the Gini Index of the given list of values (list of floats)
float var0 <- gini([1.0, 0.5, 2.0]); // var0 equals the gini index
computed i.e. 0.2857143
gml_file
Possible uses:
v 1.8.0 1147
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Special cases:
• gml_file(string,int): This file constructor allows to read a gml file and specifying
the coordinates system code, as an int (epsg code)
file f <- gml_file("file.gml", 32648);
• gml_file(string,bool): This file constructor allows to read a gml file and take a
potential z value (not taken in account by default)
file f <- gml_file("file.gml", true);
v 1.8.0 1148
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
is_gml,
graph
Possible uses:
grayscale
Possible uses:
Result:
Comment:
r=red, g=green, b=blue. Between 0 and 255 and gray = 0.299 * red + 0.587 * green
+ 0.114 * blue (Photoshop value)
Examples:
rgb var0 <- grayscale (rgb(255,0,0)); // var0 equals to a dark grey
v 1.8.0 1149
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
rgb, hsb,
grid_at
Possible uses:
Result:
returns the cell of the grid (right-hand operand) at the position given by the right-hand
operand
Comment:
Special cases:
Examples:
agent var0 <- grid_cell grid_at {1,2}; // var0 equals the agent
grid_cell with grid_x=1 and grid_y = 2
v 1.8.0 1150
GAMA v1.8.0 documentation Chapter 101. Operators
grid_cells_to_graph
Possible uses:
Result:
creates a graph from a list of cells (operand). An edge is created between neighbors.
Examples:
my_cell_graph<-grid_cells_to_graph(cells_list)
grid_file
Possible uses:
Result:
Constructs a file of type grid. Allowed extensions are limited to asc, tif
Special cases:
• grid_file(string): This file constructor allows to read a asc file or a tif (geotif)
file
v 1.8.0 1151
GAMA v1.8.0 documentation Chapter 101. Operators
file f <- grid_file("file.asc");
• grid_file(string,int): This file constructor allows to read a asc file or a tif (geotif)
file specifying the coordinates system code, as an int (epsg code)
file f <- grid_file("file.asc", 32648);
file f <- grid_file("file.asc","EPSG:32648");
See also:
is_grid,
group_by
Possible uses:
Result:
Returns a map, where the keys take the possible values of the right-hand operand
and the map values are the list of elements of the left-hand operand associated to the
key value
v 1.8.0 1152
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
in the right-hand operand, the keyword each can be used to represent, in turn, each
of the right-hand operand elements.
Special cases:
Examples:
map var0 <- [1,2,3,4,5,6,7,8] group_by (each > 3); // var0 equals [
false::[1, 2, 3], true::[4, 5, 6, 7, 8]]
map var1 <- g2 group_by (length(g2 out_edges_of each) ); // var1 equals
[ 0::[node9, node7, node10, node8, node11], 1::[node6], 2::[node5],
3::[node4]]
map var2 <- (list(node) group_by (round(node(each).location.x)); //
var2 equals [32::[node5], 21::[node1], 4::[node0], 66::[node2],
96::[node3]]
map<bool,list> var3 <- [1::2, 3::4, 5::6] group_by (each > 4); // var3
equals [false::[2, 4], true::[6]]
See also:
harmonic_mean
Possible uses:
Result:
the harmonic mean of the elements of the operand. See Harmonic_mean for more
details.
v 1.8.0 1153
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
The operator casts all the numerical element of the list into float. The elements that
are not numerical are discarded.
Examples:
float var0 <- harmonic_mean ([4.5, 3.5, 5.5, 7.0]); // var0 equals
4.804159445407279
See also:
has_belief_op
Possible uses:
Result:
Examples:
bool var0 <- has_belief_op(self,predicate("has_water")); // var0 equals
false
v 1.8.0 1154
GAMA v1.8.0 documentation Chapter 101. Operators
has_belief_with_name_op
Possible uses:
Result:
Examples:
bool var0 <- has_belief_with_name_op(self,"has_water"); // var0 equals
false
has_desire_op
Possible uses:
Result:
Examples:
bool var0 <- has_desire_op(self,predicate("has_water")); // var0 equals
false
v 1.8.0 1155
GAMA v1.8.0 documentation Chapter 101. Operators
has_desire_with_name_op
Possible uses:
Result:
Examples:
bool var0 <- has_desire_with_name_op(self,"has_water"); // var0 equals
false
has_ideal_op
Possible uses:
Result:
Examples:
bool var0 <- has_ideal_op(self,predicate("has_water")); // var0 equals
false
v 1.8.0 1156
GAMA v1.8.0 documentation Chapter 101. Operators
has_ideal_with_name_op
Possible uses:
Result:
Examples:
bool var0 <- has_ideal_with_name_op(self,"has_water"); // var0 equals
false
has_intention_op
Possible uses:
Result:
Examples:
bool var0 <- has_intention_op(self,predicate("has_water")); // var0
equals false
v 1.8.0 1157
GAMA v1.8.0 documentation Chapter 101. Operators
has_intention_with_name_op
Possible uses:
Result:
Examples:
bool var0 <- has_intention_with_name_op(self,"has_water"); // var0
equals false
has_obligation_op
Possible uses:
Result:
Examples:
bool var0 <- has_obligation_op(self,predicate("has_water")); // var0
equals false
v 1.8.0 1158
GAMA v1.8.0 documentation Chapter 101. Operators
has_obligation_with_name_op
Possible uses:
Result:
Examples:
bool var0 <- has_obligation_with_name_op(self,"has_water"); // var0
equals false
has_uncertainty_op
Possible uses:
Result:
Examples:
bool var0 <- has_uncertainty_op(self,predicate("has_water")); // var0
equals false
v 1.8.0 1159
GAMA v1.8.0 documentation Chapter 101. Operators
has_uncertainty_with_name_op
Possible uses:
Result:
Examples:
bool var0 <- has_uncertainty_with_name_op(self,"has_water"); // var0
equals false
hexagon
Possible uses:
Result:
Comment:
the center of the hexagon is by default the location of the current agent in which has
been called this operator.the center of the hexagon is by default the location of the
current agent in which has been called this operator.the center of the hexagon is by
default the location of the current agent in which has been called this operator.
v 1.8.0 1160
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
Examples:
geometry var0 <- hexagon({10,5}); // var0 equals a geometry as a
hexagon of width of 10 and height of 5.
geometry var1 <- hexagon(10); // var1 equals a geometry as a hexagon of
width of 10 and height of 10.
geometry var2 <- hexagon(10,5); // var2 equals a geometry as a hexagon
of width of 10 and height of 5.
See also:
around, circle, cone, line, link, norm, point, polygon, polyline, rectangle, triangle,
hierarchical_clustering
Possible uses:
Result:
v 1.8.0 1161
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
use of hierarchical clustering with Minimum for linkage criterion between two groups
of agents.
Examples:
list var0 <- [ag1, ag2, ag3, ag4, ag5] hierarchical_clustering 20.0; //
var0 equals for example, can return [[[ag1],[ag3]], [ag2], [[[ag4
],[ag5]],[ag6]]
See also:
simple_clustering_by_distance,
horizontal
Possible uses:
hsb
Possible uses:
Result:
v 1.8.0 1162
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
h,s and b components should be floating-point values between 0.0 and 1.0 and
when used alpha should be an integer (between 0 and 255) or a float (between 0
and 1) . Examples: Red=(0.0,1.0,1.0), Yellow=(0.16,1.0,1.0), Green=(0.33,1.0,1.0),
Cyan=(0.5,1.0,1.0), Blue=(0.66,1.0,1.0), Magenta=(0.83,1.0,1.0)
Examples:
rgb var0 <- hsb (0.0,1.0,1.0); // var0 equals rgb("red")
rgb var1 <- hsb (0.5,1.0,1.0,0.0); // var1 equals rgb("cyan",0)
See also:
rgb,
hypot
Possible uses:
Result:
Special cases:
v 1.8.0 1163
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
float var0 <- hypot(0,1,0,1); // var0 equals sqrt(2)
IDW
Possible uses:
Result:
Examples:
map<geometry,float> var0 <- IDW([ag1, ag2, ag3, ag4, ag5
],[{10,10}::25.0, {10,80}::10.0, {100,10}::15.0], 2); // var0 equals
for example, can return [ag1::12.0, ag2::23.0,ag3::12.0,ag4::14.0,
ag5::17.0]
image_file
Possible uses:
v 1.8.0 1164
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Constructs a file of type image. Allowed extensions are limited to tiff, jpg, jpeg, png,
pict, bmp
Special cases:
• image_file(string): This file constructor allows to read an image file (tiff, jpg,
jpeg, png, pict, bmp)
file f <-image_file("file.png");
See also:
is_image,
in
Possible uses:
Result:
true if the right operand contains the left operand, false otherwise
v 1.8.0 1165
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
Special cases:
• if both operands are strings, returns true if the left-hand operand patterns is
included in to the right-hand string;
Examples:
bool var0 <- 2 in [1,2,3,4,5,6]; // var0 equals true
bool var1 <- 7 in [1,2,3,4,5,6]; // var1 equals false
bool var2 <- 3 in [1::2, 3::4, 5::6]; // var2 equals false
bool var3 <- 6 in [1::2, 3::4, 5::6]; // var3 equals true
bool var4 <- 'bc' in 'abcded'; // var4 equals true
See also:
contains,
in_degree_of
Possible uses:
Result:
returns the in degree of a vertex (right-hand operand) in the graph given as left-hand
operand.
v 1.8.0 1166
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
int var1 <- graphFromMap in_degree_of (node(3)); // var1 equals 2
See also:
out_degree_of, degree_of,
in_edges_of
Possible uses:
Result:
returns the list of the in-edges of a vertex (right-hand operand) in the graph given as
left-hand operand.
Examples:
list var1 <- graphFromMap in_edges_of node({12,45}); // var1 equals [
LineString]
See also:
out_edges_of,
v 1.8.0 1167
GAMA v1.8.0 documentation Chapter 101. Operators
incomplete_beta
Possible uses:
Result:
Returns the regularized integral of the beta function with arguments a and b, from
zero to x.
Examples:
float var0 <- incomplete_beta(2,3,0.9) with_precision(3); // var0
equals 0.996
incomplete_gamma
Possible uses:
Result:
Returns the regularized integral of the Gamma function with argument a to the
integration end point x.
Examples:
float var0 <- incomplete_gamma(1,5.3) with_precision(3); // var0 equals
0.995
v 1.8.0 1168
GAMA v1.8.0 documentation Chapter 101. Operators
incomplete_gamma_complement
Possible uses:
Result:
Comment:
Examples:
float var0 <- incomplete_gamma_complement(1,5.3) with_precision(3); //
var0 equals 0.005
indented_by
Possible uses:
Result:
v 1.8.0 1169
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
string var0 <- "my" + indented_by("text", 1); // var0 equals "my
text"
index_by
Possible uses:
Result:
produces a new map from the evaluation of the right-hand operand for each element
of the left-hand operand
Special cases:
Examples:
map var0 <- [1,2,3,4,5,6,7,8] index_by (each - 1); // var0 equals
[0::1, 1::2, 2::3, 3::4, 4::5, 5::6, 6::7, 7::8]
v 1.8.0 1170
GAMA v1.8.0 documentation Chapter 101. Operators
index_of
Possible uses:
Result:
the index of the first occurence of the right operand in the left operand container the
index of the first occurence of the right operand in the left operand container
Comment:
The definition of index_of and the type of the index depend on the container
Special cases:
• if the left operand is a map, index_of returns the index of a value or nil if the
value is not mapped
• if both operands are strings, returns the index within the left-hand string of
the first occurrence of the given right-hand string
int var1 <- "abcabcabc" index_of "ca"; // var1 equals 2
v 1.8.0 1171
GAMA v1.8.0 documentation Chapter 101. Operators
int var2 <- [1,2,3,4,5,6] index_of 4; // var2 equals 3
int var3 <- [4,2,3,4,5,4] index_of 4; // var3 equals 0
point var4 <- matrix([[1,2,3],[4,5,6]]) index_of 4; // var4 equals
{1.0,0.0}
Examples:
unknown var0 <- [1::2, 3::4, 5::6] index_of 4; // var0 equals 3
See also:
at, last_index_of,
inside
Possible uses:
Result:
v 1.8.0 1172
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
list<geometry> var0 <- [ag1, ag2, ag3] inside(self); // var0 equals the
agents among ag1, ag2 and ag3 that are covered by the shape of the
right-hand argument.
list<geometry> var1 <- (species1 + species2) inside (self); // var1
equals the agents among species species1 and species2 that are
covered by the shape of the right-hand argument.
See also:
int
Possible uses:
inter
Possible uses:
Result:
the intersection of the two operands A geometry resulting from the intersection
between the two geometries
v 1.8.0 1173
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
both containers are transformed into sets (so without duplicated element, cf. remove_-
deplicates operator) before the set intersection is computed.
Special cases:
list var0 <- [1::2, 3::4, 5::6] inter [2,4]; // var0 equals [2,4]
list var1 <- [1::2, 3::4, 5::6] inter [1,3]; // var1 equals []
list var2 <- matrix([[3,2,1],[4,5,4]]) inter [3,4]; // var2 equals
[3,4]
Examples:
list var3 <- [1,2,3,4,5,6] inter [2,4]; // var3 equals [2,4]
list var4 <- [1,2,3,4,5,6] inter [0,8]; // var4 equals []
geometry var5 <- square(10) inter circle(5); // var5 equals circle(5)
See also:
remove_duplicates, union, +, -,
v 1.8.0 1174
GAMA v1.8.0 documentation Chapter 101. Operators
interleave
Possible uses:
Result:
Returns a new list containing the interleaved elements of the containers contained in
the operand
Comment:
the operand should be a list of lists of elements. The result is a list of elements.
Examples:
list var0 <- interleave([1,2,4,3,5,7,6,8]); // var0 equals
[1,2,4,3,5,7,6,8]
list var1 <- interleave([['e11','e12','e13'],['e21','e22','e23'],['e31
','e32','e33']]); // var1 equals ['e11','e21','e31','e12','e22','e32
','e13','e23','e33']
internal_at
Possible uses:
v 1.8.0 1175
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
For internal use only. Corresponds to the implementation, for agents, of the access to
containers with index For internal use only. Corresponds to the implementation, for
geometries, of the access to containers with index For internal use only. Corresponds
to the implementation of the access to containers with index
See also:
at,
internal_integrated_value
Possible uses:
Result:
For internal use only. Corresponds to the implementation, for agents, of the access to
containers with index
intersection
v 1.8.0 1176
GAMA v1.8.0 documentation Chapter 101. Operators
intersects
Possible uses:
Result:
A boolean, equal to true if the left-geometry (or agent/point) intersects the right-
geometry (or agent/point).
Special cases:
Examples:
bool var0 <- square(5) intersects {10,10}; // var0 equals false
See also:
inverse
Possible uses:
Result:
The inverse matrix of the given matrix. If no inverse exists, returns a matrix that
has properties that resemble that of an inverse.
v 1.8.0 1177
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
matrix<float> var0 <- inverse(matrix([[4,3],[3,2]])); // var0 equals
matrix([[-2.0,3.0],[3.0,-4.0]])
inverse_distance_weighting
Same signification as IDW
inverse_rotation
Possible uses:
Result:
The inverse rotation. It is a rotation around the same axis with the opposite angle.
Examples:
pair<float,point> var0 <- inverse_rotation(38.0::{1,1,1}); // var0
equals -38.0::{1,1,1}
See also:
rotation_composition, normalized_rotation,
v 1.8.0 1178
GAMA v1.8.0 documentation Chapter 101. Operators
is
Possible uses:
Result:
returns true if the left operand is of the right operand type, false otherwise
Examples:
bool var0 <- 0 is int; // var0 equals true
bool var1 <- an_agent is node; // var1 equals true
bool var2 <- 1 is float; // var2 equals false
is_csv
Possible uses:
Result:
See also:
csv_file,
v 1.8.0 1179
GAMA v1.8.0 documentation Chapter 101. Operators
is_dxf
Possible uses:
Result:
See also:
dxf_file,
is_error
Possible uses:
Result:
is_finite
Possible uses:
v 1.8.0 1180
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Examples:
bool var0 <- is_finite(4.66); // var0 equals true
bool var1 <- is_finite(#infinity); // var1 equals false
is_gaml
Possible uses:
Result:
See also:
gaml_file,
is_geojson
Possible uses:
v 1.8.0 1181
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
See also:
geojson_file,
is_gif
Possible uses:
Result:
See also:
gif_file,
is_gml
Possible uses:
Result:
v 1.8.0 1182
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
gml_file,
is_grid
Possible uses:
Result:
See also:
grid_file,
is_image
Possible uses:
Result:
v 1.8.0 1183
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
image_file,
is_json
Possible uses:
Result:
See also:
json_file,
is_number
Possible uses:
Result:
Returns whether the argument is a real number or not tests whether the operand
represents a numerical value
v 1.8.0 1184
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
Note that the symbol . should be used for a float value (a string with , will not be
considered as a numeric value). Symbols e and E are also accepted. A hexadecimal
value should begin with #.
Examples:
bool var0 <- is_number(4.66); // var0 equals true
bool var1 <- is_number(#infinity); // var1 equals true
bool var2 <- is_number(#nan); // var2 equals false
bool var3 <- is_number("test"); // var3 equals false
bool var4 <- is_number("123.56"); // var4 equals true
bool var5 <- is_number("-1.2e5"); // var5 equals true
bool var6 <- is_number("1,2"); // var6 equals false
bool var7 <- is_number("#12FA"); // var7 equals true
is_obj
Possible uses:
Result:
See also:
obj_file,
v 1.8.0 1185
GAMA v1.8.0 documentation Chapter 101. Operators
is_osm
Possible uses:
Result:
See also:
osm_file,
is_pgm
Possible uses:
Result:
See also:
pgm_file,
v 1.8.0 1186
GAMA v1.8.0 documentation Chapter 101. Operators
is_property
Possible uses:
Result:
See also:
property_file,
is_R
Possible uses:
Result:
See also:
R_file,
v 1.8.0 1187
GAMA v1.8.0 documentation Chapter 101. Operators
is_saved_simulation
Possible uses:
Result:
See also:
saved_simulation_file,
is_shape
Possible uses:
Result:
See also:
shape_file,
v 1.8.0 1188
GAMA v1.8.0 documentation Chapter 101. Operators
is_skill
Possible uses:
Result:
returns true if the left operand is an agent whose species implements the right-hand
skill name
Examples:
bool var0 <- agentA is_skill 'moving'; // var0 equals true
is_svg
Possible uses:
Result:
See also:
svg_file,
v 1.8.0 1189
GAMA v1.8.0 documentation Chapter 101. Operators
is_text
Possible uses:
Result:
See also:
text_file,
is_threeds
Possible uses:
Result:
See also:
threeds_file,
v 1.8.0 1190
GAMA v1.8.0 documentation Chapter 101. Operators
is_warning
Possible uses:
Result:
is_xml
Possible uses:
Result:
See also:
xml_file,
json_file
Possible uses:
v 1.8.0 1191
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Special cases:
See also:
is_json,
kappa
Possible uses:
Result:
v 1.8.0 1192
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
kappa([cat1,cat1,cat2,cat3,cat2],[cat2,cat1,cat2,cat1,cat2],[cat1,cat2,
cat3])
float var1 <- kappa([1,3,5,1,5],[1,1,1,1,5],[1,3,5]); // var1 equals
0.3333333333333334
float var2 <- kappa([1,1,1,1,5],[1,1,1,1,5],[1,3,5]); // var2 equals
1.0
float var3 <- kappa(["cat1","cat3","cat2","cat1","cat3"],["cat1","cat3"
,"cat2","cat3","cat1"],["cat1","cat2","cat3"], [1.0, 2.0, 3.0, 1.0,
5.0]); // var3 equals 0.29411764705882354
kappa_sim
Possible uses:
Result:
Examples:
v 1.8.0 1193
GAMA v1.8.0 documentation Chapter 101. Operators
float var0 <- kappa_sim(["cat1","cat1","cat2","cat2","cat2"],["cat1","
cat3","cat2","cat1","cat3"],["cat1","cat3","cat2","cat3","cat1"],["
cat1","cat2","cat3"], [1.0, 2.0, 3.0, 1.0, 5.0]); // var0 equals
0.2702702702702703
float var1 <- kappa_sim(["cat1","cat1","cat2","cat2","cat2"],["cat1","
cat3","cat2","cat1","cat3"],["cat1","cat3","cat2","cat3","cat1"],["
cat1","cat2","cat3"]); // var1 equals 0.3333333333333335
kmeans
Possible uses:
Result:
returns the list of clusters (list of instance indices) computed with the kmeans++
algorithm from the first operand data according to the number of clusters to split
the data into (k). Usage: kmeans(data,k) returns the list of clusters (list of instance
indices) computed with the kmeans++ algorithm from the first operand data according
to the number of clusters to split the data into (k) and the maximum number of
iterations to run the algorithm for (If negative, no maximum will be used) (maxIt).
Usage: kmeans(data,k,maxit)
Special cases:
v 1.8.0 1194
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
list<list> var0 <- kmeans ([[2,4,5], [3,8,2], [1,1,3], [4,3,4]],2); //
var0 equals [[0,2,3],[1]]
list<list> var1 <- kmeans ([[2,4,5], [3,8,2], [1,1,3], [4,3,4]],2,10);
// var1 equals [[0,2,3],[1]]
kml
Possible uses:
kurtosis
Possible uses:
Result:
returns kurtosis value computed from the operand list of values (kurtosis = { [n(n+1)
/ (n -1)(n - 2)(n-3)] sum[(x_i - mean)ˆ4] / stdˆ4 } - [3(n-1)ˆ2 / (n-2)(n-3)])
Special cases:
Examples:
float var0 <- kurtosis ([1,2,3,4,5]); // var0 equals -1.200000000000002
v 1.8.0 1195
GAMA v1.8.0 documentation Chapter 101. Operators
kurtosis
Possible uses:
Result:
Returns the kurtosis (aka excess) of a data sequence Returns the kurtosis (aka excess)
of a data sequence
Examples:
float var0 <- kurtosis(3,12) with_precision(4); // var0 equals -2.9999
float var1 <- kurtosis([13,2,1,4,1,2]) with_precision(4); // var1
equals 4.8083
last
Possible uses:
Result:
v 1.8.0 1196
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
Special cases:
• if it is a map, last returns the value of the last pair (in insertion order)
• if it is a file, last returns the last element of the content of the file (that is also
a container)
• for a matrix of object or geometry, it will return nil if the matrix is empty
• if it is a list, last returns the last element of the list, or nil if the list is empty
int var0 <- last ([1, 2, 3]); // var0 equals 3
See also:
first,
v 1.8.0 1197
GAMA v1.8.0 documentation Chapter 101. Operators
last_index_of
Possible uses:
Result:
the index of the last occurence of the right operand in the left operand container
Comment:
The definition of last_index_of and the type of the index depend on the container
Special cases:
• if the left operand is a species, the last index of an agent is the same as its
index
• if the left operand is a map, last_index_of returns the index as an int (the key
of the pair)
unknown var0 <- [1::2, 3::4, 5::4] last_index_of 4; // var0 equals 5
• if both operands are strings, returns the index within the left-hand string of
the rightmost occurrence of the given right-hand string
v 1.8.0 1198
GAMA v1.8.0 documentation Chapter 101. Operators
int var1 <- "abcabcabc" last_index_of "ca"; // var1 equals 5
See also:
last_of
last_with
Possible uses:
v 1.8.0 1199
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
the last element of the left-hand operand that makes the right-hand operand evaluate
to true.
Comment:
in the right-hand operand, the keyword each can be used to represent, in turn, each
of the right-hand operand elements.
Special cases:
• if the left-operand is a map, the keyword each will contain each value
unknown var4 <- [1::2, 3::4, 5::6] last_with (each >= 4); // var4
equals 6
unknown var5 <- [1::2, 3::4, 5::6].pairs last_with (each.value >= 4);
// var5 equals (5::6)
Examples:
unknown var0 <- [1,2,3,4,5,6,7,8] last_with (each > 3); // var0 equals
8
unknown var2 <- g2 last_with (length(g2 out_edges_of each) = 0 ); //
var2 equals node11
unknown var3 <- (list(node) last_with (round(node(each).location.x) >
32); // var3 equals node3
See also:
v 1.8.0 1200
GAMA v1.8.0 documentation Chapter 101. Operators
layout_circle
Possible uses:
Result:
layouts a Gama graph on a circle with equidistance between nodes. For now there
is no optimization on node ordering ! Usage: layoutCircle(graph, bound, shuffle)
=> graph : the graph to layout, bound : the geometry to display the graph within,
shuffle : if true shuffle the nodes, then render same ordering
Examples:
layout_circle(graph, world.shape, false);
layout_force
Possible uses:
Result:
layouts a GAMA graph using Force model. usage: layoutForce(graph, bounds, coeff_-
force, cooling_rate, max_iteration, equilibirum criterion). graph is the graph to
which applied the layout; bounds is the shape (geometry) in which the graph should
be located; coeff_force is the coefficien use to compute the force, typical value is
0.4; cooling rate is the decreasing coefficient of the temperature, typical value is
0.01; max_iteration is the maximal number of iterations; equilibirum criterion is
the maximaldistance of displacement for a vertice to be considered as in equilibrium
v 1.8.0 1201
GAMA v1.8.0 documentation Chapter 101. Operators
layouts a GAMA graph using Force model. usage: layoutForce(graph, bounds, coeff_-
force, cooling_rate, max_iteration). graph is the graph to which applied the layout;
bounds is the shape (geometry) in which the graph should be located; coeff_force
is the coefficient used to compute the force, typical value is 0.4; cooling rate is the
decreasing coefficient of the temperature, typical value is 0.01; max_iteration is the
maximal number of iterationsdistance of displacement for a vertice to be considered
as in equilibrium
layout_grid
Possible uses:
Result:
Examples:
layout_grid(graph, world.shape);
length
Possible uses:
v 1.8.0 1202
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Comment:
Special cases:
• if it is a list or a map, length returns the number of elements in the list or map
int var1 <- length([12,13]); // var1 equals 2
int var2 <- length([]); // var2 equals 0
lgamma
Same signification as log_gamma
v 1.8.0 1203
GAMA v1.8.0 documentation Chapter 101. Operators
line
Possible uses:
Result:
A polyline geometry from the given list of points. A polyline geometry from the given
list of points represented as a cylinder of radius r.
Special cases:
Examples:
geometry var0 <- polyline([{0,0}, {0,10}, {10,10}]); // var0 equals a
polyline geometry composed of the 3 points.
geometry var1 <- line([{10,10}, {10,0}]); // var1 equals a line from 2
points.
string var2 <- string(polyline([{0,0}, {0,10}, {10,10}])+line([{10,10},
{10,0}])); // var2 equals "MULTILINESTRING ((0 0, 0 10, 10 10), (10
10, 10 0))"
v 1.8.0 1204
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
around, circle, cone, link, norm, point, polygone, rectangle, square, triangle,
link
Possible uses:
Result:
Comment:
The geometry of the link is a line between the locations of the two operands, which is
built and maintained dynamically
Special cases:
• if one of the operands is nil, link returns a point geometry at the location of
the other. If both are null, it returns a point geometry at {0,0}
Examples:
geometry var0 <- link (geom1,geom2); // var0 equals a link geometry
between geom1 and geom2.
v 1.8.0 1205
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
around, circle, cone, line, norm, point, polygon, polyline, rectangle, square, triangle,
list
Possible uses:
list_with
Possible uses:
Result:
creates a list with a size provided by the first operand, and filled with the second
operand
Comment:
Note that the first operand should be positive, and that the second one is evaluated
for each position in the list.
Examples:
list var0 <- list_with(5,2); // var0 equals [2,2,2,2,2]
v 1.8.0 1206
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
list,
ln
Possible uses:
Result:
Special cases:
Examples:
float var0 <- ln(1); // var0 equals 0.0
float var1 <- ln(exp(1)); // var1 equals 1.0
See also:
exp,
v 1.8.0 1207
GAMA v1.8.0 documentation Chapter 101. Operators
load_graph_from_file
Possible uses:
Result:
loads a graph from a file returns a graph loaded from a given file encoded into a given
format. The last boolean parameter indicates whether the resulting graph will be
considered as spatial or not by GAMA
Comment:
v 1.8.0 1208
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
v 1.8.0 1209
GAMA v1.8.0 documentation Chapter 101. Operators
• “format”: the format of the file, “filename”: the filename of the file containing
the network
graph<myVertexSpecy,myEdgeSpecy> myGraph <- load_graph_from_file(
"pajek",
"example_of_Pajek_file");
• “format”: the format of the file, “file”: the file containing the network, “edges_-
species”: the species of edges, “vertices_specy”: the species of vertices
graph<myVertexSpecy,myEdgeSpecy> myGraph <- load_graph_from_file(
"pajek",
"example_of_Pajek_file",
myVertexSpecy,
myEdgeSpecy );
v 1.8.0 1210
GAMA v1.8.0 documentation Chapter 101. Operators
• “format”: the format of the file, “file”: the file containing the network
graph<myVertexSpecy,myEdgeSpecy> myGraph <- load_graph_from_file(
"pajek",
"example_of_Pajek_file");
Examples:
graph<myVertexSpecy,myEdgeSpecy> myGraph <- load_graph_from_file(
"pajek",
"./example_of_Pajek_file",
myVertexSpecy,
myEdgeSpecy);
graph<myVertexSpecy,myEdgeSpecy> myGraph <- load_graph_from_file(
"pajek",
"./example_of_Pajek_file",
myVertexSpecy,
myEdgeSpecy , true);
load_shortest_paths
Possible uses:
Result:
put in the graph cache the computed shortest paths contained in the matrix (rows:
source, columns: target)
v 1.8.0 1211
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
graph var0 <- load_shortest_paths(shortest_paths_matrix); // var0
equals return my_graph with all the shortest paths computed
load_sub_model
Possible uses:
Result:
Load a submodel
Comment:
loaded submodel
log
Possible uses:
Result:
v 1.8.0 1212
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
Examples:
float var0 <- log(1); // var0 equals 0.0
float var1 <- log(10); // var1 equals 1.0
See also:
ln,
log_gamma
Possible uses:
Result:
Examples:
float var0 <- log_gamma(0.6) with_precision(4); // var0 equals 0.3982
v 1.8.0 1213
GAMA v1.8.0 documentation Chapter 101. Operators
lower_case
Possible uses:
Result:
Examples:
string var0 <- lower_case("Abc"); // var0 equals 'abc'
See also:
upper_case,
main_connected_component
Possible uses:
Result:
returns the sub-graph corresponding to the main connected components of the graph
Examples:
graph var0 <- main_connected_component(my_graph); // var0 equals the
sub-graph corresponding to the main connected components of the
graph
v 1.8.0 1214
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
connected_components_of,
map
Possible uses:
masked_by
Possible uses:
Examples:
geometry var0 <- perception_geom masked_by obstacle_list; // var0
equals the geometry representing the part of perception_geom visible
from the agent position considering the list of obstacles
obstacle_list.
geometry var1 <- perception_geom masked_by obstacle_list; // var1
equals the geometry representing the part of perception_geom visible
from the agent position considering the list of obstacles
obstacle_list.
v 1.8.0 1215
GAMA v1.8.0 documentation Chapter 101. Operators
material
Possible uses:
Result:
Returns
Examples:
See also:
material
Possible uses:
matrix
Possible uses:
v 1.8.0 1216
GAMA v1.8.0 documentation Chapter 101. Operators
matrix_with
Possible uses:
Result:
creates a matrix with a size provided by the first operand, and filled with the second
operand
Comment:
Note that both components of the right operand point should be positive, otherwise
an exception is raised.
See also:
matrix, as_matrix,
max
Possible uses:
Result:
Comment:
v 1.8.0 1217
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
• if it is a map, max returns the maximum among the list of all elements value
• if it is a file, max returns the maximum of the content of the file (that is also a
container)
• if it is a graph, max returns the maximum of the list of the elements of the
graph (that can be the list of edges or vertexes depending on the graph)
• if it is a matrix of int, float or object, max returns the maximum of all the
numerical elements (thus all elements for integer and float matrices)
• if it is a list of int of float, max returns the maximum of all the elements
unknown var0 <- max ([100, 23.2, 34.5]); // var0 equals 100.0
• if it is a list of points: max returns the maximum of all points as a point (i.e. the
point with the greatest coordinate on the x-axis, in case of equality the point
with the greatest coordinate on the y-axis is chosen. If all the points are equal,
the first one is returned. )
unknown var1 <- max([{1.0,3.0},{3.0,5.0},{9.0,1.0},{7.0,8.0}]); // var1
equals {9.0,1.0}
See also:
min,
v 1.8.0 1218
GAMA v1.8.0 documentation Chapter 101. Operators
max_flow_between
Possible uses:
Result:
The max flow (map<edge,flow> in a graph between the source and the sink using
Edmonds-Karp algorithm
Examples:
max_flow_between(my_graph, vertice1, vertice2)
max_of
Possible uses:
Result:
the maximum value of the right-hand expression evaluated on each of the elements of
the left-hand operand
Comment:
in the right-hand operand, the keyword each can be used to represent, in turn, each
of the right-hand operand elements.
v 1.8.0 1219
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
• As of GAMA 1.6, if the left-hand operand is nil or empty, max_of throws an error
• if the left-operand is a map, the keyword each will contain each value
unknown var4 <- [1::2, 3::4, 5::6] max_of (each + 3); // var4 equals 9
Examples:
unknown var0 <- [1,2,4,3,5,7,6,8] max_of (each * 100 ); // var0 equals
800
graph g2 <- as_edge_graph([{1,5}::{12,45},{12,45}::{34,56}]);
unknown var2 <- g2.vertices max_of (g2 degree_of( each )); // var2
equals 2
unknown var3 <- (list(node) max_of (round(node(each).location.x)); //
var3 equals 96
See also:
min_of,
maximal_cliques_of
Possible uses:
Result:
returns the maximal cliques of a graph using the Bron-Kerbosch clique detection
algorithm: A clique is maximal if it is impossible to enlarge it by adding another
vertex from the graph. Note that a maximal clique is not necessarily the biggest
clique in the graph.
v 1.8.0 1220
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
graph my_graph <- graph([]);
list<list> var1 <- maximal_cliques_of (my_graph); // var1 equals the
list of all the maximal cliques as list
See also:
biggest_cliques_of,
mean
Possible uses:
Result:
Comment:
the elements of the operand are summed (see sum for more details about the sum of
container elements ) and then the sum value is divided by the number of elements.
Special cases:
• if the container contains points, the result will be a point. If the container
contains rgb values, the result will be a rgb color
Examples:
unknown var0 <- mean ([4.5, 3.5, 5.5, 7.0]); // var0 equals 5.125
v 1.8.0 1221
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
sum,
mean_deviation
Possible uses:
Result:
the deviation from the mean of all the elements of the operand. See Mean_deviation
for more details.
Comment:
The operator casts all the numerical element of the list into float. The elements that
are not numerical are discarded.
Examples:
float var0 <- mean_deviation ([4.5, 3.5, 5.5, 7.0]); // var0 equals
1.125
See also:
mean, standard_deviation,
v 1.8.0 1222
GAMA v1.8.0 documentation Chapter 101. Operators
mean_of
Possible uses:
Result:
the mean of the right-hand expression evaluated on each of the elements of the
left-hand operand
Comment:
in the right-hand operand, the keyword each can be used to represent, in turn, each
of the right-hand operand elements.
Special cases:
• if the left-operand is a map, the keyword each will contain each value
unknown var1 <- [1::2, 3::4, 5::6] mean_of (each); // var1 equals 4
Examples:
unknown var0 <- [1,2] mean_of (each * 10 ); // var0 equals 15
See also:
v 1.8.0 1223
GAMA v1.8.0 documentation Chapter 101. Operators
meanR
Possible uses:
Result:
returns the mean value of given vector (right-hand operand) in given variable (left-
hand operand).
Examples:
list<int> X <- [2, 3, 1];
int var1 <- meanR(X); // var1 equals 2
unknown var2 <- meanR([2, 3, 1]); // var2 equals 2
median
Possible uses:
Result:
Special cases:
• if the container contains points, the result will be a point. If the container
contains rgb values, the result will be a rgb color
v 1.8.0 1224
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
unknown var0 <- median ([4.5, 3.5, 5.5, 3.4, 7.0]); // var0 equals 4.5
See also:
mean,
mental_state
Possible uses:
Result:
message
Possible uses:
Result:
to be added
v 1.8.0 1225
GAMA v1.8.0 documentation Chapter 101. Operators
milliseconds_between
Possible uses:
Result:
Provide the exact number of milliseconds between two dates. This number can be
positive or negative (if the second operand is smaller than the first one)
Examples:
float var0 <- milliseconds_between(date('2000-01-01'), date
('2000-02-01')); // var0 equals 2.6784E9
min
Possible uses:
Result:
Comment:
v 1.8.0 1226
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
• if it is a list of points: min returns the minimum of all points as a point (i.e. the
point with the smallest coordinate on the x-axis, in case of equality the point
with the smallest coordinate on the y-axis is chosen. If all the points are equal,
the first one is returned. )
• if it is a map, min returns the minimum among the list of all elements value
• if it is a file, min returns the minimum of the content of the file (that is also a
container)
• if it is a graph, min returns the minimum of the list of the elements of the
graph (that can be the list of edges or vertexes depending on the graph)
• if it is a matrix of int, float or object, min returns the minimum of all the
numerical elements (thus all elements for integer and float matrices)
• if it is a matrix of geometry, min returns the minimum of the list of the geometries
• if it is a list of int or float: min returns the minimum of all the elements
unknown var0 <- min ([100, 23.2, 34.5]); // var0 equals 23.2
See also:
max,
v 1.8.0 1227
GAMA v1.8.0 documentation Chapter 101. Operators
min_of
Possible uses:
Result:
the minimum value of the right-hand expression evaluated on each of the elements of
the left-hand operand
Comment:
in the right-hand operand, the keyword each can be used to represent, in turn, each
of the right-hand operand elements.
Special cases:
• if the left-operand is a map, the keyword each will contain each value
unknown var4 <- [1::2, 3::4, 5::6] min_of (each + 3); // var4 equals 5
Examples:
unknown var0 <- [1,2,4,3,5,7,6,8] min_of (each * 100 ); // var0 equals
100
graph g2 <- as_edge_graph([{1,5}::{12,45},{12,45}::{34,56}]);
unknown var2 <- g2 min_of (length(g2 out_edges_of each) ); // var2
equals 0
unknown var3 <- (list(node) min_of (round(node(each).location.x)); //
var3 equals 4
v 1.8.0 1228
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
max_of,
minus_days
Possible uses:
Result:
Examples:
date var0 <- date('2000-01-01') minus_days 20; // var0 equals date
('1999-12-12')
minus_hours
Possible uses:
Result:
v 1.8.0 1229
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
// equivalent to date1 - 15 #h
date var1 <- date('2000-01-01') minus_hours 15 ; // var1 equals date
('1999-12-31 09:00:00')
minus_minutes
Possible uses:
Result:
Examples:
// date('2000-01-01') to date1 - 5#mn
date var1 <- date('2000-01-01') minus_minutes 5 ; // var1 equals date
('1999-12-31 23:55:00')
minus_months
Possible uses:
v 1.8.0 1230
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Examples:
date var0 <- date('2000-01-01') minus_months 5; // var0 equals date
('1999-08-01')
minus_ms
Possible uses:
Result:
Examples:
// equivalent to date1 - 15 #ms
date var1 <- date('2000-01-01') minus_ms 1000 ; // var1 equals date
('1999-12-31 23:59:59')
minus_seconds
Same signification as -
v 1.8.0 1231
GAMA v1.8.0 documentation Chapter 101. Operators
minus_weeks
Possible uses:
Result:
Examples:
date var0 <- date('2000-01-01') minus_weeks 15; // var0 equals date
('1999-09-18')
minus_years
Possible uses:
Result:
Examples:
date var0 <- date('2000-01-01') minus_years 3; // var0 equals date
('1997-01-01')
v 1.8.0 1232
GAMA v1.8.0 documentation Chapter 101. Operators
mod
Possible uses:
Result:
Returns the remainder of the integer division of the left-hand operand by the right-
hand operand.
Special cases:
Examples:
int var0 <- 40 mod 3; // var0 equals 1
See also:
div,
moment
Possible uses:
v 1.8.0 1233
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Examples:
float var0 <- moment([13,2,1,4,1,2], 2, 1.2) with_precision(4); // var0
equals 24.74
months_between
Possible uses:
Result:
Provide the exact number of months between two dates. This number can be positive
or negative (if the second operand is smaller than the first one)
Examples:
int var0 <- months_between(date('2000-01-01'), date('2000-02-01')); //
var0 equals 1
moran
Possible uses:
v 1.8.0 1234
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
• return the Moran Index of the given list of interest points (list of floats) and
the weight matrix (matrix of float)
float var0 <- moran([1.0, 0.5, 2.0], weight_matrix); // var0 equals the
Moran index is computed
mul
Possible uses:
Result:
Comment:
Special cases:
• if it is a list of points: mul returns the product of all points as a point (each
coordinate is the product of the corresponding coordinate of each element)
• if it is a list of other types: mul transforms all elements into integer and
multiplies them
v 1.8.0 1235
GAMA v1.8.0 documentation Chapter 101. Operators
• if it is a file, mul returns the product of the content of the file (that is also a
container)
• if it is a graph, mul returns the product of the list of the elements of the graph
(that can be the list of edges or vertexes depending on the graph)
• if it is a matrix of int, float or object, mul returns the product of all the
numerical elements (thus all elements for integer and float matrices)
• if it is a matrix of geometry, mul returns the product of the list of the geometries
• if it is a matrix of other types: mul transforms all elements into float and
multiplies them
• if it is a list of int or float: mul returns the product of all the elements
unknown var0 <- mul ([100, 23.2, 34.5]); // var0 equals 80040.0
See also:
sum,
nb_cycles
Possible uses:
Result:
returns the maximum number of independent cycles in a graph. This number (u) is
estimated through the number of nodes (v), links (e) and of sub-graphs (p): u = e -
v + p.
v 1.8.0 1236
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
graph graphEpidemio <- graph([]);
int var1 <- nb_cycles(graphEpidemio); // var1 equals the number of
cycles in the graph
See also:
neighbors_at
Possible uses:
Result:
a list, containing all the agents of the same species than the left argument (if it is
an agent) located at a distance inferior or equal to the right-hand operand to the
left-hand operand (geometry, agent, point).
Comment:
The topology used to compute the neighborhood is the one of the left-operand if this
one is an agent; otherwise the one of the agent applying the operator.
Examples:
list var0 <- (self neighbors_at (10)); // var0 equals all the agents
located at a distance lower or equal to 10 to the agent applying the
operator.
v 1.8.0 1237
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
neighbors_of
Possible uses:
Result:
a list, containing all the agents of the same species than the argument (if it is an
agent) located at a distance inferior or equal to 1 to the right-hand operand agent
considering the left-hand operand topology.
Special cases:
• a list, containing all the agents of the same species than the left argument (if
it is an agent) located at a distance inferior or equal to the third argument to
the second argument (agent, geometry or point) considering the first operand
topology.
list var0 <- neighbors_of (topology(self), self,10); // var0 equals all
the agents located at a distance lower or equal to 10 to the agent
applying the operator considering its topology.
v 1.8.0 1238
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
list var1 <- topology(self) neighbors_of self; // var1 equals returns
all the agents located at a distance lower or equal to 1 to the
agent applying the operator considering its topology.
list var2 <- graphEpidemio neighbors_of (node(3)); // var2 equals [
node0,node2]
list var3 <- graphFromMap neighbors_of node({12,45}); // var3 equals
[{1.0,5.0},{34.0,56.0}]
See also:
new_emotion
Possible uses:
v 1.8.0 1239
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
a new emotion with the given properties (name) a new emotion with the given
properties (name) a new emotion with the given properties (name) a new emotion
with the given properties (name, intensity) a new emotion with the given properties
(name) a new emotion with the given properties (name,intensity,decay) a new emotion
with the given properties (name) a new emotion with the given properties (name) a
new emotion with the given properties (name,about) a new emotion with the given
properties (name) a new emotion with the given properties (name,intensity,about) a
new emotion with the given properties (name)
Examples:
emotion("joy",12.3,eatFood,4)
emotion("joy",12.3,eatFood,4)
emotion("joy",12.3,eatFood,4)
emotion("joy",12.3)
emotion("joy")
emotion("joy",12.3,4.0)
emotion("joy",12.3,eatFood,4)
emotion("joy",12.3,eatFood,4)
emotion("joy",eatFood)
emotion("joy",12.3,eatFood,4)
emotion("joy",12.3,eatFood)
emotion("joy",12.3,eatFood,4)
new_folder
Possible uses:
Result:
v 1.8.0 1240
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
• If the specified string does not refer to an existing repository, the repository is
created.
Examples:
file dirNewT <- new_folder("incl/"); // dirNewT represents the
repository "../incl/"
//
eventually creates the directory ../incl
See also:
folder, file,
new_mental_state
Possible uses:
v 1.8.0 1241
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
a new mental state a new mental state a new mental state a new mental state a new
mental state a new mental state a new mental state a new mental state a new mental
state a new mental state a new mental state a new mental state a new mental state a
new mental state a new mental state a new mental state a new mental state a new
mental state a new mental state a new mental state a new mental state a new mental
state a new mental state a new mental state a new mental state
Examples:
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
v 1.8.0 1242
GAMA v1.8.0 documentation Chapter 101. Operators
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
new_mental-state(belief)
new_predicate
Possible uses:
Result:
a new predicate with the given properties (name, values, agentCause) a new predicate
with the given properties (name, values, is_true) a new predicate with the given
properties (name, values) a new predicate with the given properties (name, values,
is_true, agentCause) a new predicate with the given properties (name, values, lifetime)
v 1.8.0 1243
GAMA v1.8.0 documentation Chapter 101. Operators
a new predicate with the given properties (name) a new predicate with the given
is_true (name, is_true)
Examples:
predicate("people to meet", ["time"::10], agentA)
predicate("people to meet", ["time"::10], true)
predicate("people to meet", people1 )
predicate("people to meet", ["time"::10], true, agentA)
predicate("people to meet", ["time"::10], true)
predicate("people to meet")
predicate("hasWater", true)
new_social_link
Possible uses:
Result:
Examples:
new_social_link(agentA,0.0,-0.1,0.2,0.1)
new_social_link(agentA)
v 1.8.0 1244
GAMA v1.8.0 documentation Chapter 101. Operators
node
Possible uses:
nodes
Possible uses:
none_matches
Possible uses:
Result:
Returns true if none of the elements of the left-hand operand make the right-hand
operand evaluate to true. Returns true if the left-hand operand is empty. ‘c none_-
matches each.property’ is strictly equivalent to ‘(c count each.property) = 0’
Comment:
in the right-hand operand, the keyword each can be used to represent, in turn, each
of the elements.
v 1.8.0 1245
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
Examples:
bool var0 <- [1,2,3,4,5,6,7,8] none_matches (each > 3); // var0 equals
false
bool var1 <- [1::2, 3::4, 5::6] none_matches (each > 4); // var1 equals
false
See also:
none_verifies
norm
Possible uses:
Result:
the norm of the vector with the coordinates of the point operand.
v 1.8.0 1246
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
float var0 <- norm({3,4}); // var0 equals 5.0
Norm
Possible uses:
Result:
normal_area
Possible uses:
Result:
Returns the area to the left of x in the normal distribution with the given mean and
standard deviation.
Examples:
float var0 <- normal_area(0.9,0,1) with_precision(3); // var0 equals
0.816
v 1.8.0 1247
GAMA v1.8.0 documentation Chapter 101. Operators
normal_density
Possible uses:
Result:
Returns the probability of x in the normal distribution with the given mean and
standard deviation.
Examples:
float var0 <- (normal_density(2,1,1)*100) with_precision 2; // var0
equals 24.2
normal_inverse
Possible uses:
Result:
Returns the x in the normal distribution with the given mean and standard deviation,
to the left of which lies the given area. normal.Inverse returns the value in terms of
standard deviations from the mean, so we need to adjust it for the given mean and
standard deviation.
Examples:
float var0 <- normal_inverse(0.98,0,1) with_precision(2); // var0
equals 2.05
v 1.8.0 1248
GAMA v1.8.0 documentation Chapter 101. Operators
normalized_rotation
Possible uses:
Result:
The rotation normalized according to Euler formalism with a positive angle, such that
each rotation has a unique set of parameters (positive angle, normalize axis rotation).
Examples:
pair<float,point> var0 <- normalized_rotation(-38.0::{1,1,1}); // var0
equals
38.0::{-0.5773502691896258,-0.5773502691896258,-0.5773502691896258}
See also:
rotation_composition, inverse_rotation,
not
Same signification as !
not
Possible uses:
v 1.8.0 1249
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Examples:
not predicate1
obj_file
Possible uses:
Result:
Constructs a file of type obj. Allowed extensions are limited to obj, OBJ
Special cases:
• obj_file(string): This file constructor allows to read an obj file. The associated
mlt file have to have the same name as the file to be read.
file f <- obj_file("file.obj");
v 1.8.0 1250
GAMA v1.8.0 documentation Chapter 101. Operators
file f <- obj_file("file.obj", 90.0::{-1,0,0});
See also:
is_obj,
of
Same signification as .
of_generic_species
Possible uses:
v 1.8.0 1251
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
a list, containing the agents of the left-hand operand whose species is that denoted
by the right-hand operand and whose species extends the right-hand operand species
Examples:
// species speciesA {}
// species sub_speciesA parent: speciesA {}
list var2 <- [sub_speciesA(0),sub_speciesA(1),speciesA(2),speciesA(3)]
of_generic_species speciesA; // var2 equals [sub_speciesA0,
sub_speciesA1,speciesA0,speciesA1]
list var3 <- [sub_speciesA(0),sub_speciesA(1),speciesA(2),speciesA(3)]
of_generic_species sous_test; // var3 equals [sub_speciesA0,
sub_speciesA1]
list var4 <- [sub_speciesA(0),sub_speciesA(1),speciesA(2),speciesA(3)]
of_species speciesA; // var4 equals [speciesA0,speciesA1]
list var5 <- [sub_speciesA(0),sub_speciesA(1),speciesA(2),speciesA(3)]
of_species sous_test; // var5 equals [sub_speciesA0,sub_speciesA1]
See also:
of_species,
of_species
Possible uses:
Result:
a list, containing the agents of the left-hand operand whose species is the one denoted
by the right-hand operand.The expression agents of_species (species self) is equivalent
v 1.8.0 1252
GAMA v1.8.0 documentation Chapter 101. Operators
to agents where (species each = species self); however, the advantage of using the
first syntax is that the resulting list is correctly typed with the right species, whereas,
in the second syntax, the parser cannot determine the species of the agents within the
list (resulting in the need to cast it explicitly if it is to be used in an ask statement,
for instance).
Special cases:
Examples:
list var0 <- (self neighbors_at 10) of_species (species (self)); //
var0 equals all the neighboring agents of the same species.
list var1 <- [test(0),test(1),node(1),node(2)] of_species test; // var1
equals [test0,test1]
See also:
of_generic_species,
one_matches
Possible uses:
Result:
Returns true if at least one of the elements of the left-hand operand make the right-
hand operand evaluate to true. Returns false if the left-hand operand is empty. ‘c
one_matches each.property’ is strictly equivalent to ‘(c count each.property) > 0’
but faster in most cases (as it is a shortcircuited operator)
v 1.8.0 1253
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
in the right-hand operand, the keyword each can be used to represent, in turn, each
of the elements.
Special cases:
Examples:
bool var0 <- [1,2,3,4,5,6,7,8] one_matches (each > 3); // var0 equals
true
bool var1 <- [1::2, 3::4, 5::6] one_matches (each > 4); // var1 equals
true
See also:
one_of
Possible uses:
Result:
Comment:
v 1.8.0 1254
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
• if it is a file, one_of returns one of the elements of the content of the file (that
is also a container)
• if it is a list or a matrix, one_of returns one of the values of the list or of the
matrix
i <- any ([1,2,3]); //i equals 1, 2 or 3
string sMat <- one_of(matrix([["c11","c12","c13"],["c21","c22","c23"]])
); // sMat equals "c11","c12","c13", "c21","c22" or "c23"
• if it is a map, one_of returns one the value of a random pair of the map
int im <- one_of ([2::3, 4::5, 6::7]); // im equals 3, 5 or 7
bool var6 <- [2::3, 4::5, 6::7].values contains im; // var6 equals true
See also:
contains,
v 1.8.0 1255
GAMA v1.8.0 documentation Chapter 101. Operators
one_verifies
open_simplex_generator
Possible uses:
Result:
Examples:
float var0 <- open_simplex_generator(2,3,253); // var0 equals 10.2
or
Possible uses:
Result:
a bool value, equal to the logical or between the left-hand operand and the right-hand
operand.
v 1.8.0 1256
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
both operands are always casted to bool before applying the operator. Thus, an
expression like 1 or 0 is accepted and returns true.
Examples:
bool var0 <- true or false; // var0 equals true
bool var1 <- false or false; // var1 equals false
bool var2 <- false or true; // var2 equals true
bool var3 <- true or true; // var3 equals true
int a <-3 ; int b <- 4; int c <- 7;
bool var5 <- ((a+b) = c ) or ((a+b) > c ); // var5 equals true
See also:
bool, and, !,
or
Possible uses:
Result:
create a new predicate from two others by including them as subintentions. It’s an
exclusive “or”
Examples:
predicate1 or predicate2
v 1.8.0 1257
GAMA v1.8.0 documentation Chapter 101. Operators
osm_file
Possible uses:
Result:
Constructs a file of type osm. Allowed extensions are limited to osm, pbf, bz2, gz
Special cases:
• osm_file(string): This file constructor allows to read a osm (.osm, .pbf, .bz2,
.gz) file (using WGS84 coordinate system for the data)
file f <- osm_file("file");
See also:
is_osm,
v 1.8.0 1258
GAMA v1.8.0 documentation Chapter 101. Operators
out_degree_of
Possible uses:
Result:
returns the out degree of a vertex (right-hand operand) in the graph given as left-hand
operand.
Examples:
int var1 <- graphFromMap out_degree_of (node(3)); // var1 equals 4
See also:
in_degree_of, degree_of,
out_edges_of
Possible uses:
Result:
returns the list of the out-edges of a vertex (right-hand operand) in the graph given
as left-hand operand.
v 1.8.0 1259
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
list var1 <- graphFromMap out_edges_of (node(3)); // var1 equals 3
See also:
in_edges_of,
overlapping
Possible uses:
Result:
Examples:
list<geometry> var0 <- [ag1, ag2, ag3] overlapping(self); // var0
equals return the agents among ag1, ag2 and ag3 that overlap the
shape of the agent applying the operator.
(species1 + species2) overlapping self
See also:
v 1.8.0 1260
GAMA v1.8.0 documentation Chapter 101. Operators
overlaps
Possible uses:
Result:
A boolean, equal to true if the left-geometry (or agent/point) overlaps the right-
geometry (or agent/point).
Special cases:
• if one operand is a point, returns true if the point is included in the geometry
Examples:
bool var0 <- polyline([{10,10},{20,20}]) overlaps polyline
([{15,15},{25,25}]); // var0 equals true
bool var1 <- polygon([{10,10},{10,20},{20,20},{20,10}]) overlaps
polygon([{15,15},{15,25},{25,25},{25,15}]); // var1 equals true
bool var2 <- polygon([{10,10},{10,20},{20,20},{20,10}]) overlaps
{25,25}; // var2 equals false
bool var3 <- polygon([{10,10},{10,20},{20,20},{20,10}]) overlaps
polygon([{35,35},{35,45},{45,45},{45,35}]); // var3 equals false
bool var4 <- polygon([{10,10},{10,20},{20,20},{20,10}]) overlaps
polyline([{10,10},{20,20}]); // var4 equals true
bool var5 <- polygon([{10,10},{10,20},{20,20},{20,10}]) overlaps
{15,15}; // var5 equals true
bool var6 <- polygon([{10,10},{10,20},{20,20},{20,10}]) overlaps
polygon([{0,0},{0,30},{30,30}, {30,0}]); // var6 equals true
bool var7 <- polygon([{10,10},{10,20},{20,20},{20,10}]) overlaps
polygon([{15,15},{15,25},{25,25},{25,15}]); // var7 equals true
bool var8 <- polygon([{10,10},{10,20},{20,20},{20,10}]) overlaps
polygon([{10,20},{20,20},{20,30},{10,30}]); // var8 equals true
v 1.8.0 1261
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
pair
Possible uses:
partially_overlaps
Possible uses:
Result:
A boolean, equal to true if the left-geometry (or agent/point) partially overlaps the
right-geometry (or agent/point).
Comment:
if one geometry operand fully covers the other geometry operand, returns false
(contrarily to the overlaps operator).
Special cases:
v 1.8.0 1262
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
bool var0 <- polyline([{10,10},{20,20}]) partially_overlaps polyline
([{15,15},{25,25}]); // var0 equals true
bool var1 <- polygon([{10,10},{10,20},{20,20},{20,10}])
partially_overlaps polygon([{15,15},{15,25},{25,25},{25,15}]); //
var1 equals true
bool var2 <- polygon([{10,10},{10,20},{20,20},{20,10}])
partially_overlaps {25,25}; // var2 equals false
bool var3 <- polygon([{10,10},{10,20},{20,20},{20,10}])
partially_overlaps polygon([{35,35},{35,45},{45,45},{45,35}]); //
var3 equals false
bool var4 <- polygon([{10,10},{10,20},{20,20},{20,10}])
partially_overlaps polyline([{10,10},{20,20}]); // var4 equals false
bool var5 <- polygon([{10,10},{10,20},{20,20},{20,10}])
partially_overlaps {15,15}; // var5 equals false
bool var6 <- polygon([{10,10},{10,20},{20,20},{20,10}])
partially_overlaps polygon([{0,0},{0,30},{30,30}, {30,0}]); // var6
equals false
bool var7 <- polygon([{10,10},{10,20},{20,20},{20,10}])
partially_overlaps polygon([{15,15},{15,25},{25,25},{25,15}]); //
var7 equals true
bool var8 <- polygon([{10,10},{10,20},{20,20},{20,10}])
partially_overlaps polygon([{10,20},{20,20},{20,30},{10,30}]); //
var8 equals false
See also:
path
Possible uses:
v 1.8.0 1263
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Special cases:
• if the operand is a geometry of an agent, returns a path from the list of points
of the geometry
• if the operand is a list, cast each element of the list as a point and create a
path from these points
path p <- path([{12,12},{30,30},{50,50}]);
path_between
Possible uses:
Result:
The shortest path between two objects according to set of cells with corresponding
weights The shortest path between two objects according to set of cells The shortest
v 1.8.0 1264
GAMA v1.8.0 documentation Chapter 101. Operators
path between several objects according to set of cells The shortest path between a
list of two objects in a graph The shortest path between several objects according to
set of cells with corresponding weights
Examples:
path var0 <- path_between (cell_grid as_map (each::each.is_obstacle ?
9999.0 : 1.0), ag1, ag2); // var0 equals A path between ag1 and ag2
passing through the given cell_grid agents with a minimal cost
path var1 <- path_between (cell_grid where each.is_free, ag1, ag2); //
var1 equals A path between ag1 and ag2 passing through the given
cell_grid agents
path var2 <- my_topology path_between (ag1, ag2); // var2 equals A path
between ag1 and ag2
path var3 <- path_between (cell_grid where each.is_free, [ag1, ag2, ag3
]); // var3 equals A path between ag1 and ag2 and ag3 passing
through the given cell_grid agents
path var4 <- my_topology path_between [ag1, ag2]; // var4 equals A path
between ag1 and ag2
path var5 <- path_between (my_graph, ag1, ag2); // var5 equals A path
between ag1 and ag2
path var6 <- path_between (cell_grid as_map (each::each.is_obstacle ?
9999.0 : 1.0), [ag1, ag2, ag3]); // var6 equals A path between ag1
and ag2 and ag3 passing through the given cell_grid agents with
minimal cost
See also:
path_to
Possible uses:
v 1.8.0 1265
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
A path between two geometries (geometries, agents or points) considering the topology
of the agent applying the operator.
Examples:
path var0 <- ag1 path_to ag2; // var0 equals the path between ag1 and
ag2 considering the topology of the agent applying the operator
See also:
paths_between
Possible uses:
Result:
Examples:
list<path> var0 <- paths_between(my_graph, ag1:: ag2, 2); // var0
equals the 2 shortest paths (ordered by length) between ag1 and ag2
v 1.8.0 1266
GAMA v1.8.0 documentation Chapter 101. Operators
pbinom
Same signification as binomial_sum
pchisq
Same signification as chi_square
percent_absolute_deviation
Possible uses:
Result:
Examples:
float var0 <- percent_absolute_deviation
([200,300,150,150,200],[250,250,100,200,200]); // var0 equals 20.0
percentile
Same signification as quantile_inverse
v 1.8.0 1267
GAMA v1.8.0 documentation Chapter 101. Operators
pgamma
Same signification as gamma_distribution
pgm_file
Possible uses:
Result:
Special cases:
See also:
is_pgm,
plan
Possible uses:
v 1.8.0 1268
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Special cases:
Examples:
geometry var0 <- polyplan([{0,0}, {0,10}, {10,10}, {10,0}],10); // var0
equals a polyline geometry composed of the 4 points with a depth of
10.
See also:
around, circle, cone, link, norm, point, polygone, rectangle, square, triangle,
plus_days
Possible uses:
Result:
v 1.8.0 1269
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
date var0 <- date('2000-01-01') plus_days 12; // var0 equals date
('2000-01-13')
plus_hours
Possible uses:
Result:
Examples:
// equivalent to date1 + 15 #h
date var1 <- date('2000-01-01') plus_hours 24; // var1 equals date
('2000-01-02')
plus_minutes
Possible uses:
Result:
v 1.8.0 1270
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
// equivalent to date1 + 5 #mn
date var1 <- date('2000-01-01') plus_minutes 5 ; // var1 equals date
('2000-01-01 00:05:00')
plus_months
Possible uses:
Result:
Examples:
date var0 <- date('2000-01-01') plus_months 5; // var0 equals date
('2000-06-01')
plus_ms
Possible uses:
Result:
v 1.8.0 1271
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
// equivalent to date('2000-01-01') + 15 #ms
date var1 <- date('2000-01-01') plus_ms 1000 ; // var1 equals date
('2000-01-01 00:00:01')
plus_seconds
Same signification as +
plus_weeks
Possible uses:
Result:
Examples:
date var0 <- date('2000-01-01') plus_weeks 15; // var0 equals date
('2000-04-15')
v 1.8.0 1272
GAMA v1.8.0 documentation Chapter 101. Operators
plus_years
Possible uses:
Result:
Examples:
date var0 <- date('2000-01-01') plus_years 15; // var0 equals date
('2015-01-01')
pnorm
point
Possible uses:
v 1.8.0 1273
GAMA v1.8.0 documentation Chapter 101. Operators
points_along
Possible uses:
Result:
A list of points along the operand-geometry given its location in terms of rate of
distance from the starting points of the geometry.
Examples:
list var0 <- line([{10,10},{80,80}]) points_along ([0.3, 0.5, 0.9]);
// var0 equals the list of following points:
[{31.0,31.0,0.0},{45.0,45.0,0.0},{73.0,73.0,0.0}]
See also:
points_at
Possible uses:
Result:
v 1.8.0 1274
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
list<point> var0 <- 3 points_at(20.0); // var0 equals returns [pt1, pt2
, pt3] with pt1, pt2 and pt3 located at a distance of 20.0 to the
agent location
See also:
points_on
Possible uses:
Result:
A list of points of the operand-geometry distant from each other to the float right-
operand .
Examples:
list var0 <- square(5) points_on(2); // var0 equals a list of points
belonging to the exterior ring of the square distant from each other
of 2.
See also:
v 1.8.0 1275
GAMA v1.8.0 documentation Chapter 101. Operators
poisson
Possible uses:
Result:
A value from a random variable following a Poisson distribution (with the positive
expected number of occurence lambda as operand).
Comment:
Examples:
int var0 <- poisson(3.5); // var0 equals a random positive integer
See also:
binomial, gauss,
polygon
Possible uses:
v 1.8.0 1276
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Special cases:
Examples:
geometry var0 <- polygon([{0,0}, {0,10}, {10,10}, {10,0}]); // var0
equals a polygon geometry composed of the 4 points.
float var1 <- polygon([{0,0}, {0,10}, {10,10}, {10,0}]).area; // var1
equals 100.0
point var2 <- polygon([{0,0}, {0,10}, {10,10}, {10,0}]).location; //
var2 equals point(5.0,5.0,0.0)
See also:
around, circle, cone, line, link, norm, point, polyline, rectangle, square, triangle,
polyhedron
Possible uses:
Result:
v 1.8.0 1277
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
Examples:
geometry var0 <- polyhedron([{0,0}, {0,10}, {10,10}, {10,0}],10); //
var0 equals a polygon geometry composed of the 4 points and of depth
10.
See also:
around, circle, cone, line, link, norm, point, polyline, rectangle, square, triangle,
polyline
polyplan
v 1.8.0 1278
GAMA v1.8.0 documentation Chapter 101. Operators
predecessors_of
Possible uses:
Result:
returns the list of predecessors (i.e. sources of in edges) of the given vertex (right-hand
operand) in the given graph (left-hand operand)
Examples:
list var1 <- graphEpidemio predecessors_of ({1,5}); // var1 equals []
list var2 <- graphEpidemio predecessors_of node({34,56}); // var2
equals [{12;45}]
See also:
neighbors_of, successors_of,
predicate
Possible uses:
Result:
v 1.8.0 1279
GAMA v1.8.0 documentation Chapter 101. Operators
predict
Possible uses:
Result:
returns the value predict by the regression parameters for a given instance. Usage:
predict(regression, instance)
Examples:
predict(my_regression, [1,2,3])
product
Same signification as mul
product_of
Possible uses:
Result:
the product of the right-hand expression evaluated on each of the elements of the
left-hand operand
v 1.8.0 1280
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
in the right-hand operand, the keyword each can be used to represent, in turn, each
of the right-hand operand elements.
Special cases:
• if the left-operand is a map, the keyword each will contain each value
unknown var1 <- [1::2, 3::4, 5::6] product_of (each); // var1 equals 48
Examples:
unknown var0 <- [1,2] product_of (each * 10 ); // var0 equals 200
See also:
promethee_DM
Possible uses:
Result:
The index of the best candidate according to the Promethee II method. This method
is based on a comparison per pair of possible candidates along each criterion: all can-
didates are compared to each other by pair and ranked. More information about this
v 1.8.0 1281
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
Examples:
int var0 <- promethee_DM([[1.0, 7.0],[4.0,2.0],[3.0, 3.0]], [["name"::"
utility", "weight" :: 2.0,"p"::0.5, "q"::0.0, "s"::1.0, "maximize"
:: true],["name"::"price", "weight" :: 1.0,"p"::0.5, "q"::0.0, "s"
::1.0, "maximize" :: false]]); // var0 equals 1
See also:
property_file
Possible uses:
v 1.8.0 1282
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Special cases:
file f <-property_file("file.properties");
file f <-property_file("file.properties", map(["param1"::1.0,"param3"
::10.0 ]));
See also:
is_property,
pValue_for_fStat
Possible uses:
v 1.8.0 1283
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Returns the P value of F statistic fstat with numerator degrees of freedom dfn and
denominator degress of freedom dfd. Uses the incomplete Beta function.
Examples:
float var0 <- pValue_for_fStat(1.9,10,12) with_precision(3); // var0
equals 0.145
pValue_for_tStat
Possible uses:
Result:
Returns the P value of the T statistic tstat with df degrees of freedom. This is a
two-tailed test so we just double the right tail which is given by studentT of -|tstat|.
Examples:
float var0 <- pValue_for_tStat(0.9,10) with_precision(3); // var0
equals 0.389
pyramid
Possible uses:
v 1.8.0 1284
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Comment:
the center of the pyramid is by default the location of the current agent in which has
been called this operator.
Special cases:
Examples:
geometry var0 <- pyramid(5); // var0 equals a geometry as a square with
side_size = 5.
See also:
around, circle, cone, line, link, norm, point, polygon, polyline, rectangle, square,
quantile
Possible uses:
v 1.8.0 1285
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Returns the phi-quantile; that is, an element elem for which holds that phi percent of
data elements are less than elem. The quantile need not necessarily be contained in
the data sequence, it can be a linear interpolation. Note that the container holding
the values must be sorted first
Examples:
float var0 <- quantile
([1,3,5,6,9,11,12,13,19,21,22,32,35,36,45,44,55,68,79,80,81,88,90,91,92,100],
0.5); // var0 equals 35.5
quantile_inverse
Possible uses:
Result:
Returns how many percent of the elements contained in the receiver are <= element.
Does linear interpolation if the element is not contained but lies in between two
contained elements. Note that the container holding the values must be sorted first
Examples:
float var0 <- quantile_inverse
([1,3,5,6,9,11,12,13,19,21,22,32,35,36,45,44,55,68,79,80,81,88,90,91,92,100],
35.5) with_precision(2); // var0 equals 0.52
v 1.8.0 1286
GAMA v1.8.0 documentation Chapter 101. Operators
R_correlation
Same signification as corR
R_file
Possible uses:
Result:
Special cases:
See also:
is_R,
v 1.8.0 1287
GAMA v1.8.0 documentation Chapter 101. Operators
R_mean
range
Possible uses:
Result:
Allows to build a list of int representing all contiguous values from the first to the
second argument. The range can be increasing or decreasing. Passing the same
value for both will return a singleton list with this value Allows to build a list of int
representing all contiguous values from the first to the second argument, using the
step represented by the third argument. The range can be increasing or decreasing.
Passing the same value for both will return a singleton list with this value. Passing a
step of 0 will result in an exception. Attempting to build infinite ranges (e.g. end >
start with a negative step) will similarly not be accepted and yield an exception Allows
to build a list of int representing all contiguous values from zero to the argument.
The range can be increasing or decreasing. Passing 0 will return a singleton list with
0
Examples:
list var0 <- range(0,2); // var0 equals [0,1,2]
v 1.8.0 1288
GAMA v1.8.0 documentation Chapter 101. Operators
rank_interpolated
Possible uses:
Result:
Returns the linearly interpolated number of elements in a list less or equal to a given
element. The rank is the number of elements <= element. Ranks are of the form {0,
1, 2,. . . , sortedList.size()}. If no element is <= element, then the rank is zero. If the
element lies in between two contained elements, then linear interpolation is used and
a non integer value is returned. Note that the container holding the values must be
sorted first
Examples:
float var0 <- rank_interpolated
([1,3,5,6,9,11,12,13,19,21,22,32,35,36,45,44,55,68,79,80,81,88,90,91,92,100],
35); // var0 equals 13.0
read
Possible uses:
Result:
Reads an attribute of the agent. The attribute’s name is specified by the operand.
v 1.8.0 1289
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
agent_name <- read ('name'); //agent_name equals reads the 'name'
variable of agent then assigns the returned value to the 'agent_name
' variable.
rectangle
Possible uses:
Result:
Comment:
the center of the rectangle is by default the location of the current agent in which
has been called this operator.the center of the rectangle is by default the location of
the current agent in which has been called this operator.
Special cases:
v 1.8.0 1290
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
geometry var0 <- rectangle(10, 5); // var0 equals a geometry as a
rectangle with width = 10 and height = 5.
float var1 <- rectangle(10, 5).area; // var1 equals 50.0
geometry var2 <- rectangle({0.0,0.0}, {10.0,10.0}); // var2 equals a
geometry as a rectangle with {1.0,1.0} as the upper-left corner,
{10.0,10.0} as the lower-right corner.
float var3 <- rectangle({0.0,0.0}, {10.0,10.0}).area; // var3 equals
100.0
geometry var4 <- rectangle({10, 5}); // var4 equals a geometry as a
rectangle with width = 10 and height = 5.
float var5 <- rectangle({10, 5}).area; // var5 equals 50.0
See also:
around, circle, cone, line, link, norm, point, polygon, polyline, square, triangle,
reduced_by
Same signification as -
regression
Possible uses:
v 1.8.0 1291
GAMA v1.8.0 documentation Chapter 101. Operators
remove_duplicates
Same signification as distinct
remove_node_from
Possible uses:
Result:
Comment:
WARNING / side effect: this operator modifies the operand and does not create a
new graph. All the edges containing this node are also removed.
Examples:
graph var0 <- node(0) remove_node_from graphEpidemio; // var0 equals
the graph without node(0)
replace
Possible uses:
v 1.8.0 1292
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Returns the String resulting by replacing for the first operand all the sub-strings
corresponding the second operand by the third operand
Examples:
string var0 <- replace('to be or not to be,that is the question','to',
'do'); // var0 equals 'do be or not do be,that is the question'
See also:
replace_regex,
replace_regex
Possible uses:
Result:
Returns the String resulting by replacing for the first operand all the sub-strings
corresponding to the regular expression given in the second operand by the third
operand
Examples:
string var0 <- replace_regex("colour, color", "colou?r", "col"); //
var0 equals 'col, col'
v 1.8.0 1293
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
replace,
restore_simulation
Possible uses:
Result:
restore_simulation
restore_simulation_from_file
Possible uses:
• restore_simulation_from_file (ummisco.gama.serializer.gaml.
GamaSavedSimulationFile) —> int
Result:
restoreSimulationFromFile
v 1.8.0 1294
GAMA v1.8.0 documentation Chapter 101. Operators
reverse
Possible uses:
Result:
Comment:
Special cases:
• if it is a graph, reverse returns a copy of the graph (with all edges and vertexes),
with all of the edges reversed
• if it is a list, reverse returns a copy of the operand list with elements in the
reversed order
list<int> var0 <- reverse ([10,12,14]); // var0 equals [14, 12, 10]
• if it is a map, reverse returns a copy of the operand map with each pair in the
reversed order (i.e. all keys become values and values become keys)
v 1.8.0 1295
GAMA v1.8.0 documentation Chapter 101. Operators
map<int,string> var1 <- reverse (['k1'::44, 'k2'::32, 'k3'::12]); //
var1 equals [44::'k1', 32::'k2', 12::'k3']
Examples:
map<int,int> m <- [1::111,2::222, 3::333, 4::444];
map var5 <- reverse(m); // var5 equals map
([111::1,222::2,333::3,444::4])
rewire_n
Possible uses:
Result:
v 1.8.0 1296
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
WARNING / side effect: this operator modifies the operand and does not create a
new graph. If there are too many edges, all the edges will be rewired.
Examples:
graph var1 <- graphEpidemio rewire_n 10; // var1 equals the graph with
3 edges rewired
rgb
Possible uses:
Result:
Returns a color defined by red, green, blue components and an alpha blending value.
Special cases:
• It can be used with a name of color and alpha (between 0 and 255)
v 1.8.0 1297
GAMA v1.8.0 documentation Chapter 101. Operators
• It can be used with r=red, g=green, b=blue (each between 0 and 255), a=alpha
(between 0 and 255)
• It can be used with r=red, g=green, b=blue, each between 0 and 255
• It can be used with r=red, g=green, b=blue (each between 0 and 255), a=alpha
(between 0.0 and 1.0)
Examples:
rgb var0 <- rgb ("red"); // var0 equals rgb(255,0,0)
rgb var1 <- rgb(rgb(255,0,0),0.5); // var1 equals a light red color
rgb var2 <- rgb (255,0,0,125); // var2 equals a light red color
rgb var4 <- rgb (255,0,0); // var4 equals #red
rgb var5 <- rgb(rgb(255,0,0),125); // var5 equals a light red color
rgb var6 <- rgb (255,0,0,0.5); // var6 equals a light red color
See also:
hsb,
rgb
Possible uses:
v 1.8.0 1298
GAMA v1.8.0 documentation Chapter 101. Operators
rms
Possible uses:
Result:
Returns the RMS (Root-Mean-Square) of a data sequence. The RMS of data sequence
is the square-root of the mean of the squares of the elements in the data sequence. It
is a measure of the average size of the elements of a data sequence.
Examples:
list<float> data_sequence <- [6.0, 7.0, 8.0, 9.0];
list<float> squares <- data_sequence collect (each*each);
float var2 <- rms(length(data_sequence),sum(squares)) with_precision
(4) ; // var2 equals 7.5829
rnd
Possible uses:
v 1.8.0 1299
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Comment:
Special cases:
• if the operand is a point, returns a point with three random float ordinates,
each in the interval [0, ordinate of argument]
Examples:
int var0 <- rnd (2, 4); // var0 equals 2, 3 or 4
point var1 <- rnd ({2.0, 4.0}, {2.0, 5.0, 10.0}, 1); // var1 equals a
point with x = 2.0, y equal to 2.0, 3.0 or 4.0 and z between 0.0 and
10.0 every 1.0
float var2 <- rnd (2.0, 4.0, 0.5); // var2 equals a float number
between 2.0 and 4.0 every 0.5
float var3 <- rnd(3.4); // var3 equals a random float between 0.0 and
3.4
float var4 <- rnd (2.0, 4.0); // var4 equals a float number between 2.0
and 4.0
point var5 <- rnd ({2.0, 4.0}, {2.0, 5.0, 10.0}); // var5 equals a
point with x = 2.0, y between 2.0 and 4.0 and z between 0.0 and 10.0
point var6 <- rnd ({2.5,3, 0.0}); // var6 equals {x,y} with x in
[0.0,2.0], y in [0.0,3.0], z = 0.0
int var7 <- rnd (2); // var7 equals 0, 1 or 2
float var8 <- rnd (1000) / 1000; // var8 equals a float between 0 and 1
with a precision of 0.001
int var9 <- rnd (2, 12, 4); // var9 equals 2, 6 or 10
v 1.8.0 1300
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
flip,
rnd_choice
Possible uses:
Result:
returns an index of the given list with a probability following the (normalized)
distribution described in the list (a form of lottery)
Examples:
int var0 <- rnd_choice([0.2,0.5,0.3]); // var0 equals 2/10 chances to
return 0, 5/10 chances to return 1, 3/10 chances to return 2
See also:
rnd,
rnd_color
Possible uses:
v 1.8.0 1301
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Comment:
Examples:
rgb var0 <- rnd_color(100, 200); // var0 equals a random color,
equivalent to rgb(rnd(100, 200),rnd(100, 200),rnd(100, 200))
rgb var1 <- rnd_color(255); // var1 equals a random color, equivalent
to rgb(rnd(255),rnd(255),rnd(255))
See also:
rgb, hsb,
rotated_by
Possible uses:
v 1.8.0 1302
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
A geometry resulting from the application of the right-hand rotation operand (angles
in degree) to the left-hand operand (geometry, agent, point) A geometry resulting
from the application of a rotation by the operand angles (degree) along the operand
axis to the left-hand operand (geometry, agent, point) A geometry resulting from the
application of a rotation by the right-hand operand angle (degree) to the left-hand
operand (geometry, agent, point)
Comment:
the right-hand operand can be a float or a intreturn a vector that results from
Examples:
geometry var0 <- rotated_by(pyramid(10),45.0::{1,0,0}); // var0 equals
the geometry resulting from a 45 degrees rotation along the {1,0,0}
vector to the geometry of the agent applying the operator.
geometry var1 <- rotated_by(pyramid(10),45.0, {1,0,0}); // var1 equals
the geometry resulting from a 45 degrees rotation along the {1,0,0}
vector to the geometry of the agent applying the operator.
geometry var2 <- self rotated_by 45; // var2 equals the geometry
resulting from a 45 degrees rotation to the geometry of the agent
applying the operator.
See also:
transformed_by, translated_by,
rotation_composition
Possible uses:
v 1.8.0 1303
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
The rotation resulting from the composition of the rotations in the list, from left to
right. Angles are in degrees.
Examples:
pair<float,point> var0 <- rotation_composition
([38.0::{1,1,1},90.0::{1,0,0}]); // var0 equals
115.22128507898108::{0.9491582126366207,0.31479943993669307,-0.0}
See also:
inverse_rotation,
round
Possible uses:
Result:
Special cases:
v 1.8.0 1304
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
point var0 <- {12345.78943, 12345.78943, 12345.78943} with_precision
2; // var0 equals {12345.79,12345.79,12345.79}
int var1 <- round (0.51); // var1 equals 1
int var2 <- round (100.2); // var2 equals 100
int var3 <- round(-0.51); // var3 equals -1
See also:
row_at
Possible uses:
Result:
Examples:
list<unknown> var0 <- matrix([["el11","el12","el13"],["el21","el22","
el23"],["el31","el32","el33"]]) row_at 2; // var0 equals ["el13","
el23","el33"]
See also:
column_at, columns_list,
v 1.8.0 1305
GAMA v1.8.0 documentation Chapter 101. Operators
rows_list
Possible uses:
Result:
returns a list of the rows of the matrix, with each row as a list of elements
Examples:
list<list<unknown>> var0 <- rows_list(matrix([["el11","el12","el13"],["
el21","el22","el23"],["el31","el32","el33"]])); // var0 equals [["
el11","el21","el31"],["el12","el22","el32"],["el13","el23","el33"]]
See also:
columns_list,
sample
Possible uses:
Result:
takes a sample of the specified size from the elements of x using either with or without
replacement with given weights takes a sample of the specified size from the elements
of x using either with or without replacement
v 1.8.0 1306
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
list var0 <- sample([2,10,1],2,false,[0.1,0.7,0.2]); // var0 equals
[10,2]
list var1 <- sample([2,10,1],2,false); // var1 equals [10,1]
Sanction
Possible uses:
Result:
save_agent
Possible uses:
save_simulation
Possible uses:
v 1.8.0 1307
GAMA v1.8.0 documentation Chapter 101. Operators
saved_simulation_file
Possible uses:
Result:
Special cases:
See also:
is_saved_simulation,
v 1.8.0 1308
GAMA v1.8.0 documentation Chapter 101. Operators
scaled_by
Same signification as *
scaled_to
Possible uses:
Result:
allows to restrict the size of a geometry so that it fits in the envelope {width, height,
depth} defined by the second operand
Examples:
geometry var0 <- shape scaled_to {10,10}; // var0 equals a geometry
corresponding to the geometry of the agent applying the operator
scaled so that it fits a square of 10x10
select
v 1.8.0 1309
GAMA v1.8.0 documentation Chapter 101. Operators
serialize
Possible uses:
Result:
serialize_agent
Possible uses:
set_about
Possible uses:
Result:
Examples:
emotion set_about predicate1
v 1.8.0 1310
GAMA v1.8.0 documentation Chapter 101. Operators
set_agent
Possible uses:
Result:
Examples:
social_link set_agent agentA
set_agent_cause
Possible uses:
Result:
change the agentCause value of the given predicate change the agentCause value of
the given emotion
Examples:
predicate set_agent_cause agentA
emotion set_agent_cause agentA
v 1.8.0 1311
GAMA v1.8.0 documentation Chapter 101. Operators
set_decay
Possible uses:
Result:
Examples:
emotion set_decay 12
set_dominance
Possible uses:
Result:
Examples:
social_link set_dominance 0.4
v 1.8.0 1312
GAMA v1.8.0 documentation Chapter 101. Operators
set_familiarity
Possible uses:
Result:
Examples:
social_link set_familiarity 0.4
set_intensity
Possible uses:
Result:
Examples:
emotion set_intensity 12
v 1.8.0 1313
GAMA v1.8.0 documentation Chapter 101. Operators
set_lifetime
Possible uses:
Result:
Examples:
mental state set_lifetime 1
set_liking
Possible uses:
Result:
Examples:
social_link set_liking 0.4
v 1.8.0 1314
GAMA v1.8.0 documentation Chapter 101. Operators
set_modality
Possible uses:
Result:
Examples:
mental state set_modality belief
set_predicate
Possible uses:
Result:
Examples:
mental state set_predicate pred1
v 1.8.0 1315
GAMA v1.8.0 documentation Chapter 101. Operators
set_solidarity
Possible uses:
Result:
Examples:
social_link set_solidarity 0.4
set_strength
Possible uses:
Result:
Examples:
mental state set_strength 1.0
v 1.8.0 1316
GAMA v1.8.0 documentation Chapter 101. Operators
set_trust
Possible uses:
Result:
Examples:
social_link set_familiarity 0.4
set_truth
Possible uses:
Result:
Examples:
predicate set_truth false
v 1.8.0 1317
GAMA v1.8.0 documentation Chapter 101. Operators
set_z
Possible uses:
Result:
Sets the z ordinate of the n-th point of a geometry to the value provided by the third
argument
Examples:
triangle(3) set_z [5,10,14]
set_z (triangle(3), 1, 3.0)
shape_file
Possible uses:
Result:
v 1.8.0 1318
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
v 1.8.0 1319
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
is_shape,
shuffle
Possible uses:
Result:
Special cases:
Examples:
matrix var0 <- shuffle (matrix([["c11","c12","c13"],["c21","c22","c23"
]])); // var0 equals matrix([["c12","c21","c11"],["c13","c22","c23
"]]) (for example)
string var1 <- shuffle ('abc'); // var1 equals 'bac' (for example)
list var2 <- shuffle ([12, 13, 14]); // var2 equals [14,12,13] (for
example)
See also:
reverse,
v 1.8.0 1320
GAMA v1.8.0 documentation Chapter 101. Operators
signum
Possible uses:
Result:
Examples:
int var0 <- signum(-12); // var0 equals -1
int var1 <- signum(14); // var1 equals 1
int var2 <- signum(0); // var2 equals 0
simple_clustering_by_distance
Possible uses:
Result:
A list of agent groups clustered by distance considering a distance min between two
groups.
v 1.8.0 1321
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
list<list<agent>> var0 <- [ag1, ag2, ag3, ag4, ag5]
simpleClusteringByDistance 20.0; // var0 equals for example, can
return [[ag1, ag3], [ag2], [ag4, ag5]]
See also:
hierarchical_clustering,
simple_clustering_by_envelope_distance
Same signification as simple_clustering_by_distance
simplex_generator
Possible uses:
Result:
Examples:
float var0 <- simplex_generator(2,3,253); // var0 equals
0.0976676931220678
v 1.8.0 1322
GAMA v1.8.0 documentation Chapter 101. Operators
simplification
Possible uses:
Result:
Comment:
Examples:
geometry var0 <- self simplification 0.1; // var0 equals the geometry
resulting from the application of the Douglas-Peuker algorithm on
the geometry of the agent applying the operator with a tolerance
distance of 0.1.
sin
Possible uses:
Result:
Returns the value (in [-1,1]) of the sinus of the operand (in decimal degrees). The
argument is casted to an int before being evaluated.
v 1.8.0 1323
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
Examples:
float var0 <- sin(360) with_precision 10 with_precision 10; // var0
equals 0.0
float var1 <- sin (0); // var1 equals 0.0
See also:
cos, tan,
sin_rad
Possible uses:
Result:
Returns the value (in [-1,1]) of the sinus of the operand (in radians).
Examples:
float var0 <- sin_rad(0); // var0 equals 0.0
float var1 <- sin_rad(#pi/2); // var1 equals 1.0
See also:
cos_rad, tan_rad,
v 1.8.0 1324
GAMA v1.8.0 documentation Chapter 101. Operators
since
Possible uses:
Result:
Returns true if the current_date of the model is after (or equal to) the date passed in
argument. Synonym of ‘current_date >= argument’. Can be used, like ‘after’, in its
composed form with 2 arguments to express the lowest boundary of the computation
of a frequency. However, contrary to ‘after’, there is a subtle difference: the lowest
boundary will be tested against the frequency as well
Examples:
reflex when: since(starting_date) {} // this reflex will always be
run
every(2#days) since (starting_date + 1#day) // the computation will
return true 1 day after the starting date and every two days after
this reference date
skeletonize
Possible uses:
v 1.8.0 1325
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Examples:
list<geometry> var0 <- skeletonize(self); // var0 equals the list of
geometries corresponding to the skeleton of the geometry of the
agent applying the operator.
list<geometry> var1 <- skeletonize(self); // var1 equals the list of
geometries corresponding to the skeleton of the geometry of the
agent applying the operator.
list<geometry> var2 <- skeletonize(self); // var2 equals the list of
geometries corresponding to the skeleton of the geometry of the
agent applying the operator.
list<geometry> var3 <- skeletonize(self); // var3 equals the list of
geometries corresponding to the skeleton of the geometry of the
agent applying the operator.
skew
Possible uses:
v 1.8.0 1326
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Returns the skew of a data sequence when the 3rd moment has already been computed.
Returns the skew of a data sequence, which is moment(data,3,mean) / standardDevi-
ation3
Comment:
Examples:
float var0 <- skew(-10.125,4.407785) with_precision(2); // var0 equals
-0.12
float var1 <- skew([1,3,5,6,9,11,12,13]) with_precision(2); // var1
equals -0.14
skew_gauss
Possible uses:
Result:
A value from a skew normally distributed random variable with min value
(the minimum skewed value possible), max value (the maximum skewed val-
ue possible), skew (the degree to which the values cluster around the mode
v 1.8.0 1327
GAMA v1.8.0 documentation Chapter 101. Operators
of the distribution; higher values mean tighter clustering) and bias (the ten-
dency of the mode to approach the min, max or midpoint value; positive
values bias toward max, negative values toward min).The algorithm was tak-
en from http://stackoverflow.com/questions/5853187/skewing-java-random-number-
generation-toward-a-certain-number
Examples:
float var0 <- skew_gauss(0.0, 1.0, 0.7,0.1); // var0 equals
0.1729218460343077
See also:
skewness
Possible uses:
Result:
Special cases:
Examples:
float var0 <- skewness ([1,2,3,4,5]); // var0 equals 0.0
v 1.8.0 1328
GAMA v1.8.0 documentation Chapter 101. Operators
skill
Possible uses:
smooth
Possible uses:
Result:
Examples:
geometry var0 <- smooth(square(10), 0.0); // var0 equals a 'rounded'
square
social_link
Possible uses:
v 1.8.0 1329
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
solid
sort
sort_by
Possible uses:
Result:
Returns a list, containing the elements of the left-hand operand sorted in ascending
order by the value of the right-hand operand when it is evaluated on them.
Comment:
the left-hand operand is casted to a list before applying the operator. In the right-hand
operand, the keyword each can be used to represent, in turn, each of the elements.
v 1.8.0 1330
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
• if the left-hand operand is nil, sort_by throws an error. If the sorting function
returns values that cannot be compared, an error will be thrown as well
Examples:
list var0 <- [1,2,4,3,5,7,6,8] sort_by (each); // var0 equals
[1,2,3,4,5,6,7,8]
list var2 <- g2 sort_by (length(g2 out_edges_of each) ); // var2 equals
[node9, node7, node10, node8, node11, node6, node5, node4]
list var3 <- (list(node) sort_by (round(node(each).location.x)); //
var3 equals [node5, node1, node0, node2, node3]
list var4 <- [1::2, 5::6, 3::4] sort_by (each); // var4 equals [2, 4,
6]
See also:
group_by,
source_of
Possible uses:
Result:
returns the source of the edge (right-hand operand) contained in the graph given in
left-hand operand.
Special cases:
v 1.8.0 1331
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
graph graphEpidemio <- generate_barabasi_albert( ["edges_species"::edge
,"vertices_specy"::node,"size"::3,"m"::5] );
unknown var1 <- graphEpidemio source_of(edge(3)); // var1 equals node1
graph graphFromMap <- as_edge_graph([{1,5}::{12,45},{12,45}::{34,56}])
;
point var3 <- graphFromMap source_of(link({1,5},{12,45})); // var3
equals {1,5}
See also:
target_of,
spatial_graph
Possible uses:
Result:
allows to create a spatial graph from a container of vertices, without trying to wire
them. The container can be empty. Emits an error if the contents of the container
are not geometries, points or agents
See also:
graph,
v 1.8.0 1332
GAMA v1.8.0 documentation Chapter 101. Operators
species
Possible uses:
Result:
Special cases:
• if the operand is a string, returns the species with this name (nil if not found);
Examples:
species var0 <- species(self); // var0 equals the species of the
current agent
species var1 <- species('node'); // var1 equals node
species var2 <- species([1,5,9,3]); // var2 equals nil
species var3 <- species(node1); // var3 equals node
species_of
Same signification as species
v 1.8.0 1333
GAMA v1.8.0 documentation Chapter 101. Operators
sphere
Possible uses:
Result:
Comment:
the centre of the sphere is by default the location of the current agent in which has
been called this operator.
Special cases:
Examples:
geometry var0 <- sphere(10); // var0 equals a geometry as a circle of
radius 10 but displays a sphere.
See also:
around, cone, line, link, norm, point, polygon, polyline, rectangle, square, triangle,
split
Possible uses:
v 1.8.0 1334
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Examples:
list<list<unknown>> var0 <- split([1.0,2.0,1.0,3.0,1.0,2.0]); // var0
equals [[1.0,1.0,1.0],[2.0,2.0],[3.0]]
See also:
split_in, split_using,
split_at
Possible uses:
Result:
The two part of the left-operand lines split at the given right-operand point
Special cases:
v 1.8.0 1335
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
list<geometry> var0 <- polyline([{1,2},{4,6}]) split_at {7,6}; // var0
equals [polyline([{1.0,2.0},{7.0,6.0}]), polyline
([{7.0,6.0},{4.0,6.0}])]
split_geometry
Possible uses:
Result:
A list of geometries that result from the decomposition of the geometry according
to a grid with the given number of rows and columns (geometry, nb_cols, nb_rows)
A list of geometries that result from the decomposition of the geometry by square
cells of the given side size (geometry, size) A list of geometries that result from the
decomposition of the geometry by rectangle cells of the given dimension (geometry,
{size_x, size_y})
Examples:
list<geometry> var0 <- to_rectangles(self, 10,20); // var0 equals the
list of the geometries corresponding to the decomposition of the
geometry of the agent applying the operator
list<geometry> var1 <- to_squares(self, 10.0); // var1 equals the list
of the geometries corresponding to the decomposition of the geometry
by squares of side size 10.0
list<geometry> var2 <- to_rectangles(self, {10.0, 15.0}); // var2
equals the list of the geometries corresponding to the decomposition
of the geometry by rectangles of size 10.0, 15.0
v 1.8.0 1336
GAMA v1.8.0 documentation Chapter 101. Operators
split_in
Possible uses:
Result:
Splits a list of numbers into n bins defined by n-1 bounds between the minimum
and maximum values found in the first argument. The boolean argument controls
whether or not the splitting is strict (if true, elements are in the ith bin if they are
strictly smaller than the ith bound) Splits a list of numbers into n bins defined by
n-1 bounds between the minimum and maximum values found in the first argument.
The splitting is strict (i.e. elements are in the ith bin if they are strictly smaller than
the ith bound)
Examples:
list<float> l <- [1.0,3.1,5.2,6.0,9.2,11.1,12.0,13.0,19.9,35.9,40.0];
list<list<unknown>> var1 <- split_in(l,3, true); // var1 equals
[[1.0,3.1,5.2,6.0,9.2,11.1,12.0,13.0],[19.9],[35.9,40.0]]
list<float> li <- [1.0,3.1,5.2,6.0,9.2,11.1,12.0,13.0,19.9,35.9,40.0];
list<list<unknown>> var3 <- split_in(li,3); // var3 equals
[[1.0,3.1,5.2,6.0,9.2,11.1,12.0,13.0],[19.9],[35.9,40.0]]
See also:
split, split_using,
v 1.8.0 1337
GAMA v1.8.0 documentation Chapter 101. Operators
split_lines
Possible uses:
Result:
A list of geometries resulting after cutting the lines at their intersections. A list of
geometries resulting after cutting the lines at their intersections. if the last boolean
operand is set to true, the split lines will import the attributes of the initial lines
Examples:
list<geometry> var0 <- split_lines([line([{0,10}, {20,10}]), line
([{0,10}, {20,10}])]); // var0 equals a list of four polylines: line
([{0,10}, {10,10}]), line([{10,10}, {20,10}]), line([{10,0},
{10,10}]) and line([{10,10}, {10,20}])
list<geometry> var1 <- split_lines([line([{0,10}, {20,10}]), line
([{0,10}, {20,10}])]); // var1 equals a list of four polylines: line
([{0,10}, {10,10}]), line([{10,10}, {20,10}]), line([{10,0},
{10,10}]) and line([{10,10}, {10,20}])
split_using
Possible uses:
v 1.8.0 1338
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Splits a list of numbers into n+1 bins using a set of n bounds passed as the second
argument. The boolean argument controls whether or not the splitting is strict (if
true, elements are in the ith bin if they are strictly smaller than the ith bound Splits a
list of numbers into n+1 bins using a set of n bounds passed as the second argument.
The splitting is strict (i.e. elements are in the ith bin if they are strictly smaller than
the ith bound
Examples:
list<float> l <- [1.0,3.1,5.2,6.0,9.2,11.1,12.0,13.0,19.9,35.9,40.0];
list<list<unknown>> var1 <- split_using(l,[1.0,3.0,4.2], true); // var1
equals [[],[1.0],[3.1],[5.2,6.0,9.2,11.1,12.0,13.0,19.9,35.9,40.0]]
list<float> li <- [1.0,3.1,5.2,6.0,9.2,11.1,12.0,13.0,19.9,35.9,40.0];
list<list<unknown>> var3 <- split_using(li,[1.0,3.0,4.2]); // var3
equals [[],[1.0],[3.1],[5.2,6.0,9.2,11.1,12.0,13.0,19.9,35.9,40.0]]
See also:
split, split_in,
split_with
Possible uses:
Result:
Returns a list containing the sub-strings (tokens) of the left-hand operand delimited
by each of the characters of the right-hand operand. Returns a list containing the
sub-strings (tokens) of the left-hand operand delimited either by each of the characters
of the right-hand operand (false) or by the whole right-hand operand (true).
v 1.8.0 1339
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
Delimiters themselves are excluded from the resulting list.Delimiters themselves are
excluded from the resulting list.
Examples:
list var0 <- 'to be or not to be,that is the question' split_with ' ,';
// var0 equals ['to','be','or','not','to','be','that','is','the','
question']
list var1 <- 'aa::bb:cc' split_with ('::', true); // var1 equals ['aa
','bb:cc']
sqrt
Possible uses:
Result:
Special cases:
Examples:
float var0 <- sqrt(4); // var0 equals 2.0
float var1 <- sqrt(4); // var1 equals 2.0
v 1.8.0 1340
GAMA v1.8.0 documentation Chapter 101. Operators
square
Possible uses:
Result:
Comment:
the centre of the square is by default the location of the current agent in which has
been called this operator.
Special cases:
Examples:
geometry var0 <- square(10); // var0 equals a geometry as a square of
side size 10.
float var1 <- var0.area; // var1 equals 100.0
See also:
around, circle, cone, line, link, norm, point, polygon, polyline, rectangle, triangle,
squircle
Possible uses:
v 1.8.0 1341
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Comment:
the center of the ellipse is by default the location of the current agent in which has
been called this operator.
Special cases:
Examples:
geometry var0 <- squircle(4,4); // var0 equals a geometry as a squircle
of side 4 with a power of 4.
See also:
around, cone, line, link, norm, point, polygon, polyline, super_ellipse, rectangle,
square, circle, ellipse, triangle,
stack
Possible uses:
v 1.8.0 1342
GAMA v1.8.0 documentation Chapter 101. Operators
standard_deviation
Possible uses:
Result:
the standard deviation on the elements of the operand. See Standard_deviation for
more details.
Comment:
The operator casts all the numerical element of the list into float. The elements that
are not numerical are discarded.
Examples:
float var0 <- standard_deviation ([4.5, 3.5, 5.5, 7.0]); // var0 equals
1.2930100540985752
See also:
mean, mean_deviation,
step_sub_model
Possible uses:
Result:
Load a submodel
v 1.8.0 1343
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
loaded submodel
strahler
Possible uses:
Result:
string
Possible uses:
Result:
converts a date to astring following a custom pattern and using a specific locale
(e.g.: ‘fr’, ‘en’, etc.). The pattern can use “%Y %M %N %D %E %h %m %s %z”
for outputting years, months, name of month, days, name of days, hours, minutes,
seconds and the time-zone. A null or empty pattern will return the complete date as
defined by the ISO date & time format. The pattern can also follow the pattern
definition found here, which gives much more control over the format of the date: http-
s://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#patterns.
v 1.8.0 1344
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
string(#now, 'yyyy-MM-dd')
string(#now, 'yyyy-MM-dd')
student_area
Possible uses:
Result:
Returns the area to the left of x in the Student T distribution with the given degrees
of freedom.
Examples:
float var0 <- student_area(1.64,3) with_precision(2); // var0 equals
0.9
v 1.8.0 1345
GAMA v1.8.0 documentation Chapter 101. Operators
student_t_inverse
Possible uses:
Result:
Returns the value, t, for which the area under the Student-t probability density
function (integrated from minus infinity to t) is equal to x.
Examples:
float var0 <- student_t_inverse(0.9,3) with_precision(2); // var0
equals 1.64
subtract_days
Same signification as minus_days
subtract_hours
Same signification as minus_hours
subtract_minutes
Same signification as minus_minutes
v 1.8.0 1346
GAMA v1.8.0 documentation Chapter 101. Operators
subtract_months
Same signification as minus_months
subtract_ms
Same signification as minus_ms
subtract_seconds
Same signification as -
subtract_weeks
Same signification as minus_weeks
subtract_years
Same signification as minus_years
successors_of
Possible uses:
v 1.8.0 1347
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
returns the list of successors (i.e. targets of out edges) of the given vertex (right-hand
operand) in the given graph (left-hand operand)
Examples:
list var1 <- graphEpidemio successors_of ({1,5}); // var1 equals
[{12,45}]
list var2 <- graphEpidemio successors_of node({34,56}); // var2 equals
[]
See also:
predecessors_of, neighbors_of,
sum
Possible uses:
Result:
Comment:
v 1.8.0 1348
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
• if it is a file, sum returns the sum of the content of the file (that is also a
container)
• if it is a matrix of int, float or object, sum returns the sum of all the numerical
elements (i.e. all elements for integer and float matrices)
• if it is a matrix of other types: sum transforms all elements into float and sums
them
• if it is a list of colors: sum will sum them and return the blended resulting color
• if it is a list of int or float: sum returns the sum of all the elements
int var0 <- sum ([12,10,3]); // var0 equals 25
• if it is a list of points: sum returns the sum of all points as a point (each
coordinate is the sum of the corresponding coordinate of each element)
unknown var1 <- sum([{1.0,3.0},{3.0,5.0},{9.0,1.0},{7.0,8.0}]); // var1
equals {20.0,17.0}
See also:
mul,
v 1.8.0 1349
GAMA v1.8.0 documentation Chapter 101. Operators
sum_of
Possible uses:
Result:
the sum of the right-hand expression evaluated on each of the elements of the left-hand
operand
Comment:
in the right-hand operand, the keyword each can be used to represent, in turn, each
of the right-hand operand elements.
Special cases:
• if the left-operand is a map, the keyword each will contain each value
unknown var1 <- [1::2, 3::4, 5::6] sum_of (each + 3); // var1 equals 21
Examples:
unknown var0 <- [1,2] sum_of (each * 100 ); // var0 equals 300
See also:
v 1.8.0 1350
GAMA v1.8.0 documentation Chapter 101. Operators
svg_file
Possible uses:
Result:
Special cases:
See also:
is_svg,
tan
Possible uses:
v 1.8.0 1351
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Returns the value (in [-1,1]) of the trigonometric tangent of the operand (in decimal
degrees).
Special cases:
• Operand values out of the range [0-359] are normalized. Notice that tan(360)
does not return 0.0 but -2.4492935982947064E-16
• The tangent is only defined for any real number except 90 + k * 180 (k
an positive or negative integer). Nevertheless notice that tan(90) returns
1.633123935319537E16 (whereas we could except infinity).
Examples:
float var0 <- tan (0); // var0 equals 0.0
float var1 <- tan(90); // var1 equals 1.633123935319537E16
See also:
cos, sin,
tan_rad
Possible uses:
Result:
Returns the value (in [-1,1]) of the trigonometric tangent of the operand (in radians).
v 1.8.0 1352
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
float var0 <- tan_rad(0); // var0 equals 0.0
See also:
cos_rad, sin_rad,
tanh
Possible uses:
Result:
Returns the value (in the interval [-1,1]) of the hyperbolic tangent of the operand
(which can be any real number, expressed in decimal degrees).
Examples:
float var0 <- tanh(0); // var0 equals 0.0
float var1 <- tanh(100); // var1 equals 1.0
target_of
Possible uses:
v 1.8.0 1353
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
returns the target of the edge (right-hand operand) contained in the graph given in
left-hand operand.
Special cases:
Examples:
graph graphEpidemio <- generate_barabasi_albert( ["edges_species"::edge
,"vertices_specy"::node,"size"::3,"m"::5] );
unknown var1 <- graphEpidemio source_of(edge(3)); // var1 equals node1
graph graphFromMap <- as_edge_graph([{1,5}::{12,45},{12,45}::{34,56}])
;
unknown var3 <- graphFromMap target_of(link({1,5},{12,45})); // var3
equals {12,45}
See also:
source_of,
teapot
Possible uses:
Result:
v 1.8.0 1354
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
the centre of the teapot is by default the location of the current agent in which has
been called this operator.
Special cases:
Examples:
geometry var0 <- teapot(10); // var0 equals a geometry as a circle of
radius 10 but displays a teapot.
See also:
around, cone, line, link, norm, point, polygon, polyline, rectangle, square, triangle,
text_file
Possible uses:
Result:
Constructs a file of type text. Allowed extensions are limited to txt, data, text
v 1.8.0 1355
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
• text_file(string): This file constructor allows to read a text file (.txt, .data,
.text)
file f <-text_file("file.txt");
See also:
is_text,
TGauss
Same signification as truncated_gauss
threeds_file
Possible uses:
Result:
Constructs a file of type threeds. Allowed extensions are limited to 3ds, max
v 1.8.0 1356
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
• threeds_file(string): This file constructor allows to read a 3DS Max file. Only
loads vertices and faces
threeds_file f <- threeds_file("file");
See also:
is_threeds,
to
Possible uses:
Result:
builds an interval between two dates (the first inclusive and the second exclusive,
which behaves like a read-only list of dates. The default step between two dates is
the step of the model
Comment:
The default step can be overruled by using the every operator applied to this interval
v 1.8.0 1357
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
date('2000-01-01') to date('2010-01-01') // builds an interval between
these two dates
(date('2000-01-01') to date('2010-01-01')) every (#month) // builds an
interval between these two dates which contains all the monthly
dates starting from the beginning of the interval
See also:
every,
to_GAMA_CRS
Possible uses:
Special cases:
v 1.8.0 1358
GAMA v1.8.0 documentation Chapter 101. Operators
geometry var1 <- to_GAMA_CRS({121,14}); // var1 equals a geometry
corresponding to the agent geometry transformed into the GAMA CRS
to_gaml
Possible uses:
Result:
Examples:
string var0 <- to_gaml(0); // var0 equals '0'
string var1 <- to_gaml(3.78); // var1 equals '3.78'
string var2 <- to_gaml(true); // var2 equals 'true'
string var3 <- to_gaml({23, 4.0}); // var3 equals '{23.0,4.0,0.0}'
string var4 <- to_gaml(5::34); // var4 equals '5::34'
string var5 <- to_gaml(rgb(255,0,125)); // var5 equals 'rgb (255, 0,
125,255)'
string var6 <- to_gaml('hello'); // var6 equals "'hello'"
string var7 <- to_gaml([1,5,9,3]); // var7 equals '[1,5,9,3]'
string var8 <- to_gaml(['a'::345, 'b'::13, 'c'::12]); // var8 equals "
map(['a'::345,'b'::13,'c'::12])"
string var9 <- to_gaml([[3,5,7,9],[2,4,6,8]]); // var9 equals
'[[3,5,7,9],[2,4,6,8]]'
string var10 <- to_gaml(a_graph); // var10 equals ([((1 as node)::(3 as
node))::(5 as edge),((0 as node)::(3 as node))::(3 as edge),((1 as
node)::(2 as node))::(1 as edge),((0 as node)::(2 as node))::(2 as
edge),((0 as node)::(1 as node))::(0 as edge),((2 as node)::(3 as
node))::(4 as edge)] as map ) as graph
string var11 <- to_gaml(node1); // var11 equals 1 as node
v 1.8.0 1359
GAMA v1.8.0 documentation Chapter 101. Operators
to_rectangles
Possible uses:
Result:
A list of rectangles of the size corresponding to the given dimension that result from
the decomposition of the geometry into rectangles (geometry, dimension, overlaps), if
overlaps = true, add the rectangles that overlap the border of the geometry A list of
rectangles corresponding to the given dimension that result from the decomposition
of the geometry into rectangles (geometry, nb_cols, nb_rows, overlaps) by a grid
composed of the given number of columns and rows, if overlaps = true, add the
rectangles that overlap the border of the geometry
Examples:
list<geometry> var0 <- to_rectangles(self, {10.0, 15.0}, true); // var0
equals the list of rectangles of size {10.0, 15.0} corresponding to
the discretization into rectangles of the geometry of the agent
applying the operator. The rectangles overlapping the border of the
geometry are kept
list<geometry> var1 <- to_rectangles(self, 5, 20, true); // var1 equals
the list of rectangles corresponding to the discretization by a
grid of 5 columns and 20 rows into rectangles of the geometry of the
agent applying the operator. The rectangles overlapping the border
of the geometry are kept
v 1.8.0 1360
GAMA v1.8.0 documentation Chapter 101. Operators
to_segments
Possible uses:
Result:
A list of a segments resulting from the decomposition of the geometry (or its contours
for polygons) into sgements
Examples:
list<geometry> var0 <- to_segments(line([{10,10},{80,10},{80,80}])); //
var0 equals [line([{10,10},{80,10}]), line([{80,10},{80,80}])]
to_squares
Possible uses:
Result:
A list of a given number of squares from the decomposition of the geometry into
squares (geometry, nb_square, overlaps, precision_coefficient), if overlaps = true, add
the squares that overlap the border of the geometry, coefficient_precision should be
close to 1.0 A list of a given number of squares from the decomposition of the geometry
into squares (geometry, nb_square, overlaps), if overlaps = true, add the squares
that overlap the border of the geometry A list of squares of the size corresponding
to the given size that result from the decomposition of the geometry into squares
(geometry, size, overlaps), if overlaps = true, add the squares that overlap the border
of the geometry
v 1.8.0 1361
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
list<geometry> var0 <- to_squares(self, 10, true, 0.99); // var0 equals
the list of 10 squares corresponding to the discretization into
squares of the geometry of the agent applying the operator. The
squares overlapping the border of the geometry are kept
list<geometry> var1 <- to_squares(self, 10, true); // var1 equals the
list of 10 squares corresponding to the discretization into squares
of the geometry of the agent applying the operator. The squares
overlapping the border of the geometry are kept
list<geometry> var2 <- to_squares(self, 10.0, true); // var2 equals the
list of squares of side size 10.0 corresponding to the
discretization into squares of the geometry of the agent applying
the operator. The squares overlapping the border of the geometry are
kept
to_sub_geometries
Possible uses:
Result:
A list of geometries resulting after spliting the geometry into sub-geometries. A list
of geometries resulting after spliting the geometry into sub-geometries.
Examples:
list<geometry> var0 <- to_sub_geometries(rectangle(10, 50), [0.1, 0.5,
0.4], 1.0); // var0 equals a list of three geometries corresponding
to 3 sub-geometries using cubes of 1m size
list<geometry> var1 <- to_sub_geometries(rectangle(10, 50), [0.1, 0.5,
0.4]); // var1 equals a list of three geometries corresponding to 3
sub-geometries
v 1.8.0 1362
GAMA v1.8.0 documentation Chapter 101. Operators
to_triangles
Same signification as triangulate
tokenize
Same signification as split_with
topology
Possible uses:
Result:
Special cases:
v 1.8.0 1363
GAMA v1.8.0 documentation Chapter 101. Operators
• otherwise, casts the operand to a geometry and build a topology from it.
Examples:
topology var0 <- topology(0); // var0 equals nil
topology(a_graph) --: Multiple topology in POLYGON
((24.712119771887785 7.867357373616512, 24.712119771887785
61.283226839310565, 82.4013676510046 7.867357373616512)) at
location[53.556743711446195;34.57529210646354]
See also:
geometry,
topology
Possible uses:
touches
Possible uses:
v 1.8.0 1364
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
A boolean, equal to true if the left-geometry (or agent/point) touches the right-
geometry (or agent/point).
Comment:
returns true when the left-operand only touches the right-operand. When one
geometry covers partially (or fully) the other one, it returns false.
Special cases:
Examples:
bool var0 <- polyline([{10,10},{20,20}]) touches {15,15}; // var0
equals false
bool var1 <- polyline([{10,10},{20,20}]) touches {10,10}; // var1
equals true
bool var2 <- {15,15} touches {15,15}; // var2 equals false
bool var3 <- polyline([{10,10},{20,20}]) touches polyline
([{10,10},{5,5}]); // var3 equals true
bool var4 <- polyline([{10,10},{20,20}]) touches polyline
([{5,5},{15,15}]); // var4 equals false
bool var5 <- polyline([{10,10},{20,20}]) touches polyline
([{15,15},{25,25}]); // var5 equals false
bool var6 <- polygon([{10,10},{10,20},{20,20},{20,10}]) touches polygon
([{15,15},{15,25},{25,25},{25,15}]); // var6 equals false
bool var7 <- polygon([{10,10},{10,20},{20,20},{20,10}]) touches polygon
([{10,20},{20,20},{20,30},{10,30}]); // var7 equals true
bool var8 <- polygon([{10,10},{10,20},{20,20},{20,10}]) touches polygon
([{10,10},{0,10},{0,0},{10,0}]); // var8 equals true
bool var9 <- polygon([{10,10},{10,20},{20,20},{20,10}]) touches
{15,15}; // var9 equals false
bool var10 <- polygon([{10,10},{10,20},{20,20},{20,10}]) touches
{10,15}; // var10 equals true
v 1.8.0 1365
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
towards
Possible uses:
Result:
The direction (in degree) between the two geometries (geometries, agents, points)
considering the topology of the agent applying the operator.
Examples:
float var0 <- ag1 towards ag2; // var0 equals the direction between ag1
and ag2 and ag3 considering the topology of the agent applying the
operator
See also:
trace
Possible uses:
v 1.8.0 1366
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
The trace of the given matrix (the sum of the elements on the main diagonal).
Examples:
float var0 <- trace(matrix([[1,2],[3,4]])); // var0 equals 5
transformed_by
Possible uses:
Result:
Examples:
geometry var0 <- self transformed_by {45, 0.5}; // var0 equals the
geometry resulting from 45 degrees rotation and 50% scaling of the
geometry of the agent applying the operator.
See also:
rotated_by, translated_by,
v 1.8.0 1367
GAMA v1.8.0 documentation Chapter 101. Operators
translated_by
Possible uses:
Result:
Examples:
geometry var0 <- self translated_by {10,10,10}; // var0 equals the
geometry resulting from applying the translation to the left-hand
geometry (or agent).
See also:
rotated_by, transformed_by,
translated_to
Same signification as at_location
transpose
Possible uses:
v 1.8.0 1368
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Examples:
matrix var0 <- transpose(matrix([[5,-3],[6,-4]])); // var0 equals
matrix([[5,6],[-3,-4]])
triangle
Possible uses:
Result:
A triangle geometry which side size is given by the operand. A triangle geometry
which the base and height size are given by the operand.
Comment:
the center of the triangle is by default the location of the current agent in which has
been called this operator.the center of the triangle is by default the location of the
current agent in which has been called this operator.
Special cases:
v 1.8.0 1369
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
geometry var0 <- triangle(5); // var0 equals a geometry as a triangle
with side_size = 5.
geometry var1 <- triangle(5, 10); // var1 equals a geometry as a
triangle with a base of 5m and a height of 10m.
See also:
around, circle, cone, line, link, norm, point, polygon, polyline, rectangle, square,
triangulate
Possible uses:
Result:
v 1.8.0 1370
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
list<geometry> var0 <- triangulate(self); // var0 equals the list of
geometries (triangles) corresponding to the Delaunay triangulation
of the geometry of the agent applying the operator.
list<geometry> var1 <- triangulate(self,0.1, 1.0); // var1 equals the
list of geometries (triangles) corresponding to the Delaunay
triangulation of the geometry of the agent applying the operator.
list<geometry> var2 <- triangulate([line([{0,50},{100,50}]), line
([{50,0},{50,100}])); // var2 equals the list of geometries (
triangles) corresponding to the Delaunay triangulation of the
geometry of the agent applying the operator.
list<geometry> var3 <- triangulate(self, 0.1); // var3 equals the list
of geometries (triangles) corresponding to the Delaunay
triangulation of the geometry of the agent applying the operator.
list<geometry> var4 <- triangulate(self,0.1, 1.0); // var4 equals the
list of geometries (triangles) corresponding to the Delaunay
triangulation of the geometry of the agent applying the operator.
truncated_gauss
Possible uses:
Result:
A random value from a normally distributed random variable in the interval ]mean -
standardDeviation; mean + standardDeviation[.
Special cases:
v 1.8.0 1371
GAMA v1.8.0 documentation Chapter 101. Operators
• if the operand is a list, only the two first elements are taken into account as
[mean, standardDeviation]
• when truncated_gauss is called with a list of only one element mean, it will
always return 0.0
Examples:
float var0 <- truncated_gauss ({0, 0.3}); // var0 equals a float
between -0.3 and 0.3
float var1 <- truncated_gauss ([0.5, 0.0]); // var1 equals 0.5
See also:
gauss,
type_of
Possible uses:
Result:
Examples:
string var0 <- string(type_of("a string")); // var0 equals "string"
string var1 <- string(type_of([1,2,3,4,5])); // var1 equals "list<int>"
geometry g0 <- to_GAMA_CRS({121,14}, "EPSG:4326");
string var3 <- string(type_of(g0)); // var3 equals "point"
v 1.8.0 1372
GAMA v1.8.0 documentation Chapter 101. Operators
undirected
Possible uses:
Result:
Comment:
WARNING / side effect: this operator modifies the operand and does not create a
new graph.
See also:
directed,
union
Possible uses:
Result:
returns a new list containing all the elements of both containers without duplicated
elements.
v 1.8.0 1373
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
Examples:
geometry var0 <- union([geom1, geom2, geom3]); // var0 equals a
geometry corresponding to union between geom1, geom2 and geom3
list var1 <- [1,2,3,4,5,6] union [2,4,9]; // var1 equals
[1,2,3,4,5,6,9]
list var2 <- [1,2,3,4,5,6] union [0,8]; // var2 equals
[1,2,3,4,5,6,0,8]
list var3 <- [1,3,2,4,5,6,8,5,6] union [0,8]; // var3 equals
[1,3,2,4,5,6,8,0]
See also:
inter, +,
unknown
Possible uses:
until
Possible uses:
v 1.8.0 1374
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
Returns true if the current_date of the model is before (or equel to) the date passed
in argument. Synonym of ‘current_date <= argument’
Examples:
reflex when: until(starting_date) {} // This reflex will be run only
once at the beginning of the simulation
upper_case
Possible uses:
Result:
Examples:
string var0 <- upper_case("Abc"); // var0 equals 'ABC'
See also:
lower_case,
v 1.8.0 1375
GAMA v1.8.0 documentation Chapter 101. Operators
use_cache
Possible uses:
Result:
if the second operand is true, the operand graph will store in a cache all the previously
computed shortest path (the cache be cleared if the graph is modified).
Comment:
WARNING / side effect: this operator modifies the operand and does not create a
new graph.
See also:
path_between,
user_input
Possible uses:
Result:
asks the user for some values (not defined as parameters). Takes a string (optional)
and a map as arguments. The string is used to specify the message of the dialog
v 1.8.0 1376
GAMA v1.8.0 documentation Chapter 101. Operators
box. The map is to specify the parameters you want the user to change before the
simulation starts, with the name of the parameter in string key, and the default value
as value.
Comment:
This operator takes a map [string::value] as argument, displays a dialog asking the
user for these values, and returns the same map with the modified values (if any).
The dialog is modal and will interrupt the execution of the simulation until the user
has either dismissed or accepted it. It can be used, for instance, in an init section to
force the user to input new values instead of relying on the initial values of parameters
:
Examples:
map<string,unknown> values <- user_input(["Number" :: 100, "Location"
:: {10, 10}]);
create bug number: int(values at "Number") with: [location:: (point(
values at "Location"))];
map<string,unknown> values2 <- user_input("Enter numer of agents and
locations",["Number" :: 100, "Location" :: {10, 10}]);
create bug number: int(values2 at "Number") with: [location:: (point(
values2 at "Location"))];
using
Possible uses:
Result:
v 1.8.0 1377
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
Examples:
unknown var0 <- (agents closest_to self) using topology(world); // var0
equals the closest agent to self (the caller) in the continuous
topology of the world
variance
Possible uses:
Result:
the variance of the elements of the operand. See Variance for more details.
Comment:
The operator casts all the numerical element of the list into float. The elements that
are not numerical are discarded.
Examples:
float var0 <- variance ([4.5, 3.5, 5.5, 7.0]); // var0 equals 1.671875
See also:
mean, median,
v 1.8.0 1378
GAMA v1.8.0 documentation Chapter 101. Operators
variance
Possible uses:
Result:
Comment:
In the example we consider variance of [1,3,5,7]. The size is 4, the sum is 1+3+5+7=16
and the sum of squares is 84.The variance is (84- 16ˆ2/4)/4. CQFD.
Examples:
int var0 <- int(variance(4,16,84)); // var0 equals 5
int var1 <- int(variance([1,3,5,6,9,11,12,13])); // var1 equals 17
variance_of
Possible uses:
Result:
the variance of the right-hand expression evaluated on each of the elements of the
left-hand operand
v 1.8.0 1379
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
in the right-hand operand, the keyword each can be used to represent, in turn, each
of the right-hand operand elements.
Examples:
float var0 <- [1,2,3,4,5,6] variance_of each with_precision 2; // var0
equals 2.92
See also:
vertical
Possible uses:
voronoi
Possible uses:
v 1.8.0 1380
GAMA v1.8.0 documentation Chapter 101. Operators
Result:
A list of geometries corresponding to the Voronoi diagram built from the list of points
A list of geometries corresponding to the Voronoi diagram built from the list of points
according to the given clip
Examples:
list<geometry> var0 <- voronoi
([{10,10},{50,50},{90,90},{10,90},{90,10}]); // var0 equals the list
of geometries corresponding to the Voronoi Diagram built from the
list of points.
list<geometry> var1 <- voronoi
([{10,10},{50,50},{90,90},{10,90},{90,10}], square(300)); // var1
equals the list of geometries corresponding to the Voronoi Diagram
built from the list of points with a square of 300m side size as
clip.
weight_of
Possible uses:
Result:
returns the weight of the given edge (right-hand operand) contained in the graph
given in right-hand operand.
Comment:
In a localized graph, an edge has a weight by default (the distance between both
vertices).
v 1.8.0 1381
GAMA v1.8.0 documentation Chapter 101. Operators
Special cases:
• if the right-hand operand is not an edge of the given graph, weight_of checks
whether it is a node of the graph and tries to return its weight
Examples:
graph graphFromMap <- as_edge_graph([{1,5}::{12,45},{12,45}::{34,56}])
;
float var1 <- graphFromMap weight_of(link({1,5},{12,45})); // var1
equals 1.0
weighted_means_DM
Possible uses:
Result:
The index of the candidate that maximizes the weighted mean of its criterion values.
The first operand is the list of candidates (a candidate is a list of criterion values);
the second operand the list of criterion (list of map)
Special cases:
v 1.8.0 1382
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
int var0 <- weighted_means_DM([[1.0, 7.0],[4.0,2.0],[3.0, 3.0]], [["
name"::"utility", "weight" :: 2.0],["name"::"price", "weight" ::
1.0]]); // var0 equals 1
See also:
where
Possible uses:
Result:
a list containing all the elements of the left-hand operand that make the right-hand
operand evaluate to true.
Comment:
in the right-hand operand, the keyword each can be used to represent, in turn, each
of the right-hand operand elements.
Special cases:
• if the left-hand operand is a list nil, where returns a new empty list
• if the left-operand is a map, the keyword each will contain each value
list var4 <- [1::2, 3::4, 5::6] where (each >= 4); // var4 equals [4,
6]
v 1.8.0 1383
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
list var0 <- [1,2,3,4,5,6,7,8] where (each > 3); // var0 equals [4, 5,
6, 7, 8]
list var2 <- g2 where (length(g2 out_edges_of each) = 0 ); // var2
equals [node9, node7, node10, node8, node11]
list var3 <- (list(node) where (round(node(each).location.x) > 32); //
var3 equals [node2, node3]
See also:
with_max_of
Possible uses:
Result:
one of elements of the left-hand operand that maximizes the value of the right-hand
operand
Comment:
in the right-hand operand, the keyword each can be used to represent, in turn, each
of the right-hand operand elements.
Special cases:
• if the left-hand operand is nil, with_max_of returns the default value of the
right-hand operand
v 1.8.0 1384
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
unknown var0 <- [1,2,3,4,5,6,7,8] with_max_of (each ); // var0 equals 8
unknown var2 <- g2 with_max_of (length(g2 out_edges_of each) ) ; //
var2 equals node4
unknown var3 <- (list(node) with_max_of (round(node(each).location.x));
// var3 equals node3
unknown var4 <- [1::2, 3::4, 5::6] with_max_of (each); // var4 equals 6
See also:
where, with_min_of,
with_min_of
Possible uses:
Result:
one of elements of the left-hand operand that minimizes the value of the right-hand
operand
Comment:
in the right-hand operand, the keyword each can be used to represent, in turn, each
of the right-hand operand elements.
Special cases:
• if the left-hand operand is nil, with_max_of returns the default value of the
right-hand operand
v 1.8.0 1385
GAMA v1.8.0 documentation Chapter 101. Operators
Examples:
unknown var0 <- [1,2,3,4,5,6,7,8] with_min_of (each ); // var0 equals 1
unknown var2 <- g2 with_min_of (length(g2 out_edges_of each) ); //
var2 equals node11
unknown var3 <- (list(node) with_min_of (round(node(each).location.x));
// var3 equals node0
unknown var4 <- [1::2, 3::4, 5::6] with_min_of (each); // var4 equals 2
See also:
where, with_max_of,
with_optimizer_type
Possible uses:
Result:
Comment:
the right-hand operand can be “Djikstra”, “Bellmann”, “Astar” to use the associated
algorithm. Note that these methods are dynamic: the path is computed when needed.
In contrarily, if the operand is another string, a static method will be used, i.e. all
the shortest are previously computed.
Examples:
graphEpidemio <- graphEpidemio with_optimizer_type "static";
v 1.8.0 1386
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
set_verbose,
with_precision
Possible uses:
Result:
Rounds off the value of left-hand operand to the precision given by the value of right-
hand operand A geometry corresponding to the rounding of points of the operand
considering a given precison. Rounds off the ordinates of the left-hand point to the
precision given by the value of right-hand operand
Examples:
float var0 <- 12345.78943 with_precision 2; // var0 equals 12345.79
float var1 <- 123 with_precision 2; // var1 equals 123.00
geometry var2 <- self with_precision 2; // var2 equals the geometry
resulting from the rounding of points of the geometry with a
precision of 0.1.
point var3 <- {12345.78943, 12345.78943, 12345.78943} with_precision 2
; // var3 equals {12345.79, 12345.79, 12345.79}
v 1.8.0 1387
GAMA v1.8.0 documentation Chapter 101. Operators
See also:
round,
with_values
Possible uses:
Result:
Examples:
predicate with_values ["time"::10]
with_weights
Possible uses:
Result:
returns the graph (left-hand operand) with weight given in the map (right-hand
operand).
v 1.8.0 1388
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
WARNING / side effect: this operator modifies the operand and does not create a
new graph. It also re-initializes the path finder
Special cases:
• if the right-hand operand is a list, assigns the n elements of the list to the n
first edges. Note that the ordering of edges may change overtime, which can
create some problems. . .
• if the left-hand operand is a map, the map should contains pairs such as:
vertex/edge::double
graph_from_edges (list(ant) as_map each::one_of (list(ant)))
with_weights (list(ant) as_map each::each.food)
without_holes
Possible uses:
Result:
Examples:
geometry var0 <- solid(self); // var0 equals the geometry corresponding
to the geometry of the agent applying the operator without its
holes.
v 1.8.0 1389
GAMA v1.8.0 documentation Chapter 101. Operators
writable
Possible uses:
Result:
Marks the file as read-only or not, depending on the second boolean argument, and
returns the first argument
Comment:
A file is created using its native flags. This operator can change them. Beware that
this change is system-wide (and not only restrained to GAMA): changing a file to
read-only mode (e.g. “writable(f, false)”)
Examples:
file var0 <- shape_file("../images/point_eau.shp") writable false; //
var0 equals returns a file in read-only mode
See also:
file,
v 1.8.0 1390
GAMA v1.8.0 documentation Chapter 101. Operators
xml_file
Possible uses:
Result:
Special cases:
See also:
is_xml,
xor
Possible uses:
Result:
a bool value, equal to the logical xor between the left-hand operand and the right-hand
operand. False when they are equal
v 1.8.0 1391
GAMA v1.8.0 documentation Chapter 101. Operators
Comment:
both operands are always casted to bool before applying the operator. Thus, an
expression like 1 xor 0 is accepted and returns true.
Examples:
bool var0 <- xor(true,false); // var0 equals true
bool var1 <- xor(false,false); // var1 equals false
bool var2 <- xor(false,true); // var2 equals true
bool var3 <- xor(true,true); // var3 equals false
bool var4 <- true xor true; // var4 equals false
See also:
or, and, !,
years_between
Possible uses:
Result:
Provide the exact number of years between two dates. This number can be positive
or negative (if the second operand is smaller than the first one)
Examples:
int var0 <- years_between(date('2000-01-01'), date('2010-01-01')); //
var0 equals 10
v 1.8.0 1392
Chapter 102
This file is automatically generated from java files. Do Not Edit It.
Operators
-, :, ::, !, !=, ?, /, ., [](OperatorsAA# ), [@](OperatorsAA#@), *, +, <, <=, =, >,
>=, abs, accumulate, acos, action, add_3Dmodel, add_days, add_edge, add_ge-
ometry, add_hours, add_icon, add_minutes, add_months, add_ms, add_node,
add_point, add_seconds, add_values, add_weeks, add_years, adjacency, after, agen-
t, agent_closest_to, agent_farthest_to, agent_from_geometry, agents_at_distance,
agents_inside, agents_overlapping, all_match, all_pairs_shortest_path, all_verify,
alpha_index, among, and, and, angle_between, any, any_location_in, any_point_in,
append_horizontally, append_vertically, arc, around, as, as_4_grid, as_distance_-
graph, as_driving_graph, as_edge_graph, as_grid, as_hexagonal_grid, as_int,
as_intersection_graph, as_map, as_matrix, as_path, asin, at, at_distance, at_loca-
tion, atan, atan2, attributes, auto_correlation, BDIPlan, before, beta, beta_index,
1393
GAMA v1.8.0 documentation Chapter 102. Exhaustive list of GAMA Keywords
v 1.8.0 1394
GAMA v1.8.0 documentation Chapter 102. Exhaustive list of GAMA Keywords
v 1.8.0 1395
GAMA v1.8.0 documentation Chapter 102. Exhaustive list of GAMA Keywords
Statements
=, action, add, agents, annealing, ask, aspect, assert, benchmark, break, camera, cap-
ture, catch, chart, conscious_contagion, coping, create, data, datalist, default, diffuse,
display, display_grid, display_population, do, draw, else, emotional_contagion, en-
forcement, enter, equation, error, event, exhaustive, exit, experiment, focus, focus_on,
genetic, graphics, highlight, hill_climbing, if, image, inspect, law, layout, let, light,
loop, match, migrate, monitor, norm, output, output_file, overlay, parameter, per-
ceive, permanent, plan, put, reactive_tabu, reflex, release, remove, return, rule, rule,
run, sanction, save, set, setup, simulate, socialize, solve, species, start_simulation,
state, status, switch, tabu, task, test, trace, transition, try, unconscious_conta-
gion, user_command, user_init, user_input, user_panel, using, Variable_container,
Variable_number, Variable_regular, warn, write,
Architectures
fsm, parallel_bdi, probabilistic_tasks, reflex, rules, simple_bdi, sorted_tasks, user_-
first, user_last, user_only, weighted_tasks,
v 1.8.0 1396
GAMA v1.8.0 documentation Chapter 102. Exhaustive list of GAMA Keywords
v 1.8.0 1397
GAMA v1.8.0 documentation Chapter 102. Exhaustive list of GAMA Keywords
Skills
advanced_driving, driving, fipa, MDXSKILL, messaging, moving, moving3D, network,
physics, skill_road, skill_road_node, SQLSKILL,
Species
agent, AgentDB, base_edge, experiment, graph_edge, graph_node, physical_world,
world
Actions
init, step, isConnected, close, timeStamp, connect, testConnection, select, execu-
teUpdate, getParameter, setParameter, insert, update_outputs, compact_memo-
ry, related_to, compute_forces, advanced_follow_driving, is_ready_next_road,
test_next_road, compute_path, path_from_nodes, drive_random, drive, external_-
factor_impact, speed_choice, lane_choice, follow_driving, goto_driving, start_-
conversation, send, reply, accept_proposal, agree, cancel, cfp, end_conversation,
v 1.8.0 1398
GAMA v1.8.0 documentation Chapter 102. Exhaustive list of GAMA Keywords
Variables
Pseudo-Variables
v 1.8.0 1399
GAMA v1.8.0 documentation Chapter 102. Exhaustive list of GAMA Keywords
Types
action, agent, attributes, BDIPlan, bool, container, conversation, date, emotion,
file, float, font, gaml_type, geometry, graph, int, kml, list, map, material, matrix,
mental_state, message, Norm, pair, path, point, predicate, regression, rgb, Sanction,
skill, social_link, species, string, topology, unknown,
the world
torus, Environment Size, world, time cycle, step, time, duration, total_duration
average_duration, machine_time, agents, stop, halt, pause, scheduling
Grid
grid_x, grid_y, agents, color, grid_value
Other concepts
scheduling, step, Key concepts, Object-oriented paradigm to GAML, Correspondence
GAML and Netlogo
v 1.8.0 1400
Part IX
Tutorials
1401
Chapter 103
Tutorials
We propose some tutorials that are designed to allow modelers to become progressively
autonomous with the GAMA platform. These tutorials cover different aspects of
GAMA (Grid environment, GIS integration, 3D, multi-level modeling, equation-based
models. . . ). It is a good idea to keep a copy of the reference of the GAML language
around when undertaking one of these tutorials.
• Predator Prey
• Road Traffic
• 3D Tutorial
• Luneray’s flu
• Incremental Model
• BDI architecture
This tutorial introduces the basic concepts of GAMA and the use of grids. It is based
on the classic predator prey model (see for instance a formal definition here). It is
particularly adapted to beginners that want to quickly learn how to build a simple
model in GAMA.
1403
GAMA v1.8.0 documentation Chapter 103. Tutorials
v 1.8.0 1404
GAMA v1.8.0 documentation Chapter 103. Tutorials
v 1.8.0 1405
GAMA v1.8.0 documentation Chapter 103. Tutorials
Road Traffic
This tutorial introduces the use of GIS data. It is based on a mobility and daily
activity model. It is particularly adapted to modelers that want to quickly learn how
to integrate GIS data in their model and to use a road shapefile for the movement of
their agents.
3D Tutorial
This tutorial introduces the use of 3D in GAMA. In particular, it offers a quick
overview of the 3D capabilities of the platform and how to integrate 3D features in
models.
v 1.8.0 1406
GAMA v1.8.0 documentation Chapter 103. Tutorials
Incremental Model
This tutorial proposes is an advance version of the Luneray’s tutorial. It concerns a
model of disease spreading in a small city. In particular, it presents how to integrate
GIS data and use GIS, to use a road shapefile for the movement of agents, to define
a 3D display, to define a multi-level model and use differential equations.
BDI Architecture
This tutorial introduces the use of the BDI architecture (named BEN provided with
the GAMA platform. It is particularly adapted for advanced users who want to
integrate reasoning capabilities in theirs agents, taking into account their emotions
and social relationships.
v 1.8.0 1407
GAMA v1.8.0 documentation Chapter 103. Tutorials
v 1.8.0 1408
Chapter 104
Predator Prey
This tutorial presents the structure of a GAMA model as well as the use of a grid
topology. In particular, this tutorial shows how to define a basic model, to define
“grid agents” which are able to move within the constraints. It also introduce the
displays and agents’ aspect.
All the files related to this tutorial (images and models) are available in the Models
Library (project Tutorials/Predator Prey).
Content
Model Overview
In this model, three types of entities are considered: preys, predators and vegetation
cells. Preys eat grass on the vegetation cells and predators eat preys. At each
simulation step, grass grows on the vegetation cells. Concerning the predators and
preys, at each simulation step, they move (to a neighbor cell), eat, die if they do not
have enough energy, and eventually reproduce.
Step List
This tutorial is composed of 12 incremental steps corresponding to 12 models. For
each step we present its purpose, an explicit formulation and the corresponding
1409
GAMA v1.8.0 documentation Chapter 104. Predator Prey
v 1.8.0 1410
GAMA v1.8.0 documentation Chapter 104. Predator Prey
v 1.8.0 1411
GAMA v1.8.0 documentation Chapter 104. Predator Prey
v 1.8.0 1412
Chapter 105
1. Basic Model
Content
This first step Illustrates how to write a model in GAMA. In particular, it describes
how to structure a model and how to define species - that are the key components of
GAMA models.
Formulation
Model Definition
Model structure
1413
GAMA v1.8.0 documentation Chapter 105. 1. Basic Model
• global : this section, that is unique, defines the “world” agent, a special agent
of a GAMA model. It represents all that is global to the model: dynamics,
variables, actions. In addition, it allows to initialize the simulation (init block).
• species and grid: these sections define the species of agents composing the
model. Grid is defined in the following model step “vegetation dynamic”;
• experiment : these sections define a context of execution of the simulations.
In particular, it defines the input (parameters) and output (displays, files. . . )
of a model.
More details about the different sections of a GAMA model can be found here.
Species
A species represents a «prototype» of agents: it defines their common properties.
A species definition requires the definition of three different elements : * the internal
state of its agents (attributes) * their behavior * how they are displayed (aspects)
Internal state
An attribute is defined as follows: type of the attribute and name. Numerous types
of attributes are available: int (integer), float (floating point number), string, bool
(boolean, true or false), point (coordinates), list, pair, map, file, matrix, species of
agents, rgb (color), graph, path. . .
• Optional facets: <- (initial value), update (value recomputed at each step of
the simulation), function:{..} (value computed each time the variable is used),
min, max
In addition to the attributes the modeler explicitly defines, species “inherits” other
attributes called “built-in” variables:
v 1.8.0 1414
GAMA v1.8.0 documentation Chapter 105. 1. Basic Model
Behavior
In this first model, we define one species of agents: the prey agents. For the moment,
these agents will not have a particular behavior, they will just exist and be displayed.
Display
• A geometry: for instance, the shape of the agent (but it may be a different one,
for instance a disk instead of a complex polygon)
• An image: to draw icons
• A text: to draw a text
For the moment, we only define an aspect for this species. We want to display for
each prey agent a circle of radius size and color color. We then use the keyword
draw with a circle shape.
species prey {
float size <- 1.0 ;
rgb color <- #blue;
aspect base {
draw circle(size) color: color ;
}
}
v 1.8.0 1415
GAMA v1.8.0 documentation Chapter 105. 1. Basic Model
global section
The global section represents a specific agent, called world. Defining this agent follows
the same principle as any agent and is, thus, defined after a species. The world agent
represents everything that is global to the model: dynamics, variables. . . It allows
to initialize simulations (init block): the world is always created and initialized first
when a simulation is launched (before any other agents). The geometry (shape) of
the world agent is by default a square with 100m for side size, but can be redefined if
necessary (see the Road traffic tutorial).
global variable
In the current model, we will only have a certain number of preys thus we need to
hold this number in a global or world’s variable of type integer (int) which can be
done as follows:
global {
int nb_preys_init <- 200;
}
Model initialization
The init section of the global block allows to initialize the model which is executing
certain commands, here we will create nb_preys_init number of prey agents. We use
the statement create to create agents of a specific species: create species_name + :
v 1.8.0 1416
GAMA v1.8.0 documentation Chapter 105. 1. Basic Model
experiment
An experiment block defines how a model can be simulated (executed). Several
experiments can be defined for a given model. They are defined using : experiment
exp_name type: gui/batch {[input] [output]}
• gui: experiment with a graphical interface, which displays its input parameters
and outputs.
• batch: Allows to setup a series of simulations (w/o graphical interface).
input
Note that the init, min and max values can be defined in the global variable definition.
In the experiment, definition of a parameter from the global variable nb_preys_init:
experiment prey_predator type: gui {
parameter "Initial number of preys: " var: nb_preys_init min: 1 max:
1000 category: "Prey" ;
}
v 1.8.0 1417
GAMA v1.8.0 documentation Chapter 105. 1. Basic Model
output
Output blocks are defined in an experiment and define how to visualize a simulation
(with one or more display blocks that define separate windows). Each display can be
refreshed independently by defining the facet refresh_every: nb (int) (the display
will be refreshed every nb steps of the simulation).
Each display can include different layers (like in a GIS):
Note that it is possible to define a opengl display (for 3D display) by using the facet
type: opengl.
In our model, we define a display to draw the prey agents.
output {
display main_display {
species prey aspect: base ;
}
}
Complete Model
model prey_predator
global {
int nb_preys_init <- 200;
init {
create prey number: nb_preys_init ;
}
}
species prey {
float size <- 1.0 ;
rgb color <- #blue;
v 1.8.0 1418
GAMA v1.8.0 documentation Chapter 105. 1. Basic Model
aspect base {
draw circle(size) color: color ;
}
}
v 1.8.0 1419
GAMA v1.8.0 documentation Chapter 105. 1. Basic Model
v 1.8.0 1420
Chapter 106
2. Vegetation Dynamic
This second step presents the idea of environment or topological space. Defining a
“vegetation” environment allows to define the movement of the preys through dynamic
variables (use of the update facet). We will also discover more about displays.
Formulation
• Definition of a grid (for the vegetation)
• Definition of a dynamic for each cell (food production)
• Display of the cell color according to the quantity of food
• Localization of the prey agents on the cells (at its center)
Model Definition
grid
In GAMA, grids are specific agent species with a particular topology. First, a grid
allows yet constrains the movement of other (moving) agents but they can have
variables and behaviors.
A grid is defined as follows:
grid grid_name width: nb_cols height: nb_lines neighbors: 4/6/8 {
...
1421
GAMA v1.8.0 documentation Chapter 106. 2. Vegetation Dynamic
}
With:
• maxFood : maximum food that a cell can contain -> type: float ; init value: 1.0
• foodProd : food produced at each simulation step -> type: float ; init value:
random number between 0 and 0.01
• food : current quantity of food -> type: float ; init value: random number
between 0 and 1.0; at each simulation step : food <- food + foodProd
• color : color of the cell -> type: rgb ; init value: color computed according to
the food value: more the food value is close to 1.0, greener the color is, more
the food value is close to 0, whiter the color is; update : computation of the
new color depending on the current level of food (at each simulation step).
The update facet allows to give a behavior to the agents. Indeed, at each simulation
step, each agent is activated (by default, in a random order) and first applies for each
dynamic variable (in their definition order) its update expression. In the present case,
it allows us to link the displayed color of the cell to its food level.
grid vegetation_cell width: 50 height: 50 neighbors: 4 {
float maxFood <- 1.0 ;
float foodProd <- (rnd(1000) / 1000) * 0.01 ;
float food <- (rnd(1000) / 1000) update: food + foodProd max:
maxFood;
rgb color <- rgb(int(255 * (1 - food)), 255, int(255 * (1 - food)
)) update: rgb(int(255 * (1 - food)), 255, int(255 * (1 - food))) ;
}
• the simplest way consists in using the symbol # + the color name (for a limited
set of colors):
v 1.8.0 1422
GAMA v1.8.0 documentation Chapter 106. 2. Vegetation Dynamic
#blue
#red
• Another way consists in defining the 3 rgb integer values: rgb(red, green, blue)
with red, green and blue between 0 and 255 (as we used in the current model.
rgb(0,0,0) : black ; rgb(255,255,255) : white
rgb(255,0,0) : red ; rgb(0,255,0) : green ; rgb(0,0,255) : blue
prey agents
In order to relate our prey agents to the vegetation cell grid, we add them with
one new variable : my_cell of type vegetation_cell and for init value one of the
vegetation_cell (chosen randomly).
species prey {
...
vegetation_cell myCell <- one_of (vegetation_cell) ;
}
It is possible to obtain the list of all agents of a given species by using the name of
the species while one_of to pick one element randomly from this list.
We linked each prey agent to a vegetation_cell but we need to locate them onto the
cell. To do so, we set the prey location as equals to the location of the vegetation cell
(i.e. its centroid location), we use in the init block the <- statement that allows to
modify the value of a variable :
species prey {
...
init {
location <- myCell.location;
}
}
v 1.8.0 1423
GAMA v1.8.0 documentation Chapter 106. 2. Vegetation Dynamic
display
In order to visualize the vegetation, we need to add it to the display. We use for
that the statement grid with the optional facet lines to draw the border of the cells.
Note that grid agents have built-in aspect thus it is not necessary to define one.
output {
display main_display {
grid vegetation_cell lines: #black;
species prey aspect: base ;
}
}
Note that the layers in a display work like layers in a GIS; the drawing order will be
respected. In our model, the prey agents will be drawn above the vegetation_cell
grid thus they need to be declared afterward.
Complete Model
model prey_predator
global {
int nb_preys_init <- 200;
init {
create prey number: nb_preys_init ;
}
}
species prey {
float size <- 1.0 ;
rgb color <- #blue;
vegetation_cell myCell <- one_of (vegetation_cell) ;
init {
location <- myCell.location;
}
aspect base {
draw circle(size) color: color ;
}
}
v 1.8.0 1424
GAMA v1.8.0 documentation Chapter 106. 2. Vegetation Dynamic
v 1.8.0 1425
GAMA v1.8.0 documentation Chapter 106. 2. Vegetation Dynamic
v 1.8.0 1426
Chapter 107
This third step Illustrates how to define the behaviors of prey agents and the concept
of spatial topology.
Formulation
• Random movement of the prey agents to a distance of 2 cells (Von Neumann
neighborhood)
• At each step, the prey agents loss energy
• At each step, the prey agents eat food if there is food on the cell on which they
are localized (with a max of max_transfer) and gain energy
• If a prey agent has no more energy, it dies
Model Definition
Parameters
To define a behavior for the prey agents we add them three new parameters:
1427
GAMA v1.8.0 documentation Chapter 107. 3. Prey Agent Behavior
As we consider these parameters to be global to all prey, we define them in the global
section as follows:
float prey_max_energy <- 1.0;
float prey_max_transfer <- 0.1;
float prey_energy_consum <- 0.05;
Yet we may allow the user to change it from an experiment to another through the
user interface. To do so we add the following definition of parameters within the
experiment section :
parameter "Prey max energy: " var: prey_max_energy category: "Prey"
;
parameter "Prey max transfer: " var: prey_max_transfer category: "
Prey" ;
parameter "Prey energy consumption: " var: prey_energy_consum
category: "Prey" ;
vegetation_cell grid
We add a new variable for the vegetation_cell grid called neighbors, that contains
for each vegetation cell the list of the neighbor vegetation cells (distance of 2 - Von
Neumann neighborhood). We will use these neighbors list for the movement of the
prey.
grid vegetation_cell width: 50 height: 50 neighbors: 4 {
...
list<vegetation_cell> neighbors <- self neighbors_at 2;
}
Note that the result of the operator neighbors_at dist depends on the type of
topology of the agent applying this operator:
• For a grid topology (grid species), the operator returns the neighbor cells (with
a Von Neumann or Moore neighborhood).
• For a continuous topology, the operator returns the list of agents of which the
shape is located at a distance equals or inferior dist meters to the agent shape.
Also, note the use of the self pseudo variable which is a reference to the agent currently
executing the statement
v 1.8.0 1428
GAMA v1.8.0 documentation Chapter 107. 3. Prey Agent Behavior
Prey agents
We copy the values of the three global parameters into the prey species in order for it
to be available for each agent and possibly modified locally.
species prey {
...
float max_energy <- prey_max_energy ;
float max_transfer <- prey_max_transfer ;
float energy_consum <- prey_energy_consum ;
...
}
The energy used by each prey at each timestep is randomly computed initially (within
]0;max_energy]).
species prey {
...
float energy <- (rnd(1000) / 1000) * max_energy update: energy -
energy_consum max: max_energy ;
...
}
In order to define the movement behaviour of a prey we will add a reflex. A reflex
is a block of statements (that can be defined in global or any species) that will be
automatically executed at each simulation step if its condition is true, it is defined as
follows:
reflex reflex_name when: condition {...}
The when: facet is optional: when it is omitted, the reflex is activated at each time
step. Note that if several reflexes are defined for a species, the reflexes will be activated
following their definition order.
We define a first reflex called basic_move that allows the prey agents to choose
(randomly) a new vegetation_cell in the neighborhood of my_cell and to move to
this cell.
species prey {
...
reflex basic_move {
myCell <- one_of (myCell.neighbors) ;
location <- myCell.location ;
}
v 1.8.0 1429
GAMA v1.8.0 documentation Chapter 107. 3. Prey Agent Behavior
}
We define a second reflex called eat that will only be activated when there is food in
my_cell and that will allow the prey agents to eat food and gain energy. In order
to store the energy gain by the eating (that is equals to the minimum between the
max_transfer value and the quantity of food available in myCell), we define a
local variable called energy_transfer. A local variable is a variable that will only
exist within this block: once it has been executed, the variable is forgotten. To define
it, we have to use the following statement:
var_type var_name <- value;
We define a third reflex for the prey agent: when the agent has no more energy, it
dies (application of the built-in die action):
species prey {
...
reflex die when: energy <= 0 {
do die ;
}
}
Note that an action is a capability available to the agents of a species (what they can
do). It is a block of statements that can be used and reused whenever needed. Some
actions, called primitives, are directly coded in Java: for instance, the die action
defined for all the agents.
• An action can accept arguments. For instance, write takes an argument called
message.
• An action can return a result.
v 1.8.0 1430
GAMA v1.8.0 documentation Chapter 107. 3. Prey Agent Behavior
There are two ways to call an action: using a statement or as part of an expression
Complete Model
model prey_predator
global {
int nb_preys_init <- 200;
float prey_max_energy <- 1.0;
float prey_max_transfer <- 0.1;
float prey_energy_consum <- 0.05;
init {
create prey number: nb_preys_init ;
}
}
species prey {
float size <- 1.0 ;
rgb color <- #blue;
float max_energy <- prey_max_energy ;
float max_transfer <- prey_max_transfer ;
float energy_consum <- prey_energy_consum ;
init {
location <- myCell.location;
}
v 1.8.0 1431
GAMA v1.8.0 documentation Chapter 107. 3. Prey Agent Behavior
reflex basic_move {
myCell <- one_of (myCell.neighbors) ;
location <- myCell.location ;
}
reflex eat when: myCell.food > 0 {
float energy_transfer <- min([max_transfer, myCell.food]) ;
myCell.food <- myCell.food - energy_transfer ;
energy <- energy + energy_transfer ;
}
reflex die when: energy <= 0 {
do die ;
}
aspect base {
draw circle(size) color: color ;
}
}
v 1.8.0 1432
Chapter 108
This fourth step Illustrates how to monitor more precisely the simulation. Practically,
we will define monitors to follow the evolution of specific variables (or expression)
whereas inspector allows 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
1433
GAMA v1.8.0 documentation Chapter 108. 4. Inspectors and Monitors
int nb_preys -> {length (prey)};
monitor
With:
In this model, we define a monitor to follow the value of the variable nb_preys:
monitor "number of preys" value: nb_preys;
inspector
Inspectors allow to obtain information about a species or an agent. There are two
kinds of agent information features:
• Species browser: provides informations about all the agents of a species. Avail-
able in the Agents menu.
• Agent inspector: provides information about one specific agent. Also allows
to change the values of its variables during the simulation. Available from the
Agents menu, by right_clicking on a display, in the species inspector or when
inspecting another agent. It provides also the possibility to «highlight» the
inspected agent.
v 1.8.0 1434
GAMA v1.8.0 documentation Chapter 108. 4. Inspectors and Monitors
v 1.8.0 1435
GAMA v1.8.0 documentation Chapter 108. 4. Inspectors and Monitors
Complete Model
model prey_predator
global {
int nb_preys_init <- 200 ;
float prey_max_energy <- 1.0;
float prey_max_transfert <- 0.1;
float prey_energy_consum <- 0.05;
int nb_preys -> {length (prey)};
init {
create prey number: nb_preys_init ;
}
}
species prey {
float size <- 1.0 ;
rgb color <- #blue;
float max_energy <- prey_max_energy ;
float max_transfert <- prey_max_transfert ;
float energy_consum <- prey_energy_consum ;
init {
location <- myCell.location;
}
reflex basic_move {
myCell <- one_of (myCell.neighbors) ;
location <- myCell.location ;
}
reflex eat when: myCell.food > 0 {
float energy_transfert <- min([max_transfert, myCell.food]) ;
myCell.food <- myCell.food - energy_transfert ;
energy <- energy + energy_transfert ;
}
reflex die when: energy <= 0 {
do die ;
}
aspect base {
draw circle(size) color: color ;
v 1.8.0 1436
GAMA v1.8.0 documentation Chapter 108. 4. Inspectors and Monitors
}
}
v 1.8.0 1437
GAMA v1.8.0 documentation Chapter 108. 4. Inspectors and Monitors
v 1.8.0 1438
Chapter 109
5. Predator Agent
This fifth step Illustrates how to use parent species. Indeed,prey and predators share
a few common features thus we will define a generic species that will regroup all
the common elements (variables, behaviors and aspects) between the prey and the
predator species.
Formulation
• Definition of a new generic species: generic_species
• Definition of a new species: predator
• predator agents move randomly
• At each simulation step, a predator agent can eat a prey that is localized at its
grid cell
Model Definition
parameters
We add four new parameters related to predator agents:
1439
GAMA v1.8.0 documentation Chapter 109. 5. Predator Agent
parent species
A species can have a parent species: it automatically get all the variables, skill and
actions/reflex of the parent species
We define a species called generic_species that is the parent of the species prey
and predator:
This species integrates all of the common feature between the prey and predotor
species:
• the variables:
– size
– color
– max_energy
– max_transfer
– energy_consum
v 1.8.0 1440
GAMA v1.8.0 documentation Chapter 109. 5. Predator Agent
– myCell
– energy
• the behaviors:
– basic_move reflex
– die reflex
• the aspect:
– base aspect
species generic_species {
float size <- 1.0;
rgb color ;
float max_energy;
float max_transfer;
float energy_consum;
vegetation_cell myCell <- one_of (vegetation_cell) ;
float energy <- (rnd(1000) / 1000) * max_energy update: energy -
energy_consum max: max_energy ;
init {
location <- myCell.location;
}
v 1.8.0 1441
GAMA v1.8.0 documentation Chapter 109. 5. Predator Agent
reflex basic_move {
myCell <- one_of (myCell.neighbors) ;
location <- myCell.location ;
}
aspect base {
draw circle(size) color: color ;
}
}
prey species
We specialize the prey species from the generic_species species:
predator species
As done for the prey species, we specialize the predator species from the generic_-
species species:
v 1.8.0 1442
GAMA v1.8.0 documentation Chapter 109. 5. Predator Agent
Note that we used the ask statement. This statement allows to make a remote agent
executes a list of statements. Use of the ask statement as follows:
ask one_agent or ask agents_list
v 1.8.0 1443
GAMA v1.8.0 documentation Chapter 109. 5. Predator Agent
}
monitor
Like in the previous model, we define a monitor to display the number of predator
agents.
Definition of a global variable nb_predator that returns the current number of
predator agents:
global {
...
int nb_predators -> {length (predator)};
...
}
display
Also, do not forget to add the line to display predators in your simulation
display main_display {
...
species predator aspect: icon ;
}
Complete Model
model prey_predator
global {
int nb_preys_init <- 200;
int nb_predators_init <- 20;
float prey_max_energy <- 1.0;
float prey_max_transfer <- 0.1 ;
v 1.8.0 1444
GAMA v1.8.0 documentation Chapter 109. 5. Predator Agent
init {
create prey number: nb_preys_init ;
create predator number: nb_predators_init ;
}
}
species generic_species {
float size <- 1.0;
rgb color ;
float max_energy;
float max_transfer;
float energy_consum;
vegetation_cell myCell <- one_of (vegetation_cell) ;
float energy <- (rnd(1000) / 1000) * max_energy update: energy -
energy_consum max: max_energy ;
init {
location <- myCell.location;
}
reflex basic_move {
myCell <- one_of (myCell.neighbors) ;
location <- myCell.location ;
}
aspect base {
draw circle(size) color: color ;
}
}
v 1.8.0 1445
GAMA v1.8.0 documentation Chapter 109. 5. Predator Agent
v 1.8.0 1446
GAMA v1.8.0 documentation Chapter 109. 5. Predator Agent
output {
display main_display {
grid vegetation_cell lines: #black ;
species prey aspect: base ;
species predator aspect: base ;
}
monitor "Number of preys" value: nb_preys;
monitor "Number of predators" value: nb_predators;
}
}
v 1.8.0 1447
GAMA v1.8.0 documentation Chapter 109. 5. Predator Agent
v 1.8.0 1448
Chapter 110
6. Breeding
So far we created agents only during the initialisation of the simulation. In this sixth
step, we Illustrate how to create new agents during a simulation of a dynamic species.
Formulation
• Adding of a reproduce action of the prey and predator agents:
– When a agent has energy enough, it has a certain probability to have a
certain number of offspring
– The energy of the offspring is equal to the parent energy divided by the
number of offspring
– The parent get the same energy as its offspring
Model Definition
parameters
We add six new parameters related to breeding:
1449
GAMA v1.8.0 documentation Chapter 110. 6. Breeding
parent species
• proba_reproduce
• nb_max_offsprings
• energy_reproduce
v 1.8.0 1450
GAMA v1.8.0 documentation Chapter 110. 6. Breeding
Note that two keywords can be used to make explicit references to some agents:
• The agent that is currently executing the statements inside the block (for
example a newly created agent): self
• The agent that is executing the statement that contains this block (for instance,
the agent that has called the create statement): myself
v 1.8.0 1451
GAMA v1.8.0 documentation Chapter 110. 6. Breeding
prey species
We specialize the prey species from the generic_species species:
predator species
As done for the prey species, we specialize the predator species from the generic_-
species species:
Complete Model
model prey_predator
global {
int nb_preys_init <- 200;
int nb_predators_init <- 20;
float prey_max_energy <- 1.0;
v 1.8.0 1452
GAMA v1.8.0 documentation Chapter 110. 6. Breeding
init {
create prey number: nb_preys_init ;
create predator number: nb_predators_init ;
}
}
species generic_species {
float size <- 1.0;
rgb color ;
float max_energy;
float max_transfert;
float energy_consum;
float proba_reproduce ;
int nb_max_offsprings;
float energy_reproduce;
vegetation_cell myCell <- one_of (vegetation_cell) ;
float energy <- (rnd(1000) / 1000) * max_energy update: energy -
energy_consum max: max_energy ;
init {
location <- myCell.location;
}
reflex basic_move {
myCell <- one_of (myCell.neighbors) ;
location <- myCell.location ;
}
v 1.8.0 1453
GAMA v1.8.0 documentation Chapter 110. 6. Breeding
aspect base {
draw circle(size) color: color ;
}
}
v 1.8.0 1454
GAMA v1.8.0 documentation Chapter 110. 6. Breeding
}
energy <- energy + energy_transfert ;
}
}
output {
v 1.8.0 1455
GAMA v1.8.0 documentation Chapter 110. 6. Breeding
display main_display {
grid vegetation_cell lines: #black ;
species prey aspect: base ;
species predator aspect: base ;
}
monitor "Number of preys" value: nb_preys;
monitor "Number of predators" value: nb_predators;
}
}
v 1.8.0 1456
Chapter 111
7. Agent Aspect
In this seventh step we will focus on the display and more specifically the aspects of
the agents: how they are represented. It can be a simple shape (circle, square, etc.),
an icon, a polygon (see later GIS support).
Formulation
• Definition of two new aspects for the prey and predator agents:
– A icon
– A square with information about the agent energy
• Use of the icon aspect as default aspect for the prey and predator agents.
Model Definition
parent species
We add a new variable of type image_file (a particular kind of file) called my_icon
to the generic_species. We define as well two new aspects:
1457
GAMA v1.8.0 documentation Chapter 111. 7. Agent Aspect
• info : draw a square of side size size and color color; draw as a text the energy
of the agent (with a precision of 2)
species generic_species {
...
image_file my_icon;
...
aspect base {
draw circle(size) color: color ;
}
aspect icon {
draw my_icon size: 2 * size ;
}
aspect info {
draw square(size) color: color ;
draw string(energy with_precision 2) size: 3 color: #black ;
}
}
prey species
We specialize the prey species from the generic_species species:
predator species
As done for the prey species, we specialize the predator species from the generic_-
species species:
v 1.8.0 1458
GAMA v1.8.0 documentation Chapter 111. 7. Agent Aspect
display
We change the default aspect of the prey and predator agents to icon aspect.
output {
display main_display {
grid vegetation_cell lines: #black ;
species prey aspect: icon ;
species predator aspect: icon ;
}
}
We define a new display called info_display that displays the prey and predator
agents with the info aspect.
output {
display info_display {
species prey aspect: info;
species predator aspect: info;
}
}
Complete Model
v 1.8.0 1459
GAMA v1.8.0 documentation Chapter 111. 7. Agent Aspect
model prey_predator
global {
int nb_preys_init <- 200;
int nb_predators_init <- 20;
float prey_max_energy <- 1.0;
float prey_max_transfert <- 0.1 ;
float prey_energy_consum <- 0.05;
float predator_max_energy <- 1.0;
float predator_energy_transfert <- 0.5;
float predator_energy_consum <- 0.02;
float prey_proba_reproduce <- 0.01;
int prey_nb_max_offsprings <- 5;
float prey_energy_reproduce <- 0.5;
float predator_proba_reproduce <- 0.01;
int predator_nb_max_offsprings <- 3;
float predator_energy_reproduce <- 0.5;
init {
create prey number: nb_preys_init ;
create predator number: nb_predators_init ;
}
}
species generic_species {
float size <- 1.0;
rgb color ;
float max_energy;
float max_transfert;
float energy_consum;
float proba_reproduce ;
float nb_max_offsprings;
float energy_reproduce;
image_file my_icon;
vegetation_cell myCell <- one_of (vegetation_cell) ;
float energy <- (rnd(1000) / 1000) * max_energy update: energy -
energy_consum max: max_energy ;
init {
location <- myCell.location;
}
v 1.8.0 1460
GAMA v1.8.0 documentation Chapter 111. 7. Agent Aspect
reflex basic_move {
myCell <- one_of (myCell.neighbors) ;
location <- myCell.location ;
}
aspect base {
draw circle(size) color: color ;
}
aspect icon {
draw my_icon size: 2 * size ;
}
aspect info {
draw square(size) color: color ;
draw string(energy with_precision 2) size: 3 color: #black ;
}
}
v 1.8.0 1461
GAMA v1.8.0 documentation Chapter 111. 7. Agent Aspect
}
}
v 1.8.0 1462
GAMA v1.8.0 documentation Chapter 111. 7. Agent Aspect
output {
display main_display {
grid vegetation_cell lines: #black ;
species prey aspect: icon ;
species predator aspect: icon ;
}
display info_display {
grid vegetation_cell lines: #black ;
species prey aspect: info ;
species predator aspect: info ;
}
monitor "Number of preys" value: nb_preys;
monitor "Number of predators" value: nb_predators;
}
}
v 1.8.0 1463
GAMA v1.8.0 documentation Chapter 111. 7. Agent Aspect
v 1.8.0 1464
Chapter 112
8. Complex Behavior
This eighth step Illustrates how to define and call actions and how to use conditional
statements.
Formulation
• Definition of more complex behaviors for prey and predator agents:
– The preys agents are moving to the cell containing the highest quantity of
food
– The predator agents are moving if possible to a cell that contains preys;
otherwise random cell
Model Definition
parent species
We modify the basic_move reflex of the generic_species in order to give the prey
and predator a more complex behaviors: instead of choose a random vegetation cell
in the neighborhood, the agent will choose a vegetation cell (still in the neighborhood)
thanks to a choose_cell action. This action will be specialized for each species.
species generic_species {
...
1465
GAMA v1.8.0 documentation Chapter 112. 8. Complex Behavior
reflex basic_move {
myCell <- choose_cell();
location <- myCell.location;
}
vegetation_cell choose_cell {
return nil;
}
...
}
There are two ways to call an action: using a statement or as part of an expression
prey species
We specialize the choose_cell species for the prey species: the agent will choose
the vegetation cell of the neighborhood (list myCell.neighbors) that maximizes the
quantity of food.
Note that GAMA offers numerous operators to manipulate lists and containers:
v 1.8.0 1466
GAMA v1.8.0 documentation Chapter 112. 8. Complex Behavior
In the case of binary operators, each element (of the first operand list) can be accessed
with the keyword each
Thus the choose_cell action of the prey species is defined by:
species prey parent: generic_species {
...
vegetation_cell choose_cell {
return (myCell.neighbors) with_max_of (each.food);
}
...
}
predator species
We specialize the choose_cell species for the predator species: the agent will
choose, if possible, a vegetation cell of the neighborhood (list myCell.neighbors) that
contains at least a prey agent; otherwise it will choose a random cell.
We use for this action the first_with operator on the list neighbor vegetation cells
(myCell.neighbors) with the following condition: the list of prey agents contained in
the cell is not empty. Note that we use the shuffle operator to randomize the order
of the list of neighbor cell.
If all the neighbor cells are empty (myCell_tmp = nil, nil is the null value), then the
agent choosse a random cell in the neighborhood (one_of (myCell.neighbors)).
GAMA contains statements that allow to execute blocks depending on some conditions:
if condition1 {...}
else if condition2{...}
...
else {...}
v 1.8.0 1467
GAMA v1.8.0 documentation Chapter 112. 8. Complex Behavior
This statement means that if condition1 = true then the first block is executed;
otherwise if condition2 = true, then it is the second block, etc. When no conditions
are satisfied and an else block is defined (it is optional), this latter is executed.
We then write the choose_cell action as follows:
species predator parent: generic_species {
...
vegetation_cell choose_cell {
vegetation_cell myCell_tmp <- shuffle(myCell.neighbors)
first_with (!(empty (prey inside (each))));
if myCell_tmp != nil {
return myCell_tmp;
} else {
return one_of (myCell.neighbors);
}
}
...
}
Note there is ternary operator allowing to directly use a condition structure to evaluate
a variable:
condition ? value1 : value2
Complete Model
model prey_predator
global {
int nb_preys_init <- 200;
int nb_predators_init <- 20;
float prey_max_energy <- 1.0;
float prey_max_transfert <- 0.1 ;
float prey_energy_consum <- 0.05;
float predator_max_energy <- 1.0;
float predator_energy_transfert <- 0.5;
float predator_energy_consum <- 0.02;
float prey_proba_reproduce <- 0.01;
int prey_nb_max_offsprings <- 5;
float prey_energy_reproduce <- 0.5;
v 1.8.0 1468
GAMA v1.8.0 documentation Chapter 112. 8. Complex Behavior
init {
create prey number: nb_preys_init ;
create predator number: nb_predators_init ;
}
}
species generic_species {
float size <- 1.0;
rgb color ;
float max_energy;
float max_transfert;
float energy_consum;
float proba_reproduce ;
float nb_max_offsprings;
float energy_reproduce;
image_file my_icon;
vegetation_cell myCell <- one_of (vegetation_cell) ;
float energy <- (rnd(1000) / 1000) * max_energy update: energy -
energy_consum max: max_energy ;
init {
location <- myCell.location;
}
reflex basic_move {
myCell <- choose_cell();
location <- myCell.location;
}
vegetation_cell choose_cell {
return nil;
}
v 1.8.0 1469
GAMA v1.8.0 documentation Chapter 112. 8. Complex Behavior
aspect base {
draw circle(size) color: color ;
}
aspect icon {
draw my_icon size: 2 * size ;
}
aspect info {
draw square(size) color: color ;
draw string(energy with_precision 2) size: 3 color: #black ;
}
}
vegetation_cell choose_cell {
return (myCell.neighbors) with_max_of (each.food);
}
}
v 1.8.0 1470
GAMA v1.8.0 documentation Chapter 112. 8. Complex Behavior
vegetation_cell choose_cell {
vegetation_cell myCell_tmp <- shuffle(myCell.neighbors)
first_with (!(empty (prey inside (each))));
if myCell_tmp != nil {
return myCell_tmp;
} else {
return one_of (myCell.neighbors);
}
}
}
v 1.8.0 1471
GAMA v1.8.0 documentation Chapter 112. 8. Complex Behavior
output {
display main_display {
grid vegetation_cell lines: #black ;
species prey aspect: icon ;
species predator aspect: icon ;
}
display info_display {
grid vegetation_cell lines: #black ;
species prey aspect: info ;
species predator aspect: info ;
}
monitor "Number of preys" value: nb_preys;
monitor "Number of predators" value: nb_predators;
}
}
v 1.8.0 1472
Chapter 113
9. Stopping condition
This 9th step Illustrates how to use the pause action to stop a simulation
Formulation
• Adding of a stopping condition for the simulation: when there is no more prey
or predator agents, the simulation stops
Model Definition
We add a new reflex that stops the simulation if the number of preys or the number
of predators is null.
global {
...
reflex stop_simulation when: (nb_preys = 0) or (nb_predators = 0) {
do pause ;
}
}
Complete Model
1473
GAMA v1.8.0 documentation Chapter 113. 9. Stopping condition
model prey_predator
global {
int nb_preys_init <- 200;
int nb_predators_init <- 20;
float prey_max_energy <- 1.0;
float prey_max_transfert <- 0.1 ;
float prey_energy_consum <- 0.05;
float predator_max_energy <- 1.0;
float predator_energy_transfert <- 0.5;
float predator_energy_consum <- 0.02;
float prey_proba_reproduce <- 0.01;
int prey_nb_max_offsprings <- 5;
float prey_energy_reproduce <- 0.5;
float predator_proba_reproduce <- 0.01;
int predator_nb_max_offsprings <- 3;
float predator_energy_reproduce <- 0.5;
init {
create prey number: nb_preys_init ;
create predator number: nb_predators_init ;
}
species generic_species {
float size <- 1.0;
rgb color ;
float max_energy;
float max_transfert;
float energy_consum;
float proba_reproduce ;
float nb_max_offsprings;
float energy_reproduce;
image_file my_icon;
vegetation_cell myCell <- one_of (vegetation_cell) ;
float energy <- (rnd(1000) / 1000) * max_energy update: energy -
energy_consum max: max_energy ;
v 1.8.0 1474
GAMA v1.8.0 documentation Chapter 113. 9. Stopping condition
init {
location <- myCell.location;
}
reflex basic_move {
myCell <- choose_cell();
location <- myCell.location;
}
vegetation_cell choose_cell {
return nil;
}
aspect base {
draw circle(size) color: color ;
}
aspect icon {
draw my_icon size: 2 * size ;
}
aspect info {
draw square(size) color: color ;
draw string(energy with_precision 2) size: 3 color: #black ;
}
}
v 1.8.0 1475
GAMA v1.8.0 documentation Chapter 113. 9. Stopping condition
vegetation_cell choose_cell {
return (myCell.neighbors) with_max_of (each.food);
}
}
vegetation_cell choose_cell {
vegetation_cell myCell_tmp <- shuffle(myCell.neighbors)
first_with (!(empty (prey inside (each))));
if myCell_tmp != nil {
return myCell_tmp;
} else {
return one_of (myCell.neighbors);
}
}
}
v 1.8.0 1476
GAMA v1.8.0 documentation Chapter 113. 9. Stopping condition
output {
display main_display {
grid vegetation_cell lines: #black ;
species prey aspect: icon ;
species predator aspect: icon ;
}
display info_display {
grid vegetation_cell lines: #black ;
v 1.8.0 1477
GAMA v1.8.0 documentation Chapter 113. 9. Stopping condition
v 1.8.0 1478
Chapter 114
10. Charts
Formulation
• Adding a new display to visualize:
– One chart representing the evolution of the quantity of prey and predator
agents over the time
– Two histograms representing the energy distribution of the prey and
predator agents
Model Definition
output
• Time series
• Pie charts
• Histograms
1479
GAMA v1.8.0 documentation Chapter 114. 10. Charts
A chart must be defined in a display : it behaves exactly like any other layer.
Definition of a chart:
chart chart_name type: chart_type {
[data]
}
The data to draw are defined inside the chart block as follow:
data data_legend value: data_value
To evaluate the value of the data of the two histogram, we use the operator list
count condition" that returns the number of elements of listfor which the
condition is true.
v 1.8.0 1480
GAMA v1.8.0 documentation Chapter 114. 10. Charts
display Population_information refresh:every(5#cycles) {
chart "Species evolution" type: series size: {1,0.5} position: {0,
0} {
data "number_of_preys" value: nb_preys color: #blue ;
data "number_of_predator" value: nb_predators color: #red ;
}
chart "Prey Energy Distribution" type: histogram background: rgb("
white") size: {0.5,0.5} position: {0, 0.5} {
data "]0;0.25]" value: prey count (each.energy <= 0.25) color:#
blue;
data "]0.25;0.5]" value: prey count ((each.energy > 0.25) and (
each.energy <= 0.5)) color:#blue;
data "]0.5;0.75]" value: prey count ((each.energy > 0.5) and (
each.energy <= 0.75)) color:#blue;
data "]0.75;1]" value: prey count (each.energy > 0.75) color:#
blue;
}
chart "Predator Energy Distribution" type: histogram background:
rgb("white") size: {0.5,0.5} position: {0.5, 0.5} {
data "]0;0.25]" value: predator count (each.energy <= 0.25)
color: #red ;
data "]0.25;0.5]" value: predator count ((each.energy > 0.25)
and (each.energy <= 0.5)) color: #red ;
data "]0.5;0.75]" value: predator count ((each.energy > 0.5)
and (each.energy <= 0.75)) color: #red ;
data "]0.75;1]" value: predator count (each.energy > 0.75)
color: #red;
}
}
Complete Model
model prey_predator
global {
int nb_preys_init <- 200;
int nb_predators_init <- 20;
float prey_max_energy <- 1.0;
float prey_max_transfert <- 0.1 ;
float prey_energy_consum <- 0.05;
float predator_max_energy <- 1.0;
float predator_energy_transfert <- 0.5;
v 1.8.0 1481
GAMA v1.8.0 documentation Chapter 114. 10. Charts
init {
create prey number: nb_preys_init ;
create predator number: nb_predators_init ;
}
species generic_species {
float size <- 1.0;
rgb color ;
float max_energy;
float max_transfert;
float energy_consum;
float proba_reproduce ;
float nb_max_offsprings;
float energy_reproduce;
image_file my_icon;
vegetation_cell myCell <- one_of (vegetation_cell) ;
float energy <- (rnd(1000) / 1000) * max_energy update: energy -
energy_consum max: max_energy ;
init {
location <- myCell.location;
}
reflex basic_move {
myCell <- choose_cell();
location <- myCell.location;
}
vegetation_cell choose_cell {
return nil;
v 1.8.0 1482
GAMA v1.8.0 documentation Chapter 114. 10. Charts
aspect base {
draw circle(size) color: color ;
}
aspect icon {
draw my_icon size: 2 * size ;
}
aspect info {
draw square(size) color: color ;
draw string(energy with_precision 2) size: 3 color: #black ;
}
}
vegetation_cell choose_cell {
v 1.8.0 1483
GAMA v1.8.0 documentation Chapter 114. 10. Charts
vegetation_cell choose_cell {
vegetation_cell myCell_tmp <- shuffle(myCell.neighbors)
first_with (!(empty (prey inside (each))));
if myCell_tmp != nil {
return myCell_tmp;
} else {
return one_of (myCell.neighbors);
}
}
}
v 1.8.0 1484
GAMA v1.8.0 documentation Chapter 114. 10. Charts
output {
display main_display {
grid vegetation_cell lines: #black ;
species prey aspect: icon ;
species predator aspect: icon ;
}
display info_display {
grid vegetation_cell lines: #black ;
species prey aspect: info ;
species predator aspect: info ;
}
display Population_information refresh:every(5#cycles) {
chart "Species evolution" type: series size: {1,0.5}
position: {0, 0} {
data "number_of_preys" value: nb_preys color: #blue ;
data "number_of_predator" value: nb_predators color: #
red ;
}
v 1.8.0 1485
GAMA v1.8.0 documentation Chapter 114. 10. Charts
v 1.8.0 1486
Chapter 115
Formulation
• At each simulation step, write in a text file:
Model Definition
global section
With:
1487
GAMA v1.8.0 documentation Chapter 115. 11. Writing Files
• file_name: string (by default the file in saved in the /models/ of your project
directory)
• file_type: string
With:
• file_type : string
• file_name : string
• shp (shapefile - GIS data): in that case, my_data is treated as a list of agents:
all their geometries are saved in the file (with some variables as attributes)
• txt (text): in that case, my_data is treated as a string, which is written directly
in the file
• csv: in that case, my_data is treated as a list of values : [val1, val2, val3].
• The cycle step: use of the cycle keyword that returns the current simulation
step.
• The number of prey and predator agents: use of nb_preys and nb_predators
variables
• The min and max energy of the prey and predator agents: use of list min_of
expression and list max_of expression keywords. In addition, we verify
with the tertiary operator (condition ? val_if : val_else).
v 1.8.0 1488
GAMA v1.8.0 documentation Chapter 115. 11. Writing Files
reflex save_result when: (nb_preys > 0) and (nb_predators > 0){
save ("cycle: "+ cycle + "; nbPreys: " + nb_preys
+ "; minEnergyPreys: " + (prey min_of each.energy)
+ "; maxSizePreys: " + (prey max_of each.energy)
+ "; nbPredators: " + nb_predators
+ "; minEnergyPredators: " + (predator min_of each.energy)
+ "; maxSizePredators: " + (predator max_of each.energy))
to: "results.txt" type: "text" ;
}
Complete Model
model prey_predator
global {
int nb_preys_init <- 200;
int nb_predators_init <- 20;
float prey_max_energy <- 1.0;
float prey_max_transfert <- 0.1 ;
float prey_energy_consum <- 0.05;
float predator_max_energy <- 1.0;
float predator_energy_transfert <- 0.5;
float predator_energy_consum <- 0.02;
float prey_proba_reproduce <- 0.01;
int prey_nb_max_offsprings <- 5;
float prey_energy_reproduce <- 0.5;
float predator_proba_reproduce <- 0.01;
int predator_nb_max_offsprings <- 3;
float predator_energy_reproduce <- 0.5;
init {
create prey number: nb_preys_init ;
create predator number: nb_predators_init ;
}
v 1.8.0 1489
GAMA v1.8.0 documentation Chapter 115. 11. Writing Files
species generic_species {
float size <- 1.0;
rgb color ;
float max_energy;
float max_transfert;
float energy_consum;
float proba_reproduce ;
float nb_max_offsprings;
float energy_reproduce;
image_file my_icon;
vegetation_cell myCell <- one_of (vegetation_cell) ;
float energy <- (rnd(1000) / 1000) * max_energy update: energy -
energy_consum max: max_energy ;
init {
location <- myCell.location;
}
reflex basic_move {
myCell <- choose_cell();
location <- myCell.location;
}
vegetation_cell choose_cell {
return nil;
}
v 1.8.0 1490
GAMA v1.8.0 documentation Chapter 115. 11. Writing Files
aspect base {
draw circle(size) color: color ;
}
aspect icon {
draw my_icon size: 2 * size ;
}
aspect info {
draw square(size) color: color ;
draw string(energy with_precision 2) size: 3 color: #black ;
}
}
vegetation_cell choose_cell {
return (myCell.neighbors) with_max_of (each.food);
}
}
v 1.8.0 1491
GAMA v1.8.0 documentation Chapter 115. 11. Writing Files
vegetation_cell choose_cell {
vegetation_cell myCell_tmp <- shuffle(myCell.neighbors)
first_with (!(empty (prey inside (each))));
if myCell_tmp != nil {
return myCell_tmp;
} else {
return one_of (myCell.neighbors);
}
}
}
v 1.8.0 1492
GAMA v1.8.0 documentation Chapter 115. 11. Writing Files
output {
display main_display {
grid vegetation_cell lines: #black ;
species prey aspect: icon ;
species predator aspect: icon ;
}
display info_display {
grid vegetation_cell lines: #black ;
species prey aspect: info ;
species predator aspect: info ;
}
display Population_information refresh:every(5#cycles) {
chart "Species evolution" type: series size: {1,0.5}
position: {0, 0} {
data "number_of_preys" value: nb_preys color: #blue ;
data "number_of_predator" value: nb_predators color: #
red ;
}
chart "Prey Energy Distribution" type: histogram background
: rgb("lightGray") size: {0.5,0.5} position: {0, 0.5} {
data "]0;0.25]" value: prey count (each.energy <= 0.25)
color:#blue;
data "]0.25;0.5]" value: prey count ((each.energy >
0.25) and (each.energy <= 0.5)) color:#blue;
data "]0.5;0.75]" value: prey count ((each.energy >
0.5) and (each.energy <= 0.75)) color:#blue;
v 1.8.0 1493
GAMA v1.8.0 documentation Chapter 115. 11. Writing Files
v 1.8.0 1494
Chapter 116
This 12th step illustrates how to load an image file and to use it to initialize a grid.
Formulation
• Building of the initial environment (food and foodProd of the cells) from a
image file
Model Definition
global variable
1495
GAMA v1.8.0 documentation Chapter 116. 12. Image loading
model initialization
In order to have a more complex environment, we want to use this image as the
initialization of the environment. The food level available in a vegetation_cell will be
based on the green level of the corresponding pixel in the image. You will be able to
use such process to represent existing real environment in your model. We modify
the global init of the model in order to cast the image file in a matrix. We use for
that the file as_matrix {nb_cols, nb_lines} operator that allows to convert a
file (image, csv) to a matrix composed of nb_cols columns and nb_lines lines.
Concerning the manipulation of matrix, it is possible to obtain the element [i,j] of a
matrix by using my_matrix [i,j].
A grid can be view as spatial matrix: each cell of a grid has two built-in variables
grid_x and grid_y that represent the column and line indexes of the cell.
init {
create prey number: nb_preys_init ;
create predator number: nb_predators_init ;
matrix init_data <- map_init as_matrix {50,50};
ask vegetation_cell {
color <- rgb (init_data[grid_x,grid_y]) ;
food <- 1 - ((color as list)[0] / 255) ;
foodProd <- food / 100 ;
}
}
Conclusion
Congratulations, you have complete your first GAMA models! Now, you have enough
knowledge to create many models that includes: dynamic grid-based environment,
moving and interacting agents and the needed visualization to make good use of
your simulation. Feel free to use this knowledge to create your very own models! Or
perhaps you want to continue your study with the more advanced tutorials?
Complete Model
model prey_predator
v 1.8.0 1496
GAMA v1.8.0 documentation Chapter 116. 12. Image loading
global {
int nb_preys_init <- 200;
int nb_predators_init <- 20;
float prey_max_energy <- 1.0;
float prey_max_transfert <- 0.1 ;
float prey_energy_consum <- 0.05;
float predator_max_energy <- 1.0;
float predator_energy_transfert <- 0.5;
float predator_energy_consum <- 0.02;
float prey_proba_reproduce <- 0.01;
int prey_nb_max_offsprings <- 5;
float prey_energy_reproduce <- 0.5;
float predator_proba_reproduce <- 0.01;
int predator_nb_max_offsprings <- 3;
float predator_energy_reproduce <- 0.5;
file map_init <- image_file("../images/predator_prey_raster_map.png
");
init {
create prey number: nb_preys_init ;
create predator number: nb_predators_init ;
ask vegetation_cell {
color <- rgb (map_init at {grid_x,grid_y}) ;
food <- 1 - (((color as list)[0]) / 255) ;
foodProd <- food / 100 ;
}
}
v 1.8.0 1497
GAMA v1.8.0 documentation Chapter 116. 12. Image loading
}
}
species generic_species {
float size <- 1.0;
rgb color ;
float max_energy;
float max_transfert;
float energy_consum;
float proba_reproduce ;
float nb_max_offsprings;
float energy_reproduce;
image_file my_icon;
vegetation_cell myCell <- one_of (vegetation_cell) ;
float energy <- (rnd(1000) / 1000) * max_energy update: energy -
energy_consum max: max_energy ;
init {
location <- myCell.location;
}
reflex basic_move {
myCell <- choose_cell();
location <- myCell.location;
}
vegetation_cell choose_cell {
return nil;
}
aspect base {
v 1.8.0 1498
GAMA v1.8.0 documentation Chapter 116. 12. Image loading
vegetation_cell choose_cell {
return (myCell.neighbors) with_max_of (each.food);
}
}
v 1.8.0 1499
GAMA v1.8.0 documentation Chapter 116. 12. Image loading
}
energy <- energy + energy_transfert ;
}
vegetation_cell choose_cell {
vegetation_cell myCell_tmp <- shuffle(myCell.neighbors)
first_with (!(empty (prey inside (each))));
if myCell_tmp != nil {
return myCell_tmp;
} else {
return one_of (myCell.neighbors);
}
}
}
v 1.8.0 1500
GAMA v1.8.0 documentation Chapter 116. 12. Image loading
output {
display main_display {
grid vegetation_cell lines: #black ;
species prey aspect: icon ;
species predator aspect: icon ;
}
display info_display {
grid vegetation_cell lines: #black ;
species prey aspect: info ;
species predator aspect: info ;
}
display Population_information refresh:every(5#cycles) {
chart "Species evolution" type: series size: {1,0.5}
position: {0, 0} {
data "number_of_preys" value: nb_preys color: #blue ;
data "number_of_predator" value: nb_predators color: #
red ;
}
chart "Prey Energy Distribution" type: histogram background
: rgb("lightGray") size: {0.5,0.5} position: {0, 0.5} {
data "]0;0.25]" value: prey count (each.energy <= 0.25)
color:#blue;
data "]0.25;0.5]" value: prey count ((each.energy >
0.25) and (each.energy <= 0.5)) color:#blue;
data "]0.5;0.75]" value: prey count ((each.energy >
0.5) and (each.energy <= 0.75)) color:#blue;
data "]0.75;1]" value: prey count (each.energy > 0.75)
color:#blue;
}
chart "Predator Energy Distribution" type: histogram
background: rgb("lightGray") size: {0.5,0.5} position: {0.5, 0.5} {
data "]0;0.25]" value: predator count (each.energy <=
0.25) color: #red ;
data "]0.25;0.5]" value: predator count ((each.energy >
0.25) and (each.energy <= 0.5)) color: #red ;
data "]0.5;0.75]" value: predator count ((each.energy >
0.5) and (each.energy <= 0.75)) color: #red ;
v 1.8.0 1501
GAMA v1.8.0 documentation Chapter 116. 12. Image loading
v 1.8.0 1502
Chapter 117
Road Traffic
This tutorial has for goal to present the use of GIS data and complex geometries.
In particular, this tutorial shows how to load gis data, to agentify them and to use
a network of polylines to constraint the movement of agents. All the files related
to this tutorial (shapefiles and models) are available in the Models Library (project
road_traffic_tutorial).
If you are not familiar with agent-based models or GAMA we advice you to have a
look at the prey-predator model first.
Model Overview
The model built in this tutorial concerns the study of the road traffic in a small
city. Two layers of GIS data are used: a road layer (polylines) and a building layer
(polygons). The building GIS data contain an attribute: the ‘NATURE’ of each
building: a building can be either ‘Residential’ or ‘Industrial’. In this model, people
agents are moving along the road network. Each morning, they are going to an
industrial building to work, and each night they are coming back home. Each time a
people agent takes a road, it wears it out. More a road is worn out, more a people
agent takes time to go all over it. The town council is able to repair some roads.
1503
GAMA v1.8.0 documentation Chapter 117. Road Traffic
v 1.8.0 1504
GAMA v1.8.0 documentation Chapter 117. Road Traffic
Step List
This tutorial is composed of 7 steps corresponding to 7 models. For each step we
present its purpose, an explicit formulation and the corresponding GAML code.
v 1.8.0 1505
GAMA v1.8.0 documentation Chapter 117. Road Traffic
v 1.8.0 1506
Chapter 118
This first step Illustrates how to load GIS data (shapefiles) and to read attributes
from GIS data.
Formulation
• Set the time duration of a time step to 10 minutes
• Load, agentify and display two layers of GIS data (building and road). Agenti-
fying a GIS element will allow us to give it a behavior later on (thus not being
simply a static/passive object).
• Read the ‘NATURE’ attribute of the building data: the buildings of ‘Residential’
type will be colored in gray, the buildings of ‘Industrial’ type will be color in
blue.
Model Definition
species
In this first model, we have to define two species of agents: the building agents
and the road ones. These agents will not have a particular behavior, they will just
be displayed. For each of these species, we define a new attribute: color of type
rgb, with for initial value: “black” for the road agent and “gray” (by default) for
1507
GAMA v1.8.0 documentation Chapter 118. 1. Loading of GIS Data
the building agent. Concerning the building agent, we define a second attribute
named type representing the type of the building (“Residential” or “Industrial”). At
last, we define an aspect for these species. In this model, we want to represent the
geometry of the agent, we then use the keyword draw that allow to draw a given
geometry. In order to draw the geometry of the agent we use the attribute shape
(which is a built-in attribute of all agents).
species building {
string type;
rgb color <- #gray ;
aspect base {
draw shape color: color ;
}
}
species road {
rgb color <- #black ;
aspect base {
draw shape color: color ;
}
}
parameters
GAMA allows to automatically read GIS data that are formatted as shapefiles. In
order to let the user chooses his/her shapefiles, we define three parameters. One
allowing the user to choose the road shapefile, one allowing him/her to choose the
building shapefile, and, at last, one allowing him/her to choose the bounds shapefile.
We will come back later on the notion of “bounds” in GAMA.
Definition of the three global variables of type file concerning the GIS files:
global {
file shape_file_buildings <- file("../includes/building.shp");
file shape_file_roads <- file("../includes/road.shp");
file shape_file_bounds <- file("../includes/bounds.shp");
}
All shapefiles are available in the model library (under Library models -> Tutorials
-> Road Traffic) or you can download them by following this GitHub link.
v 1.8.0 1508
GAMA v1.8.0 documentation Chapter 118. 1. Loading of GIS Data
In the experiment section, we add three parameters to allow the user to change the
shapefile used directly through the UI:
experiment road_traffic type: gui {
parameter "Shapefile for the buildings:" var: shape_file_buildings
category: "GIS" ;
parameter "Shapefile for the roads:" var: shape_file_roads category:
"GIS" ;
parameter "Shapefile for the bounds:" var: shape_file_bounds
category: "GIS" ;
}
Init section of the global block: creation of the road and building agents from the
shape files. Concerning the building agents, reading of the “NATURE” attribute
of the shapefile to initiate the value of the type attribute. If the type attribute is
equal to “Industrial” set the color attribute to “blue”.
global {
...
init {
create building from: shape_file_buildings with: [type::read ("
NATURE")] {
if type="Industrial" {
color <- #blue ;
}
}
create road from: shape_file_roads ;
}
v 1.8.0 1509
GAMA v1.8.0 documentation Chapter 118. 1. Loading of GIS Data
time step
In GAMA, by default, a time step represents 1 second. It is possible to redefine this
value by overriding the step global variable. This value of the time step is used by
the moving primitives of GAMA.
In our model, we define that a step represent 10 minutes. Note that it is possible to
define the unit of a value by using # + unit name. For instance, #mn or #km for
kilometers.
global {
...
float step <- 10 #mn;
...
}
environment
Building a GIS environment in GAMA requires nothing special, just to define the
bounds of the environment, i.e. the geometry of the world agent. It is possible to use
a shapefile to automatically define it by computing its envelope. In this model, we
use a specific shapefile to define it. However, it would been possible to use the road
shapefile to define it and let GAMA computes it enveloppe automatically.
global {
...
geometry shape <- envelope(shape_file_bounds);
...
}
display
We define a display to visualize the road and building agents. We use for that the
classic species keyword. In order to optimize the display we use an opengl display
(facet type: opengl).
In the experiment block:
output {
display city_display type:opengl {
v 1.8.0 1510
GAMA v1.8.0 documentation Chapter 118. 1. Loading of GIS Data
Complete Model
model tutorial_gis_city_traffic
global {
file shape_file_buildings <- file("../includes/building.shp");
file shape_file_roads <- file("../includes/road.shp");
file shape_file_bounds <- file("../includes/bounds.shp");
geometry shape <- envelope(shape_file_bounds);
float step <- 10 #mn;
init {
create building from: shape_file_buildings with: [type::string(
read ("NATURE"))] {
if type="Industrial" {
color <- #blue ;
}
}
create road from: shape_file_roads ;
}
}
species building {
string type;
rgb color <- #gray ;
aspect base {
draw shape color: color ;
}
}
species road {
rgb color <- #black ;
aspect base {
draw shape color: color ;
}
}
v 1.8.0 1511
GAMA v1.8.0 documentation Chapter 118. 1. Loading of GIS Data
output {
display city_display type:opengl {
species building aspect: base ;
species road aspect: base ;
}
}
}
v 1.8.0 1512
Chapter 119
2. People Agents
This second step Illustrates how to obtain a random point inside a geometry. We will
also define some moving agent called people.
Formulation
• Define a new species of agents: the people agents. The people agents have a
point for geometry and are represented by a yellow circle of radius 10m.
• At initialization, 100 people agents are created. Each people agent is placed
inside a building of type ‘Residential’ (randomly selected).
Model Definition
species
We define a new species of agents: the people agents. In this model, these agents
will not have a specific behavior yet. They will be just displayed. Thus, we just have
to define an aspect for the agents. We want to represent the people agents by a
yellow circle of radius 10m. We then use the circle value for the shape facet of the
draw command, with the expected color and radius size (defined by the facet size).
species people {
rgb color <- #yellow ;
1513
GAMA v1.8.0 documentation Chapter 119. 2. People Agents
aspect base {
draw circle(10) color: color;
}
}
parameter
v 1.8.0 1514
GAMA v1.8.0 documentation Chapter 119. 2. People Agents
display
We add the people agent in the defined display.
output {
display city_display {
species building aspect: base ;
species road aspect: base ;
species people aspect: base ;
}
}
Complete Model
model tutorial_gis_city_traffic
global {
file shape_file_buildings <- file("../includes/building.shp");
file shape_file_roads <- file("../includes/road.shp");
file shape_file_bounds <- file("../includes/bounds.shp");
geometry shape <- envelope(shape_file_bounds);
float step <- 10 #mn;
int nb_people <- 100;
init {
create building from: shape_file_buildings with: [type::string(
read ("NATURE"))] {
if type="Industrial" {
color <- #blue ;
}
}
create road from: shape_file_roads ;
v 1.8.0 1515
GAMA v1.8.0 documentation Chapter 119. 2. People Agents
species building {
string type;
rgb color <- #gray ;
aspect base {
draw shape color: color ;
}
}
species road {
rgb color <- #black ;
aspect base {
draw shape color: color ;
}
}
species people {
rgb color <- #yellow ;
aspect base {
draw circle(10) color: color;
}
}
output {
display city_display type:opengl {
species building aspect: base ;
v 1.8.0 1516
GAMA v1.8.0 documentation Chapter 119. 2. People Agents
v 1.8.0 1517
GAMA v1.8.0 documentation Chapter 119. 2. People Agents
v 1.8.0 1518
Chapter 120
3. Movement of People
This third step presents how to create a road system from GIS data. More precisely,
it shows how to build a graph from a list of polylines and to constrain the movement
of an agent according to this graph.
Formulation
1519
GAMA v1.8.0 documentation Chapter 120. 3. Movement of People
Model Definition
people agents
First, we have to change the skill of the people agents: as we want to use an action
of the moving skill (goto), we will provide the people agents with this skill. A
skill is a built-in module that provide the modeler a self-contain and relevant set of
actions and variables.
species people skills: [moving]{
...
}
Then, we have to add new variables to the people agents: living_place, working_place,
start_work, end_work, objective. In addition, we will add a “the_target” variable
that will represents the point toward which the agent will be currently moving.
species people skills: [moving]{
rgb color <- #yellow ;
building living_place <- nil ;
building working_place <- nil ;
int start_work ;
int end_work ;
string objective ;
point the_target <- nil ;
...
}
We define two reflex methods that allow to change the objective (and the_target) of
the agent at the start_work and en_work hours. Concerning the target value, we
choose a random point in the objective building (working_place or living_place) by
using the any_location_in operator.
species people skills: [moving]{
...
reflex time_to_work when: current_hour = start_work and objective
= "resting"{
objective <- "working" ;
the_target <- any_location_in (working_place);
}
v 1.8.0 1520
GAMA v1.8.0 documentation Chapter 120. 3. Movement of People
At last, we define a reflex method that allows the agent to move. If a target point is
defined (the_target != nil), the agent moves in direction to its target using the goto
action (provided by the moving skill). Note that we specified a graph to constraint
the movement of the agents on the road network with the facet on. We will see later
how this graph is built. The agent uses the shortest path (according to the graph) to
go to the target point. When the agent arrives at destination (the_target = location),
the target is set to nil (the agent will stop moving).
species people skills: [moving]{
...
reflex move when: the_target != nil {
do goto target: the_target on: the_graph ;
if the_target = location {
the_target <- nil ;
}
}
}
parameters
We add several parameters (min_work_start, max_work_start, min_work_-
end, max_work_end, min_speed and max_speed) and two global variables:
the_graph (graph computed from the road network) and current_hour (current
hour of the day). The value of the current_hour variable is automatically computed
at each simulation step and is equals to "(time(the simulation step step) / 1 hour)
modulo 24".
In the global section:
global {
...
int current_hour update: (time / #hour) mod 24;
int min_work_start <- 6;
int max_work_start <- 8;
int min_work_end <- 16;
int max_work_end <- 20;
v 1.8.0 1521
GAMA v1.8.0 documentation Chapter 120. 3. Movement of People
initialization
First, we need to compute from the road agents, a graph for the moving of the
people agents. The operator as_edge_graph allows to do that. It automatically
builds from a set of agents or geometries a graph where the agents are the edges of
the graph, a node represent the extremities of the agent geometry.
init {
...
create road from: shape_file_roads ;
the_graph <- as_edge_graph(road);
...
}
We randomly assign one working place and one house to each people agent. To
simplify the GAML code, we define two temporary variables: the list of buildings of
type ‘Residential’ and the list of buildings of type ‘Industrial’ (by using the where
v 1.8.0 1522
GAMA v1.8.0 documentation Chapter 120. 3. Movement of People
Complete Model
model tutorial_gis_city_traffic
global {
file shape_file_buildings <- file("../includes/building.shp");
file shape_file_roads <- file("../includes/road.shp");
file shape_file_bounds <- file("../includes/bounds.shp");
geometry shape <- envelope(shape_file_bounds);
float step <- 10 #mn;
int nb_people <- 100;
int current_hour update: (time / #hour) mod 24;
int min_work_start <- 6;
int max_work_start <- 8;
int min_work_end <- 16;
int max_work_end <- 20;
float min_speed <- 1.0 #km / #h;
v 1.8.0 1523
GAMA v1.8.0 documentation Chapter 120. 3. Movement of People
init {
create building from: shape_file_buildings with: [type::string(
read ("NATURE"))] {
if type="Industrial" {
color <- #blue ;
}
}
create road from: shape_file_roads ;
the_graph <- as_edge_graph(road);
species building {
string type;
rgb color <- #gray ;
aspect base {
draw shape color: color ;
}
}
species road {
rgb color <- #black ;
aspect base {
draw shape color: color ;
}
}
v 1.8.0 1524
GAMA v1.8.0 documentation Chapter 120. 3. Movement of People
aspect base {
draw circle(10) color: color;
}
}
v 1.8.0 1525
GAMA v1.8.0 documentation Chapter 120. 3. Movement of People
output {
display city_display type:opengl {
species building aspect: base ;
species road aspect: base ;
species people aspect: base ;
}
}
}
v 1.8.0 1526
Chapter 121
The present model will introduce how to design a road system, or graph, based on
the road GIS data and provide each edge a weightrepresenting the destruction level
of the road.
Formulation
• Add a destruction_coeff variable to the road agent. The value of this
variable is higher or equal to 1 or lower or equal to 2. At initialization, the
value of this variable is randomly defined between 1 and 2.
• In the road network graph, more a road is worn out (destruction_coeff high),
more a people agent takes time to go all over it. Then the value of the arc
representing the road in the graph is equal to “length of the road * destruction_-
coeff”.
• The color of the road depends of the destruction_coeff. If “destruction_coeff
= 1”, the road is green, if “destruction_coeff = 2”, the road is red.
Model Definition
road agent
We add a destruction_coeff variable which initial value is randomly defined between
1 and 2 and which have a max of 2. The color of the agent will depend of this variable.
1527
GAMA v1.8.0 documentation Chapter 121. 4. Weight for Road Network
In order to simplify the GAML code, we define a new variable colorValue that
represents the value of red color and that will be defined between 0 and 255.
species road {
float destruction_coeff <- 1 + ((rnd(100))/ 100.0) max: 2.0;
int colorValue <- int(255*(destruction_coeff - 1)) update: int
(255*(destruction_coeff - 1));
rgb color <- rgb(min([255, colorValue]),max ([0, 255 - colorValue])
,0) update: rgb(min([255, colorValue]),max ([0, 255 - colorValue])
,0) ;
...
}
Complete Model
model tutorial_gis_city_traffic
global {
file shape_file_buildings <- file("../includes/building.shp");
file shape_file_roads <- file("../includes/road.shp");
file shape_file_bounds <- file("../includes/bounds.shp");
geometry shape <- envelope(shape_file_bounds);
v 1.8.0 1528
GAMA v1.8.0 documentation Chapter 121. 4. Weight for Road Network
init {
create building from: shape_file_buildings with: [type::string(
read ("NATURE"))] {
if type="Industrial" {
color <- #blue ;
}
}
create road from: shape_file_roads ;
map<road,float> weights_map <- road as_map (each:: (each.
destruction_coeff * each.shape.perimeter));
the_graph <- as_edge_graph(road) with_weights weights_map;
species building {
string type;
rgb color <- #gray ;
v 1.8.0 1529
GAMA v1.8.0 documentation Chapter 121. 4. Weight for Road Network
aspect base {
draw shape color: color ;
}
}
species road {
float destruction_coeff <- 1 + ((rnd(100))/ 100.0) max: 2.0;
int colorValue <- int(255*(destruction_coeff - 1)) update: int
(255*(destruction_coeff - 1));
rgb color <- rgb(min([255, colorValue]),max ([0, 255 - colorValue])
,0) update: rgb(min([255, colorValue]),max ([0, 255 - colorValue])
,0) ;
aspect base {
draw shape color: color ;
}
}
v 1.8.0 1530
GAMA v1.8.0 documentation Chapter 121. 4. Weight for Road Network
aspect base {
draw circle(10) color: color;
}
}
output {
display city_display type:opengl {
species building aspect: base ;
species road aspect: base ;
species people aspect: base ;
}
}
}
v 1.8.0 1531
GAMA v1.8.0 documentation Chapter 121. 4. Weight for Road Network
v 1.8.0 1532
Chapter 122
5. Dynamic weights
This 5th step illustrates how to obtain a shortest path from a point to another and
to update the weights of an existing graph.
Formulation
• At initialization, the value of the destruction_coeff of the road agents will
be equal to 1.
• Add a new parameter: the destroy parameter that represents the value of
destruction when a people agent takes a road. By default, it is equal to 0.02.
• When an people arrive at its destination (home or work), it updates the
destruction_coeff of the road agents it took to reach its destination: “de-
struction_coeff = destruction_coeff - destroy”. Then, the graph is updated.
Model Definition
global section
1533
GAMA v1.8.0 documentation Chapter 122. 5. Dynamic weights
We define a new reflex that updates the graph at each simulation step. For that, we
use the with_weights operator. This operator allows to update the weights of an
existing graph.
global {
...
reflex update_graph{
map<road,float> weights_map <- road as_map (each:: (each.
destruction_coeff * each.shape.perimeter));
the_graph <- the_graph with_weights weights_map;
}
}
people agents
At each time-step, after a people agent have moved over one or multiple segments,
it updates the value of the destruction coefficient of road agents crossed (i.e. roads
belonging to the path followed). We have for that to set the argument return_path
to true in the goto action to obtain the path followed, then to compute the list of
agents concerned by this path with the operator agent_from_geometry.
species people skills: [moving]{
...
reflex move when: the_target != nil {
path path_followed <- self goto [target::the_target, on::
the_graph, return_path:: true];
list<geometry> segments <- path_followed.segments;
loop line over: segments {
float dist <- line.perimeter;
ask road(path_followed agent_from_geometry line) {
destruction_coeff <- destruction_coeff + (destroy *
dist / shape.perimeter);
}
}
if the_target = location {
the_target <- nil ;
}
}
v 1.8.0 1534
GAMA v1.8.0 documentation Chapter 122. 5. Dynamic weights
...
}
Complete Model
model tutorial_gis_city_traffic
global {
file shape_file_buildings <- file("../includes/building.shp");
file shape_file_roads <- file("../includes/road.shp");
file shape_file_bounds <- file("../includes/bounds.shp");
geometry shape <- envelope(shape_file_bounds);
float step <- 10 #mn;
int nb_people <- 100;
int current_hour update: (time / #hour) mod 24;
int min_work_start <- 6;
int max_work_start <- 8;
int min_work_end <- 16;
int max_work_end <- 20;
float min_speed <- 1.0 #km / #h;
float max_speed <- 5.0 #km / #h;
float destroy <- 0.02;
graph the_graph;
init {
create building from: shape_file_buildings with: [type::string(
read ("NATURE"))] {
if type="Industrial" {
color <- #blue ;
}
}
create road from: shape_file_roads ;
map<road,float> weights_map <- road as_map (each:: (each.
destruction_coeff * each.shape.perimeter));
the_graph <- as_edge_graph(road) with_weights weights_map;
v 1.8.0 1535
GAMA v1.8.0 documentation Chapter 122. 5. Dynamic weights
reflex update_graph{
map<road,float> weights_map <- road as_map (each:: (each.
destruction_coeff * each.shape.perimeter));
the_graph <- the_graph with_weights weights_map;
}
}
species building {
string type;
rgb color <- #gray ;
aspect base {
draw shape color: color ;
}
}
species road {
float destruction_coeff <- 1 + ((rnd(100))/ 100.0) max: 2.0;
int colorValue <- int(255*(destruction_coeff - 1)) update: int
(255*(destruction_coeff - 1));
rgb color <- rgb(min([255, colorValue]),max ([0, 255 - colorValue])
,0) update: rgb(min([255, colorValue]),max ([0, 255 - colorValue])
,0) ;
aspect base {
draw shape color: color ;
}
}
v 1.8.0 1536
GAMA v1.8.0 documentation Chapter 122. 5. Dynamic weights
string objective ;
point the_target <- nil ;
aspect base {
draw circle(10) color: color;
}
}
v 1.8.0 1537
GAMA v1.8.0 documentation Chapter 122. 5. Dynamic weights
v 1.8.0 1538
Chapter 123
6. Charts
Formulation
• Add a chart to display the evolution of the road destruction: the mean value
of the destruction_coeff of the road 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).
Model Definition
chart display
First we add a chart of type series to display the road destruction evolution. To
compute the mean of the destruction_coeff, we use the mean operator. For the
max, we use the max_of operator.
output {
display chart_display refresh:every(10#cycles) {
chart "Road Status" type: series size: {1, 0.5} position:
{0, 0} {
1539
GAMA v1.8.0 documentation Chapter 123. 6. Charts
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 to compute 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 ;
}
}
}
Complete Model
model tutorial_gis_city_traffic
global {
file shape_file_buildings <- file("../includes/building.shp");
file shape_file_roads <- file("../includes/road.shp");
file shape_file_bounds <- file("../includes/bounds.shp");
geometry shape <- envelope(shape_file_bounds);
float step <- 10 #mn;
int nb_people <- 100;
int current_hour update: (time / #hour) mod 24;
int min_work_start <- 6;
int max_work_start <- 8;
int min_work_end <- 16;
v 1.8.0 1540
GAMA v1.8.0 documentation Chapter 123. 6. Charts
init {
create building from: shape_file_buildings with: [type::string(
read ("NATURE"))] {
if type="Industrial" {
color <- #blue ;
}
}
create road from: shape_file_roads ;
map<road,float> weights_map <- road as_map (each:: (each.
destruction_coeff * each.shape.perimeter));
the_graph <- as_edge_graph(road) with_weights weights_map;
reflex update_graph{
map<road,float> weights_map <- road as_map (each:: (each.
destruction_coeff * each.shape.perimeter));
the_graph <- the_graph with_weights weights_map;
}
}
species building {
string type;
rgb color <- #gray ;
v 1.8.0 1541
GAMA v1.8.0 documentation Chapter 123. 6. Charts
aspect base {
draw shape color: color ;
}
}
species road {
float destruction_coeff <- 1 + ((rnd(100))/ 100.0) max: 2.0;
int colorValue <- int(255*(destruction_coeff - 1)) update: int
(255*(destruction_coeff - 1));
rgb color <- rgb(min([255, colorValue]),max ([0, 255 - colorValue])
,0) update: rgb(min([255, colorValue]),max ([0, 255 - colorValue])
,0) ;
aspect base {
draw shape color: color ;
}
}
v 1.8.0 1542
GAMA v1.8.0 documentation Chapter 123. 6. Charts
aspect base {
draw circle(10) color: color;
}
}
v 1.8.0 1543
GAMA v1.8.0 documentation Chapter 123. 6. Charts
v 1.8.0 1544
Chapter 124
This 7th step illustrates how to select in a list an element that optimize a given
function.
Formulation
• Add a new parameter, repair_time, that is equal to 2.
• Every repair_time, the road with the highest destruction_coeff value is
repaired (set its destruction_coeff to 1).
Model Definition
parameters
We add a new parameter: the repair_time.
In the global section, definition of the repair_time variable:
int repair_time <- 2 ;
1545
GAMA v1.8.0 documentation Chapter 124. 7. Automatic Road Repair
road repairing
We have to add a reflex method in the global section that is triggered every repair_-
time hours / step. This method selects, thanks to the with_max_of operation
the road agent with the highest destruction_coeff value, then sets this value at 1.
global {
...
reflex repair_road when: every(repair_time #hour / step) {
road the_road_to_repair <- road with_max_of (each.destruction_coeff
) ;
ask the_road_to_repair {
destruction_coeff <- 1.0 ;
}
}
}
Complete Model
model tutorial_gis_city_traffic
global {
file shape_file_buildings <- file("../includes/building.shp");
file shape_file_roads <- file("../includes/road.shp");
file shape_file_bounds <- file("../includes/bounds.shp");
geometry shape <- envelope(shape_file_bounds);
float step <- 10 #mn;
int nb_people <- 100;
int current_hour update: (time / #hour) mod 24;
int min_work_start <- 6;
int max_work_start <- 8;
int min_work_end <- 16;
int max_work_end <- 20;
float min_speed <- 1.0 #km / #h;
float max_speed <- 5.0 #km / #h;
float destroy <- 0.02;
int repair_time <- 2 ;
graph the_graph;
init {
create building from: shape_file_buildings with: [type::string(
read ("NATURE"))] {
if type="Industrial" {
v 1.8.0 1546
GAMA v1.8.0 documentation Chapter 124. 7. Automatic Road Repair
reflex update_graph{
map<road,float> weights_map <- road as_map (each:: (each.
destruction_coeff * each.shape.perimeter));
the_graph <- the_graph with_weights weights_map;
}
reflex repair_road when: every(repair_time #hour / step) {
road the_road_to_repair <- road with_max_of (each.
destruction_coeff) ;
ask the_road_to_repair {
destruction_coeff <- 1.0 ;
}
}
}
species building {
string type;
rgb color <- #gray ;
aspect base {
draw shape color: color ;
v 1.8.0 1547
GAMA v1.8.0 documentation Chapter 124. 7. Automatic Road Repair
}
}
species road {
float destruction_coeff <- 1 + ((rnd(100))/ 100.0) max: 2.0;
int colorValue <- int(255*(destruction_coeff - 1)) update: int
(255*(destruction_coeff - 1));
rgb color <- rgb(min([255, colorValue]),max ([0, 255 - colorValue])
,0) update: rgb(min([255, colorValue]),max ([0, 255 - colorValue])
,0) ;
aspect base {
draw shape color: color ;
}
}
v 1.8.0 1548
GAMA v1.8.0 documentation Chapter 124. 7. Automatic Road Repair
}
}
if the_target = location {
the_target <- nil ;
}
}
aspect base {
draw circle(10) color: color;
}
}
output {
display city_display type:opengl {
species building aspect: base ;
species road aspect: base ;
species people aspect: base ;
}
display chart_display refresh:every(10#cycles) {
v 1.8.0 1549
GAMA v1.8.0 documentation Chapter 124. 7. Automatic Road Repair
v 1.8.0 1550
Chapter 125
3D Tutorial
Model Overview
Step List
This tutorial is composed of 3 steps corresponding to 3 models. For each step we
present its purpose, an explicit formulation and the corresponding GAML code.
1. Basic model
2. Moving cells
3. Moving cells with neighbors
1551
GAMA v1.8.0 documentation Chapter 125. 3D Tutorial
v 1.8.0 1552
Chapter 126
1. Basic Model
In this first step, we will see how to define a 3D environment and populate it.
Formulation
Initialize a 3D world with a population of cells placed randomly in a 3D 100x100x100
cube.
Model Definition
In this model we define one species of agent: the cells agents. The agents will be
just displayed as a blue sphere of radius 1.
species cells{
aspect default {
draw sphere(1) color:#blue;
}
}
1553
GAMA v1.8.0 documentation Chapter 126. 1. Basic Model
v 1.8.0 1554
GAMA v1.8.0 documentation Chapter 126. 1. Basic Model
Global Section
Global variable
Definition of a global variable nb_cells of type int representing the number of cells
agents.
global {
int nb_cells <-100;
}
Model initialization
Definition of the init block in order to create nb_cells cells agents. By default an
agent is created with a random location in x and y, and a z value equal to 0. In our
case we want to place the cells randomly in the 3D environment so we set a random
value for x, y and z.
create cells number: nb_cells {
location <- {rnd(100), rnd(100), rnd(100)};
}
Experiment
Input
v 1.8.0 1555
GAMA v1.8.0 documentation Chapter 126. 1. Basic Model
Output
Complete Model
This model is available in the model library (under Tutorials > 3D) and the GIT
version of the model can be found here Model 01.gaml
model Tuto3D
global {
int nb_cells <-100;
init {
create cells number: nb_cells {
location <- {rnd(100), rnd(100), rnd(100)};
}
}
}
species cells{
aspect default {
draw sphere(1) color:#blue;
}
}
v 1.8.0 1556
Chapter 127
2. Moving Cells
This second step model adds the moving3D skills to the cell agents and simply
makes move the cells agent by defining a reflex that will call the action move. We
will also add additional visual information to the display.
Formulation
• Redefining the shape of the world with a 3D Shape.
• Attaching new skills (moving3D) to cells agent.
• Modify cells aspect
• Add a graphics layer
Model Definition
Global Section
Global variable
We use a new global variable called _environmentSize_that to define the size of our
3D environment. In the global section we define the new variable
int environmentSize <-100;
1557
GAMA v1.8.0 documentation Chapter 127. 2. Moving Cells
Then we redefine the shape of the world (by default the shape of the world is a
100x100 square) as cube that will have the size defined by the environment_size
variable. To do so we change the shape of the world in the global section:
geometry shape <- cube(environmentSize);
Model initialization
When we create the cells agent we want to place them randomly in the 3D environe-
ment. To do so we set the location with a random value for x, y and z between 0 and
environmentSize.
create cells number: nb_cells {
location <- {rnd(environmentSize), rnd(environmentSize), rnd(
environmentSize)};
}
Moving3D skills
In the previous example, we only created cells agent that did not have any behavior.
In this step we want to make move the cells agent. To do so we add a moving3D
skills to the cells.
More information on built-in skills proposed by Gama can be found here
species cells skills:[moving3D]{
...
}
Then we define a new reflex for the species cells that consists in calling the action
move
bundled in moving3D skills.
reflex move{
do move;
}
Finally we modify a bit the aspect of the sphere to set its size according to the
environmentSize global variable previously defined.
aspect default {
draw sphere(environmentSize*0.01) color:#blue;
}
v 1.8.0 1558
GAMA v1.8.0 documentation Chapter 127. 2. Moving Cells
Experiment
The experiment is the same as the previous one except that we will display the bounds
of the environment by using the graphics layer.
graphics "env"{
draw cube(environmentSize) color: #black empty:true;
}
Output
output {
display View1 type:opengl{
graphics "env"{
draw cube(environmentSize) color: #black empty:true;
}
species cells;
}
}
Complete Model
The GIT version of the model can be found here Model 02.gaml
model Tuto3D
global {
int nb_cells <-100;
int environmentSize <-100;
geometry shape <- cube(environmentSize);
init {
create cells number: nb_cells {
location <- {rnd(environmentSize), rnd(environmentSize), rnd(
environmentSize)};
}
}
}
reflex move{
v 1.8.0 1559
GAMA v1.8.0 documentation Chapter 127. 2. Moving Cells
do move;
}
aspect default {
draw sphere(environmentSize*0.01) color:#blue;
}
}
v 1.8.0 1560
Chapter 128
3. Connections
Formulation
• Mapping the network of connection
Model Definition
In this final step we will display edges between cells that are within a given distance.
Cells update
We add a new reflex to collect the neighbors of the cell that are within a certain
distance :
species cells skills:[moving3D]{
...
reflex computeNeighbors {
neighbors <- cells select ((each distance_to self) <
10);
}
}
Then we update the cell aspect as follows. For each elements (cells) of the neighbors
list we draw a line between this neighbor’s location and the current cell’s location.
1561
GAMA v1.8.0 documentation Chapter 128. 3. Connections
aspect default {
draw sphere(environmentSize*0.01) color:#orange;
loop pp over: neighbors {
draw line([self.location,pp.location]);
}
}
Complete Model
The GIT version of the model can be found here Model 03.gaml
model Tuto3D
global {
int nb_cells <-100;
int environmentSize <-100;
geometry shape <- cube(environmentSize);
init {
create cells number: nb_cells {
location <- {rnd(environmentSize), rnd(environmentSize), rnd(
environmentSize)};
}
}
}
reflex move {
do wander;
}
reflex computeNeighbors {
neighbors <- cells select ((each distance_to self) < 10);
}
aspect default {
draw sphere(environmentSize*0.01) color:#orange;
loop pp over: neighbors {
draw line([self.location,pp.location]);
}
v 1.8.0 1562
GAMA v1.8.0 documentation Chapter 128. 3. Connections
}
}
v 1.8.0 1563
GAMA v1.8.0 documentation Chapter 128. 3. Connections
v 1.8.0 1564
Chapter 129
Incremental Model
This tutorial has for goal to give an overview all most of the capabilities of GAMA. In
particular, it presents how to build a simple model and the use of GIS data, graphs,
3D visualization, multi-level modeling and differential equations. All the files related
to this tutorial (images and models) are available in the Models Library (project
Tutorials/Incremental Model).
Model Overview
The model built in this tutorial concerns the study of the spreading of a disease in a
small city. Three type of entities are taken into account: the people, the buildings
and the roads.
We made the following modeling choice:
1565
GAMA v1.8.0 documentation Chapter 129. Incremental Model
Step List
This tutorial is composed of 7 steps corresponding to 7 models. For each step we
present its purpose, an explicit formulation and the corresponding GAML code.
1. Simple SI Model
2. Charts
3. Integration of GIS Data
4. Movement on Graph
5. Visualizing in 3D
6. Multi-Level
7. Differential Equations
v 1.8.0 1566
Chapter 130
1. Simple SI Model
This first step Illustrates how to write a model in GAMA. In particular, it describes
how to structure a model and how to define species - that are the key components of
GAMA models.
Formulation
• Definition of the people species with a variable (is_infected) , an aspect (base)
and two behaviors (move and infect)
• Definition of nb_infected_init, distance_infection and proba_infection
parameters
• Creation of 500 people agents randomly located in the environment (size:
500x500)
• Definition a display to visualize the people agents.
Model Definition
model structure
1567
GAMA v1.8.0 documentation Chapter 130. 1. Simple SI Model
v 1.8.0 1568
GAMA v1.8.0 documentation Chapter 130. 1. Simple SI Model
• global : this section, that is unique, defines the “world” agent, a special agent
of a GAMA model. It represents all that is global to the model: dynamics,
variables, actions. In addition, it allows to initialize the simulation (init block).
• species : these sections define the species of agents composing the model.
• experiment : these sections define a context of execution of the simulations.
In particular, it defines the input (parameters) and output (displays, files. . . )
of a model.
More details about the different sections of a GAMA model can be found here.
species
A species represents a «prototype» of agents: it defines their common properties.
A species includes several sub-definitions:
GAMA provides as well the possibility to give skills to species of agents. A skill is a
module integrating variables and actions coded in Java.
Concerning our model, we will give the moving skill to the people agents: it will
give to the people agents supplementary variables (speed, heading, destination) and
actions (follow, goto, move, wander).
species people skills:[moving]{
}
Concerning the internal state, a attribute is defined as follows: type of the attribute
(int (integer), float (floating point number), string, bool (boolean, true or false), point
(coordinates), list, pair, map, file, matrix, agent species, rgb (color), graph, path. . . )
+ name
• Optional facets: <- (initial value), update (value recomputed at each step of
the simulation), function:{..} (value computed each time the variable is used),
min, max
v 1.8.0 1569
GAMA v1.8.0 documentation Chapter 130. 1. Simple SI Model
Note that all the species inherit from predefined built-in variables:
• A name (name)
• A shape (shape)
• A location (location): the centroid of its shape.
We define an aspect for this species. In this model, we want to display for each
people agent a circle of radius 5 and red or green according to the value of is_infected
(if infected: red, green otherwise). We then use the keyword draw with a circle
shape. To define the color that depends on is_infected, we use the tertiary operator
condition ? val1 : val2. If the condition is true, this operator will return val1,
otherwise val2. Note that it is possible to get a color value by using the symbol # +
color name: e.g. #blue, #red, #white, #yellow, #magenta, #pink. . .
species people skills:[moving]{
...
aspect circle{
draw circle(5) color:is_infected ? #red : #green;
}
}
Concerning the behavior of agents, the simplest way to define it is through reflexes.
A reflex is a block of statements (that can be defined in global or any species) that
will be automatically executed at each simulation step if its condition is true. A reflex
is defined as follows:
v 1.8.0 1570
GAMA v1.8.0 documentation Chapter 130. 1. Simple SI Model
reflex reflex_name when: condition {...}
The when facet is optional: when it is omitted, the reflex is activated at each time
step. Note that if several reflexes are defined for a species, the reflexes will be activated
following their definition order.
We define a first reflex called move that allows the people agents to move using the
wander action (provided by the moving skill) that allows to randomly move (with
taking into account the agent speed)
species people {
...
reflex move{
do wander;
}
}
Note that an action is a capability available to the agents of a species (what they
can do). It is a block of statements that can be used and reused whenever needed.
Some actions, called primitives, are directly coded in Java: for instance, the wander
action defined in the moving skill.
• An action can accept arguments. For instance, write takes an argument called
message.
• An action can return a result.
There are two ways to call an action: using a statement or as part of an expression
The second reflex we have to define is the infect one. This reflex will be activated
only if is_infected is true. This reflex consists is asking all the people agents at a
distance lower or equal to infection_distance to become infected with a probability
proba_infection.
v 1.8.0 1571
GAMA v1.8.0 documentation Chapter 130. 1. Simple SI Model
species people skills:[moving]{
...
reflex infect when: is_infected{
ask people at_distance infection_distance {
if flip(proba_infection) {
is_infected <- true;
}
}
}
...
}
Note that we used the ask statement. This statement allows to make a remote agent
executes a list of statements. We used as well the flip operator that allows to test a
probability.
global section
The global section represents the definition of the species of a specific agent (called
world). The world agent represents everything that is global to the model: dynamics,
variables. . . It allows to init simulations (init block): the world is always created and
initialized first when a simulation is launched. The geometry (shape) of the world
agent is by default a square with 100m for side size, but can be redefined if necessary.
In the same way, the modeler can redefine the step variable that represents the
duration of a simulation step and that is by default 1 second.
global variable
For our model, we define 4 global variables: nb_people (int, init value: 500),
infection distance (float value, init value: 2 meters), proba_infection (float, init
value: 0.05) and nb_infected_init (int, init value: 5). In addition, we redefine the
geometry of the world by a square of 500 meters size and a simulation step of 1
minute.
global{
int nb_people <- 500;
float infection_distance <- 2.0 #m;
float proba_infection <- 0.05;
int nb_infected_init <- 5;
float step <- 1 #minutes;
v 1.8.0 1572
GAMA v1.8.0 documentation Chapter 130. 1. Simple SI Model
Model initialization
The init section of the global block allows to initialize the model. The statement
create allows to create agents of a specific species: create species_name + :
For our model, the definition of the init block in order to create nb_people people
agents. We set the init value of the speed variable (given by the moving skill) to
5km/h. > In addition we ask nb_infected_init people to become infected (use of
the nb among list to randomly draw nb elements of the list).
global{
...
init{
create people number:nb_people {
speed <- 5.0 #km/#h;
}
ask nb_infected_init among people {
is_infected <- true;
}
}
}
experiment
An experiment block defines how a model can be simulated (executed). Several
experiments can be defined for a model. They are defined using : experiment
exp_name type: gui/batch {[input] [output]}
• gui: experiment with a graphical interface, which displays its input parameters
and outputs.
• batch: Allows to setup a series of simulations (w/o graphical interface).
v 1.8.0 1573
GAMA v1.8.0 documentation Chapter 130. 1. Simple SI Model
input
Note that the init, min and max values can be defined in the global variable definition.
In the experiment, definition of three parameters from the the global variable infec-
tion_distance, proba_infection and nb_infected_init :
experiment main_experiment type:gui{
parameter "Infection distance" var: infection_distance;
parameter "Proba infection" var: proba_infection min: 0.0 max: 1.0;
parameter "Nb people infected at init" var: nb_infected_init ;
...
}
output
Output blocks are defined in an experiment and define how to visualize a simulation
(with one or more display blocks that define separate windows). Each display can be
refreshed independently by defining the facet refresh_every: nb (int) (the display
will be refreshed every nb steps of the simulation).
Each display can include different layers (like in a GIS):
v 1.8.0 1574
GAMA v1.8.0 documentation Chapter 130. 1. Simple SI Model
Note that it is possible to define a opengl display (for 3D display) by using the facet
type: opengl.
In our model, we define a display to draw the people agents with their circle aspect.
experiment main_experiment type:gui{
...
output {
display map {
species people aspect:circle;
}
}
}
Complete Model
model SI_city
global{
int nb_people <- 500;
float agent_speed <- 5.0 #km/#h;
float infection_distance <- 2.0 #m;
float proba_infection <- 0.05;
int nb_infected_init <- 5;
float step <- 1 #minutes;
geometry shape<-square(500 #m);
init{
create people number:nb_people;
ask nb_infected_init among people {
is_infected <- true;
}
}
v 1.8.0 1575
GAMA v1.8.0 documentation Chapter 130. 1. Simple SI Model
v 1.8.0 1576
Chapter 131
2. Charts
This step Illustrates how to define monitors and charts in GAMA. In addition, it
illustrates how to define a stopping condition for the simulation.
Formulation
• Definition of new global variables: current_hour, nb_people_infected, nb_-
people_not_infected, infected_rate
• Definition of a monitor to follow the current hour and the nb of people infected
• Definition of a series chart to follow the number of people infected and not
infected
• Definition of a stopping condition (when infected rate = 1)
Model Definition
global variables
In order to define dynamic variable able to update itself, we use the update facet
of variable definition. Indeed, at each simulation step, all the agents (and the world
agent) apply for each dynamic variable (in their definition order) its update expression.
We define 4 new variables:
1577
GAMA v1.8.0 documentation Chapter 131. 2. Charts
global{
...
int current_hour update: (cycle / 60) mod 24;
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;
...
}
v 1.8.0 1578
GAMA v1.8.0 documentation Chapter 131. 2. Charts
stopping condition
We add a new reflex that stops the simulation if the infected_rate is equal to 1.
To stop the simulation, we use the pause action.
global {
...
reflex end_simulation when: infected_rate = 1.0 {
do pause;
}
}
monitor
With:
In this model, we define 2 monitors to follow the value of the variable current_hour
and infected_rate:
experiment main_experiment type:gui{
...
output {
monitor "Current hour" value: current_hour;
monitor "Infected people rate" value: infected_rate;
...
}
}
v 1.8.0 1579
GAMA v1.8.0 documentation Chapter 131. 2. Charts
chart
GAMA can display various chart types:
• Time series
• Pie charts
• Histograms
A chart must be defined in a display: it behaves exactly like any other layer. Definition
of a chart :
chart chart_name type: chart_type {
[data]
}
We add a new display called chart refresh every 10 simulation steps. Inside this
display, we define a chart of type series:
v 1.8.0 1580
GAMA v1.8.0 documentation Chapter 131. 2. Charts
Complete Model
model SI_city
global{
int nb_people <- 500;
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 current_hour update: (cycle / 60) mod 24;
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/length(people);
init{
create people number:nb_people {
speed <- 5.0 #km/#h;
}
ask nb_infected_init among people {
is_infected <- true;
}
}
reflex end_simulation when: infected_rate = 1.0 {
do pause;
}
}
v 1.8.0 1581
GAMA v1.8.0 documentation Chapter 131. 2. Charts
}
}
v 1.8.0 1582
Chapter 132
Formulation
• Load, agentify and display two layers of GIS data (building and road)
• Modify the initialization of the people agents to put them inside buildings
Model Definition
species
We have to define two species of agents: the building agents and the road ones.
These agents will not have a particular behavior, they will just be displayed. We
define an aspect for these species. In this model, we want to represent the geometry
of the agent, we then use the keyword draw that allow to draw a given geometry.
In order to draw the geometry of the agent we use the attribute shape (which is a
built-in attribute of all agents).
species building {
aspect geom {
draw shape color: #gray;
}
1583
GAMA v1.8.0 documentation Chapter 132. 3. Integration of GIS Data
v 1.8.0 1584
GAMA v1.8.0 documentation Chapter 132. 3. Integration of GIS Data
species road {
aspect geom {
draw shape color: #black;
}
}
parameters
GAMA allows to automatically read GIS data that are formatted as shapefiles. In
order to let the user chooses his/her shapefiles, we define two parameters. One
allowing the user to choose the road shapefile, one allowing him/her to choose the
building shapefile.
Definition of the two global variables of type file concerning the GIS files:
global {
file shape_file_buildings <- file("../includes/building.shp");
file shape_file_roads <- file("../includes/road.shp");
}
v 1.8.0 1585
GAMA v1.8.0 documentation Chapter 132. 3. Integration of GIS Data
}
ask nb_infected_init among people {
is_infected <- true;
}
}
}
We defined here a local variable called bd of type building that is a one of the
building (randomly chosen). Note that the name of a species can be used to obtain
all the agents of this species (here building returns the list of all the buildings). The
any_location_in returns a random point inside a geometry or an agent geometry.
environment
Building a GIS environment in GAMA requires nothing special, just to define the
bounds of the environment, i.e. the geometry of the world agent. It is possible to use
a shapefile to automatically define it by computing its envelope. In this model, we
use the road shapefile to define it.
global {
...
geometry shape <- envelope(shape_file_roads);
...
}
display
v 1.8.0 1586
GAMA v1.8.0 documentation Chapter 132. 3. Integration of GIS Data
Complete Model
model model3
global {
int nb_people <- 500;
float step <- 1 #minutes;
float infection_distance <- 2.0 #m;
float proba_infection <- 0.05;
int nb_infected_init <- 5;
file roads_shapefile <- file("../includes/road.shp");
file buildings_shapefile <- file("../includes/building.shp");
geometry shape <- envelope(roads_shapefile);
int current_hour update: (cycle / 60) mod 24;
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;
reflex move{
do wander;
}
reflex infect when: is_infected{
ask people at_distance infection_distance {
v 1.8.0 1587
GAMA v1.8.0 documentation Chapter 132. 3. Integration of GIS Data
if flip(proba_infection) {
is_infected <- true;
}
}
}
aspect circle{
draw circle(5) color:is_infected ? #red : #green;
}
}
species road {
aspect geom {
draw shape color: #black;
}
}
species building {
aspect geom {
draw shape color: #gray;
}
}
v 1.8.0 1588
Chapter 133
4. Movement on Graph
This step illustrates how load a graph and use it for the displacement of our species.
Formulation
• definition of a global graph to represent the road network
• definition of a new global variable: staying_coeff to represent the fact that
people move more near 9h, 12h and 18h
• definition of two new variables for the people agents: target and staying_-
counter
• definition of a new reflex for people agents: stay
• modification of the move reflex of the people agents
Model Definition
global variables
We define two new global variables:
• road_network (graph) : represents the graph that will be built from the road
network
1589
GAMA v1.8.0 documentation Chapter 133. 4. Movement on Graph
• staying_coeff (float) : represents the fact that people have more chance to
move from their current building near 9h (go to work), 12h (lunch time) and
18h (go home). This variable is updated at each simulation step (use of the
update facet).
global{
....
graph road_network;
float staying_coeff update: 10.0 ^ (1 + min([abs(current_hour - 9),
abs(current_hour - 12),
abs(current_hour - 18)]));
....
}
initialization
We need to compute from the road agents, a graph for the moving of the people
agents. The operator as_edge_graph allows to do that. It automatically builds
from a set of agents or geometries a graph where the agents are the edges of the
graph, a node represent the extremities of the agent geometry. The weight of each
edge corresponds to the length of the road.
v 1.8.0 1590
GAMA v1.8.0 documentation Chapter 133. 4. Movement on Graph
global {
...
init {
...
create road from: roads_shapefile;
road_network <- as_edge_graph(road);
...
}
}
people agent
First, we add two new variables for the people agents:
• target (point): the target location that the people want to reach (a point inside
a building)
• staying_counter (int): the number of cycles since the agent arrived at its
building
We define a new reflex called stay that is activated when the agent has no target
(target = nil), i.e. when the agent is inside a building. This reflex increments the
staying_counter, then it test the probability to leave that is computed from the
staying_counter (longer the agent is inside the building, more it has a chance to
leave) and the staying_coeff (closer to 9h, 12h and 18h, more the agent has a chance
to leave). If the agents decide to leave, it computes a new target as a random point
inside one of the buildings (randomly chosen).
species people skills:[moving]{
...
reflex stay when: target = nil {
staying_counter <- staying_counter + 1;
if flip(staying_counter / staying_coeff) {
target <- any_location_in (one_of(building));
}
}
...
}
We modify the move reflex. Now, this reflex is activated only when the agent has a
target (target != nil). In this case the agent moves in direction to its target using
v 1.8.0 1591
GAMA v1.8.0 documentation Chapter 133. 4. Movement on Graph
the goto action. Note that we specified a graph (road_network) to constraint the
moving of the agents on the road network with the facet on. The agent uses the
shortest path (according to the graph) to go to the target point. When the agent
arrives at destination (location = location), the target is set to nil (the agent will
stop moving) and the staying_counter is set to 0.
species people skills:[moving]{
...
reflex move when: target != nil{
do goto target:target on: road_network;
if (location = target) {
target <- nil;
staying_counter <- 0;
}
}
}
Complete Model
model model4
global {
int nb_people <- 500;
float step <- 1 #minutes;
float infection_distance <- 2.0 #m;
float proba_infection <- 0.05;
int nb_infected_init <- 5;
file roads_shapefile <- file("../includes/road.shp");
file buildings_shapefile <- file("../includes/building.shp");
geometry shape <- envelope(roads_shapefile);
int current_hour update: (cycle / 60) mod 24;
graph road_network;
float staying_coeff update: 10.0 ^ (1 + min([abs(current_hour - 9),
abs(current_hour - 12), abs(current_hour - 18)]));
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;
v 1.8.0 1592
GAMA v1.8.0 documentation Chapter 133. 4. Movement on Graph
species road {
v 1.8.0 1593
GAMA v1.8.0 documentation Chapter 133. 4. Movement on Graph
aspect geom {
draw shape color: #black;
}
}
species building {
aspect geom {
draw shape color: #gray;
}
}
v 1.8.0 1594
Chapter 134
5. Visualizing in 3D
Formulation
• add a variable (height: int from 10m to 20m) and modify the aspect of buildings
to display them in 3D
• add a variable (display_shape: geometry; shape with a buffer of 2m) and modify
the aspect of the roads to display them with this new shape.
• add a new global variable that indicate if it is night or not (bool: night before
7h and after 20h).
• define a new aspect (sphere3D) for people to display them as sphere.
• modify the display to use this new aspect.
Model Definition
building
First, we add a new variable for buildings (height) of type float from 10m to 20m.
Then we modify the aspect in order to specify a depth for the geometry (using the
depth facet).
1595
GAMA v1.8.0 documentation Chapter 134. 5. Visualizing in 3D
species building {
float height <- 10#m + rnd(10) #m;
aspect geom {
draw shape color: #gray depth: height;
}
}
road
Concerning the road, we add a new variable (display_shape) of type geometry that
correspond to the shape of the road with a buffer of 2 meters. Then we modify the
aspect in order to display this geometry instead of the shape of the agent. In order
to avoid “z-fighting” problems, we add a depth to the geometry (of 3 meters).
species road {
geometry display_shape <- shape + 2.0;
aspect geom {
draw display_shape color: #black depth: 3.0;
}
}
v 1.8.0 1596
GAMA v1.8.0 documentation Chapter 134. 5. Visualizing in 3D
global variable
We define a new global variable called is_night of type bool to indicate if it is night
or not. This variable will be update at each simulation step and will be true if the
current_hour is lower than 7h or higher than 20h.
global{
...
bool is_night <- true update: current_hour < 7 or current_hour
> 20;
...
}
people
We define a new aspect for the people agent called sphere3D. This aspect draw
people agent as a 3m sphere. In order to avoid to cut the sphere in half, we translate
the centroid of the drawn sphere to 3m along the z axis.
species people skills:[moving]{
...
aspect sphere3D{
draw sphere(3) at: {location.x,location.y,location.z + 3} color
:is_infected ? #red : #green;
}
}
display
The element that we have to modify is the display. We change its name to map_3D
to better reflect its visual aspect.
In order to get a 3D aspect, we specify that this display will be an opengl one. For
that, we just have to add the facet type: opengl. In addition, to get a different
light between night and day : The statement light allows us to declare a light. We
can change up to 7 lights, called through the facet “id”. The default light is a white
light, directional, with the id=1. You can set the intensity of the light through the
facet “color” (you can pass a color, or an integer between 0 and 255). To have a nice
effect night / day, we will set the intensity of the light to 50 during the night, and
255 for the day. To learn more about light, please read this page.
v 1.8.0 1597
GAMA v1.8.0 documentation Chapter 134. 5. Visualizing in 3D
Then, we add a new layer that consists in an image (soil.jpg) by using the image
statement. In order to see the people inside the building, we add transparency to
the building (0.5). The transparency of a layer is a float value between 0 (solid)
and 1 (totally transparent). In order to be able to manage this transparency aspect,
opengl has to draw the people agents before the building, thus we modify the order
of drawing of the different layers (people agents before building agents). At last, we
modify the aspect of the people agents by the new one: sphere3D.
experiment main_experiment type:gui{
...
output {
...
display map_3D type: opengl {
light 1 color:(is_night ? 50 : 255);
image "../includes/soil.jpg";
species road aspect:geom;
species people aspect:sphere3D;
species building aspect:geom transparency: 0.5;
}
...
}
}
Complete Model
model model5
global {
int nb_people <- 500;
float step <- 1 #minutes;
float infection_distance <- 2.0 #m;
float proba_infection <- 0.05;
int nb_infected_init <- 5;
file roads_shapefile <- file("../includes/road.shp");
file buildings_shapefile <- file("../includes/building.shp");
geometry shape <- envelope(roads_shapefile);
graph road_network;
int current_hour update: (cycle / 60) mod 24;
float staying_coeff update: 10.0 ^ (1 + min([abs(current_hour - 9),
abs(current_hour - 12), abs(current_hour - 18)]));
int nb_people_infected <- nb_infected_init update: people count (
each.is_infected);
v 1.8.0 1598
GAMA v1.8.0 documentation Chapter 134. 5. Visualizing in 3D
v 1.8.0 1599
GAMA v1.8.0 documentation Chapter 134. 5. Visualizing in 3D
}
}
}
aspect circle{
draw circle(5) color:is_infected ? #red : #green;
}
aspect sphere3D{
draw sphere(3) at: {location.x,location.y,location.z + 3} color
:is_infected ? #red : #green;
}
}
species road {
geometry display_shape <- shape + 2.0;
aspect geom {
draw display_shape color: #black depth: 3.0;
}
}
species building {
float height <- 10#m + rnd(10) #m;
aspect geom {
draw shape color: #gray depth: height;
}
}
v 1.8.0 1600
GAMA v1.8.0 documentation Chapter 134. 5. Visualizing in 3D
}
}
}
v 1.8.0 1601
GAMA v1.8.0 documentation Chapter 134. 5. Visualizing in 3D
v 1.8.0 1602
Chapter 135
6. Multi-Level
Formulation
We propose to let the buildings manage what happens when the people are inside
buildings. In this context, we will use the multi-level properties of GAMA: when a
people agent will be inside a building, it will be captured by it and its species will be
modified. It will be not anymore the people agent that will decide when to leave the
building, but the building itself.
We will need to:
1603
GAMA v1.8.0 documentation Chapter 135. 6. Multi-Level
Model Definition
building
First, we define a new species called people_in_building inside the building
species. Thus, a building could have agents of this species as members and control
them. The people_in_building species has for parent the people species, which
means that a people_in_building agent has all the properties, aspect and behaviors
of a people agent. In our case, we want the once a people agent inside a building,
this people agent does nothing. Then, we use the schedules facet of the species to
remove the people_in_building from the scheduler.
species building {
...
species people_in_building parent: people schedules: [] {
}
...
}
We define a new dynamic variable for building agent: people_inside that will
correspond to the list of people_in_building agents inside the building. Note that
v 1.8.0 1604
GAMA v1.8.0 documentation Chapter 135. 6. Multi-Level
we use the syntax -> {. . . } to make the variable dynamic. However, instead of
update that allows a variable to be recomputed at each simulation step, the syntax
-> {. . . } allows the variable to be recomputed each time it is called (and thus avoid
outdated problems). To compute this variable, we use the members built-in variable
that corresponds to the list of micro-agents captured by the macro-agent.
species building {
...
list<people_in_building> people_inside -> {members collect
people_in_building(each)};
...
}
We define a first reflex for the buildings that will be activated at each simulation
step and that will allow the building to capture all the people that are inside its
geometry and that are not moving (target = nil). Capturing agents means putting
them inside its members list and changing their species: here the people agents
become people_in_building agents.
species building {
...
reflex let_people_enter {
list<people> entering_people <- people inside self where (each.
target = nil);
if not (empty (entering_people)) {
capture entering_people as: people_in_building ;
}
}
....
}
We define a second reflex for the buildings that will be activated at each simulation
step and that will allow the building to release some of the people_in_building
agents. First, it increments the staying counter of all the people_in_building
agents. Then it builds the list of leaving people by testing the same probability as
before for all the people_in_building agents. Finally, if this list is not empty, it
releases them as people agents (and gives them a new target point).
species building {
...
reflex let_people_leave {
ask members as: people_in_building{
staying_counter <- staying_counter + 1;
}
v 1.8.0 1605
GAMA v1.8.0 documentation Chapter 135. 6. Multi-Level
At last, we refine the aspect of the buildings: if there is not people inside the building,
we draw it with gray color. If the number of people_in_building infected is higher
than the number of people_in_building not infected, we draw it in red; otherwise
in green.
species building {
...
aspect geom {
int nbI <- members count people_in_building(each).is_infected;
int nbT <- length(members);
draw shape color:nbT = 0 ? #gray : (float(nbI)/nbT > 0.5 ? #red
: #green) depth: height;
}
}
global variables
In order to take into account the people that are inside the buildings for the com-
putation of nb_people_infected, we first build the list of people_in_building.
As people_in_building is a macro species of building, we cannot compute it
directly like for the other species, we then aggregate all the list people_inside of
all building in a single list (list_people_in_buildings). Then, we compute the
number of infected people as the number of people infected outside the building +
the number of people infected inside them.
global {
...
v 1.8.0 1606
GAMA v1.8.0 documentation Chapter 135. 6. Multi-Level
Complete Model
global {
int nb_people <- 500;
float step <- 1 #minutes;
float infection_distance <- 2.0 #m;
float proba_infection <- 0.05;
int nb_infected_init <- 5;
file roads_shapefile <- file("../includes/road.shp");
file buildings_shapefile <- file("../includes/building.shp");
geometry shape <- envelope(roads_shapefile);
graph road_network;
int current_hour update: (cycle / 60) mod 24;
float staying_coeff update: 10.0 ^ (1 + min([abs(current_hour - 9),
abs(current_hour - 12), abs(current_hour - 18)]));
v 1.8.0 1607
GAMA v1.8.0 documentation Chapter 135. 6. Multi-Level
}
reflex end_simulation when: infected_rate = 1.0 {
do pause;
}
}
species road {
geometry display_shape <- shape + 2.0;
aspect geom {
draw display_shape color: #black depth: 3.0;
v 1.8.0 1608
GAMA v1.8.0 documentation Chapter 135. 6. Multi-Level
}
}
species building {
float height <- 10#m + rnd(10) #m;
list<people_in_building> people_inside -> {members collect
people_in_building(each)};
aspect geom {
int nbI <- members count people_in_building(each).is_infected;
int nbT <- length(members);
draw shape color:nbT = 0 ? #gray : (float(nbI)/nbT > 0.5 ? #red
: #green) depth: height;
}
reflex let_people_leave {
ask members as: people_in_building{
staying_counter <- staying_counter + 1;
}
list<people_in_building> leaving_people <- list<
people_in_building>(members where (flip(people_in_building(each).
staying_counter / staying_coeff)));
if not (empty (leaving_people)) {
release leaving_people as: people in: world returns:
released_people;
ask released_people {
target <- any_location_in (one_of(building));
}
}
}
reflex let_people_enter {
list<people> entering_people <- people inside self where (each.
target = nil);
if not (empty (entering_people)) {
capture entering_people as: people_in_building ;
}
v 1.8.0 1609
GAMA v1.8.0 documentation Chapter 135. 6. Multi-Level
}
}
v 1.8.0 1610
Chapter 136
7. Differential Equations
Formulation
We are interested by the spreading of the disease inside the buildings. In order to
model it, we will use differential equations. So, we will need to:
• add two global variables to define the building epidemic properties (beta and
h).
• add new variables for the buildings (I, S, T, t, I_to_1);
• define differential equations for disease spreading inside buildings
• add a behavior for buildings for the spreading of the disease.
Model Definition
global variables
We define two new global variables that will be used disease spreading dynamic inside
the buildings.
1611
GAMA v1.8.0 documentation Chapter 136. 7. Differential Equations
global {
...
float beta <- 0.01;
float h<-0.1;
...
}
building
In order to define the disease spreading dynamic, we define several variables that will
be used by the differential equations:
v 1.8.0 1612
GAMA v1.8.0 documentation Chapter 136. 7. Differential Equations
species building {
....
float I;
float S;
float T;
float t;
float I_to1;
...
}
Then, we define the differential equations that will use for the disease spreading
dynamic. Note that to define a differential equation system we use the block equation
+ name. These equations are the classic ones used by SI mathematical models.
species building {
....
equation SI{
diff(S,t) = (- beta * S * I / T) ;
diff(I,t) = ( beta * S * I / T) ;
}
...
}
At last, we define a new reflex for the building called epidemic that will be activated
only when there is someone inside the building. This reflex first computes the number
of people inside the building (T), then the number of not infected people (S) and
finally the number of infected ones (I).
If there is at least one people infected and one people not infected, the differential
equations is integrated (according to the discretisation step value h) with the method
Runge-Kutta 4 to compute the new value of infected people. We then sum the old
value of I_to_1 with the number of people newly infected (this value is a float
and not an integer). Finally, we cast this value as an integer, ask the corresponding
number of not infected people to become infected, and decrement this integer value
to I_to1.
species building {
....
reflex epidemic when: not empty(members){
T <- float(length(members));
list<people_in_building> S_members <- list<people_in_building>(
members where not (people_in_building(each).is_infected));
S <- float(length(S_members));
v 1.8.0 1613
GAMA v1.8.0 documentation Chapter 136. 7. Differential Equations
I <- T-S;
float I0 <- I;
if (I > 0 and S > 0) {
solve SI method: "rk4" step: h;
I_to1 <- I_to1 + (I - I0);
int I_int <- min([int(S),int(I_to1)]);
I_to1 <- I_to1 - I_int;
ask(I_int among S_members){
is_infected <- true;
}
}
}
...
}
Complete Model
model model7
global {
int nb_people <- 500;
float step <- 1 #minutes;
float infection_distance <- 2.0 #m;
float proba_infection <- 0.05;
int nb_infected_init <- 5;
file roads_shapefile <- file("../includes/road.shp");
file buildings_shapefile <- file("../includes/building.shp");
geometry shape <- envelope(roads_shapefile);
graph road_network;
int current_hour update: (cycle / 60) mod 24;
float staying_coeff update: 10.0 ^ (1 + min([abs(current_hour - 9),
abs(current_hour - 12), abs(current_hour - 18)]));
float beta <- 0.01;
float h<-0.1;
list<people_in_building> list_people_in_buildings update: (building
accumulate each.people_inside) where (not dead(each));
int nb_people_infected <- nb_infected_init update: people count (
each.is_infected) + (empty(list_people_in_buildings) ? 0 :
list_people_in_buildings count (each.is_infected));
v 1.8.0 1614
GAMA v1.8.0 documentation Chapter 136. 7. Differential Equations
}
reflex end_simulation when: infected_rate = 1.0 {
do pause;
}
}
v 1.8.0 1615
GAMA v1.8.0 documentation Chapter 136. 7. Differential Equations
species road {
geometry display_shape <- shape + 2.0;
aspect geom {
draw display_shape color: #black depth: 3.0;
}
}
species building {
float height <- 10#m + rnd(10) #m;
list<people_in_building> people_inside -> {members collect
people_in_building(each)};
float I;
float S;
float T;
float t;
float I_to1;
aspect geom {
int nbI <- members count people_in_building(each).is_infected;
int nbT <- length(members);
draw shape color:nbT = 0 ? #gray : (float(nbI)/nbT > 0.5 ? #red
: #green) depth: height;
}
reflex let_people_leave {
ask members as: people_in_building{
staying_counter <- staying_counter + 1;
}
list<people_in_building> leaving_people <- list<
people_in_building>(members where (flip(people_in_building(each).
staying_counter / staying_coeff)));
if not (empty (leaving_people)) {
release leaving_people as: people in: world returns:
released_people;
ask released_people {
target <- any_location_in (one_of(building));
}
}
v 1.8.0 1616
GAMA v1.8.0 documentation Chapter 136. 7. Differential Equations
}
reflex let_people_enter {
list<people> entering_people <- people inside self where (each.
target = nil);
if not (empty (entering_people)) {
capture entering_people as: people_in_building ;
}
}
equation SI{
diff(S,t) = (- beta * S * I / T) ;
diff(I,t) = ( beta * S * I / T) ;
}
v 1.8.0 1617
GAMA v1.8.0 documentation Chapter 136. 7. Differential Equations
v 1.8.0 1618
Chapter 137
Luneray’s flu
This tutorial has for goal to introduce how to build a model with GAMA and to use
GIS data and graphs. In particular, this tutorial shows how to write a simple GAMA
model (the structure of a model, the notion of species. . . ) load gis data, to agentify
them and to use a network of polylines to constraint the movement of agents. All the
files related to this tutorial (shapefiles and models) are available here.
The importation of models is described here
Model Overview
The model built in this tutorial concerns the spreading of a flu in the city of Luneray
(Normandie, France).
Two layers of GIS data are used: a road layer (polylines) and a building layer
(polygons). In this model, people agents are moving from building to building using
the road network. Each infected people can infect the neighbor people.
Some data collected concerning Luneray and the disease:
1619
GAMA v1.8.0 documentation Chapter 137. Luneray’s flu
Step List
This tutorial is composed of 5 steps corresponding to 5 models. For each step we
present its purpose, an explicit formulation and the corresponding GAML code.
v 1.8.0 1620
Chapter 138
This first step illustrates how to create simple agents and make them move in their
environment.
Formulation
• Set the time duration of a time step to 5 minutes
• Define the people species with a moving skill
• Define the move reflex that allow the people agent to move randomly and the
infect reflex that allows them to infect other people agents.
• Define the aspect of the people species
• Add the people species to a display
Model Definition
The first step of this tutorial consists in launching GAMA and choosing a workspace,
then to define a new project or to import the existing one. For people that do not
want to re-write all the models but just to follow the model construction, they can
1621
GAMA v1.8.0 documentation
Chapter 138. 1. Creation of a first basic disease spreading model
v 1.8.0 1622
GAMA v1.8.0 documentation
Chapter 138. 1. Creation of a first basic disease spreading model
just download the model project here and the follow this procedure to import it into
GAMA. For the other, the project and model creation procedures are detailed here.
Note that the concepts of workspace and projects are explained here.
model structure
• global : this section, that is unique, defines the “world” agent, a special agent
of a GAMA model. It represents all that is global to the model: dynamics,
variables, actions. In addition, it allows to initialize the simulation (init block).
• species and grid: these sections define the species of agents composing the
model. Grid are defined in the following model step “vegetation dynamic”;
• experiment : these sections define a context of execution of the simulations.
In particular, it defines the input (parameters) and output (displays, files. . . )
of a model.
More details about the different sections of a GAMA model can be found here.
species
}
v 1.8.0 1623
GAMA v1.8.0 documentation
Chapter 138. 1. Creation of a first basic disease spreading model
In addition, we want to add a new capability to our agent: the possibility to move
randomly. For that, we add a specific skill to our people agents. A skill is a built-
in module that provide the modeler a self-contain and relevant set of actions and
variables. The moving provides the agents with several attributes and actions related
to movement.
species people skills: [moving]{
...
}
Internal state
• Optional facets: <- (initial value), update (value recomputed at each step of
the simulation), function:{..} (value computed each time the variable is used),
min, max
In addition to the attributes the modeler explicitly defines, species “inherits” other
attributes called “built-in” variables:
• speed of type float, with for initial value: a random value between 2 and 5
km/h
• is_infected of type bool, with for initial value: false
v 1.8.0 1624
GAMA v1.8.0 documentation
Chapter 138. 1. Creation of a first basic disease spreading model
species people skills:[moving]{
float speed <- (2 + rnd(3)) #km/#h;
bool is_infected <- false;
}
Note we use the rnd operator to define a random value between 2 and 5 for the speed.
In addition, we precise a unit for the speed value by using the # symbol. For more
details about units, see here.
Behavior
GAMA proposes several ways to define the behavior of a species: dynamic variables
(update facet), reflexes. . . .
A reflex is a block of statements (that can be defined in global or any species) that
will be automatically executed at each simulation step if its condition is true, it is
defined as follows:
reflex reflex_name when: condition {...}
The when facet is optional: when it is omitted, the reflex is activated at each time
step. Note that if several reflexes are defined for a species, the reflexes will be activated
following their definition order.
We define a first reflex called move that is activated at each simulation step (no
condition) and that makes the people move randomly using the wander action from
the moving skill.
species people skills:[moving]{
//variable definition
reflex move{
do wander;
}
}
We define a second reflex called infect that is activated only when the agent is
infected (is_infected = true) and that ask all the people at a distance of 10m to test
a probability to be infected.
species people skills:[moving]{
//variable definition and move reflex
v 1.8.0 1625
GAMA v1.8.0 documentation
Chapter 138. 1. Creation of a first basic disease spreading model
The ask allows an agent to ask another agents to do something (i.e. to execute a
sequence of statements). The at_distance operator allows to get the list of agents
(here of people agents) that are located at a distance lower or equal to the given
distance (here 10m). The flip operator allows to test a probability.
Display
• A geometry : for instance, the shape of the agent (but it may be a different
one, for instance a disk instead of a complex polygon)
• An image : to draw icons
• A text : to draw a text
In our model, we define an aspect for the people agent called circle that draw the
agents as a circle of 10m radius with a color that depends on their is_infected
attribute. If the people agent is infected, it will be draw in red, in green otherwise.
species people {
...//variable and reflex definition
aspect circle {
draw circle(10) color:is_infected ? #red : #green;
}
}
}
The ? structure allows to return a different value (here red or green) according to a
condition (here is_infected = true).
v 1.8.0 1626
GAMA v1.8.0 documentation
Chapter 138. 1. Creation of a first basic disease spreading model
global section
The global section represents a specific agent, called world. Defining this agent follows
the same principle as any agent and is, thus, defined after a species. The world agent
represents everything that is global to the model : dynamics, variables. . . It allows
to initialize simulations (init block): the world is always created and initialized first
when a simulation is launched (before any other agents). The geometry (shape) of
the world agent is by default a square with 100m for side size, but can be redefined if
necessary. The step attribute of the world agent allows to specify the duration of one
simulation step (by default, 1 step = 1 seconde).
global variable
• nb_people: the number of people that we want to create (init value: 2147)
• nb_infected_init: the number of people infected at the initialization of the
simulation (init value: 5)
• step: redefine in order to set the duration of a simulation step to 5 minutes.
• shape: redefine in order to set the geometry of the world to a square of 1500
meters side size.
global {
int nb_people <- 2147;
int nb_infected_init <- 5;
float step <- 5 #mn;
geometry shape<-square(1500 #m);
}
Model initialization
The init section of the global block allows to initialize the define what will happen at
the initialization of a simulation, for instance to create agents. We use the statement
create to create agents of a specific species: create species_name + :
v 1.8.0 1627
GAMA v1.8.0 documentation
Chapter 138. 1. Creation of a first basic disease spreading model
For our model, we define the init block in order to create nb_people people agents
and ask nb_infected_init of them to be infected:
global {
// world variable definition
init{
create people number:nb_people;
ask nb_infected_init among people {
is_infected <- true;
}
}
}
experiment
• gui : experiment with a graphical interface, which displays its input parameters
and outputs.
• batch : Allows to setup a series of simulations (w/o graphical interface).
input
v 1.8.0 1628
GAMA v1.8.0 documentation
Chapter 138. 1. Creation of a first basic disease spreading model
Note that the init, min and max values can be defined in the global variable definition.
In our model, we define one parameter:
• “Nb people infected at init” that will define the value of the global variable
nb_infected_init with a min value of 1 and a max value of 2147 (the number of
people living in Luneray).
experiment main_experiment type:gui{
parameter "Nb people infected at init" var: nb_infected_init min: 1
max: 2147;
output {
}
}
output
Output blocks are defined in an experiment and define how to visualize a simulation
(with one or more display blocks that define separate windows). Each display can be
refreshed independently by defining the facet refresh_every: nb (int) (the display
will be refreshed every nb steps of the simulation).
Each display can include different layers (like in a GIS):
v 1.8.0 1629
GAMA v1.8.0 documentation
Chapter 138. 1. Creation of a first basic disease spreading model
Note that it is possible to define a opengl display (for 3D display or just to optimize
the display) by using the facet type: opengl.
output {
display map {
species people aspect:circle;
}
}
Complete Model
model model1
global {
int nb_people <- 2147;
int nb_infected_init <- 5;
float step <- 5 #mn;
geometry shape<-square(1500 #m);
init{
create people number:nb_people;
ask nb_infected_init among people {
is_infected <- true;
}
}
}
reflex move{
do wander;
}
reflex infect when: is_infected{
ask people at_distance 10 #m {
if flip(0.05) {
is_infected <- true;
}
}
}
aspect circle {
v 1.8.0 1630
GAMA v1.8.0 documentation
Chapter 138. 1. Creation of a first basic disease spreading model
output {
display map {
species people aspect:circle;
}
}
}
v 1.8.0 1631
GAMA v1.8.0 documentation
Chapter 138. 1. Creation of a first basic disease spreading model
v 1.8.0 1632
Chapter 139
This second step illustrates how to create monitors and charts to follows the evolution
of variables and to add an ending condition to the simulation.
Formulation
• Add three new global dynamic variables to follow the evolution of the number of
infected people agents, of not infected people agents and of the rate of infected
people.
• Define an ending condition for the simulation
• Define a monitor to follow the rate of infected people agents
• Define a chart to follow the rate of infected people agents
Model Definition
global section
global variables
GAMA offers the possibility to define dynamic variable that will be recomputed at
each simulation step by using the update facet when defining a variable. When an
1633
GAMA v1.8.0 documentation
Chapter 139. 2. Definition of monitors and chart outputs
v 1.8.0 1634
GAMA v1.8.0 documentation
Chapter 139. 2. Definition of monitors and chart outputs
agent is activated, first, it recomputes each of its variables with a update facet (in
their definition order), then it activates each of its reflexes (in their definition order).
To better follow the evolution of sick people, we add three new global variables to
the model:
We used the count operator that allows to count the number of elements of a list for
which the left condition is true. The keyword each represents each element of the list.
ending condition
The simplest way to add an ending condition to a model is to add a global reflex that
is activated at the end of the simulation that will pause the simulation (use of the
pause global action).
In our model, we add a new reflex called end_simulation that will be activated when
the infected rate is 1.0 (i.e. all the people agents are infected) and that will apply the
pause action.
global {
//.. variable and init definition
v 1.8.0 1635
GAMA v1.8.0 documentation
Chapter 139. 2. Definition of monitors and chart outputs
do pause;
}
}
experiment
monitor
GAMA provides modelers with the possibility to define monitors. A monitor allows
to follow the value of an arbitrary expression in GAML. It will appear, in the User
Interface, in a small window on its own and be recomputed every time step (or
according to its ‘refresh’ facet).
Definition of a monitor:
• value: mandatory, the expression whose value will be displayed by the monitor.
• refresh: bool, optional : if the expression is true, compute (default is true).
For our model, we define a monitor to follow the value of the infected_rate variable:
experiment main_experiment type:gui{
//...parameters
output {
monitor "Infected people rate" value: infected_rate;
//...display
}
}
Chart
In GAMA, charts are considered as a display layer. GAMA can display 3 main types
of charts using the type facet:
• histogram
• pie
• series/xy/scatter: both display series with lines or dots, with 3 subtypes :
– series: to display the evolution of one/several variable (vs time or not).
v 1.8.0 1636
GAMA v1.8.0 documentation
Chapter 139. 2. Definition of monitors and chart outputs
– xy: to specify both x and y value. To allow stacked plots, only one y value
for each x value.
– scatter: free x and y values for each serie.
In our model, we define a new display called _ chart_display_ that will be refresh
every 10 simulation steps. In this display, we add a series charts with 2 layers of data:
• susceptible: the number of people that are not infected (in green)
• infected: the number of people that are infected (in red)
experiment main_experiment type:gui{
//...parameters
output {
//...display and monitors
Complete Model
model model2
global {
int nb_people <- 2147;
int nb_infected_init <- 5;
float step <- 5 #mn;
geometry shape<-square(1500 #m);
v 1.8.0 1637
GAMA v1.8.0 documentation
Chapter 139. 2. Definition of monitors and chart outputs
init{
create people number:nb_people;
ask nb_infected_init among people {
is_infected <- true;
}
}
}
reflex move{
do wander;
}
reflex infect when: is_infected{
ask people at_distance 10 #m {
if flip(0.05) {
is_infected <- true;
}
}
}
aspect circle {
draw circle(10) color:is_infected ? #red : #green;
}
}
output {
monitor "Infected people rate" value: infected_rate;
display map {
species people aspect:circle;
}
v 1.8.0 1638
GAMA v1.8.0 documentation
Chapter 139. 2. Definition of monitors and chart outputs
}
}
}
v 1.8.0 1639
GAMA v1.8.0 documentation
Chapter 139. 2. Definition of monitors and chart outputs
v 1.8.0 1640
Chapter 140
This third step illustrates how load GIS data and to agentify them.
Formulation
• Define 2 new species that will just be displayed: road and building.
• Define new global attributes to load GIS data (shape file).
• Use the GIS data to create the road and building agents.
• Add the road and building agents to the display.
Model Definition
For this step, you will need to add the shapefiles of the roads and buildings inside the
includes folder of the project. The shapefiles (and all the other files) can be found
here.
species
In this model, we have to define two species of agents: the road agents and the
building ones. These agents will not have a particular behavior, they will just be
displayed. For each of this species we define an aspect called geom. As we want to
represent the geometry of the agent, we then use the keyword draw that allow to draw
1641
GAMA v1.8.0 documentation Chapter 140. 3. Importation of GIS data
v 1.8.0 1642
GAMA v1.8.0 documentation Chapter 140. 3. Importation of GIS data
a given geometry. In order to draw the geometry of the agent we use the attribute
shape (which is a built-in attribute of all agents). The road will be displayed in
black and the building in gray.
species road {
aspect geom {
draw shape color: #black;
}
}
species building {
aspect geom {
draw shape color: #gray;
}
}
global section
global variables
GAMA allows to automatically read GIS data that are formatted as shape files (or as
OSM file). In our model, we define 2 shapefiles: one corresponding to the roads and
the other ones to the buildings. Note that GAMA is able to manage the projection
of the GIS data. In order to set the right size (and position) of the world geometry,
we define its value as the envelope of the road shapefile (and no more a square of
1500 meters).
global{
//... other attributes
file roads_shapefile <- file("../includes/routes.shp");
file buildings_shapefile <- file("../includes/batiments.shp");
geometry shape <- envelope(roads_shapefile);
//... init
}
v 1.8.0 1643
GAMA v1.8.0 documentation Chapter 140. 3. Importation of GIS data
The reading of an attribute in a shapefile is also very simple. It only requires to use
the with facet: the argument of this facet is a dictionary of which the keys are the
names of the agent attributes and the value the read command followed by the name
of the shapefile attribute.
In our model, we modify the init section in order to first create the road agents
from the road shapefile, and the building agents from the building shapefile. Then,
when creating people agents, we choose for them a random location inside a random
building. Note that it is possible to execute a sequence of statements at the creation
of agents by using a block ({. . . }) rather than a simple line (;) when using the create
statement.
global {
// world variable definition
init{
create road from: roads_shapefile;
create building from: buildings_shapefile;
create people number:nb_people {
location <- any_location_in(one_of(building)); }
}
ask nb_infected_init among people {
is_infected <- true;
}
}
}
We used here the one_of operator that returns a random element from a list and the
any_location_in operator that returns a random location inside a geometry.
experiment
Output
In the map display, we add the road and building species with their geom aspect just
before the people species (in order to draw the people agents on the top of the roads
and buildings).
experiment main_experiment type: gui {
... //parameter definition
output {
v 1.8.0 1644
GAMA v1.8.0 documentation Chapter 140. 3. Importation of GIS data
Complete Model
model model3
global {
int nb_people <- 2147;
int nb_infected_init <- 5;
float step <- 5 #mn;
file roads_shapefile <- file("../includes/roads.shp");
file buildings_shapefile <- file("../includes/buildings.shp");
geometry shape <- envelope(roads_shapefile);
init{
create road from: roads_shapefile;
create building from: buildings_shapefile;
create people number:nb_people {
location <- any_location_in(one_of(building));
}
ask nb_infected_init among people {
is_infected <- true;
}
}
}
v 1.8.0 1645
GAMA v1.8.0 documentation Chapter 140. 3. Importation of GIS data
reflex move{
do wander;
}
aspect circle {
draw circle(10) color:is_infected ? #red : #green;
}
}
species road {
aspect geom {
draw shape color: #black;
}
}
species building {
aspect geom {
draw shape color: #gray;
}
}
output {
monitor "Infected people rate" value: infected_rate;
display map {
species road aspect:geom;
species building aspect:geom;
species people aspect:circle;
}
v 1.8.0 1646
GAMA v1.8.0 documentation Chapter 140. 3. Importation of GIS data
v 1.8.0 1647
GAMA v1.8.0 documentation Chapter 140. 3. Importation of GIS data
v 1.8.0 1648
Chapter 141
This fourth step illustrates how to use a graph to constraint the movements of agents
Formulation
• Define a new global variable: the road network (graph).
• Build the road network graph from the road agents
• Add new attribute to the people agents (target)
• Define a new reflex for people agents: stay.
• Modify the move reflex of the people agents.
Model Definition
global section
global variables
In this model, we want that people agents move from buildings to buildings by using
the shortest path in the road network. In order to compute this shortest path, we
need to use a graph structure.
1649
GAMA v1.8.0Chapter
documentation
141. 4. Use of a graph to constraint the movements of people
v 1.8.0 1650
GAMA v1.8.0Chapter
documentation
141. 4. Use of a graph to constraint the movements of people
We thus define a new global variable called road_network of type graph that will
represent the road network.
global{
//... other attributes
graph road_network;
//... init
}
In order to compute the graph from the road network, we use, just after having
creating the road agents, the as_edge_graph operator. This operator automatically
built a graph from a set of polylines. Each extremity point of the lines will become a
node in the graph, and each polyline an edge. By default, the graph is not oriented
and the weights of the edges are the perimeters of the polylines. It is of course
possible to change through the use of some operators.
global {
// world variable definition
init{
create road from: roads_shapefile;
road_network <- as_edge_graph(road);
create building from: buildings_shapefile;
create people number:nb_people {
location <- any_location_in(one_of(building));
}
ask nb_infected_init among people {
is_infected <- true;
}
}
}
people species
We want to modify the behavior of the people agents in order to make them move
from buildings to buildings by using the shortest path in the road network.
variables
In order to implement this behavior, we will add two variables to our people species:
v 1.8.0 1651
GAMA v1.8.0Chapter
documentation
141. 4. Use of a graph to constraint the movements of people
• target of type point that will be the location where the agent wants to go
species people skills:[moving]{
//...the other attributes
point target;
//....
}
behavior
First, we add a new reflex called stay that will be activated when the agent is in
a house (i.e. its target is null) and that will define with a probability of 0.05 if the
agent has to go or not. If the agent has to go, it will randomly choose a new target
(a random location inside one of the building).
reflex stay when: target = nil {
if flip(0.05) {
target <- any_location_in (one_of(building));
}
}
Then, we modify the move reflex. This one will be only activated when the agent
will have to move (target not null). Instead of using the wander action of the moving
skill, we use the goto one that allows to make an agent moves toward a given target.
In addition, it is possible to add a facet on to precise on which topology the agent
will have to move on. In our case, the topology is the road network. When the agent
reach its destination (location = target), it sets its target to null.
reflex move when: target != nil{
do goto target:target on: road_network;
if (location = target) {
target <- nil;
}
}
Complete Model
v 1.8.0 1652
GAMA v1.8.0Chapter
documentation
141. 4. Use of a graph to constraint the movements of people
model model4
global {
int nb_people <- 2147;
int nb_infected_init <- 5;
float step <- 5 #mn;
file roads_shapefile <- file("../includes/roads.shp");
file buildings_shapefile <- file("../includes/buildings.shp");
geometry shape <- envelope(roads_shapefile);
graph road_network;
init{
create road from: roads_shapefile;
road_network <- as_edge_graph(road);
create building from: buildings_shapefile;
create people number:nb_people {
location <- any_location_in(one_of(building));
}
ask nb_infected_init among people {
is_infected <- true;
}
}
}
v 1.8.0 1653
GAMA v1.8.0Chapter
documentation
141. 4. Use of a graph to constraint the movements of people
if (location = target) {
target <- nil;
}
}
aspect circle {
draw circle(10) color:is_infected ? #red : #green;
}
}
species road {
aspect geom {
draw shape color: #black;
}
}
species building {
aspect geom {
draw shape color: #gray;
}
}
output {
monitor "Infected people rate" value: infected_rate;
display map {
species road aspect:geom;
species building aspect:geom;
species people aspect:circle;
}
v 1.8.0 1654
GAMA v1.8.0Chapter
documentation
141. 4. Use of a graph to constraint the movements of people
v 1.8.0 1655
GAMA v1.8.0Chapter
documentation
141. 4. Use of a graph to constraint the movements of people
v 1.8.0 1656
Chapter 142
5. Definition of 3D displays
Formulation
• Define a new 3D aspect for roads.
• Define a new 3D aspect for buildings
• Define a new 3D aspect for people
• Define a new 3D display
Model Definition
species
We define a new aspect for the road species called geom3D that draw the road agent
that as a black tube of 2m radius built from its geometry. Note that it is possible
to get the list of points composing a geometry by using the points variable of the
geometry.
species road {
//....
aspect geom3D {
draw line(shape.points, 2.0) color: #black;
}
1657
GAMA v1.8.0 documentation Chapter 142. 5. Definition of 3D displays
v 1.8.0 1658
GAMA v1.8.0 documentation Chapter 142. 5. Definition of 3D displays
}
Concerning the building species, we define an aspect called geom3D that draws the
shape of the building with a depth of 20 meters and with using a texture “texture.jpg”
for the face and a texture for the roof “roof_top.png”.
species building {
//....
aspect geom3D {
draw shape depth: 20 #m border: #black texture:["../includes/
roof_top.png","../includes/texture.jpg"];
}
}
At last, we define a new aspect called geom3D for the people species that displays
the agent only if it is on a road (target != nil). In this aspect, we use an obj file
that contains a 3D object. The use of the obj_file operator allows to apply an initial
rotation to an obj file. In our case, we add a rotation of -90° along the x axis. We
specify with the size facet that we want to draw the 3D object inside a bounding box
of 5m. As the location of the 3D object is its centroid and as we want to draw the 3D
object on the top of the ground, we use the at facet to put an offset along the z axis.
We use also the rotate facet to change the orientation of the 3D object according to
the heading of the agent. At last, we choose to draw the 3D object in green if the
agent is not infected; in red otherwise.
species people skills:[moving]{
//....
aspect geom3D {
if target != nil {
v 1.8.0 1659
GAMA v1.8.0 documentation Chapter 142. 5. Definition of 3D displays
output
We define a new display called view3D of type opengl with an ambient_light of 80.
Inside this display, we first draw a background image representing the satellite image
of the Luneray. Note that GAMA is able to manage world files to georeferenced
images. In our case, as a pgw file exists in the includes folder, the satellite image
will be well localized in the display. After drawing the background image, we display
first the building species with their geom3D aspect, then the road species with their
geom3D aspect and finally the people species with their geom3D aspect. Only the
people agents will be redrawn at each simulation step.
v 1.8.0 1660
GAMA v1.8.0 documentation Chapter 142. 5. Definition of 3D displays
Complete Model
model model4
global {
int nb_people <- 2147;
int nb_infected_init <- 5;
float step <- 5 #mn;
file roads_shapefile <- file("../includes/roads.shp");
file buildings_shapefile <- file("../includes/buildings.shp");
geometry shape <- envelope(roads_shapefile);
graph road_network;
init{
create road from: roads_shapefile;
road_network <- as_edge_graph(road);
create building from: buildings_shapefile;
create people number:nb_people {
location <- any_location_in(one_of(building));
}
ask nb_infected_init among people {
is_infected <- true;
v 1.8.0 1661
GAMA v1.8.0 documentation Chapter 142. 5. Definition of 3D displays
}
}
}
aspect circle {
draw circle(10) color:is_infected ? #red : #green;
}
aspect geom3D {
if target != nil {
draw obj_file("../includes/people.obj", 90::{-1,0,0}) size:
5
at: location + {0,0,7} rotate: heading - 90 color:
is_infected ? #red : #green;
}
}
species road {
v 1.8.0 1662
GAMA v1.8.0 documentation Chapter 142. 5. Definition of 3D displays
aspect geom {
draw shape color: #black;
}
aspect geom3D {
draw line(shape.points, 2.0) color: #black;
}
}
species building {
aspect geom {
draw shape color: #gray;
}
aspect geom3D {
draw shape depth: 20 #m border: #black texture:["../includes/
roof_top.png","../includes/texture.jpg"];
}
}
output {
monitor "Infected people rate" value: infected_rate;
display map {
species road aspect:geom;
species building aspect:geom;
species people aspect:circle;
}
v 1.8.0 1663
GAMA v1.8.0 documentation Chapter 142. 5. Definition of 3D displays
}
}
v 1.8.0 1664
Chapter 143
Co-modeling tutorial
Model Overview
Step List
This tutorial is composed of 3 steps corresponding to 3 models. For each step we
present its purpose, an explicit formulation and the corresponding GAML code.
1665
GAMA v1.8.0 documentation Chapter 143. Co-modeling tutorial
v 1.8.0 1666
Chapter 144
BDI Agents
This tutorial aims at presenting the use of BDI agents in GAMA. In particular,
this tutorial shows how to define a BDI agents, then to add social relation between
BDI agents, to add emotions and a personality to the agents and finally social
norms, obligations and enforcements. These notions come from the BEN architecture,
described in details in the page Using BEN architecture.
If you are not familiar with agent-based models or GAMA we advise you to have a
look at the prey-predator model first.
Model Overview
The model built in this tutorial concerns gold miners that try to find and sell gold
nuggets. More precisely, we consider that several gold mines containing a certain
amount of gold nuggets are located in the environment. In the same way, a market
where the miners can sell their gold nuggets is located in the environment. The gold
miners try to find gold mines, to extract gold nuggets from them and to sell the gold
extracted nuggets at the market.
Step List
This tutorial is composed of 5 steps corresponding to 5 models. For each step, we
present its purpose, an explicit formulation, and the corresponding GAML code.
1667
GAMA v1.8.0 documentation Chapter 144. BDI Agents
v 1.8.0 1668
Chapter 145
1. Skeleton model
This first step consists in defining the skeleton model with the gold mines and the
gold market.
Formulation
• Definition of the gold mine species
• Definition of the market species
• Creation of the gold mine and market agents
• Definition of a display with the gold mines and the market
Model Definition
species
In this first model, we have to define two species of agents: the goldmine agents
and the market ones. These agents will not have a particular behavior, they will
just be displayed. For the goldmine species, we define a new attribute: quantity of
type int, with for initial value a random integer between 0 and 20. We also define
aspect called default that displays the goldmine as a triangle with a gray color if
the gold mine is empty, yellow otherwise. The size of the triangle depends on the
quantity of gold nuggets in the mine. Concerning the market species, we define a
1669
GAMA v1.8.0 documentation Chapter 145. 1. Skeleton model
new attribute: golds of type int. We define as well an aspect called default that
displays the market as a blue square.
species goldmine {
int quantity <- rnd(1,20);
aspect default
{
if (quantity = 0) {
draw triangle(200) color: #gray border: #black;
} else {
draw triangle(200 + quantity*50) color: #yellow border: #
black;
}
}
}
species market {
int golds;
aspect default
{
draw square(1000) color: #black ;
}
}
global variables
We define two global variables for the model: one called nb_mines that will be used
to define the number of mines and that will be set to 10. One call the_market that
will represent the market agent (that will be unique).
In addition, we define the duration of a simulation step to 10 minutes, and we define
the shape of the environnement by a square with a side size of 20 kilometers.
global {
int nb_mines <- 10;
market the_market;
float step <- 10#mn;
geometry shape <- square(20 #km);
}
v 1.8.0 1670
GAMA v1.8.0 documentation Chapter 145. 1. Skeleton model
global init
At the initialisation of the model, we create a market agent and nb_mines goldmine
agents. For the market agent, we set the value of the the_market agent with the
created agent.
global {
...
init
{
create market {
the_market <- self;
}
create goldmine number:nb_mines;
}
}
display
We define a display to visualize the market and goldmine agents. We use for that the
classic species keyword. In order to optimize the display we use an opengl display
(facet type: opengl).
In the experiment block:
output {
display map type: opengl {
species market ;
species goldmine ;
}
}
Complete Model
model GoldBdi
global {
int nb_mines <- 10;
market the_market;
float step <- 10#mn;
v 1.8.0 1671
GAMA v1.8.0 documentation Chapter 145. 1. Skeleton model
init
{
create market {
the_market <- self;
}
create goldmine number:nb_mines;
}
}
species goldmine {
int quantity <- rnd(1,20);
aspect default
{
if (quantity = 0) {
draw triangle(200) color: #gray border: #black;
} else {
draw triangle(200 + quantity*50) color: #yellow border: #
black;
}
}
}
species market {
int golds;
aspect default
{
draw square(1000) color: #black ;
}
}
output {
display map type: opengl
{
species market ;
species goldmine ;
}
}
}
Back to the start of the tutorial 1. Definition of the BDI miners 1. Definition of
v 1.8.0 1672
GAMA v1.8.0 documentation Chapter 145. 1. Skeleton model
social relations between miners 1. Use of emotions and personality for the miners 1.
Adding norms, obligations and enforcement
v 1.8.0 1673
GAMA v1.8.0 documentation Chapter 145. 1. Skeleton model
v 1.8.0 1674
Chapter 146
2. BDI Agents
This second step consists in defining the gold miner agents using the GAMA BDI
architecture.
Formulation
• Definition of global predicates
• Definition of the gold miner species
• Definition of the gold miner perceptions
• Definition of the gold miner rules
• Definition of the gold miner plans
• Creation and display of the gold miners
BDI agents
A classic paradigm to formalize the internal architecture of cognitive agents in Agent-
Oriented Software Engineering is the BDI (Belief-Desire-Intention) paradigm. This
paradigm, based on the philosophy of action (Bratman, 1987), allows to design
expressive and realistic agents.
The concepts of Belief-Desire-Intention can be summarized as follow for the Gold
Miner: the Miner agent has a general desire to find gold. As it is the only thing it
wants at the beginning, it is its initial intention (what it is currently doing). To find
1675
GAMA v1.8.0 documentation Chapter 146. 2. BDI Agents
gold, it wanders around (its plan is to wander). When it perceives some gold nuggets,
it stores this information (it has a new belief about the existence and location of
this gold nugget), and it adopts a new desire (it wants to extract the gold). When it
perceives a gold nugget, the intention to find gold is put on hold and a new intention
is selected (to extract gold). To achieve this intention, the plan has two steps, i.e. two
new (sub)intentions: to choose a gold nugget to extract (among its known gold
nuggets) and to go and take it. And so on.
In GAMA, we propose a control architecture for agents based on this paradigm.
This control architecture provides the agents with 3 databases linked to the agent
cognition:
• belief_base (what it knows): the internal knowledge the agent has about the
world or about its internal state, updated during the simulation. A belief can
concern any type of information (a quantity, a location, a boolean value, etc).
• desire_base (what it wants): objectives that the agent would like to accom-
plish, also updated during the simulation. Desires can have hierarchical links
(sub/super desires) when a desire is created as an intermediary objective.
• intention_base (what it is doing): what the agent has chosen to do. The
current intention will determine the selected plan. Intentions can be put on
hold (for example when they require a sub-intention to be achieved).
In addition, the BDI architecture provides agents with three types of behavior
structures
To be more precise on the behavior of BDI agents (what the agent is going to do when
activated), this one is composed of 10 steps (see (Caillou et al., 2017) and (Taillandier
et al., 2016) for more details):
v 1.8.0 1676
GAMA v1.8.0 documentation Chapter 146. 2. BDI Agents
The architecture introduces two new main types of variables related to cognition:
v 1.8.0 1677
GAMA v1.8.0 documentation Chapter 146. 2. BDI Agents
the predicate indicates the fact about which is this mental state (a mental state
can also be about another mental state like a belief about a belief, etc), the
value has a different interpretation depending on the modality and finally, the
lifetime indicates the duration of the mental state (it can be infinite).
Model Definition
predicates
As a first step of the integration of the BDI agents in our model, we define a set of
global predicate that will represent all the information that will be manipulated by
the miner agents:
v 1.8.0 1678
GAMA v1.8.0 documentation Chapter 146. 2. BDI Agents
We define the init block of the species such as to add at the creation of the agent
the desire to find gold nuggets (find_gold predicate). we use for that the add_desire
action provides with the BDI architecture.
At last, we define an aspect in which we draw the agent with its mycolor color and
with a depth that depends on the number of gold nuggets collected.
species miner skills: [moving] control:simple_bdi {
float viewdist<-1000.0;
float speed <- 2#km/#h;
rgb mycolor<-rnd_color(255);
point target;
int gold_sold;
init
{
do add_desire(find_gold);
}
aspect default {
draw circle(200) color: mycolor border: #black depth:
gold_sold;
}
}
perception
We add a perceive statement for the miner agents. This perceive will allow to detect
the gold mine that are not empty (i.e. the quantity of gold is higher than 0) at a
distance lower or equal to “viewdist”. The use of the focus statement allows to add for
v 1.8.0 1679
GAMA v1.8.0 documentation Chapter 146. 2. BDI Agents
each detected goldmine a belief corresponding to the location of this goldmine. The
name of the belief will be “mine_at_location” and the location value of the goldmine
will be stored in the values (a map) variable of the belief at the key “location_value”.
In addition, we ask the miner agent to remove the intention to find gold, allowing the
agent to choose a new intention. The boolean value of the remove_intention action is
used to specify if the agent should or not remove the given intention from the desire
base as well. In our case, we choose to keep the desire to find golds.
species miner skills: [moving] control:simple_bdi {
...
perceive target:goldmine where (each.quantity > 0) in:viewdist {
focus id:mine_at_location var:location;
ask myself {
do remove_intention(find_gold, false);
}
}
}
Note that the perceive statement works as the ask statement: the instructions written
in the statement are executed in the context of the perceive agents. It is for that
that we have to use the myself keyword to ask the miner agent to execute the
remove_intention action.
rules
We define two rules for the miner agents:
• if the agent believes that there is somewhere at least one gold mine with gold
nuggets, the agent gets the new desire to has a gold nugget with a strength of 2.
• if the agent believes that it has a gold nugget, the agent gets the new desire to
sell the gold nugget with a strength of 3.
species miner skills: [moving] control:simple_bdi {
...
rule belief: mine_location new_desire: has_gold strength: 2.0;
rule belief: has_gold new_desire: sell_gold strength: 3.0;
}
The strength of a desire will be used when selecting a desire as a new intention: the
agent will choose as new intention the one with the highest strength. In our model, if
v 1.8.0 1680
GAMA v1.8.0 documentation Chapter 146. 2. BDI Agents
the agent has the desires to find gold, to has gold and to sell gold, it will choose as
intention to sell gold as it is the one with the highest strength. It is possible to replace
this deterministic choice by a probabilistic one by setting the probabilistic_choice
built-in varibale of the BDI agent to true (false by default).
plans
The last (and most important) part of the definition of BDI agents consist in defining
the plans that the agents can carry out to acheive its intention.
The first plan called letsWander is defined to achieve the find_gold intention. This
plan will just consists in executing the wander action of the moving skill (random
move).
species miner skills: [moving] control:simple_bdi {
...
plan letsWander intention:find_gold
{
do wander;
}
...
}
The second plan called getGold is defined to achieve the has_gold intention. if the
agent has no target (it does not know where to go), it adds a new sub-intention to
choose a goldmine and put the current intention on hold (the agent will wait to select
a gold mine to go before executing again this plan). The add_subintention has 3
arguments: the sub-intention (choose_goldmine), the super intention (extract_gold)
and a boolean that defines if the sub-intention should or not be added as well as
a desire. If the agent has already a target, it moves toward this target using the
goto action of the moving skill. If the agent reaches its target - goldmine - (target
= location), the agent tries to extract gold nuggets from it. If the corresponding
goldmine (that one located at the target location) is not empty, the agent extract
a gold nugget from it: the agent adds the belief that it has a gold nugget, then the
quantity of golds in the gold mine is reduced. Otherwise, if the gold mine is empty,
the agent adds the belief that this gold mine is empty. then the target is set to nil.
get_current_intention() returns the current intention. As plan getGold is executed
only when intention is about the has_gold predicate, the current intention is about
this predicate.
species miner skills: [moving] control:simple_bdi {
v 1.8.0 1681
GAMA v1.8.0 documentation Chapter 146. 2. BDI Agents
...
plan getGold intention:has_gold
{
if (target = nil) {
do add_subintention(get_current_intention(),choose_goldmine
, true);
do current_intention_on_hold();
} else {
do goto target: target ;
if (target = location) {
goldmine current_mine<- goldmine first_with (target =
each.location);
if current_mine.quantity > 0 {
do add_belief(has_gold);
ask current_mine {quantity <- quantity - 1;}
} else {
do add_belief(new_predicate(empty_mine_location, ["
location_value"::target]));
}
target <- nil;
}
}
}
...
}
v 1.8.0 1682
GAMA v1.8.0 documentation Chapter 146. 2. BDI Agents
The last plan called return_to_base is defined to achieve the sell_gold intention. The
agent moves in direction of the market using the goto action. if the agent reaches
the market, it sells its gold nugget to it: first, it removes the belief that it has a gold
nugget, then it removes the intention and the desire to sell golds, at last it increments
its gold_sold variable.
species miner skills: [moving] control:simple_bdi {
...
plan return_to_base intention: sell_gold {
do goto target: the_market ;
if (the_market.location = location) {
do remove_belief(has_gold);
do remove_intention(sell_gold, true);
gold_sold <- gold_sold + 1;
}
}
...
}
Gobal section
We define two new global variables:
v 1.8.0 1683
GAMA v1.8.0 documentation Chapter 146. 2. BDI Agents
In the global init, after creating the gold mines and the market, we create the gold
miner agents.
At last, we define a global reflex end_simulation that is activated when all the
gold mines are empty and no more miner has a gold nuggets and that pauses the
simulation.
global {
...
int nbminer<-5;
float inequality <- 0.0 update:standard_deviation(miner collect
each.gold_sold);
...
init
{
...
create miner number:nbminer;
}
Map display
output {
display map type: opengl
{
species market ;
species goldmine ;
species miner;
}
}
}
v 1.8.0 1684
GAMA v1.8.0 documentation Chapter 146. 2. BDI Agents
Complete Model
model GoldBdi
global {
int nb_mines <- 10;
int nbminer<-5;
market the_market;
init
{
create market {
the_market <- self;
}
create goldmine number:nb_mines;
create miner number:nbminer;
}
species goldmine {
int quantity <- rnd(1,20);
v 1.8.0 1685
GAMA v1.8.0 documentation Chapter 146. 2. BDI Agents
aspect default
{
if (quantity = 0) {
draw triangle(200) color: #gray border: #black;
} else {
draw triangle(200 + quantity*50) color: #yellow border: #
black;
}
}
}
species market {
int golds;
aspect default
{
draw square(1000) color: #black ;
}
}
float viewdist<-1000.0;
float speed <- 2#km/#h;
rgb mycolor<-rnd_color(255);
point target;
int gold_sold;
init
{
do add_desire(find_gold);
}
v 1.8.0 1686
GAMA v1.8.0 documentation Chapter 146. 2. BDI Agents
v 1.8.0 1687
GAMA v1.8.0 documentation Chapter 146. 2. BDI Agents
do remove_intention(sell_gold, true);
gold_sold <- gold_sold + 1;
}
}
aspect default {
draw circle(200) color: mycolor border: #black depth: gold_sold;
}
}
output {
display map type: opengl
{
species market ;
species goldmine ;
species miner;
}
}
}
Back to the start of the tutorial 1. Creation of the basic model: gold mines and
market 3. Definition of social relations between miners 4. Use of emotions and
personality for the miners 5. Adding norms, obligations and enforcement
v 1.8.0 1688
Chapter 147
3. Social relation
This third step consists in adding social relation between agents and the possibility
to share information about the known gold mines.
Formulation
• Definition of global predicates
• Definition of the gold miner species
• Definition of the gold miner perceptions with socialization
• Definition of a new gold miner plan to share information
Social relation
The BDI architecture of GAMA allows to define explicit social relations between
agents. Based on the work of Svennevig, a social link with another agent is defined
as a tuple <agent, liking, dominance, solidarity, familiarity, trust> with the following
elements:
1689
GAMA v1.8.0 documentation Chapter 147. 3. Social relation
With this definition, a social relation is not necessarily symmetric. For example, let’s
take two agents, Alice and Bob, with a social link towards each other. The agent
Bob may have a social link <Alice,1,-0.5,0.6,0.8,-0.2> (Bob likes Alice with a value
of 1, he thinks he is dominated by Alice, he is solidary with Alice with a value of 0.6,
he is familiar with Alice with a value of 0.8 and he doubts about her with a value
0.2) and Alice may have a social link <Bob,-0.2,0.2,0.4,0.5,0.8> (Alice dislikes Bob
with a value of 0.2, she thinks she is dominating Bob, she is solidary with Bob with a
value of 0.4, she is familiar with Bob with a value of 0.5 and she trusts Bob with a
value of 0.5).
Model Definition
predicates
We add a new global predicate called share_information that represents the informa-
tion that the miner wants to share information.
global {
...
predicate share_information <- new_predicate("share information") ;
...
}
v 1.8.0 1690
GAMA v1.8.0 documentation Chapter 147. 3. Social relation
perception
We add a new perceive statement for the miner agents. This perceive will allow to
create a social relation with the miners that are located at a distance lower or equal
to “viewdist” to the agent. For each of these miner agents, the agents create a new
social relation using the socialize statement with a liking value that depends on the
color of the agents: more the agents are close, higher will be the liking value.
species miner skills: [moving] control:simple_bdi {
...
perceive target:miner in:viewdist {
socialize liking: 1 - point(mycolor.red, mycolor.green,
mycolor.blue) distance_to point(myself.mycolor.red, myself.mycolor.
green, myself.mycolor.blue) / ( 255);
}
}
We also modify the perceive statement previously defined in order to add the desire
to share information with a strength of 5 if the agent finds a gold mine.
species miner skills: [moving] control:simple_bdi {
...
perceive target:goldmine where (each.quantity > 0) in:viewdist {
focus mine_at_location var:location;
ask myself {
do add_desire(predicate:share_information, strength: 5.0);
do remove_intention(find_gold, false);
}
}
plan
At last, we add a new plan for the miner agents called share_information_to_friends
to achieve the intention share_information that is instantaneous. In this plan, the
miner agent first defines its list of friends, i.e. the miners with which it has a social
link and that it likes (linking higher than 0). then for each friend, it shares its list of
known mines (beliefs about their location), then its knowledge about the mines that
are empty (beliefs about their location). At last, it removes the desire and intention
to share_information.
species miner skills: [moving] control:simple_bdi {
...
v 1.8.0 1691
GAMA v1.8.0 documentation Chapter 147. 3. Social relation
do remove_intention(share_information, true);
}
}
Complete Model
model GoldBdi
global {
int nb_mines <- 10;
int nbminer<-5;
market the_market;
v 1.8.0 1692
GAMA v1.8.0 documentation Chapter 147. 3. Social relation
species goldmine {
int quantity <- rnd(1,20);
aspect default
{
if (quantity = 0) {
draw triangle(200) color: #gray border: #black;
} else {
draw triangle(200 + quantity*50) color: #yellow border: #
black;
}
}
}
species market {
int golds;
aspect default
{
draw square(1000) color: #black ;
}
}
float viewdist<-1000.0;
float speed <- 2#km/#h;
rgb mycolor<-rnd_color(255);
v 1.8.0 1693
GAMA v1.8.0 documentation Chapter 147. 3. Social relation
point target;
int gold_sold;
init
{
do add_desire(find_gold);
}
v 1.8.0 1694
GAMA v1.8.0 documentation Chapter 147. 3. Social relation
} else {
do add_belief(new_predicate(empty_mine_location, ["
location_value"::target]));
}
target <- nil;
}
}
}
v 1.8.0 1695
GAMA v1.8.0 documentation Chapter 147. 3. Social relation
do remove_intention(share_information, true);
}
aspect default {
draw circle(200) color: mycolor border: #black depth: gold_sold;
}
}
Back to the start of the tutorial 1. Creation of the basic model: gold mines and
market 2. Definition of the BDI miners 4. Use of emotions and personality for the
miners 5. Adding norms, obligations and enforcement
v 1.8.0 1696
Chapter 148
This fourth step consists in adding emotions that will impact the gold miner agent
behavior and defining the personality of the agents.
Formulation
• Definition of global emotions
• Modification of the miner species to integrate emotions and personality
Emotions
The BDI architecture of GAMA gives the possibility to generate emotions and to use
them in the cognition. The definition of emotions in GAMA is based on the OCC
theory of emotions. According to this theory, an emotion is a valued answer to the
appraisal of a situation. In GAMA an emotion is represented by a set of 5 elements:
1697
GAMA v1.8.0 documentation Chapter 148. 4. Emotions and Personality
Personality
In order to facilitate the parametrization of the BDI agents, we add the possibility
to define all the parameters related to the BDI architecture through the OCEAN
model, which proposes to represent the personality of a person according to five
factors (corresponding to the 5 variables of the BDI agents):
Each of these variables has a value between 0 and 1. 0.5 represents the neutral value,
below 0.5, the value is considered negatively and above 0.5, it is considered positively.
For example, someone with a value of 1 for N is considered as calm and someone
with a value of 0 for A is considered as hostile.
Model Definition
emotions
We add a new global emotion called joy that represents the joy emotion.
global {
...
emotion joy <- new_emotion("joy");
...
}
v 1.8.0 1698
GAMA v1.8.0 documentation Chapter 148. 4. Emotions and Personality
To use emotions (and to activate the automatic emotion generation process), we just
have to set the value of the built-in variable use_emotions_architecture to true (false
by default). In our case, one of the possible desires concerns the predicate has_gold,
and when an agent fulfill this desire and find a gold nugget (plan getGold), it gets
the belief has_gold, and the emotion engine automatically creates a joy emotion.
To be able to define the parameter of a BDI agent through the OCEAN model, we
have to set the value of the built-in variable use_personality to true (false by default).
In this model, we chose to use the default value of the O, C, E, A and N variables
(default value: 0.5). The interest of using the personality in our case is to allow the
emotion engine to give a lifetime to the created emotions (otherwise, the emotions
would have an infinite lifetime).
In this model, we only use the emotions to define if the miner agents are going to
share or not its knowledge about the gold mines. We consider that the miner only
shares information if it has a joy emotion.
species miner skills: [moving] control:simple_bdi {
...
bool use_emotions_architecture <- true;
bool use_personality <- true;
Complete Model
model GoldBdi
global {
int nb_mines <- 10;
v 1.8.0 1699
GAMA v1.8.0 documentation Chapter 148. 4. Emotions and Personality
int nbminer<-5;
market the_market;
species goldmine {
int quantity <- rnd(1,20);
aspect default
{
if (quantity = 0) {
draw triangle(200) color: #gray border: #black;
} else {
v 1.8.0 1700
GAMA v1.8.0 documentation Chapter 148. 4. Emotions and Personality
}
}
species market {
int golds;
aspect default
{
draw square(1000) color: #black ;
}
}
float viewdist<-1000.0;
float speed <- 2#km/#h;
rgb mycolor<-rnd_color(255);
point target;
int gold_sold;
init
{
do add_desire(find_gold);
}
v 1.8.0 1701
GAMA v1.8.0 documentation Chapter 148. 4. Emotions and Personality
v 1.8.0 1702
GAMA v1.8.0 documentation Chapter 148. 4. Emotions and Personality
do remove_intention(choose_goldmine, true);
}
do remove_intention(share_information, true);
}
aspect default {
draw circle(200) color: mycolor border: #black depth: gold_sold;
}
}
v 1.8.0 1703
GAMA v1.8.0 documentation Chapter 148. 4. Emotions and Personality
}
Back to the start of the tutorial 1. Creation of the basic model: gold mines and
market 2. Definition of the BDI miners 3. Definition of social relations between
miners 5. Adding norms, obligations and enforcement
v 1.8.0 1704
Chapter 149
This last step consists of adding social norms, obligations, and enforcement into the
agents ’behavior.
Formulation
• Definition of global predicates
• Definition of the policeman species
• Definition of the enforcement done by policeman species
• Definition of the law agents have to follow
• Definition of a gold miner norm to fulfill its obligation and its social norms
• Definition of the enforcement done by gold miners
1705
GAMA v1.8.0 documentation Chapter 149. 5. Norms, obligation, and enforcement
violated which mean an agent chose to disobey and do not execute it while it should.
To do this, each agent has an obedient value, between 0 and 1 ad computed from
its personality and each norm has a threshold. If the obedient value of the agent
is above the threshold, the norm is executed. An obligation is a mental state that
can be assimilated with a desire. It is created by a law that indicates under which
conditions the agent has to follow a particular obligation. Once again, the law can
have a threshold value to be activated or not depending on the obedient value of the
agent. If an agent has an obligation, it will give up its current intention and current
plan to get this obligation as its intention. Then, it will choose a specific norm to
answer this obligation, once again with a threshold on the obedient value. Finally, an
enforcement mechanism can be defined during the perception process. Norms, laws,
and obligation can be enforced. If a violation is detected, a sanction can be executed.
If the norm/law/obligation is fulfilled, a reward can be executed.
Model Definition
law
We add a law to the gold miner species that will create the obligation to get a gold
if a gold nugget is perceived. This law replaces a rule and expresses the fact that
miners are working or not, depending on their obedience value.
species miner skills: [moving] control:simple_bdi {
...
law working belief: mine_location new_obligation: has_gold
when:not has_obligation(has_gold) and not has_belief(has_gold)
strength: 2.0 threshold:thresholdLaw;
...
}
norms
The miners will have two norms. A first one to answer the obligation to collect gold.
This norms replaces the previous plan created for this purpose. However, a new plan
is declared to get 3 pieces of gold at each time. This plan will be considered illegal
by the policeman species.
v 1.8.0 1706
GAMA v1.8.0 documentation Chapter 149. 5. Norms, obligation, and enforcement
species miner skills: [moving] control:simple_bdi {
...
norm doingJob obligation:has_gold finished_when: has_belief(
has_gold) threshold:thresholdObligation{
if (target = nil) {
do add_subintention(has_gold,choose_goldmine, true);
do current_intention_on_hold();
} else {
do goto target: target ;
if (target = location) {
goldmine current_mine<- goldmine first_with (target =
each.location);
if current_mine.quantity > 0 {
gold_transported <- gold_transported+1;
do add_belief(has_gold);
ask current_mine {quantity <- quantity - 1;}
} else {
do add_belief(new_predicate(empty_mine_location, ["
location_value"::target]));
do remove_belief(new_predicate(mine_at_location, ["
location_value"::target]));
}
target <- nil;
}
}
}
}
The second norm is a social norm to communicate the list of known mines to one’s
friends. It replaces the previous plan that did this action, while a new plan is added
to give a wrong list of mines to one’s friend.
species miner skills: [moving] control:simple_bdi {
...
norm share_information intention:share_information threshold:
thresholdNorm instantaneous: true{
list<miner> my_friends <- list<miner>((social_link_base where (
each.liking > 0)) collect each.agent);
loop known_goldmine over: get_beliefs_with_name(
mine_at_location) {
ask my_friends {
do add_belief(known_goldmine);
}
}
loop known_empty_goldmine over: get_beliefs_with_name(
v 1.8.0 1707
GAMA v1.8.0 documentation Chapter 149. 5. Norms, obligation, and enforcement
empty_mine_location) {
ask my_friends {
do add_belief(known_empty_goldmine);
}
}
do remove_intention(share_information, true);
}
sanction sanctionToNorm{
do change_liking(agent_perceived,-0.1);
}
sanction rewardToNorm{
do change_liking(agent_perceived,0.1);
}
}
v 1.8.0 1708
GAMA v1.8.0 documentation Chapter 149. 5. Norms, obligation, and enforcement
init {
do add_desire(patroling);
}
sanction sanctionToLaw{
ask agent_perceived{
thresholdLaw <- 0.0;
gold_sold <- gold_sold-5;
}
fine <- fine +5;
}
sanction sanctionToObligation {
ask agent_perceived{
gold_sold <- gold_sold-3;
do remove_intention(sell_gold,true);
thresholdObligation <- self.thresholdObligation - 0.1;
}
fine <- fine + 3;
}
sanction rewardToObligation{
ask agent_perceived{
gold_sold <- gold_sold+2;
}
fine <- fine -2;
}
aspect base{
draw circle(viewdist) color: #blue depth:0.0;
}
}
v 1.8.0 1709
GAMA v1.8.0 documentation Chapter 149. 5. Norms, obligation, and enforcement
Complete Model
model GoldBdi
global {
int nb_mines <- 10;
int nbminer<-5;
int nb_police <- 1;
int fine <-0;
market the_market;
v 1.8.0 1710
GAMA v1.8.0 documentation Chapter 149. 5. Norms, obligation, and enforcement
species goldmine {
int quantity <- rnd(1,20);
aspect default
{
if (quantity = 0) {
draw triangle(200) color: #gray border: #black;
} else {
draw triangle(200 + quantity*50) color: #yellow border: #
black;
}
}
}
species market {
int golds;
aspect default
{
draw square(1000) color: #black ;
}
}
init {
do add_desire(patroling);
}
sanction sanctionToLaw{
ask agent_perceived{
v 1.8.0 1711
GAMA v1.8.0 documentation Chapter 149. 5. Norms, obligation, and enforcement
sanction sanctionToObligation {
ask agent_perceived{
gold_sold <- gold_sold-3;
do remove_intention(sell_gold,true);
thresholdObligation <- self.thresholdObligation - 0.1;
}
fine <- fine + 3;
}
sanction rewardToObligation{
ask agent_perceived{
gold_sold <- gold_sold+2;
}
fine <- fine -2;
}
aspect base{
draw circle(viewdist) color: #blue depth:0.0;
}
}
float viewdist<-1000.0;
float speed <- 2#km/#h;
rgb mycolor<-rnd_color(255);
point target;
int gold_sold;
int gold_transported<-0;
agent agent_perceived<-nil;
v 1.8.0 1712
GAMA v1.8.0 documentation Chapter 149. 5. Norms, obligation, and enforcement
init
{
do add_desire(find_gold);
}
perceive target:self{
if(gold_transported>0){
do add_belief(has_gold);
} else {
do remove_belief(has_gold);
}
}
sanction sanctionToNorm{
do change_liking(agent_perceived,-0.1);
}
sanction rewardToNorm{
do change_liking(agent_perceived,0.1);
}
v 1.8.0 1713
GAMA v1.8.0 documentation Chapter 149. 5. Norms, obligation, and enforcement
v 1.8.0 1714
GAMA v1.8.0 documentation Chapter 149. 5. Norms, obligation, and enforcement
docurrent_intention_on_hold();
} else{
dogoto target: target ;
if(target = location) {
goldmine current_mine<- goldmine first_with (target =
each.location);
if current_mine.quantity > 0 {
gold_transported <- 3;
do add_belief(has_gold);
ask current_mine {if(quantity>=3) {
quantity <- quantity - 3;
}else {
quantity <- 0;
}
}
} else {
do add_belief(new_predicate(empty_mine_location, ["
location_value"::target]));
do remove_belief(new_predicate(mine_at_location, ["
location_value"::target]));
}
target <- nil;
}
}
}
v 1.8.0 1715
GAMA v1.8.0 documentation Chapter 149. 5. Norms, obligation, and enforcement
do remove_intention(share_information, true);
}
aspect default {
draw circle(200) color: mycolor border: #black depth: gold_sold;
}
}
v 1.8.0 1716
GAMA v1.8.0 documentation Chapter 149. 5. Norms, obligation, and enforcement
}
}
Back to the start of the tutorial 1. Creation of the basic model: gold mines and
market 2. Definition of the BDI miners 3. Definition of social relations between
miners 4. Use of emotions and personality for the miners
v 1.8.0 1717
GAMA v1.8.0 documentation Chapter 149. 5. Norms, obligation, and enforcement
v 1.8.0 1718
Part X
Pedagogical materials
1719
Chapter 150
A set of exercices for your first step to algorithms using the graphical tool Scratch:
PDF.
Memo GAML
A summary of the organization of a GAML model, its main parts and the main
keywords, statements: PDF.
1721
GAMA v1.8.0 documentation Chapter 150. Some pedagogical materials
• Keywords: grid, GIS data, displays, plot, Graphical modeling, Schelling model.
• Subject: PDF, Keynote, PPTX
• A model: gaml file
v 1.8.0 1722
GAMA v1.8.0 documentation Chapter 150. Some pedagogical materials
v 1.8.0 1723
GAMA v1.8.0 documentation Chapter 150. Some pedagogical materials
v 1.8.0 1724
Part XI
Extensions
1725
Chapter 151
Extensions
Here’s the community list of existing extensions. Feel free to add yours.
If you want to add your extension, please follow this structure : - A title (the name
of your extension) - A short description (explain what your extension could be used
for) - An image (optional) - A link (to your website, a download page or whatever
relevant link)
Thanks!
RAMA
1727
GAMA v1.8.0 documentation Chapter 151. Extensions
v 1.8.0 1728
Chapter 152
Developing Extensions
• the first one consists in defining the GAML extensions in a plug-in (in the OSGI
sense, see here) that will be loaded by GAMA at runtime and must “declare”
that it is contributing to the platform.
– the second one is to indicate to GAMA where to look for extensions, using
Java annotations that are gathered at compile time (some being also used
at runtime) and directly compiled into GAML structures.
– 2. Architecture of GAMA
– 3. Developing a Plugin
– 4. Developing a Skill
1729
GAMA v1.8.0 documentation Chapter 152. Developing Extensions
– 5. Developing a Statement
– 6. Developing an Operator
– 7. Developing a Type
– 8. Developing a Species
– 9. Developing a Control Architecture
– 10. Index of annotations
v 1.8.0 1730
Chapter 153
1731
GAMA v1.8.0 documentation Chapter 153. Installing the GIT version
– Choose Git
v 1.8.0 1732
GAMA v1.8.0 documentation Chapter 153. Installing the GIT version
v 1.8.0 1733
GAMA v1.8.0 documentation Chapter 153. Installing the GIT version
* In Local Destination windows, * Choose a Directory (where the source files will
be downloaded). * Everything else should be unchecked * Finish
v 1.8.0 1734
GAMA v1.8.0 documentation Chapter 153. Installing the GIT version
v 1.8.0 1735
GAMA v1.8.0 documentation Chapter 153. Installing the GIT version
• File / Import...,
v 1.8.0 1736
GAMA v1.8.0 documentation Chapter 153. Installing the GIT version
v 1.8.0 1737
GAMA v1.8.0 documentation Chapter 153. Installing the GIT version
• Click on Next,
– In the new window, select your Git repository,
– Click on Next,
– In the Select a wizard to used to import projects, check that
∗ Import existing Eclipse projects is selected
∗ Working Tree is selected
• Click on Next,
– In the Import project window,
∗ Uncheck Search for nested projects
v 1.8.0 1738
GAMA v1.8.0 documentation Chapter 153. Installing the GIT version
v 1.8.0 1739
GAMA v1.8.0 documentation Chapter 153. Installing the GIT version
1.8 by default (in Preferences > Java > Compiler > Compiler Compliance Level) or
you change the error produced by Eclipse to a warning only (in Preferences > Java
> Compiler > Building > "No strictly compatible JRE for execution environment
available).
Run GAMA
1. In the ummisco.gama.product plugin, open the gama.runtime.product file
(gama.product is used to produce the release).
2. Go to “Overview” tab and click on Synchronize
3. Click on Launch an Eclipse Application
GIT Tutorials
For those who want learn more about Git and Egit, please consult the following
tutorials/papers
v 1.8.0 1740
Chapter 154
Architecture of GAMA
GAMA is made of a number of Eclipse Java projects, some representing the core
projects without which the platform cannot be run, others additional plugins adding
functionalities or concepts to the platform.
Vocabulary: Each project is either designed as a plugin (containing an xml file
“plugin.xml”) or as a feature (containing an xml file “feature.xml”).
To see how to create a plugin and a feature, please read this page.
Table of contents
• Architecture of GAMA
– The minimal configuration
1741
GAMA v1.8.0 documentation Chapter 154. Architecture of GAMA
– Optional Plugins
∗ Plugins present in the release version
∗ Plugins not present by default in the release version
∗ Plugins not designated to be in the release version
– Unmaintained projects
– Features
– Models
– Plugins overview
v 1.8.0 1742
GAMA v1.8.0 documentation Chapter 154. Architecture of GAMA
v 1.8.0 1743
GAMA v1.8.0 documentation Chapter 154. Architecture of GAMA
Optional Plugins
From this minimal configuration, it is possible to add some features. Here is the list
of the features installed by default in the release version:
Some other plugins are not present by default in the release version (because their
use is very specific), but it’s possible to install them through features. Here is the list
of those plugins:
v 1.8.0 1744
GAMA v1.8.0 documentation Chapter 154. Architecture of GAMA
Other plugins will never be on the released version, and will never be loaded during
the gama execution. They are just used in the “developer” version:
Unmaintained projects
Some other projects are still in the git repository in case we need to work on it one
day, but they are either unfinished, obsolete, or used in very rare situations (They
are not delivered in release versions, of course). Here is the list:
v 1.8.0 1745
GAMA v1.8.0 documentation Chapter 154. Architecture of GAMA
Features
v 1.8.0 1746
GAMA v1.8.0 documentation Chapter 154. Architecture of GAMA
Models
Beside those plugins and features, a project dedicated to gather a bunch of examples
is also in the git repository. It contains gaml code: * msi.gama.models
Plugins overview
Global architecture of GAMA (nb: the features graphlayout, core, dependencies,
plugins, jogl2.product and product are not represented here)
v 1.8.0 1747
GAMA v1.8.0 documentation Chapter 154. Architecture of GAMA
v 1.8.0 1748
Chapter 155
Developing Plugins
This page details how to create a new plug-in in order to extend the GAML language
with new skills, species, displays or operators. It also details how to create a plug-in
that can be uploaded on an update site and can be installed into the GAMA release.
We consider here that the developer version of GAMA has been installed (as detailled
in this page).
Creation of a plug-in
Here are detailled steps to create and configure a new GAMA plug-in.
1749
GAMA v1.8.0 documentation Chapter 155. Developing Plugins
– Overview pane:
∗ check « This plug-in is a singleton »
– Dependencies pane:
∗ add (at least minimum) the two plug-ins “msi.gama.core” and “m-
si.gama.ext” in the “Required Plug-ins”. When you click on “Add”, a
new window will appear without any plug-in. Just write the beginning
of the plug-in name in the text field under “Select a plug-in”.
– Runtime pane:
∗ In exported Packages: nothing (but when you will have implemented
new packages in the plug-in you should add them there)
∗ Add in the classpath all the additional libraries (.jar files) used in the
project.
– Extensions pane:
∗ “Add” “gaml.extension”
– Save the file. This should create a “plugin.xml” file.
– Select the project and in menu Project > Properties:
v 1.8.0 1750
GAMA v1.8.0 documentation Chapter 155. Developing Plugins
The plug-in is ready to accept any addition to the GAML language, e.g. skills, actions,
operators.
Do not forget to export the created packages that could be used by “clients”, especially
the packages containing the code of the additions (in the plugin.xml of the new project,
tab “Runtime”).
To test the plug-in and use it into GAMA, developers have to define a new feature
project containing your plugin and its dependencies, and adds this feature to the
existing product (or a new .product file of your own). The use of feature is also
mandatory to define a plug-in that can be uploaded on the update site and can be
installed in the release of GAMA.
Creation of a feature
A feature is an Eclipse project dedicated to gather one or several plug-ins to integrate
them into a product or to deploy them on the update site and install them from the
GAMA release (a feature is mandatory in this case).
Here are detailled steps to create and configure a new feature.
• File > New > Feature project (or File > New > Project. . . then Plug-in
Development > Feature Project)
– In Feature properties
∗ Choose a project name (e.g. “institution.gama.feature.pluginsName”)
v 1.8.0 1751
GAMA v1.8.0 documentation Chapter 155. Developing Plugins
∗ Click on “Next”
– In Referenced Plug-ins and fragments
∗ Check “Initialize from the plug-ins list:”
∗ Choose the plug-ins that have to be gathered in the feature
∗ Click on “Finish”
– A new project has been created. The “feature.xml” file will configure the
feature.
∗ In “Information pane”:
· You can add description of the various plug-ins of the feature,
define the copyright notice and the licence.
∗ In “Plug-ins and Fragments”
· In the Plug-ins and Fragments, additional plug-ins can be added.
• Contents pane
Remark: To check whether the new plug-in has been taken into account by GAMA,
after GAMA launch, it should appear in the Eclipse console in a line beginning by “»
GAMA bundle loaded in”.
v 1.8.0 1752
GAMA v1.8.0 documentation Chapter 155. Developing Plugins
• Right click -> Configure -> Convert to maven project to add pom.xml:
• Set:
• Finish
• Save
c/ Update maven cache in eclipse (optional) It will fix this compilation error “Project
configuration is not up-to-date with pom.xml. Select: Maven->Update Project. . .
from the project context menu or use Quick Fix.”
v 1.8.0 1753
GAMA v1.8.0 documentation Chapter 155. Developing Plugins
• New -> Project -> type in : feature -> Select “Feature Project”
• Set:
– Project name: institution.gama.feature.pluginsName
– Uncheck use default location, type in: {current git repository}\aaa.
bbb.feature.ccc
– Feature Version: 1.0.0.qualifier
– Update Site URL: http://updates.gama-platform.org/experimental
– Update Site Name: GAMA 1.7.x Experimental Plugins Update Site
• Click Next
– Initialize from the plugin list -> check all plugins needed: institu-
tion.gama.pluginsName (1.0.0.qualifier)
• Finish
• Right click -> Configure -> Convert to maven project (to add pom.xml)
• Set:
– Group id: institution.gama.feature.pluginsName
– Artifact id: institution.gama.feature.pluginsName
– Version: 1.0.0-SNAPSHOT
– Packaging: eclipse-feature
• Finish
v 1.8.0 1754
GAMA v1.8.0 documentation Chapter 155. Developing Plugins
– Version: 1.7.0-SNAPSHOT
– Relative path: ../msi.gama.experimental.parent
• Save
d/ Update maven cache in eclipse (optional) It will fix this compilation error “Project
configuration is not up-to-date with pom.xml. Select: Maven->Update Project. . .
from the project context menu or use Quick Fix.”
• File > New > Other. . . > SVN > Project from SVN
– In Checkout Project from SVN repository
∗ Use existing repository location (it is the same location as for the
GAMA code)
∗ Next
– In Select resource:
∗ Browse
v 1.8.0 1755
GAMA v1.8.0 documentation Chapter 155. Developing Plugins
Now the update_site project is available in the project list (in Package Explorer).
The sequel describes how to add a new feature to the update site.
The plug-in is now available as an extension from the GAMA release. More details
about the update of the GAMA release are available on the dedicated page.
v 1.8.0 1756
Chapter 156
A skill adds new features (attributes) and new capabilities (actions) to the instances
of the species that use it.
1757
GAMA v1.8.0 documentation Chapter 156. Developing a New Skill
In order to detail how to access these new attributes (if needed), developers have to
define a getter (using @getter) and a setter (using @setter) methods. If no getter
(and setter) is defined, the attribute can nevertheless be set and get, using implicit
by default getter and setter. But as soon as a getter and/or a setter is defined, they
replace the implicit default ones. For example:
@getter(IKeyword.SPEED)
public double getSpeed(final IAgent agent) {
return (Double) agent.getAttribute(IKeyword.SPEED);
}
@setter(IKeyword.SPEED)
public void setSpeed(final IAgent agent, final double s) {
agent.setAttribute(IKeyword.SPEED, s);
}
v 1.8.0 1758
GAMA v1.8.0 documentation Chapter 156. Developing a New Skill
or
path path_followed <- self goto (target: the_target, on: the_graph,
return_path: true);
Warnings
Developers should notice that: * the method associated with an action has to return
a non-void object. * the method should have only one parameter: the scope (type
IScope). * the method can only throw GamaRuntimeExceptions. Other exceptions
should be caught in the method and wrapped in a GamaRuntimeException before
being thrown.
Annotations
@skill
This annotations Allows to define a new skill (class grouping variables and actions
that can be used by agents).
This annotation contains: * name (String): a String representing the skill name in
GAML (must be unique throughout GAML). * attach_to (set of strings): an array of
species names to which the skill will be automatically added (complements the “skills”
v 1.8.0 1759
GAMA v1.8.0 documentation Chapter 156. Developing a New Skill
parameter of species). * internal (boolean, false by default): return whether this skill
is for internal use only. * doc (set of @doc, empty by default): the documentation
associated to the skill.
@variable
@doc
v 1.8.0 1760
GAMA v1.8.0 documentation Chapter 156. Developing a New Skill
@getter
This annotations is used to indicate that a method is to be used as a getter for a
variable defined in the class. The variable must be defined on its own (in vars).
This annotation contains: * value (String): the name of the variable for which the
annotated method is to be considered as a getter. * initializer (boolean, false by
default): returns whether or not this getter should also be used as an initializer
@setter
This annotations is used to indicate that a method is to be used as a setter for a
variable defined in the class. The variable must be defined on its own (in vars).
This annotation contains: * value (String): the name of the variable for which the
annotated method is to be considered as a setter.
@action
This annotations is used to tag a method that will be considered as an action
(or primitive) in GAML. The method must have the following signature: Object
methodName(IScope) throws GamaRuntimeException and be contained in a class
annotated with @species or @skill (or a related class, like a subclass or an interface).
This annotation contains: * name (String): the name of the variable as it can be
used in GAML. * virtual (boolean, false by default): if true the action is virtual,
i.e. equivalent to abstract method in java. * args (set of arg, empty by default): the
list of arguments passed to this action. Each argument is an instance of arg. * doc
(set of @doc, empty by default): the documentation associated to the action.
@arg
This annotations describes an argument passed to an action.
This annotation contains: * name (String, "" by default): the name of the argument
as it can be used in GAML. * type (set of ints, empty by default): An array containing
the textual representation of the types that can be taken by the argument (see IType).
* optional (boolean, true by default): whether this argument is optional or not. *
doc (set of @doc, empty by default): the documentation associated to the argument.
v 1.8.0 1761
GAMA v1.8.0 documentation Chapter 156. Developing a New Skill
All these annotations are defined in the GamlAnnotations.java file of the msi.gama
.processor plug-in. # Developing Statements
Statements are a fundamental part of GAML, as they represent both commands
(imperative programming style) or declarations (declarative programming style).
Developing a new statement allows, then, to add a new instruction to GAML.
v 1.8.0 1762
GAMA v1.8.0 documentation Chapter 156. Developing a New Skill
Examples
v 1.8.0 1763
GAMA v1.8.0 documentation Chapter 156. Developing a New Skill
action) in any species, experiment or global statement. It defines several facets and
uses a custom validator and a custom serializer.
@symbol(name = IKeyword.ACTION, kind = ISymbolKind.ACTION,
with_sequence = true, with_args = true, unique_name = true)
@inside(kinds = { ISymbolKind.SPECIES, ISymbolKind.EXPERIMENT,
ISymbolKind.MODEL })
@facets(value = {
@facet(name = IKeyword.NAME, type = IType.ID, optional = false),
@facet(name = IKeyword.TYPE, type = IType.TYPE_ID, optional = true,
internal = true),
@facet(name = IKeyword.OF, type = IType.TYPE_ID, optional = true,
internal = true),
@facet(name = IKeyword.INDEX, type = IType.TYPE_ID, optional = true
, internal = true),
@facet(name = IKeyword.VIRTUAL, type = IType.BOOL, optional = true)
}, omissible = IKeyword.NAME)
@validator(ActionValidator.class)
@serializer(ActionSerializer.class)
public class ActionStatement extends AbstractStatementSequenceWithArgs
{
Implementation
All the statements inherit from the abstract class AbstractStatement. S-
tatements with a sequence of embedded statements inherit from the class
AbstractStatementSequence (which extends AbstractStatement).
v 1.8.0 1764
GAMA v1.8.0 documentation Chapter 156. Developing a New Skill
• the method privateExecuteIn: this method is executed each time the state-
ment is called in the model.
protected Object privateExecuteIn(IScope scope) throws
GamaRuntimeException {
IAgent agent = stack.getAgentScope();
String nameStr = null;
if ( agent != null && !agent.dead() ) {
nameStr = Cast.asString(stack, name.value(stack));
if ( nameStr == null ) {
nameStr = "nil";
v 1.8.0 1765
GAMA v1.8.0 documentation Chapter 156. Developing a New Skill
}
GuiUtils.informConsole(nameStr);
}
return nameStr;
}
v 1.8.0 1766
GAMA v1.8.0 documentation Chapter 156. Developing a New Skill
Annotations
@symbol
This annotation represents a “statement” in GAML, and is used to define its name(s)
as well as some meta-data that will be used during the validation process.
This annotation contains:
v 1.8.0 1767
GAMA v1.8.0 documentation Chapter 156. Developing a New Skill
@inside
This annotation is used in conjunction with symbol. Provides a way to tell where
this symbol should be located in a model (i.e. what its parents should be). Either
direct symbol names (in symbols) or generic symbol kinds can be used.
This annotation contains:
@facets
This annotation describes a list of facets used by a statement in GAML.
This annotation contains:
• value (set of @facet): array of @facet, each representing a facet name, type..
– ommissible (string): the facet that can be safely omitted by the modeler
(provided its value is the first following the keyword of the statement).
@facet
This facet describes a facet in a list of facets.
This annotation contains:
• name (String): the name of the facet. Must be unique within a symbol.
v 1.8.0 1768
GAMA v1.8.0 documentation Chapter 156. Developing a New Skill
– type (set of Strings): the string values of the different types that can be
taken by this facet.
– values (set of Strings): the values that can be taken by this facet. The
value of the facet expression will be chosen among the values described
here.
– optional (boolean, false by default): whether or not this facet is optional
or mandatory.
– doc (set of @doc, empty by default): the documentation associated to the
facet.
@doc
It provides a unified way of attaching documentation to the various GAML elements
tagged by the other annotations. The documentation is automatically assembled at
compile time and also used at runtime in GAML editors.
@serializer
It allows to declare a custom serializer for Symbols (statements, var declarations,
species, experiments, etc.). This serializer will be called instead of the standard serial-
v 1.8.0 1769
GAMA v1.8.0 documentation Chapter 156. Developing a New Skill
izer, superseding this last one. Serializers must be subclasses of the SymbolSerializer
class.
@validator
It allows to declare a custom validator for Symbols (statements, var declarations,
species, experiments, etc.). This validator, if declared on subclasses of Symbol, will
be called after the standard validation is done. The validator must be a subclass of
IDescriptionValidator.
All these annotations are defined in the GamlAnnotations.java file of the msi.gama
.processor plug-in.
v 1.8.0 1770
Chapter 157
Developing Operators
Implementation
A new operator can be any Java method that:
@operator(value = "rgb")
public static GamaColor rgb(final int r, final int g, final int b,
final double alpha) {
The method:
• must return a value (that has to be one of the GAMA Type: Integer, Double,
Boolean, String, IShape, IList, IGraph, IAgent. . . ),
– can define any number of parameters, defined using Java type,
1771
GAMA v1.8.0 documentation Chapter 157. Developing Operators
Annotations
@operator
This annotation represents an “operator” in GAML, and is used to define its name(s)
as well as some meta-data that will be used during the validation process.
This annotation contains:
@doc
It provides a unified way of attaching documentation to the various GAML elements
tagged by the other annotations. The documentation is automatically assembled at
compile time and also used at runtime in GAML editors.
v 1.8.0 1772
GAMA v1.8.0 documentation Chapter 157. Developing Operators
All these annotations are defined in the GamlAnnotations.java file of the msi.gama
.processor plug-in.
v 1.8.0 1773
GAMA v1.8.0 documentation Chapter 157. Developing Operators
v 1.8.0 1774
Chapter 158
Developing Types
GAML provides a given number of built-in simple types (int, bool. . . ) and more
complex ones (path, graph. . . ). Developing a new type allows, then, to add a new
data structure to GAML.
Implementation
Developing a new type requiers the implementation of 2 Java files:
• the first one that describes the data structure (e.g.: GamaColor.java to define
a type color)
– the second one that implements the type itself, wrapping the data structure
file (e.g.: GamaColorType.java), and providing accessors to data structure
attributes.
1775
GAMA v1.8.0 documentation Chapter 158. Developing Types
@vars({ @var(name = IKeyword.COLOR_RED, type = IType.INT), @var(name =
IKeyword.COLOR_GREEN, type = IType.INT),
@var(name = IKeyword.COLOR_BLUE, type = IType.INT), @var(name =
IKeyword.ALPHA, type = IType.INT),
@var(name = IKeyword.BRIGHTER, type = IType.COLOR), @var(name =
IKeyword.DARKER, type = IType.COLOR) })
public class GamaColor extends Color implements IValue {
It can contain setter and/or getter for each of its attributes. Setters and getters
are methods annotated by the [@getter](DevelopingIndexAnnotations#@getter) or
[@setter](DevelopingIndexAnnotations#@setter) annotations.
@getter(IKeyword.COLOR_RED)
public Integer red() {
return super.getRed();
}
v 1.8.0 1776
GAMA v1.8.0 documentation Chapter 158. Developing Types
This class imposes to implement the three following methods (with the example of
the GamaColorType):
Remark: for each type, a unary operator is created with the exact name of the type.
It can be used to cast any expression in the given type. This operator calls the
previous cast method.
Annotations
@type
It provides information necessary to the processor to identify a type.
This annotation contains:
• name (String, "" by default): a String representing the type name in GAML.
– id (int, 0 by default): the unique identifier for this type. User-added types
can be chosen between IType.AVAILABLE_TYPE and IType.SPECIES_-
TYPE (exclusive) (cf. IType.java).
– wraps (tab of Class, null by default): the list of Java Classes this type is
“wrapping” (i.e. representing). The first one is the one that will be used
preferentially throughout GAMA. The other ones are to ensure compati-
bility, in operators, with compatible Java classes (for instance, List and
GamaList).
v 1.8.0 1777
GAMA v1.8.0 documentation Chapter 158. Developing Types
v 1.8.0 1778
Chapter 159
Developing Species
Additional built-in species can be defined in Java in order to be used in GAML models.
Additional attributes and actions can be defined. It could be very useful in order to
define its behavior thanks to external libraries (e.g. mulit-criteria decision-making,
database connection. . . ).
A new built-in species extends the GamlAgent class, which defines the basic GAML
agents. As a consequence, new built-in species have all the attributes (name, shape,
. . . ) and actions (die. . . ) of regular species.
Implementation
A new species can be any Java class that:
1779
GAMA v1.8.0 documentation Chapter 159. Developing Species
Additional attributes
For example, regular species are defined with the following annotation:
@vars({ @var(name = IKeyword.NAME, type = IType.STRING), @var(name =
IKeyword.PEERS, type = IType.LIST),
@var(name = IKeyword.HOST, type = IType.AGENT),
@var(name = IKeyword.LOCATION, type = IType.POINT, depends_on =
IKeyword.SHAPE),
@var(name = IKeyword.SHAPE, type = IType.GEOMETRY) })
@setter(IKeyword.NAME)
public abstract void setName(String name);
Additional actions
v 1.8.0 1780
GAMA v1.8.0 documentation Chapter 159. Developing Species
Annotations
@species
This annotation represents a “species” in GAML. The class annotated with this
annotation will be the support of a species of agents.
This annotation contains:
• name (string): the name of the species that will be created with this class as
base. Must be unique throughout GAML.
– skills (set of strings, empty by default): An array of skill names that will
be automatically attached to this species. Example: @species(value="
animal" skills={"moving"})
– internal (boolean, false by default): whether this species is for internal
use only.
– doc (set of @doc, empty by default): the documentation attached to this
operator.
All these annotations are defined in the GamlAnnotations.java file of the msi.gama
.processor plug-in.
v 1.8.0 1781
GAMA v1.8.0 documentation Chapter 159. Developing Species
v 1.8.0 1782
Chapter 160
Developing architecture
Implementation
A control architecture is a Java class, that:
The AbstractArchitecture extends the ISkill and IStatement interfaces and add
the 2 following methods:
1783
GAMA v1.8.0 documentation Chapter 160. Developing architecture
v 1.8.0 1784
Chapter 161
Index of annotations
Annotations are used to link Java methods and classes to GAML language.
@action
This annotations is used to tag a method that will be considered as an action
(or primitive) in GAML. The method must have the following signature: Object
methodName(IScope) throws GamaRuntimeException and be contained in a class
annotated with [@species](#species) or [@skill](#skill) (or a related class, like a
subclass or an interface).
This annotation contains:
@arg
This annotations describes an argument passed to an action.
1785
GAMA v1.8.0 documentation Chapter 161. Index of annotations
• name (String, "" by default): the name of the argument as it can be used in
GAML.
– type (set of ints, empty by default): An array containing the textual
representation of the types that can be taken by the argument (see IType).
– optional (boolean, true by default): whether this argument is optional or
not.
– doc (set of [@doc](#doc), empty by default): the documentation associated
to the argument.
@constant
This annotation is used to annotate fields that are used as constants in GAML.
This annotation contains:
@doc
It provides a unified way of attaching documentation to the various GAML elements
tagged by the other annotations. The documentation is automatically assembled at
compile time and also used at runtime in GAML editors.
This annotation contains:
v 1.8.0 1786
GAMA v1.8.0 documentation Chapter 161. Index of annotations
@example
This facet describes an example, that can be used either in the documentation, as
unit test or as pattern.
This annotation contains:
v 1.8.0 1787
GAMA v1.8.0 documentation Chapter 161. Index of annotations
– isNot (String, "" by default): The value to which the value will be compared.
– raises (String, "" by default): The exception or warning that the expression
could raise.
– isTestOnly (boolean, false by default): specifies that the example should
not be included into the documentation.
– isExecutable (boolean, true by default): specifies that the example is
correct GAML code that can be executed.
– test (boolean, true by default): specifies that the example is will be tested
with the equals.
– isPattern (boolean, false by default): whether or not this example should
be treated as part of a pattern (see @usage). If true, the developers might
want to consider writing the example line (and its associated lines) using
template variables (e.g. ${my_agent}).
@facet
This facet describes a facet in a list of facets.
This annotation contains:
• name (String): the name of the facet. Must be unique within a symbol.
– type (set of int): the string values of the different types that can be taken
by this facet.
– values (set of Strings, empty by default): the values that can be taken
by this facet. The value of the facet expression will be chosen among the
values described here.
– optional (boolean, false by default): whether or not this facet is optional
or mandatory.
– doc (set of [@doc](#doc), empty by default): the documentation associated
to the facet.
@facets
This annotation describes a list of facets used by a statement in GAML.
This annotation contains:
v 1.8.0 1788
GAMA v1.8.0 documentation Chapter 161. Index of annotations
– ommissible (string): the facet that can be safely omitted by the modeler
(provided its value is the first following the keyword of the statement).
@file
This annotation is used to define a type of file.
This annotation contains:
v 1.8.0 1789
GAMA v1.8.0 documentation Chapter 161. Index of annotations
@getter
This annotations is used to indicate that a method is to be used as a getter for a
variable defined in the class. The variable must be defined on its own (in vars).
This annotation contains:
• value (String): the name of the variable for which the annotated method is to
be considered as a getter.
– initializer (boolean, false by default): returns whether or not this getter
shoud also be used as an initializer
@inside
This annotation is used in conjunction with symbol. Provides a way to tell where
this symbol should be located in a model (i.e. what its parents should be). Either
direct symbol names (in symbols) or generic symbol kinds can be used.
This annotation contains:
@operator
This annotation represents an “operator” in GAML, and is used to define its name(s)
as well as some meta-data that will be used during the validation process.
This annotation contains:
v 1.8.0 1790
GAMA v1.8.0 documentation Chapter 161. Index of annotations
@serializer
v 1.8.0 1791
GAMA v1.8.0 documentation Chapter 161. Index of annotations
@setter
This annotations is used to indicate that a method is to be used as a setter for a
variable defined in the class. The variable must be defined on its own (in vars).
This annotation contains:
• value (String): the name of the variable for which the annotated method is to
be considered as a setter.
@skill
This annotation allows to define a new skill (class grouping variables and actions that
can be used by agents).
This annotation contains:
• name (String): a String representing the skill name in GAML (must be unique
throughout GAML).
– attach_to (set of strings): an array of species names to which the skill
will be automatically added (complements the “skills” parameter of species).
– internal (boolean, false by default): return whether this skill is for internal
use only.
– doc (set of [@doc](#doc), empty by default): the documentation associated
to the skill.
@species
This annotation represents a “species” in GAML. The class annotated with this
annotation will be the support of a species of agents.
This annotation contains:
• name (string): the name of the species that will be created with this class as
base. Must be unique throughout GAML.
v 1.8.0 1792
GAMA v1.8.0 documentation Chapter 161. Index of annotations
– skills (set of strings, empty by default): An array of skill names that will
be automatically attached to this species. Example: @species(value="
animal" skills={"moving"})
– internal (boolean, false by default): whether this species is for internal
use only.
– doc (set of [@doc](#doc), empty by default): the documentation attached
to this operator.
@symbol
This annotation represents a “statement” in GAML, and is used to define its name(s)
as well as some meta-data that will be used during the validation process.
This annotation contains:
– kind (int): the kind of the annotated symbol (see ISymbolKind.java for
more details).
– with_scope (boolean, true by default): indicates if the statement (usually
a sequence) defines its own scope. Otherwise, all the temporary variables
defined in it are actually defined in the super-scope.
– with_sequence (boolean): indicates wether or not a sequence can or
should follow the symbol denoted by this class.
– with_args (boolean, false by default): indicates wether or not the symbol
denoted by this class will accept arguments.
– remote_context (boolean, false by default): indicates that the context of
this statement is actually an hybrid context: although it will be executed in
a remote context, any temporary variables declared in the enclosing scopes
should be passed on as if the statement was executed in the current context.
– doc (set of [@doc](#doc), empty by default): the documentation attached
to this symbol.
– internal (boolean, false by default): returns whether this symbol is for
internal use only.
– unique_in_context (boolean, false by default): Indicates that this s-
tatement must be unique in its super context (for example, only one return
is allowed in the body of an action)..
v 1.8.0 1793
GAMA v1.8.0 documentation Chapter 161. Index of annotations
@type
It provides information necessary to the processor to identify a type.
This annotation contains:
• name (String, "" by default): a String representing the type name in GAML.
– id (int, 0 by default): the unique identifier for this type. User-added types
can be chosen between IType.AVAILABLE_TYPE and IType.SPECIES_-
TYPE (exclusive) (cf. IType.java).
– wraps (tab of Class, null by default): the list of Java Classes this type is
“wrapping” (i.e. representing). The first one is the one that will be used
preferentially throughout GAMA. The other ones are to ensure compati-
bility, in operators, with compatible Java classes (for instance, List and
GamaList).
– kind (int, ISymbolKind.Variable.REGULAR by default): the kind of
Variable used to store this type. See ISymbolKind.Variable.
– internal (boolean, false by default): whether this type is for internal use
only.
– doc (set of [@doc](#doc), empty by default): the documentation associated
to the facet.
@usage
This replaces @special_cases and @examples, and unifies the doc for operators,
statements and others. An @usage can also be used for defining a template for a
GAML structure, and in that case requires the following to be defined:
v 1.8.0 1794
GAMA v1.8.0 documentation Chapter 161. Index of annotations
• value (String): a String representing one usage of the keyword. Note that for
usages aiming at defining templates, the description is displayed on a tooltip
in the editor. The use of the path allows to remove unecessary explanations.
For instance, instead of writing : description=“This template illustrates the use
of a complex form of the”create" statement, which reads agents from a shape
file and uses the tabular data of the file to initialize their attributes“, choose:
name=”Create agents from shapefile" menu=STATEMENT; path={“Create”,
“Complex forms”} description=“Read agents from a shape file and initialze their
attributes”. If no description is provided, GAMA will try to grab it from the
context where the template is defined (in the documentation, for example).
– menu (String, "" by default): Define the top-level menu where this template
should appear. Users are free to use other names than the provided constants
if necessary (i.e. “My templates”). When no menu is defined, GAMA tries
to guess it from the context where the template is defined.
– path (set of Strings, empty be default): The path indicates where to
put this template in the menu. For instance, the following annotation: "
menu = STATEMENT; path = {“Control”, “If”} will put the template in
a menu called “If”, within “Control”, within the top menu “Statement”.
When no path is defined, GAMA will try to guess it from the context
where the template is defined (i.e. keyword of the statement, etc.)
– name (String, "" by default): The name of the template should be both
concise (as it will appear in a menu) and precise (to remove ambiguities
between templates).
– examples (set of [@example](#example), empty by default): An array
of String representing some examples or use-cases about how to use this
element, related to the particular usage above.
– pattern (String, "" by default): Alternatively, the contents of the us-
age can be descried using a @pattern (rather than an array of [@exam-
ple](#example)). The formatting of this string depends entirely on the
user (e.g. including \n and \t for indentation, for instance).
v 1.8.0 1795
GAMA v1.8.0 documentation Chapter 161. Index of annotations
@validator
@variable
– type (int): The textual representation of the type of the variable (see
IType).
– of (int, 0 by default): The textual representation of the content type of the
variable (see IType#defaultContentType()).
– index (int, 0 by default): The textual representation of the index type of
the variable (see IType#defaultKeyType()).
– constant (boolean, false by default): returns whether or not this variable
should be considered as non modifiable.
– init (String, "" by default): the initial value of this variable as a String
that will be interpreted by GAML.
– depend_on (set of Strings, empty by default): an array of String repre-
senting the names of the variables on which this variable depends (so that
they are computed before).
– internal (boolean, false by default): return whether this var is for internal
use only.
– doc (set of [@doc](#doc), empty by default): the documentation associated
to the variable.
v 1.8.0 1796
GAMA v1.8.0 documentation Chapter 161. Index of annotations
@vars
This annotation is used to describe a set of variables or fields.
This annotation contains:
v 1.8.0 1797
GAMA v1.8.0 documentation Chapter 161. Index of annotations
v 1.8.0 1798
Part XII
Developing GAMA
1799
Chapter 162
GAMA is written in Java and made of tens of Eclipse plugins and projects, thousand
of classes, methods and annotations. This section of the wiki should help you have a
general idea on how to manipulate GAMA Java API and where to find the proper
classes and methods. A general introduction to the GAMA architecture gives a
general overview of the organization of Java packages and Eclipse plugins, and should
be read first. In the following sub-sections we give a more practical introduction.
1801
GAMA v1.8.0 documentation Chapter 162. Get into the GAMA Java API
v 1.8.0 1802
Chapter 163
This introduction to the Java API is dedicated to programmers that want to participate
in the java code of GAMA. The main purpose is to describe the main packages and
classes of the API to makes it simple to find such crucial information such as: how
GAMA create containers, agent and geometries, how exceptions and log are managed,
how java code maintain Type safety, etc.
Table of content
Concepts
1. Factories
2. Spatial
3. Type
4. IScope
5. Exception
6. Debug
7. Test
Packages
• 1.Core
1803
GAMA v1.8.0 documentation Chapter 163. Introduction to GAMA Java API
v 1.8.0 1804
Chapter 164
Concepts
Factories
Container factories
GAMA provides 2 factories for containers: GamaListFactory and GamaMapFactory.
Each of them has create methods to create objects of type IList and IMap. The
types of elements in the container can be specified at creation using one of the
elements defined in Types.
Warning: the create method is used to create the container, with elements of a given
type, but it also converts elements added in this type. To avoid conversion
(not recommended), use the method createWithoutCasting.
As an example:
IList<Double> distribution = GamaListFactory.create(Types.FLOAT);
1805
GAMA v1.8.0 documentation Chapter 164. Concepts
or only:
IList<Object> result = GamaListFactory.create();
As an example:
final IMap<String, IList<?>> ncdata = GamaMapFactory.create(Types.
STRING, Types.LIST);
or only:
IMap<Object, Object> result = GamaMapFactory.create();
If you want to use map or set, try to the best to rely on collection that ensure order,
so to avoid unconsistency in container access. Try the most to avoid returning high
order hash based collection, e.g. Set or Map; in this case, rely on standard definition
in Gama:
5. Stream : you can use java build-in streams but there is a special version in
Gama taken from StreamEx that should be preferred.
my_container.stream(my_scope)
If you want to get a stream back to a Gama container, you can use the collector in
Factories:
my_container.stream(my_scope).collect(GamaListFactory.toGamaList())
v 1.8.0 1806
GAMA v1.8.0 documentation Chapter 164. Concepts
Geometry factory
Gama geometry is based on the well established Jstor geometric library, while
geographic aspect are handle using GeoTools library
2.
Spatial
The Spatial class provide several static access to the main methods to create, query,
manipulate and transform geometries
Operators
Queries
Transpositions
enlarge, transpose, rotate, reduce and other specific transposition (like triangulation,
squarification, etc.)
Punctal
v 1.8.0 1807
GAMA v1.8.0 documentation Chapter 164. Concepts
Type
IType: The main class to manipulate GamaType (main implementation of IType) is
Types, that provides access to most common type manipulated in Gama
Opérateur de cast:
Types.get(IType.class)
IScope interface
An object of type IScope represents the context of execution of an agent (including
experiments, simulations, and “regular” agents). Everywhere it is accessible (either
passed as a parameter or available as an instance variable in some objects), it provides
an easy access to a number of features: the current active agent, the shared random
number generator, the global clock, the current simulation and experiment agents,
the local variables declared in the current block, etc.
It also allows modifying this context, like changing values of local variables, adding
new variables, although these functions should be reserved to very specific usages. Or-
dinarily, the scope is simply passed to core methods that allow to evaluate expressions,
cast values, and so on.
Use of an IScope
A variable scope of type IScope can be used to: * get the current agent with:
scope.getAgentScope()
IAgent agent = scope.getAgentScope();
v 1.8.0 1808
GAMA v1.8.0 documentation Chapter 164. Concepts
Exception
Exceptions in GAMA
An exception that can appear in the GAMA platform can be run using the
GamaRuntimeException class. This class allows throwing an error (using error(
String,IScope) method) or a warning (using warning(String,IScope) method).
In particular, it can be useful to catch the Java Exception and to throw a GAMA
exception.
try {
...
} catch(Exception e) {
throw GamaRuntimeException.error("informative message", scope);
}
Debug
• To turn GAMA Git version to debug mode change variable of the Debug class
like: GLOBAL_OFF = false
Test
v 1.8.0 1809
GAMA v1.8.0 documentation Chapter 164. Concepts
test "Operator + (1)" {
assert (circle(5) + 5).height with_precision 1 = 20.0;
assert (circle(5) + 5).location with_precision 9 = (circle(10)).
location with_precision 9;
}
v 1.8.0 1810
Chapter 165
Packages
Core
The main plugin of the GAMA Platform that defines the core functionalities: most
Gaml operators, statements, skills, types, etc.
Metamodel
Ouputs
Util
1811
GAMA v1.8.0 documentation Chapter 165. Packages
GamaRND is the main class that implements Random java class. It has several
implementations and is mainly used with RandomUtils that define all the Gaml
random operators
2. Graph in Gama:
3. File in Gama:
Operators
The packages where you can find all the operators defined in the core of Gama
v 1.8.0 1812
Chapter 166
IScope interface
Use of an IScope
A variable scope of type IScope can be used to:
1813
GAMA v1.8.0 documentation Chapter 166. IScope interface
String mes = Cast.asString(scope, message.value(scope));
v 1.8.0 1814
Chapter 167
It is located at the root of the gama Git repository on your computer. The easiest way
to proceed is to select one of the GAMA projects in the Eclipse explorer and choose,
in the contextual menu, Show in > System Explorer. Then open a shell with this
path and cd ... Alternatively, you can open a shell and cd to your Git repository
and then inside gama.
Simply type ../build.sh in your terminal and the build should begin and log its
activity.
1815
GAMA v1.8.0 documentation Chapter 167. Product your own release of GAMA
• Place them anywhere in the commit message, i.e: " fix bug #1111 ci deploy ci
clean ci docs“,” update readme ci skip "
v 1.8.0 1816
GAMA v1.8.0 documentation Chapter 167. Product your own release of GAMA
Table of contents
• Requirements
– Configuration
– Generated files location
• Workflow to generate wiki files
• Workflow to generate PDF files
• Workflow to generate unit tests
• Main internal steps
– Generate wiki files
– Generate pdf files
– Generate unit test files
• How to document
– [The @doc annotation](#the-doc-annotation)
– [the @example annotation](#the-example-annotation)
– How to document operators
– How to document statements
– How to document skills
• How to change the processor
• General workflow of file generation
v 1.8.0 1817
GAMA v1.8.0 documentation Chapter 167. Product your own release of GAMA
v 1.8.0 1818
Chapter 168
Documentation
The GAMA documentation comes in 2 formats: a set of wiki files availaible from the
wiki section of the GitHub website and a PDF file. The PDF file is produced from
the wiki files.
In the wiki files, some are hand-written by the GAMA community and some others
are generated automatically from the Java code and the associated java annotations.
The section summarizes:
Requirements
To generate automatically the documentation, the GAMA Git version is required.
See Install Git version for more details.
Among all the GAMA plugins, the following ones are related to documentation
generation:
1819
GAMA v1.8.0 documentation Chapter 168. Documentation
java annotations. For each plugin it produces the docGAMA.xml file in the gaml
directory.
• msi.gama.documentation: it contains all the java classes needed to gather all
the docGAMA.xml files and generate wiki, pdf or unit test files.
In addition, the folder containing the wiki files is required. In the GitHub architecture,
the wiki documentation is stored in a separate Git repository https://github.com
/gama-platform/gama.wiki.git. A local clone of this repository should thus be
created:
3. In the Git perspective and the Git Repositories view, Right-Click on “Work-
ing Directory” inside the gama.wiki repository, and choose “Import projects”
v 1.8.0 1820
GAMA v1.8.0 documentation Chapter 168. Documentation
2. Go back to the Java perspective: a gama.wiki plugin should have been added.
In order to generate the PDF file from the wiki files, we use an external application
named Pandoc. Follow the Pandoc installation instructions to install it. Specify
the path to the pandoc folder in the file “Constants.java”, in the static constant
CMD_PANDOC : “yourAbsolutePathToPandoc/pandoc”.
Note that Latex should be installed in order to be able to generate PDF files. Make
sure you have already installed Miktex (for OS Windows and Mac). Specify the path
to the miktex folder in the file “Constants.java”, in the static constant CMD_PDFLATEX
: “yourAbsolutePathToMiktex/pdflatex”.
Configuration
The location where the files are generated (and other constants used by the generator)
are defined in the file msi.gama.documentation/src/msi/gama/doc/util/Constants
.java.
The use of Pandoc (path to the application and so on) is defined in the file msi.
gama.documentation/src/msi/gama/doc/util/ConvertToPDF.java. This should be
changed in the future. . .
v 1.8.0 1821
GAMA v1.8.0 documentation Chapter 168. Documentation
Note that generating the PDF takes a lot of time. Please be patient!
If you want to update the file “gama_style.sty” (for syntax coloration), you have to
turn the flag “generateGamaStyle” to “true” (and make sure the file “keywords.xml”
is already generated).
v 1.8.0 1822
GAMA v1.8.0 documentation Chapter 168. Documentation
– they prepare the gen folder by deleting the existing folders and create all
the folders that may contain intermediary generated folders
– they merge all the docGAMA.xml files in a docGAMAglobal.xml file, created
in the files/gen/java2xml folder. Only the plugins that are referred
in the product files are merged.
After these common main first steps, each generator (wiki, pdf or unit test) performs
specific tasks.
– operators,
– statements,
– skills,
– architectures,
– built-in species,
– constants and units.
– in addition an index wiki file containing all the GAML keywords is gener-
ated.
• One wiki file is generated for each extension plugin, i.e. plugin existing in the
Eclipse workspace but not referred in the product.
The pdf generator uses the table of content (toc) file located in the files/input/toc
folder (msi.gama.documetation plugin) to organize the wiki files in a pdf file.
v 1.8.0 1823
GAMA v1.8.0 documentation Chapter 168. Documentation
• MainGeneratePDF.java file parsers the toc file and create the associated PDF
file using the wiki files associated to each element of the toc. The generation is
tuned using files located in the files/input/pandocPDF folder.
How to document
The documentation is generate from the Java code thanks to the Java additional
processor, using mainly information from Java classes or methods and from the Java
annotations. (see the list of all annotations for more details about annotations).
v 1.8.0 1824
GAMA v1.8.0 documentation Chapter 168. Documentation
examples = {
@example(value = "[1,2,3,4,5,6] inter [2,4]", equals = "[2,4]"),
@example(value = "[1,2,3,4,5,6] inter [0,8]", equals = "[]") },
see = { "remove_duplicates" })
In this example:
v 1.8.0 1825
GAMA v1.8.0 documentation Chapter 168. Documentation
• isTestOnly = false, meaning that the example will be added to the documen-
tation too,
• isExecutable = true, meaning that content of value can be added in a model
and can be compiled (it can be useful to switch it to false, in a documentation
example containing name of species that have not been defined),
• test = true, meaning that the content of value will be tested to the content of
equals,
• isPattern = false.
v 1.8.0 1826
GAMA v1.8.0 documentation Chapter 168. Documentation
• @symbol annotation,
• @facets annotation (each facet can contain a documentation in a @doc annota-
tion),
• @inside annotation (where the statement can be used),
• @doc annotation
• @skill annotation,
• @vars annotation (each var can contain a documentation in a @doc annotation),
• @doc annotation
v 1.8.0 1827
GAMA v1.8.0 documentation Chapter 168. Documentation
v 1.8.0 1828
Chapter 169
1829
GAMA v1.8.0 documentation Chapter 169. General workflow of file generation
v 1.8.0 1830
Chapter 170
In this page, we will explain all about the convention we use to write and generate
the website content and the wiki content. Since the release of GAMA 1.7, with the
new GAMA website, we have two contents:
• The wiki content is hosted in github, witch directly interpret the markdown
format of the files to display them in a proper way. This wiki, since it is a wiki,
can be edited by any user. It is then, in constant changes.
• The website content is the content of the real GAMA website. It is a verified
and fixed version of the documentation (usually a re-generation of the website
content is done when there is a new release of the software)
Index
• Requirements
• gama.wiki tree structure
• Good practices when writing markdown files
– Title
– Hypertext Links
– Images Links
– Insert Metadatas
• Website Generation Workflow
1831
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
– Website Database
– Loading the Database
• Manage concepts keywords
Requirements
To generate automatically the documentation, the GAMA Git version is required.
See Install Git version for more details.
Among all the GAMA plugins, only one is related to documentation generation:
In addition, the folder containing the wiki files is required. In the GitHub architecture,
the wiki documentation is stored in a separate Git repository https://github.com
/gama-platform/gama.wiki.git. A local clone of this repository should thus be
created:
v 1.8.0 1832
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
∗ Choose the directory in which the gama Git repository has been cloned
∗ Everything else should be unchecked
∗ Finish
3. In the Git perspective and the Git Repositories view, Right-Click on “Work-
ing Directory” inside the gama.wiki repository, and choose “Import projects”
2. Go back to the Java perspective: a gama.wiki plugin should have been added.
• Tutorials
– LearnGAMLStepByStep: contains the linear documentation to learn about
the concepts of GAML
– Recipes: contains short pieces of documentation answering a specific
problematic
– Tutorials: contains applicative tutorials
• References
– ModelLibrary: contains the model library (only present in the website)
– PlatformDocumentation: contains the documentation dealing with how to
use the platform
– GAMLReferences: contains GAML references
v 1.8.0 1833
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
• Community
• WikiOnly: contains the content only present in the wiki, and not in the website
For the rest of this document, the highest level of tree structure (“Tutorial-
s”/“References”/“Community”/“WikiOnly”) will be named as tabs. The level just
under will be named as sections, and the level under will be named as sub-section.
All this content is written using the markdown format. All the images resources
are included in the resources/images folder. They are actually under different sub-
folders. From the markdown page, you can call the resource with the relative path
resource/images/sub_folder/image_name.png. If a section/sub-section contains
one of several sub-division, then those sub-divisions will be stored in a folder with the
name of the corresponding section/sub-section, and this section/sub-section folder
will be associated with a markdown file with the same name (indeed, a section/sub-
section has its own page). If a section/sub-section has no sub-division, then this
section/sub-section is simply defined with a markdown file containing the content
wanted.
Notice that there is some content which is present only in the wiki (the “WikiOnly”
content), some content present only in the website (the model library, most of the com-
munity content. . . ). In fact, the wiki tree structure is determined by the file _Sidebar,
while the website tree structure is determined by the file WebsiteTreeStructure.
v 1.8.0 1834
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
Title
Each markdown files has to start with a title in the markdown format (like # title).
This is this title which will be displayed in the tree structure of the website.
Hypertext Links
Even if the repository how have a more complexe tree structure, you don’t have to
(and you must not !) speficy the relative or absolute path to the target page, just
naming the page will work : [text_displayed](the_name_of_the_md_file)
Images Links
As already said in the previous paragraph, images have to be in an “resources/im-
ages/folder_name” folder next to your md file, so that you can write the relative
path more easily.
Insert Metadatas
Metadatas in content files are written as comments, with the following syntax:
[//]: # (name_of_the_medatada|value_of_the_metadata)
Medatadas are not displayed in the wiki and the website content. For the website
generation, metadatas are used in order to build the database, most of all to manage
the search engine, and the learning graph.
Here is the list of metadata we use in the content files:
• keyword : will write an invisible anchor in this exact place in the website.
When the user will do a research about this word, he can access directly to this
anchor.
• startConcept/endConcept : used to delimit a concept. The value of those
two metadatas is the name of the concept. All the concepts are listed in the file
“DependencyGraph”, in the content folder in your wiki repository.
v 1.8.0 1836
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
keyword
startConcept/endConcept
The value of the keyword have to be one of the values defined in the file learningCon-
cept.xml.
Notice that a concept in the meaning of keyword is not the same as a concept (or
learning concept) in the learning graph! Please read the part concerning the database
to learn more about it.
learningGraphDatabaseGenerator
v 1.8.0 1837
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
“learningGraph.xml” file as input. Each learning concepts has an id, a name, a very
short description, a position (position in x and y in %, between 0 and 1. This value
is then multiplied by the coeff in the learningGraphDatabaseGenerator), and a list
of prerequisite learning concepts. A category of learning concept (also defined in the
learningGraph.xml file) has an id, a position (position in x and y), a position for the
hallow (position in x and y of the big circle displayed when a category is selected), a
size for the hallow, a color, a name, and the list of learningConcept associated.
modelLibraryGenerator
• Parse all the models of the model library, and build an “input” xml file for a
headless execution (this file is deleted at the end of the execution).
– By default, this will ask to execute all the experiments for each model,
and take a screenshot of the 10th cycle for each display.
v 1.8.0 1838
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
TODO
• A copy of the content of the wiki repo (copy/pasted manually to freeze a specific
commit of the wiki)
v 1.8.0 1839
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
Website database
Keyword
A keyword is a keyword that can be used for search, either manually (the user enters
the wanted keyword in the searchbar of the website) or automatically (through the
search tab in the navigation panel) A keyword in attached with a category (among the
following names : concept, type, operator, statement, species, architecture, constant,
action, attribute, skill, facet).
v 1.8.0 1840
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
• A keyword that is a concept can be linked with other keywords (ex : the key-
word “BDI” will be linked with the keywords “eval_when”, “get_priority”. . . )
• A keyword that is a facet is linked to a statement or a species keyword (ex
: the keyword “torus” will be linked with the keyword “global”).
• A keyword that is an action or an attribute is linked either to a skill keyword
(if it is actually an action or an attribute of a skill), an architecture keyword
(if it is an action or a behavior of an architecture), or a species keyword (if it
is a built-in action or attribute).
• A keyword that is a statement can be linked to an architecture.
• id (unique id)
• name (the word which is searched by the user)
• idCategory (id of the category)
• id (unique id)
• name (the name of the category)
Alias
Another database is used to join an alias to an existing keyword. Ex: the word “alias”
will be changed as “die”.
An alias is composed of:
• id (unique id)
• name (name of the alias. ex : “kill”)
• attachedKeywordName (name of the keyword attached. ex : “die”)
Note that an alias does not know the id of the keyword, but only the name of the
attached keyword(s). Indeed, the alias “integer” will give the keyword name “int”,
but several keywords correspond to the keyword name “int” (it can be the type “int”,
or the cast operator “int”)
v 1.8.0 1841
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
v 1.8.0 1842
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
Webpage
A webpage can be either a page of the model library, a page of the gaml reference,
or an other page of the documentation.
A webpage is composed of:
• id (unique id)
• name (name of the webpage)
• webpageCategory (the name of the category of the webpage, a value among
modelPage, docPage, gamlRefPage_).
The tables webpage and keyword are linked through an association table. This
association table contains also an anchor (an anchor has a unique value) to the wanted
page.
Note that only the keywords which have the category concept, species, type, operator,
skill and constant can be attached to a webpage.
The keywords which have the category action, attribute and facet forward to the
attached keyword.
The keywords which have the category statement are attached to a webpage only if
they are not attached to another keyword. If they are attached to another keyword (an
architecture keyword), then the statement keyword forward to the attached keyword.
LearningConcept
• id (unique id)
• name (name of the learning concept)
v 1.8.0 1843
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
v 1.8.0 1844
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
v 1.8.0 1845
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
The file keyword.xml is an xml file that contains all the possible keywords (all
except some keywords written manually directly in the documentation pages). The
GAML words can be found directly using the code of GAMA. The concept words
can be found using the code of GAMA (thanks to the tag “category”) and also by
using the tags in the header of the model files. This xml file will be used to build the
Keyword and the AssociationKeywordCategory tables.
Format of the file:
<keyword id:keywordname_keywordcategory>
<name>keywordname</name>
<category>keywordcategory</category>
<associatedKeywordList>
<associatedKeyword>keywordId1</associatedKeyword>
<associatedKeyword>keywordId2</associatedKeyword>
</associatedKeywordList>
</keyword>
Note that:
• The list associatedKeywordList contains only one element for the facet key-
words, one of no element for the action or attribute keywords (none when the
v 1.8.0 1846
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
After the generation of the markdown content in the wiki repository, two other files
have to be built manually: the files alias.txt and learningConcept.xml.
The alias.txt file contains all the connexions between alias and keyword name. It
will be used to build the Alias table.
Format of the file :
aliasName1:remplacedWord1
aliasName2:remplacedWord2
kill:die
The learningConcept.xml file is used to list the learning concepts, and to connect
them to their prerequisite concepts. It will be used to build the LearningConcept
and the AssociationLearningConcept tables.
Format of the file :
<learningConcept id:learningConceptName>
<name>learningConceptName</name>
<prerequisiteList>
<prerequisite>learningConcept1</prerequisite>
<prerequisite>learningConcept2...</prerequisite>
</prerequisiteList>
</learningConcept>
Note that the value of the attribute “name” can be used as an unique id.
After copy-paste the content to the website folder, a script is used to build the
database and to generate website content.
v 1.8.0 1847
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
The markdown files are converted one by one into html format.
ALL the concepts must be declared in the “IConcept” java class. If you want
to add a new concept, please check before if your the concept you want to add
cannot be remplaced by one of the existing concept. If it is the case, you can add
your word as if it was an alias, pointing to the existing concept. Note that all
the alias are listed in the alias.txt file. If you realy think that the concept has
to be added, please add it to the IConcept file, and also to (one or several) of the
lists CONCEPTS_NOT_FOR_GAML_REF, CONCEPTS_NOT_FOR_MODEL_-
LIBRARY, CONCEPTS_DEDICATED_TO_SYNTAX in the ConceptManager class
if needed.
Most of the keywords of the website (used for the search) are managed automatically.
But the “concepts” keywords have to be (partially) hand-made managed. You can
add the concepts with 3 differents methods :
v 1.8.0 1848
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
In the Documentation
“Documentation” here designs all the content manually written in the wiki. All those
pages can contain “concepts” through the metadata format :
[//]: # (keyword|concept_name_of_concept)
You can either : - place those metadatas anywhere in the page if you want to point
directly in this part of the page if the user makes a search - place those metadatas
above the title : doing this, the “automatic search” (left navigation panel) will be
made with this concept. You have to be really sure this concept is the main concept
of the page to place it there.
Note that if you don’t want this model to have a page in the website, you can name
it starting with the character _.
Exemple :
v 1.8.0 1849
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
@operator(value = "flip",
concept = { IConcept.RANDOM }
v 1.8.0 1850
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
v 1.8.0 1851
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
v 1.8.0 1852
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
v 1.8.0 1853
GAMA v1.8.0 documentation Chapter 170. How to write the Website Content
v 1.8.0 1854
Part XIII
Scientific References
1855
Chapter 171
References
This page contains a subset of the scientific papers that have been written either
about GAMA or using the platform as an experimental/modeling support.
If you happen to publish a paper that uses or discusses GAMA, please let us know,
so that we can include it in this list.
As stated in the first page, if you need to cite GAMA in a paper, we kindly ask you
to use this reference:
1857
GAMA v1.8.0 documentation Chapter 171. References
• Chapuis, K., Taillandier, P., Renaud, M., Drogoul, A. (2018) "Gen*: a generic
toolkit to generate spatially explicit synthetic populations". International
Journal of Geographical Information Science 32 (6), 1194-1210
• Taillandier, Patrick, Arnaud Grignard, Benoit Gaudou, and Alexis Drogoul.
“Des données géographiques à la simulation à base d’agents: application de la
plate-forme GAMA.” Cybergeo: European Journal of Geography (2014).
• Grignard, A., Taillandier, P., Gaudou, B., Vo, D-A., Huynh, Q.N., Drogoul, A.
(2013) GAMA 1.6: Advancing the Art of Complex Agent-Based Modeling and
Simulation. In ‘PRIMA 2013: Principles and Practice of Multi-Agent Systems’,
Lecture Notes in Computer Science, Vol. 8291, Springer, pp. 117-131.
• Grignard, A., Drogoul, A., Zucker, J.D. (2013) Online analysis and visualization
of agent based models, Computational Science and Its Applications–ICCSA
2013. Springer Berlin Heidelberg, 2013. 662-672.
• Taillandier, P., Drogoul, A., Vo, D.A. and Amouroux, E. (2012) GAMA: a
simulation platform that integrates geographical information data, agent-based
modeling and multi-scale control, in ‘The 13th International Conference on
Principles and Practices in Multi-Agent Systems (PRIMA)’, India, Volume
7057/2012, pp 242-258.
• Taillandier, P., Drogoul, A. (2011) From Grid Environment to Geographic Vector
Agents, Modeling with the GAMA simulation platform. In ‘25th Conference of
the International Cartographic Association’, Paris, France.
• Taillandier, P., Drogoul A., Vo D.A., Amouroux, E. (2010) GAMA : bringing
GIS and multi-level capabilities to multi-agent simulation, in ‘the 8th European
Workshop on Multi-Agent Systems’, Paris, France.
• Amouroux, E., Taillandier, P. & Drogoul, A. (2010) Complex environment
representation in epidemiology ABM: application on H5N1 propagation. In ‘the
3rd International Conference on Theories and Applications of Computer Science’
(ICTACS’10).
• Amouroux, E., Chu, T.Q., Boucher, A. and Drogoul, A. (2007) GAMA: an
environment for implementing and running spatially explicit multi-agent simu-
lations. In ‘Pacific Rim International Workshop on Multi-Agents’, Bangkok,
Thailand, pp. 359–371.
HDR theses
• Patrick Taillandier, “Vers une meilleure intégration des dimensions spatiales,
comportementales et participatives en simulation à base d’agents”, University
v 1.8.0 1858
GAMA v1.8.0 documentation Chapter 171. References
PhD theses
• Mathieu Bourgais, “Vers des agents cognitifs, affectifs et sociaux dans la
simulation”, Normandie Université, defended November 30th, 2018.
• Huynh Quang Nghi, “CoModels, engineering dynamic compositions of cou-
pled models to support the simulation of complex systems”, University of Paris
6, defended December 5th, 2016.
• Truong Chi Quang, “Integrating cognitive models of human decision-
makingin agent-based models : an application to land useplanning under
climate change in the Mekong river delta”, University of Paris 6 & Can Tho
University, defended December 7th, 2016.
• Arnaud Grignard, “Modèles de visualisation à base d’agents”, University of
Paris 6, defended October 2nd, 2015.
• Truong Minh Thai, “To Develop a Database Management Tool for Multi-
Agent Simulation Platform”, ’Université Toulouse 1 Capitole, defended February
11th, 2015.
• Truong Xuan Viet, “Optimization by Simulation of an Environmental Surveil-
lance Network: Application to the Fight against Rice Pests in the Mekong Delta
(Vietnam)”, University of Paris 6 & Ho Chi Minh University of Technology,
defended June 24th, 2014.
• Nguyen Nhi Gia Vinh, “Designing multi-scale models to support environ-
mental decision: application to the control of Brown Plant Hopper invasions in
the Mekong Delta (Vietnam)”, University of Paris 6, defended Oct. 31st, 2013.
• Vo Duc An, “An operational architecture to handle multiple levels of repre-
sentation in agent-based models”, University of Paris 6, defended Nov. 30th
2012.
• Amouroux Edouard, “KIMONO: a descriptive agent-based modeling method-
ology for the exploration of complex systems: an application to epidemiology”,
University of Paris 6, defended Sept. 30th, 2011.
v 1.8.0 1859
GAMA v1.8.0 documentation Chapter 171. References
2019
• Adam, C., Taillandier, F.. Games ready to use: A serious game for teaching
natural risk management. Simulation and Gaming, SAGE Publications, 2018.
• Mancheva, L., Adam, C., & Dugdale, J., 2019. Multi-agent geospatial simulation
of human interactions and behaviour in bushfires. In International Conference
on Information Systems for Crisis Response and Management. In ISCRAM
2019 conference, Valencia, Spain.
• Daudé, E., Chapuis, K., Taillandier, P., Tranouez, P., Caron, C., Drogoul, A.,
Gaudou, B., Rey-Coyrehourq, S., Saval, A., Zucker, J. D., 2019. ESCAPE: Ex-
ploring by Simulation Cities Awareness on Population Evacuation. In ISCRAM
2019 conference, Valencia, Spain.
• Farias, G. P., Leitzke, B. S., Born, M. B., de Aguiar, M. S., Adamatti, D. F.,
2019. Modelagem Baseada em Agentes para Analise de Recursos Hidricos. In
the Workshop-School on Agents, Environments, and Applications (WESAAC),
Florianopolis – Santa Catarina (Brazil).
• Marrocco, L., Ferrer, E. C., Bucchiarone, A., Grignard, A., Alonso, L., Larson,
K., 2019. BASIC: Towards a Blockchained Agent-Based SImulator for Cities.
In International Workshop on Massively Multiagent Systems (pp. 144-162).
Springer, Cham.
• Ruiz-Chavez, Z., Salvador-Meneses, J., Mejía-Astudillo, C., Diaz-Quilachamin,
S., 2019. Analysis of Dogs’s Abandonment Problem Using Georeferenced
Multi-agent Systems. International Work-Conference on the Interplay Be-
tween Natural and Artificial Computation (pp. 297-306). Springer, Cham.
https://doi.org/10.1007/978-3-030-19651-6_29
v 1.8.0 1860
GAMA v1.8.0 documentation Chapter 171. References
• Rodrique, K., Tuong, H., Manh, N., 2019. An Agent-based Simulation for Study-
ing Air Pollution from Traffic in Urban Areas: The Case of Hanoi City. Int. J.
Adv. Comput. Sci. Appl. 10. https://doi.org/10.14569/IJACSA.2019.0100376
• Micolier, A., Taillandier, F., Taillandier, P., Bos, F., 2019. Li-BIM, an
agent-based approach to simulate occupant-building interaction from the
Building-Information Modelling. Eng. Appl. Artif. Intell. 82, 44–59. http-
s://doi.org/10.1016/j.engappai.2019.03.008
• Houssou, N.L.J., Cordero, J.D., Bouadjio-Boulic, A., Morin, L., Maestripieri,
N., Ferrant, S., Belem, M., Pelaez Sanchez, J.I., Saenz, M., Lerigoleur, E., Elger,
A., Gaudou, B., Maurice, L., Saqalli, M., 2019. Synchronizing Histories of
Exposure and Demography: The Construction of an Agent-Based Model of the
Ecuadorian Amazon Colonization and Exposure to Oil Pollution Hazards. J.
Artif. Soc. Soc. Simul. 22, 1. https://doi.org/10.18564/jasss.3957
• Knapps, V., Zimmermann, K.-H., 2019. Distributed Monitoring of Topological
Events via Homology. ArXiv190104146 Cs Math.
• Galimberti, A., Alyokhin, A., Qu, H., Rose, J., 2019. Simulation modelling
of Potato virus Y spread in relation to initial inoculum and vector activity.
Journal of Integrative Agriculture
2018
• Marilleau, N., Lang, C., Giraudoux, P., 2018. Coupling agent-based with
equation-based models to study spatially explicit megapopulation dynamics.
Ecol. Model. 384, 34–42. https://doi.org/10.1016/j.ecolmodel.2018.06.011
• Alfeo, A.L., Ferrer, E.C., Carrillo, Y.L., Grignard, A., Pastor, L.A., Sleeper,
D.T., Cimino, M.G.C.A., Lepri, B., Vaglini, G., Larson, K., Dorigo, M., Pent-
land, A. ‘Sandy’, 2018. Urban Swarms: A new approach for autonomous waste
management. ArXiv181007910 Cs.
• Qu, H., Drummond, F., 2018. Simulation-based modeling of wild blue-
berry pollination. Comput. Electron. Agric. 144, 94–101. http-
s://doi.org/10.1016/j.compag.2017.11.003
• Shaham, Y., Benenson, I., 2018. Modeling fire spread in cities with non-
flammable construction. Int. J. Disaster Risk Reduct. 31, 1337–1353. http-
s://doi.org/10.1016/j.ijdrr.2018.03.010
• Mewes, B., Schumann, A.H., 2018. IPA (v1): a framework for agent-based
modelling of soil water movement. Geosci. Model Dev. 11, 2175–2187.
https://doi.org/10.5194/gmd-11-2175-2018
v 1.8.0 1861
GAMA v1.8.0 documentation Chapter 171. References
• Grignard, A., Macià, N., Alonso Pastor, L., Noyman, A., Zhang, Y., Larson,
K., 2018. CityScope Andorra: A Multi-level Interactive and Tangible Agent-
based Visualization, in: Proceedings of the 17th International Conference on
Autonomous Agents and MultiAgent Systems, AAMAS ’18. International
Foundation for Autonomous Agents and Multiagent Systems, Richland, SC,
pp. 1939–1940.
• Zhang, Y., Grignard, A., Lyons, K., Aubuchon, A., Larson, K., 2018. Real-time
Machine Learning Prediction of an Agent-Based Model for Urban Decision-
making (Extended Abstract) 3.
• Bandyopadhyay, M., Singh, V., 2018. Agent-based geosimulation for as-
sessment of urban emergency response plans. Arab. J. Geosci. 11, 165.
https://doi.org/10.1007/s12517-018-3523-5
• Samad, T., Iqbal, S., Malik, A.W., Arif, O., Bloodsworth, P., 2018.
A multi-agent framework for cloud-based management of collaborative
robots. Int. J. Adv. Robot. Syst. 15, 172988141878507. http-
s://doi.org/10.1177/1729881418785073
• Humann, J., Spero, E., 2018. Modeling and simulation of multi-UAV, multi-
operator surveillance systems, in: 2018 Annual IEEE International Systems
Conference (SysCon). Presented at the 2018 Annual IEEE International Systems
Conference (SysCon), pp. 1–8. https://doi.org/10.1109/SYSCON.2018.8369546
• Mazzoli, M., Re, T., Bertilone, R., Maggiora, M., Pellegrino, J., 2018. Agent
Based Rumor Spreading in a scale-free network. ArXiv180505999 Cs.
• Grignard, A., Alonso, L., Taillandier, P., Gaudou, B., Nguyen-Huu, T., Gruel,
W., Larson, K., 2018a. The Impact of New Mobility Modes on a City: A Generic
Approach Using ABM, in: Morales, A.J., Gershenson, C., Braha, D., Minai,
A.A., Bar-Yam, Y. (Eds.), Unifying Themes in Complex Systems IX, Springer
Proceedings in Complexity. Springer International Publishing, pp. 272–280.
• Touhbi, S., Babram, M.A., Nguyen-Huu, T., Marilleau, N., Hbid, M.L.,
Cambier, C., Stinckwich, S., 2018. Time Headway analysis on urban road-
s of the city of Marrakesh. Procedia Comput. Sci. 130, 111–118. http-
s://doi.org/10.1016/j.procs.2018.04.019
• Laatabi, A., Marilleau, N., Nguyen-Huu, T., Hbid, H., Ait Babram, M., 2018.
ODD+2D: An ODD Based Protocol for Mapping Data to Empirical ABMs. J.
Artif. Soc. Soc. Simul. 21, 9. https://doi.org/10.18564/jasss.3646
• Chapuis K., Taillandier P., Gaudou B., Drogoul A., Daudé E. (2018) A Multi-
modal Urban Traffic Agent-Based Framework to Study Individual Response to
Catastrophic Events. In: Miller T., Oren N., Sakurai Y., Noda I., Savarimuthu
B., Cao Son T. (eds) PRIMA 2018: Principles and Practice of Multi-Agent
v 1.8.0 1862
GAMA v1.8.0 documentation Chapter 171. References
Systems. PRIMA 2018. Lecture Notes in Computer Science, vol 11224. Springer,
Cham
• Bourgais, M., Taillandier, P., Vercouter, L., Adam, C., 2018. Emotion Modeling
in Social Simulation: A Survey. J. Artif. Soc. Soc. Simul. 21, 5.
• Grillot, M., Guerrin, F., Gaudou, B., Masse, D., Vayssières, J., 2018. Multi-
level analysis of nutrient cycling within agro-sylvo-pastoral landscapes in West
Africa using an agent-based model. Environ. Model. Softw. 107, 267–280.
https://doi.org/10.1016/j.envsoft.2018.05.003
• Valette, M., Gaudou, B., Longin, D., Taillandier, P., 2018. Modeling a Real-
Case Situation of Egress Using BDI Agents with Emotions and Social Skills, in:
Miller, T., Oren, N., Sakurai, Y., Noda, I., Savarimuthu, B.T.R., Cao Son, T.
(Eds.), PRIMA 2018: Principles and Practice of Multi-Agent Systems. Springer
International Publishing, Cham, pp. 3–18. https://doi.org/10.1007/978-3-030-
03098-8_1
• Humann, J., Spero, E. (2018) Modeling and Simulation of multi-UAV, multi-
Operator Surveillance Systems, 2018 Annual IEEE International Systems Con-
ference (SysCon), Vancouver, BC.
• Lammoglia, A., Leturcq, S., Delay, E., 2018. Le modèle VitiTerroir pour
simuler la dynamique spatiale des vignobles sur le temps long (1836-2014).
Exemple d’application au département d’Indre-et-Loire. Cybergeo Eur. J.
Geogr. https://doi.org/10.4000/cybergeo.29324
• Amores, D., Vasardani, M., Tanin, E., 2018. Early Detection of
Herding Behaviour during Emergency Evacuations 15 pages. http-
s://doi.org/10.4230/lipics.giscience.2018.1
• Rakotoarisoa, M.M., Fleurant, C., Taibi, A.N., Rouan, M., Caillault, S.,
Razakamanana, T., Ballouche, A., 2018. Un modèle multi-agents pour é-
valuer la vulnérabilité aux inondations : le cas des villages aux alentours
du Fleuve Fiherenana (Madagascar). Cybergeo Eur. J. Geogr. http-
s://doi.org/10.4000/cybergeo.29144
2017
• Cura, R., Tannier, C., Leturcq, S., Zadora-Rio, E., Lorans, E., & Rodi-
er, X. (2017). Transition 8: 800-1100. Fixation, polarisation et hiérar-
chisation de l’habitat rural en Europe du Nord-Ouest (chap. 11). (http-
s://simfeodal.github.io/)
• Becu, N., Amalric, M., Anselme, B., Beck, E., Bertin, X., Delay, E., Long,
v 1.8.0 1863
GAMA v1.8.0 documentation Chapter 171. References
v 1.8.0 1864
GAMA v1.8.0 documentation Chapter 171. References
2016
• Fosset, P., Banos, A., Beck, E., Chardonnel, S., Lang, C., Marilleau, N.,
Piombini, A., Leysens, T., Conesa, A., Andre-Poyaud, I., Thevenin, T.,
2016. Exploring Intra-Urban Accessibility and Impacts of Pollution Policies
with an Agent-Based Simulation Platform: GaMiroD. Systems 4, 5. http-
s://doi.org/10.3390/systems4010005
• Grignard, A., Fantino, G., Lauer, J.W., Verpeaux, A., Drogoul, A., 2016. Agent-
Based Visualization: A Simulation Tool for the Analysis of River Morphosed-
imentary Adjustments, in: Gaudou, B., Sichman, J.S. (Eds.), Multi-Agent
Based Simulation XVI. Springer International Publishing, Cham, pp. 109–120.
https://doi.org/10.1007/978-3-319-31447-1_7
• Lucien, L., Lang, C., Marilleau, N., Philippe, L., 2016. Multiagent Hy-
brid Architecture for Collaborative Exchanges between Communicating Ve-
hicles in an Urban Context. Procedia Comput. Sci. 83, 695–699. http-
s://doi.org/10.1016/j.procs.2016.04.154
• Laatabi, A., Marilleau, N., Nguyen-Huu, T., Hbid, H., Babram, M.A., 2016.
Formalizing Data to Agent Model Mapping Using MOF: Application to a Mod-
el of Residential Mobility in Marrakesh, in: Jezic, G., Chen-Burger, Y.-H.J.,
Howlett, R.J., Jain, L.C. (Eds.), Agent and Multi-Agent Systems: Technolo-
gy and Applications. Springer International Publishing, Cham, pp. 107–117.
https://doi.org/10.1007/978-3-319-39883-9_9
• Taillandier, P., Banos, A., Drogoul, A., Gaudou, B., Marilleau, N., Truong, Q.C.
(2016) Simulating Urban Growth with Raster and Vector models: A case study
for the city of Can Tho, Vietnam, in: Osman, N., Sierra, C. (Eds.), Autonomous
Agents and Multiagent Systems, Lecture Notes in Computer Science. Springer
International Publishing, pp. 154–171. Doi: 10.1007/978-3-319-46840-2_10.
• Nghi, H.Q, Nguyen-Huu, T., Grignard, A., Huynh, X.H., Drogoul, A. (2016) To-
ward an Agent-Based and Equation-Based Coupling Framework. International
Conference on Nature of Computation and Communication, 311-324
• Bhamidipati, S., van der Lei, T., & Herder, P. (2016) A layered approach to
model interconnected infrastructure and its significance for asset management.
EJTIR, 16(1), 254-272.
• Drogoul A., Huynh N.Q. and Truong Q.C. (2016) Coupling environmental,
v 1.8.0 1865
GAMA v1.8.0 documentation Chapter 171. References
2015
• Gasmi, N., Grignard, A., Drogoul, A., Gaudou, B., Taillandier, P., Tessier, O.,
An, V.D., 2015. Reproducing and Exploring Past Events Using Agent-Based
Geo-Historical Models, in: Grimaldo, F., Norling, E. (Eds.), Multi-Agent-Based
Simulation XV. Springer International Publishing, Cham, pp. 151–163.
• Le, V.-M., Chevaleyre, Y., Ho Tuong Vinh, Zucker, J.-D., 2015. Hybrid of
v 1.8.0 1866
GAMA v1.8.0 documentation Chapter 171. References
2014
v 1.8.0 1867
GAMA v1.8.0 documentation Chapter 171. References
in: Hanachi, C., Bénaben, F., Charoy, F. (Eds.), Information Systems for Crisis
Response and Management in Mediterranean Countries. Springer International
Publishing, Cham, pp. 21–31. https://doi.org/10.1007/978-3-319-11818-5_3
• Emery, J., Marilleau, N., Thévenin, T., Martiny, N., 2014. Du comptage
ponctuel à l’affectation par simulation multi-agents : application à la circulation
routière de la ville de Dijon, in: Conférence Internationale de Géomatique et
d’analyse Spatiale (SAGEO). Grenoble, France, p. CD-ROM.
2013
• Drogoul, A., Gaudou, B., Grignard, A., Taillandier, P., & Vo, D. A. (2013).
Practical Approach To Agent-Based Modelling. In: Water and its Many Issues.
Methods and Cross-cutting Analysis. Stéphane Lagrée (Eds.), Journées de Tam
Dao, p. 277-300, Regional Social Sciences Summer University.
• Drogoul, A., Gaudou, B. (2013) Methods for Agent-Based Computer Modelling.
In: Water and its Many Issues. Methods and Cross-cutting Analysis. Stéphane
Lagrée (Eds.), Journées de Tam Dao, 1.6, p. 130-154, Regional Social Sciences
Summer University.
• Truong, M.-T., Amblard, F., Gaudou, B., Sibertin-Blanc, C., Truong, V. X.,
Drogoul, A., Hyunh, X. H., Le, M. N. (2013). An implementation of framework
of business intelligence for agent-based simulation. In: Symposium on Infor-
mation and Communication Technology (SoICT 2013), Da Nang, Viet Nam,
05/12/2013-06/12/2013, Quyet Thang Huynh, Thanh Binh Nguyen, Van Tien
Do, Marc Bui, Hong Son Ngo (Eds.), ACM, p. 35-44.
• Le, V. M., Gaudou, B., Taillandier, P., Vo, D. A (2013). A New BDI Architecture
To Formalize Cognitive Agent Behaviors Into Simulations. In: Advanced
Methods and Technologies for Agent and Multi-Agent Systems (KES-AMSTA
2013), Hue, Vietnam, 27/05/2013-29/05/2013, Vol. 252, Dariusz Barbucha,
Manh Thanh Le, Robert J. Howlett, C. Jain Lakhmi (Eds.), IOS Press, Frontiers
in Artificial Intelligence and Applications, p. 395-403.
• Emery, J., Boyard-Micheau, J., Marilleau, N., Martiny, N., Thévenin, T., 2013.
Exploitation of traffic counting data for traffic study in urban areas: from traffic
assignment to simulation model validation, in: 18th European Colloquium in
Theoretical and Quantitative Geography (ECTQG). Dourdan, France.
• Banos, A., Marilleau, N., 2013. Improving Individual Accessibility to the City,
in: Gilbert, T., Kirkilionis, M., Nicolis, G. (Eds.), Proceedings of the European
Conference on Complex Systems 2012, Springer Proceedings in Complexity.
v 1.8.0 1868
GAMA v1.8.0 documentation Chapter 171. References
2012
• Taillandier, P., Therond, O., Gaudou B. (2012), A new BDI agent architecture
based on the belief theory. Application to the modelling of cropping plan
decision-making. In ‘International Environmental Modelling and Software
Society’, Germany, pp. 107-116.
• NGUYEN, Q.T., BOUJU, A., ESTRAILLIER, P. (2012) Multi-agent architec-
ture with space-time components for the simulation of urban transportation
systems.
• Cisse, A., Bah, A., Drogoul, A., Cisse, A.T., Ndione, J.A., Kebe, C.M.F. &
Taillandier P. (2012), Un modèle à base d’agents sur la transmission et la
diffusion de la fièvre de la Vallée du Rift à Barkédji (Ferlo, Sénégal), Studia
Informatica Universalis 10 (1), pp. 77-97.
• Taillandier, P., Amouroux, E., Vo, D.A. and Olteanu-Raimond A.M. (2012), Us-
ing Belief Theory to formalize the agent behavior: application to the simulation
of avian flu propagation. In ‘The first Pacific Rim workshop on Agent-based
modeling and simulation of Complex Systems (PRACSYS)’, India, Volume
7057/2012, pp. 575-587.
• Le, V.M., Adam, C., Canal, R., Gaudou, B., Ho, T.V. and Taillandier, P. (2012),
Simulation of the emotion dynamics in a group of agents in an evacuation
situation. In ‘The first Pacific Rim workshop on Agent-based modeling and
simulation of Complex Systems (PRACSYS)’, India, Volume 7057/2012, pp. 604-
619.
• Nguyen Vu, Q. A., Canal, R., Gaudou, B., Hassas, S., Armetta, F. (2012),
TrustSets - Using trust to detect deceitful agents in a distributed informa-
tion collecting system. In: Journal of Ambient Intelligence and Humanized
Computing, Springer-Verlag, Vol. 3 N. 4, p. 251-263.
2011
• Taillandier, P., Therond, O. (2011), Use of the Belief Theory to formalize Agent
Decision Making Processes : Application to cropping Plan Decision Making. In
’25th European Simulation and Modelling Conference’, Guimaraes, Portugal,
pp. 138-142.
v 1.8.0 1869
GAMA v1.8.0 documentation Chapter 171. References
2010
• Nguyen Vu, Q.A. , Gaudou, B., Canal, R., Hassas, S. and Armetta, F. (2010),
A cluster-based approach for disturbed, spatialized, distributed information
gathering systems, in ‘The first Pacific Rim workshop on Agent-based modeling
and simulation of Complex Systems (PRACSYS)’, India, pp. 588-603.
• Nguyen, N.D., Taillandier, P., Drogoul, A. and Augier, P. (2010), Inferring
Equation-Based Models from Agent-Based Models: A Case Study in Competi-
tion Dynamics.In ‘The 13th International Conference on Principles and Practices
in Multi-Agent Systems (PRIMA)’, India, Volume 7057/2012, pp. 413-427.
• Amouroux, E., Gaudou, B. Desvaux, S. and Drogoul, A. (2010), O.D.D.: a
Promising but Incomplete Formalism For Individual-Based Model Specifica-
tion. in ‘IEEE International Conference on Computing and Telecommunication
Technologies’(2010 IEEE RIVF’), pp. 1-4.
• Nguyen, N.D., Phan, T.H.D., Nguyen, T.N.A., Drogoul, A., Zucker, J-D. (2010),
Disk Graph-Based Model for Competition Dynamic, in ‘IEEE International
Conference on Computing and Telecommunication Technologies’(2010 IEEE
RIVF’).
• Nguyen, T.K., Marilleau, N., Ho T.V., El Fallah Seghrouchni, A. (2010), A
meta-model for specifying collaborative simulation, Paper to appear in ‘IEEE
International Conference on Computing and Telecommunication Technolo-
gies’(2010 IEEE RIVF’).
• Nguyen Vu, Q.A. , Gaudou, B., Canal, R., Hassas, S. and Armetta, F. (2010),
TrustSets - Using trust to detect deceitful agents in a distributed informa-
tion collecting system, Paper to appear in ‘IEEE International Conference on
Computing and Telecommunication Technologies’(2010 IEEE RIVF’), the best
student paper award.
• Nguyen Vu, Q.A. , Gaudou, B., Canal, R., Hassas, S., Armetta, F. and Stinck-
wich, S. (2010), Using trust and cluster organisation to improve robot swarm
v 1.8.0 1870
GAMA v1.8.0 documentation Chapter 171. References
2009
• Taillandier, P. and Buard, E. (2009), Designing Agent Behaviour in Agent-
Based Simulation through participatory method. In ‘The 12th International
Conference on Principles and Practices in Multi-Agent Systems (PRIMA)’,
Nagoya, Japan, pp. 571–578.
• Taillandier, P. and Chu, T.Q. (2009), Using Participatory Paradigm to Learn
Human Behaviour. In ‘International Conference on Knowledge and Systems
Engineering’, Ha noi, Viet Nam, pp. 55–60.
• Gaudou, B., Ho, T.V. and Marilleau, N. (2009), Introduce collaboration in
methodologies of modeling and simulation of Complex Systems. In ‘International
Conference on Intelligent Networking and Collaborative Systems (INCOS ’09)’.
Barcelona, pp. 1–8.
• Nguyen, T.K., Gaudou B., Ho T.V. and Marilleau N. (2009), Application of
PAMS Collaboration Platform to Simulation-Based Researches in Soil Science:
The Case of the MIcro-ORganism Project. In ‘IEEE International Conference
on Computing and Telecommunication Technologies (IEEE-RIVF 09)’. Da
Nang, Viet Nam, pp. 296–303.
• Nguyen, V.Q., Gaudou B., Canal R., Hassas S. and Armetta F. (2009), S-
tratégie de communication dans un système de collecte d’information à base
d’agents perturbés. In ‘Journées Francophones sur les Systèmes Multi-Agents
(JFSMA’09)’.
2008
• Chu, T.Q., Boucher, A., Drogoul, A., Vo, D.A., Nguyen, H.P. and Zucker,
J.D. (2008). Interactive Learning of Expert Criteria for Rescue Simulations.
In Pacific Rim International Workshop on Multi-Agents, Ha Noi, Viet Nam,
pp. 127–138.
• Amouroux, E., Desvaux, S. and Drogoul, A. (2008), Towards Virtual Epi-
demiology: An Agent-Based Approach to the Modeling of H5N1 Propagation
and Persistence in North-Vietnam. In Pacific Rim International Workshop on
Multi-Agents, Ha Noi, Viet Nam, pp. 26–33.
v 1.8.0 1871
GAMA v1.8.0 documentation Chapter 171. References
v 1.8.0 1872
Part XIV
1873
Chapter 172
Projects
References
This page contains a subset of the scientific papers that have been written either
about GAMA or using the platform as an experimental/modeling support.
If you happen to publish a paper that uses or discusses GAMA, please let us know,
so that we can include it in this list.
If you need to cite GAMA in a paper, we kindly ask you to use this reference:
1875
GAMA v1.8.0 documentation Chapter 172. Projects
Systems’, Lecture Notes in Computer Science, Vol. 8291, Springer, pp. 117-
131.
– Grignard, Arnaud, Alexis Drogoul, and Jean-Daniel Zucker. “Online
analysis and visualization of agent-based models.” Computational Science
and Its Applications–ICCSA 2013. Springer Berlin Heidelberg, 2013. 662-
672.
– Taillandier, P., Drogoul, A., Vo, D.A. and Amouroux, E. (2012), GAMA: a
simulation platform that integrates geographical information data, agent-
based modeling and multi-scale control. In ‘The 13th International Con-
ference on Principles and Practices in Multi-Agent Systems (PRIMA)’,
India, Volume 7057/2012, pp 242-258.
– Taillandier, P. & Drogoul, A. (2011), From Grid Environment to Geo-
graphic Vector Agents, Modeling with the GAMA simulation platform.
In ‘25th Conference of the International Cartographic Association’, Paris,
France.
– Taillandier, P. ; Drogoul A. ; Vo D.A. & Amouroux, E. (2010), GAMA :
bringing GIS and multi-level capabilities to multi-agent simulation, in ‘the
8th European Workshop on Multi-Agent Systems’, Paris, France.
– Amouroux, E., Taillandier, P. & Drogoul, A. (2010), Complex environment
representation in epidemiology ABM: application on H5N1 propagation.
In ‘the 3rd International Conference on Theories and Applications of
Computer Science’ (ICTACS’10).
– Amouroux, E., Chu, T.Q., Boucher, A. and Drogoul, A. (2007), GAMA: an
environment for implementing and running spatially explicit multi-agent
simulations. In ‘Pacific Rim International Workshop on Multi-Agents’,
Bangkoku, Thailand, pp. 359–371.
PhD theses
• Truong Xuan Viet, “Optimization by Simulation of an Environmental Surveil-
lance Network: Application to the Fight against Rice Pests in the Mekong Delta
(Vietnam)”, University of Paris 6 & Ho Chi Minh University of Technology,
defended June 24th, 2014.
v 1.8.0 1876
GAMA v1.8.0 documentation Chapter 172. Projects
2014
v 1.8.0 1877
GAMA v1.8.0 documentation Chapter 172. Projects
Y., Lardy, R., Louail, T., Mayor, E., Panzoli, D., Sauvage, S., Sanchez-
Perez, J., Taillandier, P., Nguyen, V. B., Vavasseur, M., Mazzega, P. (2014).
The MAELIA multi-agent platform for integrated assessment of low-water
management issues. In: International Workshop on Multi-Agent-Based
Simulation (MABS 2013), Saint-Paul, MN, USA, 06/05/2013-07/05/2013,
Vol. 8235, Shah Jamal Alam, H. Van Dyke Parunak, (Eds.), Springer,
Lecture Notes in Computer Science, p. 85-110.
– Gaudou, B., Lorini, E., Mayor, E. (2014.) Moral Guilt: An Agent-Based
Model Analysis. In: Conference of the European Social Simulation Associ-
ation (ESSA 2013), Warsaw, 16/09/2013-20/09/2013, Vol. 229, Springer,
Advances in Intelligent Systems and Computing, p. 95-106.
2013
• Drogoul, A., Gaudou, B., Grignard, A., Taillandier, P., & Vo, D. A. (2013).
Practical Approach To Agent-Based Modelling. In: Water and its Many Issues.
Methods and Cross-cutting Analysis. Stéphane Lagrée (Eds.), Journées de Tam
Dao, p. 277-300, Regional Social Sciences Summer University.
v 1.8.0 1878
GAMA v1.8.0 documentation Chapter 172. Projects
2012
• Taillandier, P., Therond, O., Gaudou B. (2012), A new BDI agent architecture
based on the belief theory. Application to the modelling of cropping plan
decision-making. In ‘International Environmental Modelling and Software
Society’, Germany, pp. 107-116.
2011
v 1.8.0 1879
GAMA v1.8.0 documentation Chapter 172. Projects
2010
• Nguyen Vu, Q.A. , Gaudou, B., Canal, R., Hassas, S. and Armetta, F. (2010),
A cluster-based approach for disturbed, spatialized, distributed information
gathering systems, in ‘The first Pacific Rim workshop on Agent-based modeling
and simulation of Complex Systems (PRACSYS)’, India, pp. 588-603.
v 1.8.0 1880
GAMA v1.8.0 documentation Chapter 172. Projects
– Nguyen Vu, Q.A. , Gaudou, B., Canal, R., Hassas, S. and Armetta, F.
(2010), TrustSets - Using trust to detect deceitful agents in a distributed
information collecting system, Paper to appear in ‘IEEE International
Conference on Computing and Telecommunication Technologies’(2010
IEEE RIVF’), the best student paper award.
– Nguyen Vu, Q.A. , Gaudou, B., Canal, R., Hassas, S., Armetta, F. and
Stinckwich, S. (2010), Using trust and cluster organisation to improve
robot swarm mapping, Paper to appear in ‘Workshop on Robots and
Sensors integration in future rescue INformation system’ (ROSIN 2010).
2009
2008
v 1.8.0 1881
GAMA v1.8.0 documentation Chapter 172. Projects
• Chu, T.Q., Boucher, A., Drogoul, A., Vo, D.A., Nguyen, H.P. and Zucker,
J.D. (2008). Interactive Learning of Expert Criteria for Rescue Simulations.
In ‘Pacific Rim International Workshop on Multi-Agents’, Ha Noi, Viet Nam,
pp. 127–138.
v 1.8.0 1882
Part XV
Training Session
1883
Chapter 173
Training Session
1885
GAMA v1.8.0 documentation Chapter 173. Training Session
v 1.8.0 1886
GAMA v1.8.0 documentation Chapter 173. Training Session
Trainers: Drogoul Alexis, Gaudou Benoit, Trung Quang, Philippon Damien, Mazars
Julien.
v 1.8.0 1887
GAMA v1.8.0 documentation Chapter 173. Training Session
development. For this 7th JTD, the topic was about the perception and management
of risks, and a workshop has been made especially about how to use tools as GAMA
to build models in order to understand past crises to better understand the present.
Trainers: Alexis Drogoul, Benoit Gaudou, Nasser Gasmi, Arnaud Grignard, Patrick
Taillandier, Olivier Tessier, Vo Duc An
Here is the link to download the pdf report of the JTD 2013: http-
s://drive.google.com/file/d/0B2Go6pohIhQcNXFwVllHd2pFdlk/view.
v 1.8.0 1888
Chapter 174
Introduction
1889
GAMA v1.8.0 documentation Chapter 174. Introduction
v 1.8.0 1890
Part XVI
Events
1891
Chapter 175
References
1893
GAMA v1.8.0 documentation Chapter 175. References
v 1.8.0 1894
Part XVII
Older versions
1895
Chapter 176
Versions of GAMA
GAMA exists since 2007 and has undergone a number of changes since its first release,
materialized by different versions of the platform. Although we do not maintain
these versions anymore, some are still used in lectures or specific projects. This page
provides a list of these versions and, for each of them, a summary of its features and
a link to its documentation in PDF format.
1897
GAMA v1.8.0 documentation Chapter 176. Versions of GAMA
v 1.8.0 1898
GAMA v1.8.0 documentation Chapter 176. Versions of GAMA
v 1.8.0 1899
GAMA v1.8.0 documentation Chapter 176. Versions of GAMA
Documentation:
• Documentation in PDF
v 1.8.0 1900
GAMA v1.8.0 documentation Chapter 176. Versions of GAMA
v 1.8.0 1901
GAMA v1.8.0 documentation Chapter 176. Versions of GAMA
Documentation:
• Documentation in PDF
Documentation:
• Documentation in PDF
v 1.8.0 1902
GAMA v1.8.0 documentation Chapter 176. Versions of GAMA
v 1.8.0 1903
GAMA v1.8.0 documentation Chapter 176. Versions of GAMA
v 1.8.0 1904
GAMA v1.8.0 documentation Chapter 176. Versions of GAMA
Documentation:
• Documentation in PDF
v 1.8.0 1905
GAMA v1.8.0 documentation Chapter 176. Versions of GAMA
Documentation:
• Documentation in PDF
v 1.8.0 1906
GAMA v1.8.0 documentation Chapter 176. Versions of GAMA
Documentation:
v 1.8.0 1907
GAMA v1.8.0 documentation Chapter 176. Versions of GAMA
v 1.8.0 1908