Statements
This file is automatically generated from java files. Do Not Edit It.
Table of Contents​
=, abort, action, add, agents, annealing, ask, aspect, assert, benchmark, betad, break, browse, camera, capture, catch, category, chart, conscious_contagion, continue, coping, create, data, datalist, default, diffuse, diffusion, display, display_grid, do, do_rule, draw, else, emotional_contagion, enforcement, enter, equation, error, event, exit, experiment, exploration, focus, focus_on, genetic, global, graphics, grid, highlight, hill_climbing, if, image_layer, init, inspect, invoke, law, layout, let, light, loop, match, match_between, match_one, match_regex, mesh, migrate, monitor, morris, norm, output, output_file, overlay, parameter, perceive, permanent, plan, pso, put, reactive_tabu, reflex, release, remove, restore, return, rotation, rule, run, sanction, save, set, setup, sobol, socialize, solve, species, species_layer, start_simulation, state, status, stochanalyse, switch, tabu, task, test, text, trace, transition, try, unconscious_contagion, user_command, user_init, user_input, user_panel, using, Variable_container, Variable_number, Variable_regular, warn, write,
Statements by kinds​
- Batch method
- Behavior
- Experiment
- Layer
- agents, camera, chart, display_grid, event, graphics, image_layer, light, mesh, overlay, rotation, species_layer,
- Output
- Parameter
- Sequence of statements or action
- Single statement
- =, add, assert, break, category, conscious_contagion, continue, data, datalist, diffuse, diffusion, do, draw, emotional_contagion, enforcement, error, focus, focus_on, highlight, invoke, law, let, put, remove, restore, return, rule, save, set, socialize, solve, status, text, unconscious_contagion, user_input, warn, write,
- Species
- Variable (container)
- Variable (number)
- Variable (regular)
Statements by embedment​
- Behavior
- add, ask, assert, benchmark, capture, conscious_contagion, create, diffuse, do, emotional_contagion, enforcement, error, focus, focus_on, highlight, if, inspect, let, loop, migrate, put, release, remove, restore, return, run, save, set, socialize, solve, start_simulation, status, switch, trace, transition, try, unconscious_contagion, using, warn, write,
- Environment
- Experiment
- Layer
- Model
- action, aspect, coping, do_rule, equation, experiment, law, norm, output, perceive, plan, reflex, rule, run, sanction, setup, species, start_simulation, state, task, test, user_command, user_init, user_panel, Variable_container, Variable_number, Variable_regular,
- Output
- Sequence of statements or action
- add, ask, assert, assert, benchmark, break, capture, conscious_contagion, continue, create, data, datalist, diffuse, do, draw, emotional_contagion, enforcement, error, focus, focus_on, highlight, if, inspect, let, loop, migrate, put, release, remove, restore, return, save, set, socialize, solve, status, switch, trace, transition, try, unconscious_contagion, using, warn, write,
- Single statement
- Species
- action, aspect, coping, do_rule, equation, law, norm, perceive, plan, reflex, rule, run, sanction, setup, species, start_simulation, state, task, test, user_command, user_init, user_panel, Variable_container, Variable_number, Variable_regular,
- action
- aspect
- draw,
- chart
- display
- agents, camera, chart, display_grid, event, graphics, image_layer, light, mesh, overlay, rotation, species_layer,
- equation
- =,
- fsm
- if
- else,
- output
- parallel_bdi
- permanent
- probabilistic_tasks
- task,
- rules
- simple_bdi
- sorted_tasks
- task,
- species_layer
- state
- switch
- test
- try
- user_command
- user_first
- user_init
- user_last
- user_only
- user_panel
- weighted_tasks
- task,
General syntax​
A statement represents either a declaration or an imperative command. It consists in a keyword, followed by specific facets, some of them mandatory (in bold), some of them optional. One of the facet names can be omitted (the one denoted as omissible). It has to be the first one.
statement_keyword expression1 facet2: expression2 ... ;
or
statement_keyword facet1: expression1 facet2: expression2 ...;
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...;
}
=
Facets​
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)
Definition​
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.
Usages​
- The syntax of the = statement is a bit different from the other statements. It has to be used as follows (in an equation):
float t;
float S;
float I;
equation SI {
diff(S,t) = (- 0.3 * S * I / 100);
diff(I,t) = (0.3 * S * I / 100);
}
Embedments​
- The
=
statement is of type: Single statement - The
=
statement can be embedded into: equation, - The
=
statement embeds statements:
action​
Facets​
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)
Definition​
Allows to define in a species, model or experiment a new action that can be called elsewhere.
Usages​
- The simplest syntax to define an action that does not take any parameter and does not return anything is:
action simple_action {
// [set of statements]
}
- If the action needs some parameters, they can be specified betwee, braquets after the identifier of the action:
action action_parameters(int i, string s){
// [set of statements using i and s]
}
- If the action returns any value, the returned type should be used instead of the "action" keyword. A return statement inside the body of the action statement is mandatory.
int action_return_val(int i, string s){
// [set of statements using i and s]
return i + i;
}
- If virtual: is true, then the action is abstract, which means that the action is defined without body. A species containing at least one abstract action is abstract. Agents of this species cannot be created. The common use of an abstract action is to define an action that can be used by all its sub-species, which should redefine all abstract actions and implements its body.
species parent_species {
int virtual_action(int i, string s);
}
species children parent: parent_species {
int virtual_action(int i, string s) {
return i + i;
}
}
- See also: do,
Embedments​
- The
action
statement is of type: Sequence of statements or action - The
action
statement can be embedded into: Species, Experiment, Model, - The
action
statement embeds statements: assert, return,
add​
Facets​
to
(any type in [container, species, agent, geometry]): the left member of the addition assignment ('cont << expr;') is an expression cont that evaluates to a container (list, map, matrix, graph)item
(any type), (omissible) : the right member of the addition assignment ('cont << expr;') is an expression expr that evaluates to the element(s) to be added to the containerall
(any type): the symbol '<<+' allows to pass a container as item so as to add all its elements to the receiving containerat
(any type): the index at which to add the item can be specified using 'container[index]' and the symbol '+<-' must prefix the item (instead of '<<', which would be ambiguous if the container contains other containers)'
Definition​
A statement used to add items to containers. It can be written using the classic syntax (add ... to: ...
) or a compact one, which is now preferred.
- To add an element to a container (other than a matrix), use
container << element;
orcontainer <+ element;
(classic form:add element to: container;
) - To add all the elements contained in another container, use
container <<+ elements;
(classic form:add all: elements to: container;
) - To add an element to a container at a certain index, use
container[index] +<- element;
(classic form:add element at: index to: container;
)
Usages​
- The new element can be added either at the end of the container or at a particular position.
expr_container << expr; // Add expr at the end
expr_container[index] +<- expr; // Add expr at position index
- For lists, the index can only be integers
list<int> workingList <- [];
workingList[0] +<- 0; // workingList equals [0]
workingList[0] +<- 10; // workingList equals [10,0]
workingList[2] +<- 20; // workingList equals [10,0,20]
workingList <+ 50; // or workingList << 50; // workingList equals [10,0,20,50]
workingList <<+ [60,70]; // Add all the values in the list // workingList equals [10,0,20,50,60,70]
- Case of a map: As a map is basically a list of pairs key::value, we can also use the add statement on it. It is important to note that the behavior of the statement is slightly different, in particular in the use of the at facet, which denotes the key of the pair.
map<string,string> workingMap <- [];
workingMap['x'] +<- 'val1'; //equivalent to workingMap['x'] <- 'val1' // workingMap equals ["x"::"val1"]
- If no index is provided, a pair (expr_item::expr_item) will be added to the map. An important exception is the case where the expr_item is a pair itself: in this case, the pair is added.
workingMap << 'val2'; // workingMap equals ["x"::"val1", "val2"::"val2"]
workingMap << "5"::"val4"; // workingMap equals ["x"::"val1", "val2"::"val2", "5"::"val4"]
- Notice that, as the key should be unique, the addition of an item at an existing position (i.e. existing key) will only modify the value associated with the given key.
workingMap['x'] +<- "val3"; // workingMap equals ["x"::"val3", "val2"::"val2", "5"::"val4"]
- On a map, the all facet will add all the values of a container in the map: if the argument is a map itself, all its pairs will be added, otherwise a set of pairs <cont_value, cont_value> will be added
workingMap <<+ ["val4","val5"]; // workingMap equals ["x"::"val3", "val2"::"val2", "5"::"val4","val4"::"val4","val5"::"val5"]
- In case of a graph, it is advised to use the various edge(), node(), edges(), nodes() operators, which can build the correct objects to add to the graph
graph g <- as_edge_graph([{1,5}::{12,45}]);
g << edge({1,5}::{2,3});
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})]
g << node({5,5});
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})]
Embedments​
- The
add
statement is of type: Single statement - The
add
statement can be embedded into: chart, Behavior, Sequence of statements or action, Layer, - The
add
statement embeds statements:
agents​
Facets​
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 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. In case of negative value OpenGl will position the layer out of the environment.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)rotate
(float): Defines the angle of rotation of this layer, in degrees, around the z-axis.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 level of the layer (between 0 -- opaque -- and 1 -- fully transparent)visible
(boolean): Defines whether this layer is visible or not
Definition​
agents
allows the modeler to display only the agents that fulfill a given condition.
Usages​
- The general syntax is:
display my_display {
agents layer_name value: expression [additional options];
}
- For instance, in a segregation model,
agents
will only display unhappy agents:
display Segregation {
agents agentDisappear value: people as list where (each.is_happy = false) aspect: with_group_color;
}
- See also: display, chart, event, graphics, display_grid, image_layer, overlay, species_layer,
Embedments​
- The
agents
statement is of type: Layer - The
agents
statement can be embedded into: display, - The
agents
statement embeds statements: