This file is automatically generated from java files. Do Not Edit It.
=, action, add, agents, annealing, ask, aspect, assert, benchmark, break, camera, capture, chart, conscious_contagion, create, data, datalist, default, diffuse, display, display_grid, display_population, do, draw, else, emotional_contagion, enter, equation, error, event, exhaustive, exit, experiment, export, focus, focus_on, genetic, graphics, highlight, hill_climbing, if, image, inspect, let, light, loop, match, migrate, monitor, output, output_file, overlay, parameter, perceive, permanent, plan, put, reactive_tabu, reflex, release, remove, return, rule, run, save, save_batch, set, setup, simulate, socialize, solve, species, state, status, switch, tabu, task, test, trace, transition, unconscious_contagion, user_command, user_init, user_input, user_panel, using, Variable_container, Variable_number, Variable_regular, warn, write,
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 ...;
If the statement encloses other statements, it is called a sequence statement, and its sub-statements (either sequence statements or single statements) are declared between curly brackets, as in:
statement_keyword1 expression1 facet2: expression2... { // a sequence statement
statement_keyword2 expression1 facet2: expression2...; // a single statement
statement_keyword3 expression1 facet2: expression2...;
}
right
(float), (omissible) : the right part of the equation (it is mandatory that it can be evaluated as a floatleft
(any type): the left part of the equation (it should be a variable or a call to the diff() or diff2() operators)Allows to implement an equation in the form function(n, t) = expression. The left function is only here as a placeholder for enabling a simpler syntax and grabbing the variable as its left member.
float t;
float S;
float I;
equation SI {
diff(S,t) = (- 0.3 * S * I / 100);
diff(I,t) = (0.3 * S * I / 100);
}
=
statement is of type: Single statement=
statement can be embedded into: equation,=
statement embeds statements:name
(an identifier), (omissible) : identifier of the actionindex
(a datatype identifier): if the action returns a map, the type of its keysof
(a datatype identifier): if the action returns a container, the type of its elementstype
(a datatype identifier): the action returned typevirtual
(boolean): whether the action is virtual (defined without a set of instructions) (false by default)Allows to define in a species, model or experiment a new action that can be called elsewhere.
action simple_action {
// [set of statements]
}
action action_parameters(int i, string s){
// [set of statements using i and s]
}
int action_return_val(int i, string s){
// [set of statements using i and s]
return i + i;
}
species parent_species {
int virtual_action(int i, string s);
}
species children parent: parent_species {
int virtual_action(int i, string s) {
return i + i;
}
}
action
statement is of type: Sequence of statements or actionaction
statement can be embedded into: Species, Experiment, Model,action
statement embeds statements: return,to
(any type in [container, species, agent, geometry]): an expression that evaluates to a containeritem
(any type), (omissible) : any expression to add in the containerall
(any type): Allows to either pass a container so as to add all its element, or ‘true’, if the item to add is already a container.at
(any type): position in the container of added elementedge
(any type): a pair that will be added to a graph as an edge (if nodes do not exist, they are also added)node
(any type): an expression that will be added to a graph as a node.vertex
(any type):weight
(float):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
add expr to: expr_container; // Add at the end
add expr at: expr to: expr_container; // Add at position expr
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]
map<string,string> workingMap <- [];
add "val1" at: "x" to: workingMap; // workingMap equals ["x"::"val1"]
add "val2" to: workingMap; // workingMap equals ["x"::"val1", "val2"::"val2"]
add "5"::"val4" to: workingMap; // workingMap equals ["x"::"val1", "val2"::"val2", "5"::"val4"]
add "val3" at: "x" to: workingMap; // workingMap equals ["x"::"val3", "val2"::"val2", "5"::"val4"]
add ["val4","val5"] all: true at: "x" to: workingMap; // workingMap equals ["x"::"val3", "val2"::"val2", "5"::"val4","val4"::"val4","val5"::"val5"]
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 graphgraph 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})]
add
statement is of type: Single statementadd
statement can be embedded into: chart, Behavior, Sequence of statements or action, Layer,add
statement embeds statements:value
(container): the set of agents to displayname
(a label), (omissible) : Human readable title of the layeraspect
(an identifier): the name of the aspect that should be used to display the speciesfading
(boolean): Used in conjunction with ‘trace:’, allows to apply a fading effect to the previous traces. Default is falsefocus
(agent): the agent on which the camera will be focused (it is dynamically computed)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, useful 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 truesize
(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 directionstrace
(any type in [boolean, int]): Allows to aggregate the visualization of agents 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)agents
allows the modeler to display only the agents that fulfill a given condition.
display my_display {
agents layer_name value: expression [additional options];
}
agents
will only display unhappy agents:display Segregation {
agents agentDisappear value: people as list where (each.is_happy = false) aspect: with_group_color;
}
agents
statement is of type: Layeragents
statement can be embedded into: display,agents
statement embeds statements:name
(an identifier), (omissible) :aggregation
(a label), takes values in: {min, max}: the agregation methodmaximize
(float): the value the algorithm tries to maximizeminimize
(float): the value the algorithm tries to minimizenb_iter_cst_temp
(int): number of iterations per level of temperaturetemp_decrease
(float): temperature decrease coefficienttemp_end
(float): final temperaturetemp_init
(float): initial temperatureThis algorithm is an implementation of the Simulated Annealing algorithm. See the wikipedia article and [batch161 the batch dedicated page].
method annealing
instead of the expected annealing name: id
:method annealing [facet: value];
method annealing temp_init: 100 temp_end: 1 temp_decrease: 0.5 nb_iter_cst_temp: 5 maximize: food_gathered;
annealing
statement is of type: Batch methodannealing
statement can be embedded into: Experiment,annealing
statement embeds statements:target
(any type in [container, agent]), (omissible) : an expression that evaluates to an agent or a list of agentsas
(species): an expression that evaluates to a speciesparallel
(any type in [boolean, int]): (experimental) setting this facet to ‘true’ will allow ‘ask’ to use concurrency when traversing the targets; 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 false by default.Allows an agent, the sender agent (that can be the [Sections161#global world agent]), 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.
ask ${receiver_agents} {
${cursor}
}
ask ${one_agent} {
${cursor}
}
as
facet. An error is thrown if an agent is not a direct or undirect instance of this speciesask${receiver_agent(s)} as: ${a_species_expression} {
${cursor}
}
of_species
operator can be used. If none of the agents belong to the species, nothing happensask ${receiver_agents} of_species ${species_name} {
${cursor}
}
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
.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
}
}
}
}
ask
statement is of type: Sequence of statements or actionask
statement can be embedded into: chart, Behavior, Sequence of statements or action,ask
statement embeds statements: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)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. The aspect is evaluate for each agent each time it has to be displayed.
species one_species {
int a <- rnd(10);
aspect aspect1 {
if(a mod 2 = 0) { draw circle(a);}
else {draw square(a);}
draw text: "a= " + a color: #black size: 5;
}
}
aspect
statement is of type: Behavioraspect
statement can be embedded into: Species, Model,aspect
statement embeds statements: draw,value
(any type), (omissible) : the value that is evaluated and compared to other facetsequals
(any type): an expression, assert tests whether the value is equals to this expressionis_not
(any type): an expression, assert tests whether the value is not equals to this expressionraises
(an identifier): “error” or “warning”, used in testing what raises the evaluation of the value: expressionAllows to check whether the evaluation of a given expression fulfills a given condition. If it is not fulfilled, an exception is raised.
assert (2+2) equals: 4;
assert self is_not: nil;
int z <- 0;
assert (3/z) raises: "error";
assert
statement is of type: Single statementassert
statement can be embedded into: test,assert
statement embeds statements:message
(any type), (omissible) : A message to display alongside the results. Should concisely describe the contents of the benchmarkrepeat
(int): An int expression describing how many executions of the block must be handled. The output in this case will return the min, max and average durationsDisplays 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
benchmark
statement is of type: Sequence of statements or actionbenchmark
statement can be embedded into: Behavior, Sequence of statements or action, Layer,benchmark
statement embeds statements:break
allows to interrupt the current sequence of statements.
break
statement is of type: Single statementbreak
statement can be embedded into: Sequence of statements or action,break
statement embeds statements:name
(string), (omissible) : The name of the cameralocation
(point): The location of the camera in the worldlook_at
(point): The location that the camera is lookingup_vector
(point): The up-vector of the camera.camera
allows 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.
camera
statement is of type: Layercamera
statement can be embedded into: display,camera
statement embeds statements:target
(any type in [agent, container]), (omissible) : an expression that is evaluated as an agent or a list of the agent to be capturedas
(species): the species that the captured agent(s) will become, this is a micro-species of the calling agent’s speciesreturns
(a new identifier): a list of the newly captured agent(s)Allows an agent to capture other agent(s) as its micro-agent(s).
species A {
...
}
species B {
...
species C parent: A {
...
}
...
}
capture list(B) as: C;
capture target: list (B) as: C;
capture
statement is of type: Sequence of statements or actioncapture
statement can be embedded into: Behavior, Sequence of statements or action,capture
statement embeds statements:name
(a label), (omissible) : the identifier of the chart layeraxes
(rgb): the axis colorbackground
(rgb): the background colorcolor
(rgb): Text colorgap
(float): minimum gap between bars (in proportion)label_font
(string): Label font facelabel_font_size
(int): Label font sizelabel_font_style
(an identifier), takes values in: {plain, bold, italic}: the style used to display labelslegend_font
(string): Legend font facelegend_font_size
(int): Legend font sizelegend_font_style
(an identifier), takes values in: {plain, bold, italic}: the style used to display legendmemorize
(boolean): Whether or not to keep the values in memory (in order to produce a csv file, for instance). The default value, true, can also be changed in the preferencesposition
(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.reverse_axes
(boolean): reverse X and Y axis (for example to get horizental bar chartsseries_label_position
(an identifier), takes values in: {default, none, legend, onchart, yaxis, xaxis}: Position of the Series names: default (best guess), none, legend, onchart, xaxis (for category plots) or yaxis (uses the first serie name).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 facetick_font_size
(int): Tick font sizetick_font_style
(an identifier), takes values in: {plain, bold, italic}: the style used to display tickstitle_font
(string): Title font facetitle_font_size
(int): Title font sizetitle_font_style
(an identifier), takes values in: {plain, bold, italic}: the style used to display titlestype
(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 axisx_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_unit
(float): the tick unit for the y-axis (distance between horyzontal lines and values on the left of the axis).y_label
(string): the title for the Y axisy_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_unit
(float): the tick unit for the x-axis (distance between vertical lines and values bellow the axis).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).
display chart_display {
chart "chart name" type: series [additional options] {
[Set of data, datalists statements]
}
}
chart
statement is of type: Layerchart
statement can be embedded into: display,chart
statement embeds statements: add, ask, data, datalist, do, put, remove, set, simulate, using,emotion_created
(546706): the emotion that will be created with the contagionemotion_detected
(546706): the emotion that will start the contagionname
(an identifier), (omissible) : the identifier of the unconscious contagioncharisma
(float): The charisma value of the perceived agent (between 0 and 1)receptivity
(float): The receptivity value of the current agent (between 0 and 1)threshold
(float): The threshold value to make the contagionwhen
(boolean): A boolean value to get the emotion only with a certain conditionenables to directly add an emotion of a perceived specie if the perceived agent ges a patricular emotion.
conscious_contagion emotion_detected:fear emotion_created:fearConfirmed;
conscious_contagion emotion_detected:fear emotion_created:fearConfirmed charisma: 0.5 receptivity: 0.5;
conscious_contagion
statement is of type: Single statementconscious_contagion
statement can be embedded into: Behavior, Sequence of statements or action,conscious_contagion
statement embeds statements:species
(any type in [species, agent]), (omissible) : an expression that evaluates to a species, the species of the agents to be created. In the case of simulations, the name ‘simulation’, which represents the current instance of simulation, can also be used as a proxy to their speciesas
(species):from
(any type): an expression that evaluates to a localized entity, a list of localized entities, a string (the path of a file), a file (shapefile, a .csv, a .asc or a OSM file) or a container returned by a request to a databaseheader
(boolean): an expression that evaluates to a boolean, when creating agents from csv file, specify whether the file header is loadednumber
(int): an expression that evaluates to an int, the number of created agentsreturns
(a new identifier): a new temporary variable name containing the list of created agents (a list, even if only one agent has been created)with
(map): an expression that evaluates to a map, for each pair the key is a species attribute and the value the assigned valueAllows 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).
an_int
agents of species a_species
is:create a_species number: an_int;
create species_of(self) number: 5 returns: list5Agents;
5
a_species (with two attributes
type and
nature with types corresponding to the types of the shapefile attributes) from a shapefile
the_shapefile` while reading attributes ‘TYPE_OCC’ and ‘NATURE’ of the shapefile. One agent will be created by object contained in the shapefile:create a_species from: the_shapefile with: [type:: read('TYPE_OCC'), nature::read('NATURE')];
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
create species_of(self) from: [square(4),circle(4)]; // 2 agents have been created, with shapes respectively square(4) and circle(4)
create species (self) number: rnd (4) returns: children;
ask children {
// ...
}
create a_species number: an_int {
[statements]
}
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)
}
// Simple syntax
create species: a_species number: an_int;
number
equals 0 or species is not a species, the statement is ignored.create
statement is of type: Sequence of statements or actioncreate
statement can be embedded into: Behavior, Sequence of statements or action,create
statement embeds statements:legend
(string), (omissible) :value
(any type in [float, point, list]):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): Line visible or notmarker
(boolean): marker visible or notmarker_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 markermarker_size
(float): Size in pixels of the markerstyle
(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 drawx_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)data
statement is of type: Single statementdata
statement can be embedded into: chart, Sequence of statements or action,data
statement embeds statements: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 notmarker_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)x_err_values
(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
(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)datalist
statement is of type: Single statementdatalist
statement can be embedded into: chart, Sequence of statements or action,datalist
statement embeds statements:value
(any type), (omissible) :Used in a switch match structure, the block prefixed by default is executed only if no other block has matched (otherwise it is not).
default
statement is of type: Sequence of statements or actiondefault
statement can be embedded into: switch,default
statement embeds statements:var
(an identifier), (omissible) : the variable to be diffusedon
(any type in [container, species]): the list of agents (in general cells of a grid), on which the diffusion will occuravoid_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 stepmask
(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.mat_diffu
(matrix): the diffusion matrix (can have any size)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 diffusion methodmin_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 ‘diffusion’.proportion
(float): a diffusion rateradius
(int): a diffusion radius (in number of cells from the center)variation
(float): an absolute value to decrease at each neighborsThis statements allows a value to diffuse among a species on agents (generally on a grid) depending on a given diffusion matrix.
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 mat_diffu: math_diff;
diffuse var: phero on: cells mat_diffu: math_diff mask: mymask;
diffuse var: phero on: cells proportion: 1/9 radius: 1;
diffuse
statement is of type: Single statementdiffuse
statement can be embedded into: Behavior, Sequence of statements or action,diffuse
statement embeds statements:name
(a label), (omissible) : the identifier of the displayambient_light
(any type in [int, rgb]): 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(127,127,127,255)autosave
(any type in [boolean, point]): Allows to save this display on disk. A value of true/false will save it at a resolution of 500x500. A point can be passed to personalize these dimensionsbackground
(rgb): Allows to fill the background of the display with a specific colorcamera_interaction
(boolean): If false, the user will not be able to modify the position and the orientation of the camera, and neither using the ROI. Default is true.camera_lens
(int): Allows to define the lens of the cameracamera_look_pos
(point): Allows to define the direction of the cameracamera_pos
(any type in [point, agent]): Allows to define the position of the cameracamera_up_vector
(point): Allows to define the orientation of the cameradiffuse_light
(any type in [int, rgb]): 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 (127,127,127,255)diffuse_light_pos
(point): Allows to define the position of the diffuse light either using an point (diffuse_light_pos:{x,y,z}). default is {world.shape.width/2,world.shape.height/2,world.shape.width*
2}draw_diffuse_light
(boolean): Allows to show/hide a representation of the lights. Default is false.draw_env
(boolean): Allows to enable/disable the drawing of the world shape and the ordinate axes. Default can be configured in Preferencesfocus
(geometry): the geometry (or agent) on which the display will (dynamically) focusfullscreen
(any type in [boolean, int]): Indicates, when using a boolean value, whether or not the display should cover the whole screen (default is false). If an integer is passed, specifies also the screen to use: 0 for the primary monitor, 1 for the secondary one, and so on and so forth. If the monitor is not available, the first one is usedkeystone
(container): Set the position of the 4 corners of your screen ([topLeft,topRight,botLeft,botRight]), in (x,y) coordinate ( the (0,0) position is the top left corner, while the (1,1) position is the bottom right corner). The default value is : [{0,0},{1,0},{0,1},{1,1}]light
(boolean): Allows to enable/disable the light. Default is trueorthographic_projection
(boolean): Allows to enable/disable the orthographic projection. Default can be configured in Preferencesrefresh
(boolean): Indicates the condition under which this output should be refreshed (default is true)refresh_every
(int): Allows to refresh the display every n time steps (default is 1)rotate
(float): Set the angle for the rotation around the Z axisscale
(any type in [boolean, float]): Allows to display a scale bar in the overlay. Accepts true/false or an unit nameshow_fps
(boolean): Allows to enable/disable the drawing of the number of frames per secondsynchronized
(boolean): Indicates whether the display should be directly synchronized with the simulationtype
(a label): Allows to use either Java2D (for planar models) or OpenGL (for 3D models) as the rendering subsystemuse_shader
(boolean): Under construction…z_fighting
(boolean): Allows to alleviate a problem where agents at the same z would overlap each other in random waysA display refers to a independent and mobile part of the interface that can display species, images, texts or charts.
display my_display [additional options] { ... }
display gridWithElevationTriangulated type: opengl ambient_light: 100 {
grid cell elevation: true triangulation: true;
species people aspect: base;
}
display
statement is of type: Outputdisplay
statement can be embedded into: output, permanent,display
statement embeds statements: agents, camera, chart, display_grid, display_population, event, graphics, image, light, overlay,species
(species), (omissible) : the species of the agents in the griddem
(matrix):draw_as_dem
(boolean):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)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 truesize
(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 directionstext
(boolean): specify whether the attribute used to compute the elevation is displayed on each cells (false by default)texture
(any type in [boolean, file]): Either file containing the texture image to be applied on the grid or, if true, the use of the image composed by the colors of the cells. If false, no texture is appliedtransparency
(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)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).
display my_display {
grid ant_grid lines: #black position: { 0.5, 0 } size: {0.5,0.5};
}
display my_display {
grid cell texture: texture_file text: false triangulation: true elevation: true;
}
display_grid
statement is of type: Layerdisplay_grid
statement can be embedded into: display,display_grid
statement embeds statements:species
(species), (omissible) : the species to be displayedaspect
(an identifier): the name of the aspect that should be used to display the speciesfading
(boolean): Used in conjunction with ‘trace:’, allows to apply a fading effect to the previous traces. Default is falseposition
(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 truesize
(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 directionstrace
(any type in [boolean, int]): Allows to aggregate the visualization of agents 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)The display_population
statement is used using the species keyword
. It 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.
display my_display {
species species_name [additional options];
}
display my_display {
species agent1 aspect: base;
species agent2 aspect: base;
species agent3 aspect: base;
}
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};
}
display_population
statement is of type: Layerdisplay_population
statement can be embedded into: display, display_population,display_population
statement embeds statements: display_population,action
(an identifier), (omissible) : the name of an action or a primitiveinternal_function
(any type):returns
(a new identifier): create a new variable and assign to it the result of the actionwith
(map): a map expression containing the parameters of the actionAllows the agent to execute an action or a primitive. For a list of primitives available in every species, see this [BuiltIn161 page]; for the list of primitives defined by the different skills, see this [Skills161 page]. Finally, see this [Species161 page] to know how to declare custom actions.
do name_of_action_or_primitive;
do name_of_action_or_primitive arg1: expression1 arg2: expression2;
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 [];
type_returned_by_action result <- self name_of_action_or_primitive [arg1::expression1, arg2::expression2];
do
statement (still accepted) are now deprecated:// Simple syntax:
do action: name_of_action_or_primitive;
// In case the result of the action needs to be made available to the agent, the `returns` keyword can be defined; the result will then be referred to by the temporary variable declared in this attribute:
do name_of_action_or_primitive returns: result;
do name_of_action_or_primitive arg1: expression1 arg2: expression2 returns: result;
type_returned_by_action result <- name_of_action_or_primitive(self, [arg1::expression1, arg2::expression2]);
// In case the result of the action needs to be made available to the agent
let result <- name_of_action_or_primitive(self, []);
// In case the action expects one or more arguments to be passed, they can also be defined by using enclosed `arg` statements, or the `with` facet with a map of parameters:
do name_of_action_or_primitive with: [arg1::expression1, arg2::expression2];
or
do name_of_action_or_primitive {
arg arg1 value: expression1;
arg arg2 value: expression2;
...
}
do
statement is of type: Single statementdo
statement can be embedded into: chart, Behavior, Sequence of statements or action,do
statement embeds statements:geometry
(any type), (omissible) : any type of data (it can be geometry, image, text)at
(point): location where the shape/text/icon is drawnbegin_arrow
(any type in [int, float]): the size of the arrow, located at the beginning of the drawn geometrybitmap
(boolean): Whether to render the text in 3D or notborder
(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 pointempty
(boolean): a condition specifying whether the geometry is empty or fullend_arrow
(any type in [int, float]): the size of the arrow, located at the end of the drawn geometryfont
(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)material
(25): Set a particular material to the object (only if you are in the “use_shader” mode).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}rounded
(boolean): specify whether the geometry have to be rounded (e.g. for squares)size
(any type in [float, point]): size of the object to draw, expressed as a bounding box (width, height, depth). If expressed as a float, represents the size in the three directions.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 pathswidth
(float): The line width to use for drawing this objectdraw
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.
aspect geometryAspect {
draw circle(1.0) empty: !hasFood color: #orange ;
}
aspect arrowAspect {
draw "Current state= "+state at: location + {-3,1.5} color: #white font: font('Default', 12, #bold) ;
draw file(ant_shape_full) rotate: heading at: location size: 5
}
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;
}
draw
statement is of type: Single statementdraw
statement can be embedded into: aspect, Sequence of statements or action, Layer,draw
statement embeds statements:This statement cannot be used alone
else
statement is of type: Sequence of statements or actionelse
statement can be embedded into: if,else
statement embeds statements:emotion_detected
(546706): the emotion that will start the contagionname
(an identifier), (omissible) : the identifier of the emotional contagioncharisma
(float): The charisma value of the perceived agent (between 0 and 1)emotion_created
(546706): the emotion that will be created with the contagionreceptivity
(float): The receptivity value of the current agent (between 0 and 1)threshold
(float): The threshold value to make the contagionwhen
(boolean): A boolean value to get the emotion only with a certain conditionenables to make conscious or unconscious emotional contagion
emotional_contagion emotion_detected:fearConfirmed;
emotional_contagion emotion_detected:fear emotion_created:fearConfirmed;
emotional_contagion emotion_detected:fear emotion_created:fearConfirmed charisma: 0.5 receptivity: 0.5;
emotional_contagion
statement is of type: Single statementemotional_contagion
statement can be embedded into: Behavior, Sequence of statements or action,emotional_contagion
statement embeds statements:In an FSM architecture, enter
introduces a sequence of statements to execute upon entering a state.
state s_init {
enter { write "Enter in" + state; }
write "Enter in" + state;
}
write state;
}
enter
statement is of type: Sequence of statements or actionenter
statement can be embedded into: state,enter
statement embeds statements:name
(an identifier), (omissible) : the equation identifierparams
(list): the list of parameters used in predefined equation systemssimultaneously
(list): a list of species containing a system of equations (all systems will be solved simultaneously)type
(an identifier), takes values in: {SI, SIS, SIR, SIRS, SEIR, LV}: the choice of one among classical models (SI, SIS, SIR, SIRS, SEIR, LV)vars
(list): the list of variables used in predefined equation systemsThe equation statement is used to create an equation system from several single equations.
float t;
float S;
float I;
equation SI {
diff(S,t) = (- 0.3 * S * I / 100);
diff(I,t) = (0.3 * S * I / 100);
}
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] ;
equation
statement is of type: Sequence of statements or actionequation
statement can be embedded into: Species, Model,equation
statement embeds statements: =,message
(string), (omissible) : the message to display in the error.The statement makes the agent output an error dialog (if the simulation contains a user interface). Otherwise displays the error in the console.
error 'This is an error raised by ' + self;
error
statement is of type: Single statementerror
statement can be embedded into: Behavior, Sequence of statements or action, Layer,error
statement embeds statements:name
(an identifier), (omissible) : the type of event captured: can be “mouse_up”, “mouse_down”, “mouse_move”, “mouse_exit”, “mouse_enter” or a characteraction
(26): Either a block of statements to execute in the context of the simulation or the identifier of the action to be executed. 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_locationunused
(an identifier), takes values in: {mouse_up, mouse_down, mouse_move, mouse_enter, mouse_exit}: an unused facet that serves only for the purpose of declaring the string valuesevent
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
event [event_type] action: myAction;
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
// code written by modelers
}
}
experiment Simple type:gui {
display my_display {
event mouse_up action: myAction;
}
}
event
statement is of type: Layerevent
statement can be embedded into: display,event
statement embeds statements:name
(an identifier), (omissible) :aggregation
(a label), takes values in: {min, max}: the agregation methodmaximize
(float): the value the algorithm tries to maximizeminimize
(float): the value the algorithm tries to minimizeThis 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 [batch161 the batch dedicated page].
method exhaustive
instead of the expected exhaustive name: id
:method exhaustive [facet: value];
method exhaustive maximize: food_gathered;
exhaustive
statement is of type: Batch methodexhaustive
statement can be embedded into: Experiment,exhaustive
statement embeds statements:In an FSM architecture, exit
introduces a sequence of statements to execute right before exiting the state.
state s_init initial: true {
write state;
transition to: s1 when: (cycle > 2) {
write "transition s_init -> s1";
}
exit {
write "EXIT from "+state;
}
}
exit
statement is of type: Sequence of statements or actionexit
statement can be embedded into: state,exit
statement embeds statements:name
(a label), (omissible) : identifier of the experimenttitle
(a label):type
(a label), takes values in: {batch, memorize, gui, headless}: the type of the experiment (either ‘gui’ or ‘batch’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):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 memoryparallel
(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 useparent
(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 repeatedschedules
(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 terminatedexperiment
statement is of type: Experimentexperiment
statement can be embedded into: Model,experiment
statement embeds statements:var
(an identifier), (omissible) :framerate
(int):name
(string):export
statement is of type: Single statementexport
statement can be embedded into: Experiment,export
statement embeds statements:name
(an identifier), (omissible) : the identifier of the focusagent_cause
(agent): the agentCause value of the created belief (can be nilexpression
(any type): an expression that will be the value kept in the belieflifetime
(int): the lifetime value of the created beliefpriority
(any type in [float, int]): The priority of the created predicatetruth
(boolean): the truth value of the created beliefvar
(any type in [any type, list, container]): the variable of the perceived agent you want to add to your beliefswhen
(boolean): A boolean value to focus only with a certain conditionenables to directly add a belief from the variable of a perceived specie.
focus var:speed /*where speed is a variable from a species that is being perceived*/
focus
statement is of type: Single statementfocus
statement can be embedded into: Behavior, Sequence of statements or action,focus
statement embeds statements:value
(any type), (omissible) : The agent, list of agents, geometry to focus onAllows to focus on the passed parameter in all available displays. Passing ‘nil’ for the parameter will make all screens return to their normal zoom
focus_on my_species(0);
focus_on
statement is of type: Single statementfocus_on
statement can be embedded into: Behavior, Sequence of statements or action, Layer,focus_on
statement embeds statements:name
(an identifier), (omissible) :aggregation
(a label), takes values in: {min, max}: the agregation methodcrossover_prob
(float): crossover probability between two individual solutionsmax_gen
(int): number of generationsmaximize
(float): the value the algorithm tries to maximizeminimize
(float): the value the algorithm tries to minimizemutation_prob
(float): mutation probability for an individual solutionnb_prelim_gen
(int): number of random populations used to build the initial populationpop_dim
(int): size of the population (number of individual solutions)This is a simple implementation of Genetic Algorithms (GA). See the wikipedia article and [batch161 the batch dedicated page]. 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).
genetic
statement uses method genetic
instead of the expected genetic name: id
:method genetic [facet: value];
method genetic maximize: food_gathered pop_dim: 5 crossover_prob: 0.7 mutation_prob: 0.1 nb_prelim_gen: 1 max_gen: 20;
genetic
statement is of type: Batch methodgenetic
statement can be embedded into: Experiment,genetic
statement embeds statements:name
(a label), (omissible) : the human readable title of the graphicsfading
(boolean): Used in conjunction with ‘trace:’, allows to apply a fading effect to the previous traces. Default is falseposition
(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 directionstrace
(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)graphics
allows the modeler to freely draw shapes/geometries/texts without having to define a species. It works exactly like a species [Aspect161 aspect]: the draw statement can be used in the same way.
display my_display {
graphics "my new layer" {
draw circle(5) at: {10,10} color: #red;
draw "test" at: {10,10} size: 20 color: #black;
}
}
graphics
statement is of type: Layergraphics
statement can be embedded into: display,graphics
statement embeds statements:value
(agent), (omissible) : The agent to hightlightcolor
(rgb): An optional color to highlight the agent. Note that this color will become the default color for further higlight operationsAllows 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
highlight my_species(0) color: #blue;
highlight
statement is of type: Single statementhighlight
statement can be embedded into: Behavior, Sequence of statements or action, Layer,highlight
statement embeds statements:name
(an identifier), (omissible) :aggregation
(a label), takes values in: {min, max}: the agregation methoditer_max
(int): number of iterationsmaximize
(float): the value the algorithm tries to maximizeminimize
(float): the value the algorithm tries to minimizeThis algorithm is an implementation of the Hill Climbing algorithm. See the wikipedia article and [batch161 the batch dedicated page].
hill_climbing
statement uses method hill_climbing
instead of the expected hill_climbing name: id
:method hill_climbing [facet: value];
method hill_climbing iter_max: 50 maximize : food_gathered;
hill_climbing
statement is of type: Batch methodhill_climbing
statement can be embedded into: Experiment,hill_climbing
statement embeds statements:condition
(boolean), (omissible) : A boolean expression: the condition that is evaluated.Allows the agent to execute a sequence of statements if and only if the condition evaluates to true.
if bool_expr {
[statements]
}
if bool_expr {
[statements]
}
else {
[statements]
}
string valTrue <- "";
if true {
valTrue <- "true";
}
else {
valTrue <- "false";
}
// valTrue equals "true"
string valFalse <- "";
if false {
valFalse <- "true";
}
else {
valFalse <- "false";
}
// valFalse equals "false"
if bool_expr {
[statements]
}
else if bool_expr2 {
[statements]
}
else {
[statements]
}
if
statement is of type: Sequence of statements or actionif
statement can be embedded into: Behavior, Sequence of statements or action, Layer,if
statement embeds statements: else,name
(any type in [string, file]), (omissible) : Human readable title of the image layercolor
(rgb): in the case of a shapefile, this the color used to fill in geometries of the shapefilefile
(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. (true by default, usefull in case of images that is not 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 directionstransparency
(float): the transparency rate of the agents (between 0 and 1, 1 means no transparency)image
allows modeler to display an image (e.g. as background of a simulation).
display my_display {
image layer_name file: image_file [additional options];
}
display my_display {
image background file:"../images/my_backgound.jpg";
}
display my_display {
image testGIS gis: "../includes/building.shp" color: rgb('blue');
}
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};
}
image
statement is of type: Layerimage
statement can be embedded into: display,image
statement embeds statements:name
(any type), (omissible) : the identifier of the inspectorattributes
(list): the list of attributes to inspectrefresh
(boolean): Indicates the condition under which this output should be refreshed (default is true)refresh_every
(int): Allows to refresh the inspector every n time steps (default is 1)type
(an identifier), takes values in: {agent, table}: the way to inspect agents: in a table, or a set of inspectorsvalue
(any type): the set of agents to inspect, could be a species, a list of agents or an agentinspect
(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.
inspect "my_inspector" value: ant attributes: ["name", "location"];
inspect
statement is of type: Outputinspect
statement can be embedded into: output, permanent, Behavior, Sequence of statements or action,inspect
statement embeds statements:name
(a new identifier), (omissible) :index
(a datatype identifier):of
(a datatype identifier):type
(a datatype identifier):value
(any type):let
statement is of type: Single statementlet
statement can be embedded into: Behavior, Sequence of statements or action, Layer,let
statement embeds statements:id
(int), (omissible) : a number from 1 to 7 to specify which light we are usingactive
(boolean): a boolean expression telling if you want this light to be switch on or not. (default value : true)color
(any type in [int, rgb]): an int / rgb / rgba value to specify the color and the intensity of the light. (default value : (127,127,127,255) ).direction
(point): the direction of the light (only for direction and spot light). (default value : {0.5,0.5,-1})draw_light
(boolean): draw or not the light. (default value : false).linear_attenuation
(float): the linear attenuation of the positionnal light. (default value : 0)position
(point): the position of the light (only for point and spot light). (default value : {0,0,1})quadratic_attenuation
(float): the linear attenuation of the positionnal light. (default value : 0)spot_angle
(float): the angle of the spot light in degree (only for spot light). (default value : 45)type
(a label): the type of light to create. A value among {point, direction, spot}. (default value : direction)update
(boolean): specify if the light has to be updated. (default value : true).light
allows to define diffusion lights in your 3D display.
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
light
statement is of type: Layerlight
statement can be embedded into: display,light
statement embeds statements:name
(a new identifier), (omissible) : a temporary variable namefrom
(int): an int expressionover
(any type in [container, point]): a list, point, matrix or map expressionstep
(int): an int expressiontimes
(int): an int expressionto
(int): an int expressionwhile
(boolean): a boolean expressionAllows 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.
loop times: an_int_expression {
// [statements]
}
loop while: a_bool_expression {
// [statements]
}
loop a_temp_var over: a_collection_expression {
// [statements]
}
loop a_temp_var from: int_expression_1 to: int_expression_2 {
// [statements]
}
loop a_temp_var from: int_expression_1 to: int_expression_2 step: int_expression3 {
// [statements]
}
int a <- 0;
loop i over: [10, 20, 30] {
a <- a + i;
} // a now equals 60
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
loop
statement is of type: Sequence of statements or actionloop
statement can be embedded into: Behavior, Sequence of statements or action, Layer,loop
statement embeds statements:value
(any type), (omissible) :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
switch 3 {
match 1 {write "Match 1"; }
match 3 {write "Match 2"; }
}
switch 3 {
match_between [1,2] {write "Match OK between [1,2]"; }
match_between [2,5] {write "Match OK between [2,5]"; }
}
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]"; }
}
match
statement is of type: Sequence of statements or actionmatch
statement can be embedded into: switch,match
statement embeds statements:source
(any type in [agent, species, container, an identifier]), (omissible) : can be an agent, a list of agents, a agent’s population to be migratedtarget
(species): target species/population that source agent(s) migrate to.returns
(a new identifier): the list of returned agents in a new local variableThis command permits agents to migrate from one population/species to another population/species and stay in the same host after the migration. Species of source agents and target species respect the following constraints: (i) they are “peer” species (sharing the same direct macro-species), (ii) they have sub-species vs. parent-species relationship.
migrate ball_in_group target: ball_in_cloud;
migrate
statement is of type: Sequence of statements or actionmigrate
statement can be embedded into: Behavior, Sequence of statements or action,migrate
statement embeds statements:name
(a label), (omissible) : identifier of the monitorvalue
(any type): expression that will be evaluated to be displayed in the monitorcolor
(rgb): Indicates the (possibly dynamic) color of this output (default is a light gray)refresh
(boolean): Indicates the condition under which this output should be refreshed (default is true)refresh_every
(int): Allows to refresh the monitor every n time steps (default is 1)A monitor allows to follow the value of an arbitrary expression in GAML.
monitor "nb preys" value: length(prey as list) refresh_every: 5;
monitor
statement is of type: Outputmonitor
statement can be embedded into: output, permanent,monitor
statement embeds statements: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
.
experiment exp_name type: gui {
// [inputs]
output {
// [display, file, inspect, layout or monitor statements]
}
}
output
statement is of type: Outputoutput
statement can be embedded into: Model, Experiment,output
statement embeds statements: display, inspect, monitor, output_file,name
(an identifier), (omissible) : The name of the file where you want to export the datadata
(string): The data you want to exportfooter
(string): Define a footer for your export fileheader
(string): Define a header for your export filerefresh
(boolean): Indicates the condition under which this file should be saved (default is true)refresh_every
(int): Allows to save the file every n time steps (default is 1)rewrite
(boolean): Rewrite or not the existing filetype
(an identifier), takes values in: {csv, text, xml}: The type of your output dataoutput_file
statement is of type: Outputoutput_file
statement can be embedded into: output, permanent,output_file
statement embeds statements: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 defaultcenter
(any type): an expression that will be evaluated and displayed in the center section of the bottom overlaycolor
(any type in [list, rgb]): the color(s) used to display the expressions given in the ‘left’, ‘center’ and ‘right’ facetsleft
(any type): an expression that will be evaluated and displayed in the left section of the bottom overlayposition
(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.right
(any type): an expression that will be evaluated and displayed in the right section of the bottom overlayrounded
(boolean): Whether or not the rectangular shape of the overlay should be rounded. True by defaultsize
(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 coordinatetransparency
(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.75overlay
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.
overlay "Cycle: " + (cycle) center: "Duration: " + total_duration + "ms" right: "Model time: " + as_date(time,"") color: [#yellow, #orange, #yellow];
overlay
statement is of type: Layeroverlay
statement can be embedded into: display,overlay
statement embeds statements:var
(an identifier): the name of the variable (that should be declared in the global)name
(a label), (omissible) : The message displayed in the interfaceamong
(list): the list of possible valuescategory
(a label): a category label, used to group parameters in the interfaceinit
(any type): the init valuemax
(any type): the maximum valuemin
(any type): the minimum valueon_change
(any type): Provides a block of statements that will be executed whenever the value of the parameter changesslider
(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 effectstep
(float): the increment step (mainly used in batch mode to express the variation step between simulation)type
(a datatype identifier): the variable typeunit
(a label): the variable unitThe parameter statement specifies which global attributes (i) will change through the successive simulations (in batch experiments), (ii) can be modified by user via the interface (in gui experiments). In GUI experiments, parameters are displayed depending on their type.
parameter title var: global_var category: cat;
parameter 'Value of toto:' var: toto among: [1, 3, 7, 15, 100];
parameter 'Value of titi:' var: titi min: 1 max: 100 step: 2;
parameter
statement is of type: Parameterparameter
statement can be embedded into: Experiment,parameter
statement embeds statements:target
(any type in [container, point, agent]): the list of the agent you want to perceivename
(an identifier), (omissible) : the name of the perceptionas
(species): an expression that evaluates to a speciesemotion
(546706): The emotion needed to do the perceptionin
(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.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 activeAllow the agent, with a bdi architecture, to perceive others agents
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}
}
perceive
statement is of type: Sequence of statements or actionperceive
statement can be embedded into: Species, Model,perceive
statement embeds statements:layout
(int), (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 viewsRepresents 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.
permanent {
display Ants background: rgb('white') refresh_every: 1 {
chart "Food Gathered" type: series {
data "Food" value: food_gathered;
}
}
}
permanent
statement is of type: Outputpermanent
statement can be embedded into: Experiment,permanent
statement embeds statements: display, inspect, monitor, output_file,name
(an identifier), (omissible) :emotion
(546706):finished_when
(boolean):instantaneous
(boolean):intention
(546704):priority
(float):threshold
(float):when
(boolean):plan
statement is of type: Behaviorplan
statement can be embedded into: Species, Model,plan
statement embeds statements:in
(any type in [container, species, agent, geometry]): an expression that evaluates to a containeritem
(any type), (omissible) : any expressionall
(any type): any expressionat
(any type): any expressionedge
(any type): Indicates that the item to put should be considered as an edge of the receiving graph. Soon to be deprecated, use ‘put edge(item)…’ insteadkey
(any type): any expressionweight
(float): an expression that evaluates to a floatAllows 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.
put expr at: expr in: expr_container;
put all: expr in: expr_container;
list<int> 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]
matrix<int> 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]])
map<string,int> 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]
put
statement is of type: Single statementput
statement can be embedded into: chart, Behavior, Sequence of statements or action, Layer,put
statement embeds statements:name
(an identifier), (omissible) :aggregation
(a label), takes values in: {min, max}: the agregation methodcycle_size_max
(int): minimal size of the considered cyclescycle_size_min
(int): maximal size of the considered cyclesiter_max
(int): number of iterationsmaximize
(float): the value the algorithm tries to maximizeminimize
(float): the value the algorithm tries to minimizenb_tests_wthout_col_max
(int): number of movements without collision before shortening the tabu listtabu_list_size_init
(int): initial size of the tabu listtabu_list_size_max
(int): maximal size of the tabu listtabu_list_size_min
(int): minimal size of the tabu listThis algorithm is a simple implementation of the Reactive Tabu Search algorithm ((Battiti et al., 1993)). This Reactive Tabu Search is an enhance version of the Tabu search. It adds two new elements to the classic Tabu Search. The first one concerns the size of the tabu list: in the Reactive Tabu Search, this one is not constant anymore but it dynamically evolves according to the context. Thus, when the exploration process visits too often the same solutions, the tabu list is extended in order to favor the diversification of the search process. On the other hand, when the process has not visited an already known solution for a high number of iterations, the tabu list is shortened in order to favor the intensification of the search process. The second new element concerns the adding of cycle detection capacities. Thus, when a cycle is detected, the process applies random movements in order to break the cycle. See [batch161 the batch dedicated page].
method reactive_tabu
instead of the expected reactive_tabu name: id
:method reactive_tabu [facet: value];
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;
reactive_tabu
statement is of type: Batch methodreactive_tabu
statement can be embedded into: Experiment,reactive_tabu
statement embeds statements:name
(an identifier), (omissible) : the identifier of the reflexwhen
(boolean): an expression that evaluates a boolean, the condition to fulfill in order to execute the statements embedded in the reflex.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.
reflex my_reflex when: flip (0.5){ //Only executed when flip returns true
write "Executing the unconditional reflex";
}
reflex
statement is of type: Behaviorreflex
statement can be embedded into: Species, Experiment, Model,reflex
statement embeds statements: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 mapas
(species): an expression that is evaluated as a species in which the micro-agent will be releasedin
(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 hostreturns
(a new identifier): a new variable containing a list of the newly released agent(s)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. [Species161#Nesting_species Nesting 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).
species A {
...
}
species B {
...
species C parent: A {
...
}
species D {
...
}
...
}
release list(C);
release list (C) as: new_species in: new host;
release
statement is of type: Sequence of statements or actionrelease
statement can be embedded into: Behavior, Sequence of statements or action,release
statement embeds statements:from
(any type in [container, species, agent, geometry]): an expression that evaluates to a containeritem
(any type), (omissible) : any expression to remove from the containerall
(any type): an expression that evaluates to a container. If it is true and if the value a list, it removes the first instance of each element of the list. If it is true and the value is not a container, it will remove all instances of this value.edge
(any type): Indicates that the item to remove should be considered as an edge of the receiving graphindex
(any type): any expression, the key at which to remove the element from the containerkey
(any type): any expression, the key at which to remove the element from the containernode
(any type): Indicates that the item to remove should be considered as a node of the receiving graphvertex
(any type):Allows the agent to remove an element from a container (a list, matrix, map…).
remove expr from: expr_container;
remove index: expr from: expr_container;
remove key: expr from: expr_container;
remove all: expr from: expr_container;
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]
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([])
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([])
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 []
remove
allows to remove an attribute from the attributes map of the receiver. However, for agents, it will only remove attributes that have been added dynamically, not the ones defined in the species or in its built-in parent.global {
init {
create speciesRemove;
speciesRemove sR <- speciesRemove(0); // sR.a now equals 100
remove key:"a" from: sR; // sR.a now equals nil
}
}
species speciesRemove {
int a <- 100;
}
remove
statement is of type: Single statementremove
statement can be embedded into: chart, Behavior, Sequence of statements or action, Layer,remove
statement embeds statements:value
(any type), (omissible) : an expression that is returnedAllows 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 [Section161 section].
string foo {
return "foo";
}
reflex {
string foo_result <- foo(); // foos_result is now equals to "foo"
}
// 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"
}
return
statement is of type: Single statementreturn
statement can be embedded into: action, Behavior, Sequence of statements or action,return
statement embeds statements:name
(an identifier), (omissible) : The name of the rulebelief
(546704): The mandatory beliefdesire
(546704): The mandatory desireemotion
(546706): The mandatory emotionnew_belief
(546704): The belief that will be addednew_beliefs
(list): The belief that will be addednew_desire
(546704): The desire that will be addednew_desires
(list): The desire that will be addednew_emotion
(546706): The emotion that will be addednew_emotions
(list): The emotion that will be addednew_uncertainties
(list): The uncertainty that will be addednew_uncertainty
(546704): The uncertainty that will be addedparallel
(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.priority
(any type in [float, int]): The priority of the predicate added as a desireremove_belief
(546704): The belief that will be removedremove_beliefs
(list): The belief that will be removedremove_desire
(546704): The desire that will be removedremove_desires
(list): The desire that will be removedremove_emotion
(546706): The emotion that will be removedremove_emotions
(list): The emotion that will be removedremove_intention
(546704): The intention that will be removedremove_uncertainties
(list): The uncertainty that will be removedremove_uncertainty
(546704): The uncertainty that will be removedthreshold
(float): Threshold linked to the emotion.uncertainty
(546704): The mandatory uncertaintywhen
(boolean):enables to add a desire or a belief or to remove a belief, a desire or an intention if the agent gets the belief or/and desire or/and condition mentioned.
rule belief: new_predicate("test") when: flip(0.5) new_desire: new_predicate("test")
rule
statement is of type: Single statementrule
statement can be embedded into: Species, Model,rule
statement embeds statements:name
(string), (omissible) :of
(string):core
(int):end_cycle
(int):seed
(int):with_output
(map):with_param
(map):run
statement is of type: Sequence of statements or actionrun
statement can be embedded into: Behavior, Single statement, Species, Model,run
statement embeds statements:data
(any type), (omissible) : any expression, that will be saved in the fileattributes
(map): Allows to specify the attributes of a shape file (or other files that accept attributes). The keys of the map are the names of the attributes that will be present in the file, the values are whatever expression neeeded to define their valuecrs
(any type): the name of the projection, e.g. crs:”EPSG:4326” or its EPSG id, e.g. crs:4326. Here a list of the CRS codes (and EPSG id): http://spatialreference.orgheader
(boolean): an expression that evaluates to a boolean, specifying whether the save will write a header if the file does not existrewrite
(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 trueto
(string): an expression that evaluates to an string, the path to the filetype
(an identifier), takes values in: {shp, text, csv, asc, geotiff, image}: an expression that evaluates to an string, the type of the output file (it can be only “shp”, “asc”, “geotiff”, “image”, “text” or “csv”)with
(map): Allows to define the attributes of a shape file. Keys of the map are the attributes of agents to save, values are the names of attributes in the shape fileAllows to save data in a file. The type of file can be “shp”, “asc”, “geotiff”, “text” or “csv”.
save data to: output_file type: a_type_file;
save (string(cycle) + "->" + name + ":" + location) to: "save_data.txt" type: "text";
save [name, location, host] to: "save_data.csv" type: "csv";
save species_of(self) to: "save_csvfile.csv" type: "csv" header: false;
save species_of(self) to: "save_shapefile.shp" type: "shp" with: [name::"nameAgent", location::"locationAgent"] crs: "EPSG:4326";
save grid to: "save_grid.asc" type: "asc";
save grid to: "save_grid.tif" type: "geotiff";
save grid to: "save_grid.png" type: "image";
save
statement is of type: Single statementsave
statement can be embedded into: Behavior, Sequence of statements or action,save
statement embeds statements:to
(a label):data
(any type), (omissible) :rewrite
(boolean):save_batch
statement is of type: Batch methodsave_batch
statement can be embedded into: Experiment,save_batch
statement embeds statements:name
(any type), (omissible) : the name of an existing variable or attribute to be modifiedvalue
(any type): the value to affect to the variable or attributeAllows to assign a value to the variable or attribute specified
set
statement is of type: Single statementset
statement can be embedded into: chart, Behavior, Sequence of statements or action, Layer,set
statement embeds statements:The setup statement is used to define the set of instructions that will be executed before every [#test test].
species Tester {
int val_to_test;
setup {
val_to_test <- 0;
}
test t1 {
// [set of instructions, including asserts]
}
}
setup
statement is of type: Sequence of statements or actionsetup
statement can be embedded into: Species, Experiment, Model,setup
statement embeds statements:comodel
(file), (omissible) :repeat
(int):reset
(boolean):share
(list):until
(boolean):with_experiment
(string):with_input
(map):with_output
(map):Allows an agent, the sender agent (that can be the [Sections161#global world agent]), 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):
ask receiver_agent(s) {
// [statements]
}
simulate
statement is of type: Single statementsimulate
statement can be embedded into: chart, Experiment, Species, Behavior, Sequence of statements or action,simulate
statement embeds statements:name
(an identifier), (omissible) : the identifier of the socialize statementagent
(agent): the agent value of the created social linkdominance
(float): the dominance value of the created social linkfamiliarity
(float): the familiarity value of the created social linkliking
(float): the appreciation value of the created social linksolidarity
(float): the solidarity value of the created social linkwhen
(boolean): A boolean value to socialize only with a certain conditionenables to directly add a social link from a perceived agent.
socialize;
socialize
statement is of type: Single statementsocialize
statement can be embedded into: Behavior, Sequence of statements or action,socialize
statement embeds statements:equation
(an identifier), (omissible) : the equation system identifier to be numerically solvedcycle_length
(int): length of simulation cycle which will be synchronize with step of integrator (default value: 1)discretizing_step
(int): number of discrete between 2 steps of simulation (default value: 0)integrated_times
(list): time interval inside integration processintegrated_values
(list): list of variables’s value inside integration processmax_step
(float): maximal step, (used with dp853 method only), (sign is irrelevant, regardless of integration direction, forward or backward), the last step can be smaller than this valuemethod
(an identifier), takes values in: {Euler, ThreeEighthes, Midpoint, Gill, Luther, rk4, dp853, AdamsBashforth, AdamsMoulton, DormandPrince54, GraggBulirschStoer, HighamHall54}: integrate method (can be only “Euler”, “ThreeEighthes”, “Midpoint”, “Gill”, “Luther”, “rk4” or “dp853”, “AdamsBashforth”, “AdamsMoulton”, “DormandPrince54”, “GraggBulirschStoer”, “HighamHall54”) (default value: “rk4”)min_step
(float): minimal step, (used with dp853 method only), (sign is irrelevant, regardless of integration direction, forward or backward), the last step can be smaller than this valuescalAbsoluteTolerance
(float): allowed absolute error (used with dp853 method only)scalRelativeTolerance
(float): allowed relative error (used with dp853 method only)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 timeSolves all equations which matched the given name, with all systems of agents that should solved simultaneously.
solve SIR method: "rk4" step:0.001;
solve
statement is of type: Single statementsolve
statement can be embedded into: Behavior, Sequence of statements or action,solve
statement embeds statements:name
(an identifier), (omissible) : the identifier of the speciescell_height
(float): (grid only), the height of the cells of the gridcell_width
(float): (grid only), the width of the cells of the gridcompile
(boolean):control
(22): defines the architecture of the species (e.g. fsm…)edge_species
(species): In the case of a species defining a graph topology for its instances (nodes of the graph), specifies the species to use for representing the edgesfile
(file): (grid only), a bitmap file that will be loaded at runtime so that the value of each pixel can be assigned to the attribute ‘grid_value’frequency
(int): The execution frequency of the species (default value: 1). For instance, if frequency is set to 10, the population of agents will be executed only every 10 cycles.height
(int): (grid only), the height of the grid (in terms of agent number)mirrors
(any type in [list, species]): The species this species is mirroring. The population of this current species will be dependent of that of the species mirrored (i.e. agents creation and death are entirely taken in charge by GAMA with respect to the demographics of the species mirrored). In addition, this species is provided with an attribute called ‘target’, which allows each agent to know which agent of the mirrored species it is representing.neighbors
(int): (grid only), the chosen neighborhood (4, 6 or 8)neighbours
(int): (grid only), the chosen neighborhood (4, 6 or 8)parallel
(any type in [boolean, int]): (experimental) setting this facet to ‘true’ will allow this species to use concurrency when scheduling its agents; 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 has a default set in the preferences (Under Performances > Concurrency)parent
(species): the parent class (inheritance)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): 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 speciestopology
(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 redefinedtorus
(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 geometriesuse_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 versionuse_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.)width
(int): (grid only), the width of the grid (in terms of agent number)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.
species ant skills: [moving] control: fsm {
species node_agent mirrors: list(bug) parent: graph_node edge_species: edge_agent {
grid ant_grid width: gridwidth height: gridheight file: grid_file neighbors: 8 use_regular_agents: false {
grid ant_grid file: grid_file neighbors: 8 use_regular_agents: false {
species
statement is of type: Speciesspecies
statement can be embedded into: Model, Environment, Species,species
statement embeds statements:name
(an identifier), (omissible) : the identifier of the statefinal
(boolean): specifies whether the state is a final one (i.e. there is no transition from this state to another state) (default value= false)initial
(boolean): specifies whether the state is the initial one (default value = false)A state, like a reflex, can contains several statements that can be executed at each time step by the agent.
state s_init initial: true {
enter { write "Enter in" + state; }
write "Enter in" + state;
}
write state;
transition to: s1 when: (cycle > 2) {
write "transition s_init -> s1";
}
exit {
write "EXIT from "+state;
}
}
state s1 {
enter {write 'Enter in '+state;}
write state;
exit {write 'EXIT from '+state;}
}
state
statement is of type: Behaviorstate
statement can be embedded into: fsm, Species, Experiment, Model,state
statement embeds statements: enter, exit,message
(any type), (omissible) : Allows to display a necessarily short message in the status box in the upper left corner. No formatting characters (carriage returns, tabs, or Unicode characters) should be used, but a background color 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 againcolor
(rgb):The statement makes the agent output an arbitrary message in the status box.
status ('This is my status ' + self) color: #yellow;
status
statement is of type: Single statementstatus
statement can be embedded into: Behavior, Sequence of statements or action, Layer,status
statement embeds statements:value
(any type), (omissible) : an expressionThe “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).
switch an_expression {
match value1 {...}
match_one [value1, value2, value3] {...}
match_between [value1, value2] {...}
default {...}
}
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"; }
}
switch
statement is of type: Sequence of statements or actionswitch
statement can be embedded into: Behavior, Sequence of statements or action, Layer,switch
statement embeds statements: default, match,name
(an identifier), (omissible) :aggregation
(a label), takes values in: {min, max}: the agregation methoditer_max
(int): number of iterationsmaximize
(float): the value the algorithm tries to maximizeminimize
(float): the value the algorithm tries to minimizetabu_list_size
(int): size of the tabu listThis algorithm is an implementation of the Tabu Search algorithm. See the wikipedia article and [batch161 the batch dedicated page].
method tabu
instead of the expected tabu name: id
:method tabu [facet: value];
method tabu iter_max: 50 tabu_list_size: 5 maximize: food_gathered;
tabu
statement is of type: Batch methodtabu
statement can be embedded into: Experiment,tabu
statement embeds statements:name
(an identifier), (omissible) : the identifier of the taskweight
(float): the priority level of the taskAs 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.
task
statement is of type: Behaviortask
statement can be embedded into: weighted_tasks, sorted_tasks, probabilistic_tasks, Species, Experiment, Model,task
statement embeds statements:name
(an identifier), (omissible) : identifier of the testThe 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 (if GAMA is configured in the preferences that the program does not stop at the first exception).
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]
}
}
test
statement is of type: Behaviortest
statement can be embedded into: Species, Experiment, Model,test
statement embeds statements: assert,All the statements executed in the trace statement are displayed in the console.
trace
statement is of type: Sequence of statements or actiontrace
statement can be embedded into: Behavior, Sequence of statements or action, Layer,trace
statement embeds statements:to
(an identifier): the identifier of the next statewhen
(boolean), (omissible) : a condition to be fulfilled to have a transition to another given stateIn 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.
state s_init initial: true {
write state;
transition to: s1 when: (cycle > 2) {
write "transition s_init -> s1";
}
}
transition
statement is of type: Sequence of statements or actiontransition
statement can be embedded into: Sequence of statements or action, Behavior,transition
statement embeds statements:emotion
(546706): the emotion that will be copied with the contagionname
(an identifier), (omissible) : the identifier of the unconscious contagioncharisma
(float): The charisma value of the perceived agent (between 0 and 1)receptivity
(float): The receptivity value of the current agent (between 0 and 1)threshold
(float): The threshold value to make the contagionwhen
(boolean): A boolean value to get the emotion only with a certain conditionenables to directly copy an emotion presents in the perceived specie.
unconscious_contagion emotion:fearConfirmed;
unconscious_contagion emotion:fearConfirmed charisma: 0.5 receptivity: 0.5;
unconscious_contagion
statement is of type: Single statementunconscious_contagion
statement can be embedded into: Behavior, Sequence of statements or action,unconscious_contagion
statement embeds statements:name
(a label), (omissible) : the identifier of the user_commandaction
(26): the identifier of the action to be executed. This action should be accessible in the context in which the user_command is defined (an experiment, the global section or a species). A special case is allowed to maintain the compatibility with older versions of GAMA, when the user_command is declared in an experiment and the action is declared in ‘global’. In that case, all the simulations managed by the experiment will run the action in response to the user executing the commandcolor
(rgb): The color of the button to displaycontinue
(boolean): Whether or not the button, when clicked, should dismiss the user panel it is defined in. Has no effect in other contexts (menu, parameters, inspectors)when
(boolean): the condition that should be fulfilled (in addition to the user clicking it) in order to execute this actionwith
(map): the map of the parameters::values required by the actionAnywhere in the global block, in a species or in an (GUI) experiment, user_command statements allows to either call directly an existing action (with or without arguments) or to be followed by a block that describes what to do when this command is run.
user_command kill_myself action: some_action with: [arg1::val1, arg2::val2, ...];
user_command
statement is of type: Sequence of statements or actionuser_command
statement can be embedded into: user_panel, Species, Experiment, Model,user_command
statement embeds statements: user_input,name
(an identifier), (omissible) : The name of the panelinitial
(boolean): Whether or not this panel will be the initial oneUsed 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.
user_init
statement is of type: Behavioruser_init
statement can be embedded into: Species, Experiment, Model,user_init
statement embeds statements: user_panel,returns
(a new identifier): a new local variable containing the value given by the username
(a label), (omissible) : the displayed nameamong
(list): the set of acceptable values for the variableinit
(any type): the init valuemax
(float): the maximum valuemin
(float): the minimum valueslider
(boolean): Whether to display a slider or not when applicabletype
(a datatype identifier): the variable typeIt allows to let the user define the value of a variable.
user_panel "Advanced Control" {
user_input "Location" returns: loc type: point <- {0,0};
create cells number: 10 with: [location::loc];
}
user_input
statement is of type: Single statementuser_input
statement can be embedded into: user_command,user_input
statement embeds statements:name
(an identifier), (omissible) : The name of the panelinitial
(boolean): Whether or not this panel will be the initial oneIt 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.
user_panel default initial: true {
user_input 'Number' returns: number type: int <- 10;
ask (number among list(cells)){ do die; }
transition to: "Advanced Control" when: every (10);
}
user_panel "Advanced Control" {
user_input "Location" returns: loc type: point <- {0,0};
create cells number: 10 with: [location::loc];
}
user_panel
statement is of type: Behavioruser_panel
statement can be embedded into: fsm, user_first, user_last, user_init, user_only, Species, Experiment, Model,user_panel
statement embeds statements: user_command,topology
(topology), (omissible) : the topologyusing
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.
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);
}
using
statement is of type: Sequence of statements or actionusing
statement can be embedded into: chart, Behavior, Sequence of statements or action, Layer,using
statement embeds statements:name
(a new identifier), (omissible) : The name of the attributecategory
(a label): Soon to be deprecated. Declare the parameter in an experiment insteadconst
(boolean): Indicates whether this attribute can be subsequently modified or notfill_with
(any type):function
(any type): Used to specify an expression that will be evaluated each time the attribute is accessed. This facet is incompatible with both ‘init:’ and ‘update:’index
(a datatype identifier):init
(any type): The initial value of the attributeof
(a datatype identifier):on_change
(any type): Provides a block of statements that will be executed whenever the value of the attribute changesparameter
(a label): Soon to be deprecated. Declare the parameter in an experiment insteadsize
(any type in [int, point]):type
(a datatype identifier):update
(any type): An expression that will be evaluated each cycle to compute a new value for the attributevalue
(any type):Allows to declare an attribute of a species or an experiment
Variable_container
statement is of type: Variable (container)Variable_container
statement can be embedded into: Species, Experiment, Model,Variable_container
statement embeds statements:name
(a new identifier), (omissible) : The name of the attributeamong
(list): A list of constant values among which the attribute can take its valuecategory
(a label): Soon to be deprecated. Declare the parameter in an experiment insteadconst
(boolean): Indicates whether this attribute can be subsequently modified or notfunction
(any type in [int, float]): Used to specify an expression that will be evaluated each time the attribute is accessed. This facet is incompatible with both ‘init:’ and ‘update:’init
(any type in [int, float]): The initial value of the attributemax
(any type in [int, float]): The maximum value this attribute can take.min
(any type in [int, float]): The minimum value this attribute can takeon_change
(any type): Provides a block of statements that will be executed whenever the value of the attribute changesparameter
(a label): Soon to be deprecated. Declare the parameter in an experiment insteadstep
(int):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 attributevalue
(any type in [int, float]):Allows to declare an attribute of a species or experiment
Variable_number
statement is of type: Variable (number)Variable_number
statement can be embedded into: Species, Experiment, Model,Variable_number
statement embeds statements:name
(a new identifier), (omissible) : The name of the attributeamong
(list): A list of constant values among which the attribute can take its valuecategory
(a label): Soon to be deprecated. Declare the parameter in an experiment insteadconst
(boolean): Indicates whether this attribute can be subsequently modified or notfunction
(any type): Used to specify an expression that will be evaluated each time the attribute is accessed. This facet is incompatible with both ‘init:’ and ‘update:’index
(a datatype identifier): The type of the index used to retrieve elements if the type of the attribute is a container typeinit
(any type): The initial value of the attributeof
(a datatype identifier): The type of the elements contained in the type of this attribute if it is a container typeon_change
(any type): Provides a block of statements that will be executed whenever the value of the attribute changesparameter
(a label): Soon to be deprecated. Declare the parameter in an experiment insteadtype
(a datatype identifier): The type of this attribute. Can be combined with facets ‘of’ and ‘index’ to describe container typesupdate
(any type): An expression that will be evaluated each cycle to compute a new value for the attributevalue
(any type):Allows to declare an attribute of a species or an experiment
Variable_regular
statement is of type: Variable (regular)Variable_regular
statement can be embedded into: Species, Experiment, Model,Variable_regular
statement embeds statements:message
(string), (omissible) : the message to display as a warning.The statement makes the agent output an arbitrary message in the error view as a warning.
warn 'This is a warning from ' + self;
warn
statement is of type: Single statementwarn
statement can be embedded into: Behavior, Sequence of statements or action, Layer,warn
statement embeds statements: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 specifiedThe statement makes the agent output an arbitrary message in the console.
write 'This is a message from ' + self;
write
statement is of type: Single statementwrite
statement can be embedded into: Behavior, Sequence of statements or action, Layer,write
statement embeds statements: