Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms
26, 27 & 28 oct. 2009, Hanoi, Vietnam
An introduction to GAMA
Alexis Drogoul, IRD
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 2
Background
• Work on GAMA began late 2006, as a framework (meta-model on top of Repast J) able to
support the requirements of 3 research projects (avian flu propagation, by E. Amouroux,
urban emergencies, by Q. Chu Thanh and household daily activities, by F. Sempé)
• The idea of translating the concepts shared by these projects into computational
abstractions manipulated by a script language gained momentum, and GAML was officially
born in mid-2007. A. Vo Duc joined the team to port it onto the Eclipse RCP environment.
• In 2008, GAMA began to be used as a training tool for the IFI Master students. The addition
of batch controllers and several developments targeting its usability, stability and
performances achieved to transform it into a more versatile platform.
• In 2009, it was released as an open-source project and used for the Master lectures at the
Univ. of Can Tho. Since then, with the help of P. Taillandier, work has begun on its second
incarnation (GAMAv2). Two new projects running on top of GAMA (strategies against rice
pests) have been launched in 2009.
• GAMA is now both a simulation environment, which we use in 6 projects, a pedagogical
tool, used in our master lectures, and the object of ongoing researches, notably on
modeling languages for describing emergent phenomena.
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 3
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 4
Internal architecture
GAML
Compiler Language
• Explicit meta-model to guide ANTLR grammar
Plug-in architecture
Based on the meta-model
Extensible at runtime
development of DSLs
Kernel
• Advanced support for simulation/ Simulation
Environments
GIS, continuous,
experimentation/visualization Scheduler, inputs, outputs
grids, networks
(controllers)
Eclipse RCP Repast OpenMap
Java libraries
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 5
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 6
UI Controller
• Based on Eclipse RCP and used for designing models
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 7
Batch Controller
Sequential batch
• Allows to explore the parameters space of <batch
type="sequence"
models by running simulations and controlling sameSeed="true"
repeat="3"
stopSimWhen="food = 0"
their input parameters and outcomes. >
<param
name="evaporation_rate"
Exploratory batch
Ⴡ Exploratory: optimization techniques are used <batch
to find “interesting” sets of parameters that type="optimize"
sameSeed="true"
repeat="3"
produce the desired result. stopSimWhen="time > 200"
>
<param
◦ Simulated annealing name="evaporation_rate"
min="0.05"
max="0.7"
◦ Ant Colony Metaheuristic step="0.01"
/>
<optimize minimize="foodLeft"/>
</batch>
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam
Metamodel
manages >
defines >
* * *
Control
Skill Attribute Behavior Interaction Communication
Architecture
* *
1 * *
*
* *
* 1 specifies > * controls > 1 1
Species Agent Body
1 1
World
* *
1..n
*
Environment Place Action Perception
< changes
< uses
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 9
Databases OpenMap
GIS data foundation
UI control
GAML Language
Batch experiments
manages >
defines >
* * *
Control
Skill Attribute Behavior Interaction Communication
Architecture
1 * *
* *
*
* *
* 1 specifies > * controls > 1 1
Species Agent Body
1 1
Experts World
* *
Modellers
Users
1..n
*
Environment Place Action Perception
< changes
< uses
GAMA Java
Framework
Java subclassing
Abstract/
Java reuse
Concrete
classes
Developers
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 10
Meta-model
• The meta-model allows:
Ⴡ To extend GAMA in Java by defining new (concrete) subclasses to anything : agents,
control architectures, etc. The meta-model defines all the relationships needed.
Ⴡ To provide a clean interface for manipulating GAMA from outside (example with
PAMS)
• The link between GAML and Java, and the possibility to develop hybrid models, is
realized through the use of Java meta-informations (annotations) and dedicated
parsers and compilers.
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 11
Meta-annotations, once
interpreted, directly
translate into structures GAML Language
defines >
* * *
/**
* *
* *
* 1 specifies > * controls > 1 1
* The OR expression
Species Agent Body
1 1
Subclassing of existing
World
*
* *
1..n
*
Environment Place Action Perception
*/
< uses
Java annotations
@left_operand_types( { GamlType.BOOL }) XML parser
@right_operand_types( { GamlType.BOOL }) GAML parser
Partial Java compiler
@return_type(GamlType.BOOL)
@keyword( { "or", "|" }) GAMA Java
public class BinaryOpOrExpr extends AbstractBinaryOpExpr { Java subclassing
Framework
Abstract/
Java reuse
Concrete
public Boolean value(final BasicEntity agent) { classes
return boolValue(agent);
}
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 12
Ex: adding new entities to GAML
• Messages are bits of information exchanged between agents, that
follow some protocols inside a
conversation. @species_name("message")
@vars( { "sender", "receivers", "performative", "content", "unread",
"conversation", "protocol", "timestamp" })
public class Message extends GamaObject implements IMessage {
/**
* Action: wander
* @param args
* the args : speed (meter/sec) : the speed with which the agent
* wants to move ; distance (meter) : the distance the agent want
* to cover in one step ; amplitude (in degrees) : 360 or 0 means
Once defined, an action caled * completely random move, while other values, combined with the
"wander" becomes available for the * heading of the agent, defines the cone in which the agent will
agents that use/implement this skill * choose a new place.
*/
@action("wander")
@facets( {
@facet(name = "amplitude", type = GamlType.INT, optional = true),
@facet(name = "speed", type = GamlType.FLOAT, optional = true),
@facet(name = "distance", type = GamlType.FLOAT, optional = true) })
public CommandStatus primMoveRandomly(final Arguments args) {
...
}
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 14
Training session
• This training session will not deal with these aspects. No programming
in Java (unless you want to correct a bug) will be required, as we will
focus on the modeling part of the platform, leaving aside its role as a
framework.
• Next part makes you discover the User Interface controller of GAMA,
and some bits of the GAML language.
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 15
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 16
Opening and running a model
Models are simple
XML text files
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 17
Progress bar
• Progress bar during the opening of the model
Ⴡ Parsing -> Compilation -> Agents Creation -> UI Opening
Ⴡ Currently not cancellable (but interrupted in case of errors !)
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 18
GAMA User Interface
• Once a model has
been loaded,
compiled and
launched, the window
display several views
that depend on the
outputs defined in it.
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 19
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 20
Running a model
• To run a model already loaded, two buttons can be used. Each
of them causes the views to be updated.
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 21
Monitors
• Monitors : a way to follow arbitrary values during a simulation.
At which frequency (in
simulation steps) should
the value be updated.
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 22
Monitors
• Monitors
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 23
Monitors
• New monitors can be added at will
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 24
Monitors
• The monitors view can accomodate for an arbitrary number of monitors
(they can be described programmatically in the model, and saved at
once for future reuse in the model)
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 25
Using GAMA
• Errors in
expressions
are caught at
run-time and
prevent faulty
monitors to
be created
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 26
Using GAMA
• All dynamical views in GAMA share a same set of controls
Pause the update of the view (NOT the simulation)
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 27
Using GAMA
• Graphical views (charts, displays) add the possibility to save snapshots
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 28
Using GAMA
• Parameters can be visualized and edited from the Parameters view
category name of the parameter current value (editable) bounds type
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 29
Using GAMA
• Specialized editors exist for booleans, lists and colors
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 30
Parameters
• Parameters modified by the user are indicated in red. They can be
reverted to their original values using the appropriate button.
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 31
Parameters
• Simulations can be relaunched with the modified set of parameters
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 32
Parameters
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 33
Parameters
• Modified parameters (and user-created monitors) can be saved for
future reuse.
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 34
Parameters
• This new model is available as any other model and can be run in the
same conditions as the others
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 35
Parameters
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 36
Edition mode
• Models can be edited directly from GAMA (although any other text or
XML editor can be used).
Edit any model file Edit all the model files composing the current simulation
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 37
Edition Mode
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 38
Edition mode
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 39
Edition mode
• Going back and forth the simulation and the edition modes
Does not relaunch the model
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 40
Overview
• GAML is a programming language, interpreted (actually, semi-compiled)
by GAMA, and dedicated to agent-based modeling. It does not replace
Java, but is sufficient for most models (even complex ones).
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 41
GAML Documentation
• A limited (and incomplete) documentation is available here:
Ⴡ http://www1.ifi.auf.org/mediawiki/index.php/New_programming_guide
• From there, you have access to the definition of the most common
features of GAML (commands, operators, variables, types, skills, species,
actions, etc.)
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 42
Structure of a model : 4 sections
<model_name>
<entities> Inside are described the <species 1... > Inside are described the
... different species of agents attributes and behaviors of
</entities> involved in the model <species 2...> each agent of the species
</model_name>
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 43
Species
• The heart of the GAML model is the description of the structure and
dynamics of the global level, the environment(s) and the species of
agents. For global, grid and species, the definition uses the same format
of a generic species. They specify three things :
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 44
Attributes
Attributes are defined by a type (9 predefined) and some facets : name (the
only mandatory one), init (an initial value), value (an update function), and
some specific facets (max, min, of, size, etc.).
Each facet (save name) contains an expression in GAML.
Predefined types: int, float, bool, string, rgb, list, matrix, point, agent
Ⴡ More types become available as species are created : the species
themselves can be used to provide a type for attributes.
• Examples :
<float name="i" init="0.1" value="i+0.01" max="100"/>
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 45
Example:
<int name="na" init="100" max="1000" min="1" parameter="Number of agents:" category="Agents" />
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 46
Expressions: constants
• Constant literals :
‘aaa’ (a string); 10 (an int); 10.23 (a float); true (a bool); [‘ab’, 1, 32.2] (a
list); {12.0,12.23} (a point)
• Other constants :
Units : m, km, meter, decimeter, second, s, sec, hour, month, etc.
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 47
Expressions: variables
• If a variable is an attribute of the agent, or a global attribute, the name of
this variable can be used directly in an expression.
Example:
Access to the global
attribute "time"
<species name="my_species" > Direct access to
own attribute
"date_of_birth"
<int name="date_of_birth" init="time" />
Use of <int name="age" value="time - date_of_birth"/>
"my_species"
as a type <my_species name="my_friend"/>
<bool name="older" value="age > my_friend.age"/>
</species>
Direct access to own attribute "age" Access to the attribute "age" of "my_friend"
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 48
Expressions: unary operators
• Unary operators: functions that only take one argument.
Syntax: operator expression
• Examples:
sum [10,20,30] -> 60; round 19.54 -> 20; length ‘abc’ -> 3; empty [ ] -> true;
max [10,20,30] -> 30 ; reverse [10,20,30] -> [30,20,10];
shuffle [‘a’,’b’,’c’] -> [‘c’, ‘a’, ‘b’].
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 49
• Examples
10 + 23 ; [10,20,30] at 1 -> 20 ; 2 among [1,2,3,4,5] -> [3,5]
• Example:
3 agents a1, a2, a3 with attribute size = 1, 2, 3 and a list la = [a2,a1,a3]
la where each.size > 1 -> [a2,a3]; la with_max_of each.size -> a3 ; la sort_by
each.size -> [a1,a2,a3] ; la min_of each.size -> 1
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 50
Expressions: ternary operator
• Only one function with three arguments ("functional if").
Syntax: bool_expression ? expression1 : expression2
Example:
2 > 12 ? 1 : 2 -> 1
la collect ((each.size > mean (la collect each.size)) ? ‘taller’ : ‘smaller’))
-> [‘smaller’,‘smaller’,‘taller than average’]
XML disallows some keywords. For instance, the less-than operator '<' has
to be written < (the corresponding HTML entity).
Ⴡ The whole reference to expressions is available on the documents and the wiki.
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 51
Actions
• Actions describe what an agent of the species can do. It can take
arguments, and consists in a sequence of commands.
<action name="my_action">
[arguments]*
[commands]*
</action>
Arguments are defined by the arg keyword. They accept two facets : a name
and a possible default value.
<action name="my_action">
<arg name="arg1" default="0"/>
<arg name="arg2"/>
[commands]*
</action>
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 52
Commands
• There are 9 basic commands in GAML
let, set, do, return, if, else, loop, create and ask
• Temporary variables
let allows to create and initialize a temporary variable. This variable is
local to the scope in which it is created (i.e. If it is created within an
action, for instance, it cannot be used outside of this action). The type of
the variable is not declared (it is inferred from the value).
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 53
Commands: set
• Assignment
setallows to assign a new value to an attribute, a temporary variable, a
location in a list, matrix or point.
if the types do not match, the value is casted using that of the variable :
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 54
Commands: do & return
• Action calls and returns
do allows the agent to perform an action (built-in or defined in the species).
The optional facet result declares a temporary variable that will be assigned
with the result of the execution (if any).
In an action, return allows to describe which value to return (if any) at the
end of its execution.
<action name="my_action2">
temp2 is assigned with 100
<do action="my_action1" result="temp1"/>
<do action="my_action1">
<arg name="arg1" value="temp1 + 100" result="temp2"/>
</do>
</action>
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 55
Commands: if
• Conditional statements
if allows to conditionally execute another command (or a sequence of) if a
condition evaluates to true
<if condition="a_bool_expression">
[command]*
</if>
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 56
Commands: loop
• Repetitions
Loopallows to execute several times a sequence of commands, either
conditionnaly or within certain bounds. It takes several forms :
<loop while="a_bool_expression">
[command]*
</loop>
<loop times="an_int_expression">
[command]* temp is assigned, in turn, with each integer in the
sequence between int1 and int2
</loop>
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 57
Commands : ask
• Remote execution
askis a way for an agent to "control" other agents by making them execute a
sequence of commands.
<ask target="an_agent | a_list_of_agents" [as="a_species"]>
[command]*
</ask>
Commands are executed in the context of the target. If the calling agent wants
to transmit on some data of its own, it needs to use the keyword myself.
<ask target="a1">
<set name="size" value="myself.size"/>
</ask>
<action name="invite_friends">
<ask target="all_my_friends" as="species self">
<do action="come"> <arg name="location" value="myself.home"/> </do>
</ask>
</action>
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 58
Commands: create
• Instantiation of agents
create allows to instantiate new agents of a given species. Optionnaly it can
contain a sequence of commands that will be executed by the agents
created immediately after their "birth" (just like ask). It can also contain a
facet result, that assigns to the temporary variable declared the list of newly
created agents.
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 59
<species name="human">
<int name="sleepless_hours" init="0" value="in_bed ? sleepless_hours - 1 : sleepless_hours + 1"/>
<bool name="in_bed"/>
<init>
<set name="in_bed" value="flip 0.5"/>
</init>
<reflex name="go_to_bed" when="sleepless_hours > 12">
<set name="in_bed" value="true"/>
</reflex>
<reflex name="wake_up" when="sleepless_hours < 0">
<set name="in_bed" value="false"/>
</reflex>
</species>
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 60
Specific declarations
• Species can inherit their attributes, actions and behaviors from another
one (and redefine them). This is specified using the facet parent:
<species name="human" parent="mammal">
• "Grid" species can specify their width and height, how many neighbours
each cell has, and whether or not they are to be considered as toroidal
<grid name="my_grid" width="30" height="30" torus="false" neighbours="8">
<rgb name="color" value="rgb [rnd 255, rnd 255, rnd 255]"/>
</grid>
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 61
Time to play !
Training session on agent-based modeling, introduction to the GAMA and PAMS platforms, IRD, UMI UMMISCO 209, MSI Team, 26, 27 & 28 oct. 2009, Hanoi, Vietnam 62