#Operators (A to C)
This file is automatically generated from java files. Do Not Edit It.
Operators in the GAML language are used to compose complex expressions. An operator performs a function on one, two, or n operands (which are other expressions and thus may be themselves composed of operators) and returns the result of this function.
Most of them use a classical prefixed functional syntax (i.e. operator_name(operand1, operand2, operand3)
, see below), with the exception of arithmetic (e.g. +
, /
), logical (and
, or
), comparison (e.g. >
, <
), access (.
, [..]
) and pair (::
) operators, which require an infixed notation (i.e. operand1 operator_symbol operand1
).
The ternary functional if-else operator, ? :
, uses a special infixed syntax composed with two symbols (e.g. operand1 ? operand2 : operand3
). Two unary operators (-
and !
) use a traditional prefixed syntax that does not require parentheses unless the operand is itself a complex expression (e.g. ` - 10,
! (operand1 or operand2)`).
Finally, special constructor operators ({...}
for constructing points, [...]
for constructing lists and maps) will require their operands to be placed between their two symbols (e.g. {1,2,3}
, [operand1, operand2, ..., operandn]
or [key1::value1, key2::value2... keyn::valuen]
).
With the exception of these special cases above, the following rules apply to the syntax of operators:
operator_name(operand1)
)operator_name(operand1, operand2)
) or the infixed syntax (e.g. operand1 operator_name operand2
) can be used.operator_name(operand1, operand2, ..., operand)
) or a special infixed syntax with the first operand on the left-hand side of the operator name (e.g. operand1 operator_name(operand2, ..., operand)
) can be used.All of these alternative syntaxes are completely equivalent.
Operators in GAML are purely functional, i.e. they are guaranteed to not have any side effects on their operands. For instance, the shuffle
operator, which randomizes the positions of elements in a list, does not modify its list operand but returns a new shuffled list.
The priority of operators determines, in the case of complex expressions composed of several operators, which one(s) will be evaluated first.
GAML follows in general the traditional priorities attributed to arithmetic, boolean, comparison operators, with some twists. Namely:
::
, used to compose pairs of operands, have the lowest priority of all operators (e.g. a > b :: b > c
will return a pair of boolean values, which means that the two comparisons are evaluated before the operator applies. Similarly, [a > 10, b > 5]
will return a list of boolean values.?:
operator, the functional if-else (e.g. ` a > b ? a + 10 : a - 10` will return the result of the if-else).and
and or
(e.g. a > b or b > c
will return the value of the test)>
, <
, <=
, >=
, =
, !=
)-
and !
.
and []
(e.g. {1,2,3}.x > 20 + {4,5,6}.y
will return the result of the comparison between the x and y ordinates of the two points)Actions defined in species can be used as operators, provided they are called on the correct agent. The syntax is that of normal functional operators, but the agent that will perform the action must be added as the first operand.
For instance, if the following species is defined:
species spec1 {
int min(int x, int y) {
return x > y ? x : y;
}
}
Any agent instance of spec1 can use min
as an operator (if the action conflicts with an existing operator, a warning will be emitted). For instance, in the same model, the following line is perfectly acceptable:
global {
init {
create spec1;
spec1 my_agent <- spec1[0];
int the_min <- my_agent min(10,20); // or min(my_agent, 10, 20);
}
}
If the action doesn’t have any operands, the syntax to use is my_agent the_action()
. Finally, if it does not return a value, it might still be used but is considering as returning a value of type unknown
(e.g. unknown result <- my_agent the_action(op1, op2);
).
Note that due to the fact that actions are written by modelers, the general functional contract is not respected in that case: actions might perfectly have side effects on their operands (including the agent).
box, cone3D, cube, cylinder, dem, hexagon, pyramid, rgb_to_xyz, set_z, sphere, teapot,
-, /, [^](OperatorsAC#^), [](OperatorsAC#), +, abs, acos, asin, atan, atan2, ceil, cos, cos_rad, div, even, exp, fact, floor, hypot, is_finite, is_number, ln, log, mod, round, signum, sin, sin_rad, sqrt, tan, tan_rad, tanh, with_precision,
and, eval_when, get_about, get_agent, get_agent_cause, get_decay, get_dominance, get_familiarity, get_intensity, get_lifetime, get_liking, get_praiseworthiness, get_priority, get_solidarity, get_super_intention, new_emotion, new_predicate, new_social_link, or, set_about, set_agent, set_agent_cause, set_decay, set_dominance, set_familiarity, set_intensity, set_liking, set_solidarity, set_truth, with_lifetime, with_praiseworthiness, with_priority, with_values,
as, as_int, as_matrix, font, is, is_skill, list_with, matrix_with, species, to_gaml, topology,
-, /, [](OperatorsAC#), +, blend, brewer_colors, brewer_palettes, grayscale, hsb, mean, median, rgb, rnd_color, sum,
-, ::, +, accumulate, among, at, collect, contains, contains_all, contains_any, count, distinct, empty, every, first, first_with, get, group_by, in, index_by, inter, interleave, internal_at, internal_integrated_value, last, last_with, length, max, max_of, mean, mean_of, median, min, min_of, mul, one_of, product_of, range, reverse, shuffle, sort_by, sum, sum_of, union, variance_of, where, with_max_of, with_min_of,
-, !=, +, <, <=, =, >, >=, after, before, between, every, milliseconds_between, minus_days, minus_hours, minus_minutes, minus_months, minus_ms, minus_weeks, minus_years, months_between, plus_days, plus_hours, plus_minutes, plus_months, plus_ms, plus_weeks, plus_years, since, to, until, years_between,
diff, diff2, internal_zero_order_equation,
crs, file, file_exists, folder, get, new_folder, osm_file, read, writable,
add_edge, add_node, adjacency, agent_from_geometry, all_pairs_shortest_path, alpha_index, as_distance_graph, as_edge_graph, as_intersection_graph, as_path, beta_index, betweenness_centrality, biggest_cliques_of, connected_components_of, connectivity_index, contains_edge, contains_vertex, degree_of, directed, edge, edge_between, edge_betweenness, edges, gamma_index, generate_barabasi_albert, generate_complete_graph, generate_watts_strogatz, grid_cells_to_graph, in_degree_of, in_edges_of, layout, load_graph_from_file, load_shortest_paths, maximal_cliques_of, nb_cycles, neighbors_of, node, nodes, out_degree_of, out_edges_of, path_between, paths_between, predecessors_of, remove_node_from, rewire_n, source_of, spatial_graph, successors_of, sum, target_of, undirected, use_cache, weight_of, with_optimizer_type, with_weights,
as_4_grid, as_grid, as_hexagonal_grid, grid_at, path_between,
accumulate, as_map, collect, count, distribution_of, distribution_of, distribution_of, distribution2d_of, distribution2d_of, distribution2d_of, first_with, frequency_of, group_by, index_by, last_with, max_of, mean_of, min_of, product_of, sort_by, sum_of, variance_of, where, with_max_of, with_min_of,
copy_between, index_of, last_index_of,
fuzzy_kappa, fuzzy_kappa_sim, kappa, kappa_sim, percent_absolute_deviation,
as_map, index_of, last_index_of,
-, /, ., [](OperatorsAC#), +, append_horizontally, append_vertically, column_at, columns_list, determinant, eigenvalues, index_of, inverse, last_index_of, row_at, rows_list, shuffle, trace, transpose,
electre_DM, evidence_theory_DM, promethee_DM, weighted_means_DM,
agent_from_geometry, all_pairs_shortest_path, as_path, load_shortest_paths, path_between, path_to, paths_between, use_cache,
-, /, [](OperatorsAC#), +, <, <=, >, >=, add_point, angle_between, any_location_in, centroid, closest_points_with, farthest_point_to, grid_at, norm, point, points_along, points_at, points_on,
binomial, flip, gauss, poisson, rnd, rnd_choice, sample, shuffle, skew_gauss, truncated_gauss,
arc, box, circle, cone, cone3D, cross, cube, curve, cylinder, ellipse, envelope, geometry_collection, hexagon, line, link, plan, polygon, polyhedron, pyramid, rectangle, sphere, square, squircle, teapot, triangle,
-, [](OperatorsAC#), +, add_point, agent_closest_to, agent_farthest_to, agents_at_distance, agents_inside, agents_overlapping, angle_between, any_location_in, arc, around, as_4_grid, as_grid, as_hexagonal_grid, at_distance, at_location, box, centroid, circle, clean, closest_points_with, closest_to, cone, cone3D, convex_hull, covers, cross, crosses, crs, CRS_transform, cube, curve, cylinder, dem, direction_between, disjoint_from, distance_between, distance_to, ellipse, envelope, farthest_point_to, farthest_to, geometry_collection, gini, hexagon, hierarchical_clustering, IDW, inside, inter, intersects, line, link, masked_by, moran, neighbors_at, neighbors_of, overlapping, overlaps, partially_overlaps, path_between, path_to, plan, points_along, points_at, points_on, polygon, polyhedron, pyramid, rectangle, rgb_to_xyz, rotated_by, round, scaled_to, set_z, simple_clustering_by_distance, simplification, skeletonize, smooth, sphere, split_at, split_geometry, split_lines, square, squircle, teapot, to_GAMA_CRS, to_rectangles, to_squares, touches, towards, transformed_by, translated_by, triangle, triangulate, union, using, voronoi, with_precision, without_holes,
covers, crosses, intersects, partially_overlaps, touches,
agent_closest_to, agent_farthest_to, agents_at_distance, agents_inside, agents_overlapping, at_distance, closest_to, farthest_to, inside, neighbors_at, neighbors_of, overlapping,
direction_between, distance_between, distance_to, path_between, path_to, towards,
hierarchical_clustering, simple_clustering_by_distance,
-, [](OperatorsAC#), +, as_4_grid, as_grid, as_hexagonal_grid, at_location, clean, convex_hull, CRS_transform, rotated_by, scaled_to, simplification, skeletonize, smooth, split_geometry, split_lines, to_GAMA_CRS, to_rectangles, to_squares, transformed_by, translated_by, triangulate, voronoi, without_holes,
index_of, last_index_of, of_generic_species, of_species,
build, corR, dbscan, distribution_of, distribution2d_of, frequency_of, gamma_rnd, geometric_mean, gini, harmonic_mean, hierarchical_clustering, kmeans, kurtosis, max, mean, mean_deviation, meanR, median, min, moran, mul, predict, simple_clustering_by_distance, skewness, standard_deviation, sum, variance,
+, <, <=, >, >=, at, char, contains, contains_all, contains_any, copy_between, date, empty, first, in, indented_by, index_of, is_number, last, last_index_of, length, lower_case, replace, replace_regex, reverse, sample, shuffle, split_with, string, upper_case,
., command, copy, dead, eval_gaml, every, user_input,
-
-
(int
) —> int
-
(point
) —> point
-
(float
) —> float
int
-
float
—> float
-
(int
, float
) —> float
int
-
int
—> int
-
(int
, int
) —> int
matrix
-
float
—> matrix
-
(matrix
, float
) —> matrix
float
-
matrix
—> matrix
-
(float
, matrix
) —> matrix
date
-
float
—> date
-
(date
, float
) —> date
species
-
agent
—> container
-
(species
, agent
) —> container
date
-
date
—> float
-
(date
, date
) —> float
matrix
-
matrix
—> matrix
-
(matrix
, matrix
) —> matrix
point
-
int
—> point
-
(point
, int
) —> point
date
-
int
—> date
-
(date
, int
) —> date
point
-
float
—> point
-
(point
, float
) —> point
float
-
float
—> float
-
(float
, float
) —> float
rgb
-
rgb
—> rgb
-
(rgb
, rgb
) —> rgb
int
-
matrix
—> matrix
-
(int
, matrix
) —> matrix
container
-
container
—> container
-
(container
, container
) —> container
rgb
-
int
—> rgb
-
(rgb
, int
) —> rgb
container
-
unknown
—> container
-
(container
, unknown
) —> container
point
-
point
—> point
-
(point
, point
) —> point
float
-
int
—> float
-
(float
, int
) —> float
geometry
-
geometry
—> geometry
-
(geometry
, geometry
) —> geometry
matrix
-
int
—> matrix
-
(matrix
, int
) —> matrix
geometry
-
float
—> geometry
-
(geometry
, float
) —> geometry
map
-
map
—> map
-
(map
, map
) —> map
map
-
pair
—> map
-
(map
, pair
) —> map
geometry
-
container<geometry>
—> geometry
-
(geometry
, container<geometry>
) —> geometry
Returns the difference of the two operands. If it is used as an unary operator, it returns the opposite of the operand.
The behavior of the operator depends on the type of the operands.
int var7 <- 1 - 1; // var7 equals 0
int var8 <- 1.0 - 1; // var8 equals 0.0
int var9 <- 3.7 - 1.2; // var9 equals 2.5
int var10 <- 3 - 1.2; // var10 equals 1.8
float var11 <- date1 - date2; // var11 equals 598
date1 - 200
point var13 <- {1, 2} - 4.5; // var13 equals {-3.5, -2.5, -4.5}
point var14 <- {1, 2} - 4; // var14 equals {-3.0,-2.0,-4.0}
rgb var15 <- rgb([255, 128, 32]) - rgb('red'); // var15 equals rgb([0,128,32])
matrix var16 <- 3.5 - matrix([[2,5],[3,4]]); // var16 equals matrix([[1.5,-1.5],[0.5,-0.5]])
list<int> var17 <- [1,2,3,4,5,6] - [2,4,9]; // var17 equals [1,3,5,6]
list<int> var18 <- [1,2,3,4,5,6] - [0,8]; // var18 equals [1,2,3,4,5,6]
rgb var19 <- rgb([255, 128, 32]) - 3; // var19 equals rgb([252,125,29])
list<int> var20 <- [1,2,3,4,5,6] - 2; // var20 equals [1,3,4,5,6]
list<int> var21 <- [1,2,3,4,5,6] - 0; // var21 equals [1,2,3,4,5,6]
point var22 <- {1, 2} - {4, 5}; // var22 equals {-3.0, -3.0}
geometry var23 <- geom1 - geom2; // var23 equals a geometry corresponding to difference between geom1 and geom2
geometry var24 <- shape - 5; // var24 equals a geometry corresponding to the geometry of the agent applying the operator reduced by a distance of 5
geometry var25 <- rectangle(10,10) - [circle(2), square(2)]; // var25 equals rectangle(10,10) - (circle(2) + square(2))
int var0 <- - (-56); // var0 equals 56
point var1 <- -{3.0,5.0}; // var1 equals {-3.0,-5.0}
point var2 <- -{1.0,6.0,7.0}; // var2 equals {-1.0,-6.0,-7.0}
map var3 <- ['a'::1,'b'::2] - ['b'::2]; // var3 equals ['a'::1]
map var4 <- ['a'::1,'b'::2] - ['b'::2,'c'::3]; // var4 equals ['a'::1]
map var5 <- ['a'::1,'b'::2] - ('b'::2); // var5 equals ['a'::1]
map var6 <- ['a'::1,'b'::2] - ('c'::3); // var6 equals ['a'::1,'b'::2]
+, [](OperatorsAC#), /, milliseconds_between, -,
:
unknown
:
unknown
—> unknown
:
(unknown
, unknown
) —> unknown
?,
::
any expression
::
any expression
—> pair
::
(any expression
, any expression
) —> pair
produces a new pair combining the left and the right operands
!
!
(bool
) —> bool
opposite boolean value.
bool var0 <- ! (true); // var0 equals false
!=
float
!=
float
—> bool
!=
(float
, float
) —> bool
unknown
!=
unknown
—> bool
!=
(unknown
, unknown
) —> bool
date
!=
date
—> bool
!=
(date
, date
) —> bool
float
!=
int
—> bool
!=
(float
, int
) —> bool
int
!=
float
—> bool
!=
(int
, float
) —> bool
true if both operands are different, false otherwise
bool var0 <- 3.0 != 3.0; // var0 equals false
bool var1 <- 4.0 != 4.7; // var1 equals true
bool var2 <- [2,3] != [2,3]; // var2 equals false
bool var3 <- [2,4] != [2,3]; // var3 equals true
#now != #now minus_hours 1 :- true
bool var5 <- 3.0 != 3; // var5 equals false
bool var6 <- 4.7 != 4; // var6 equals true
bool var7 <- 3 != 3.0; // var7 equals false
bool var8 <- 4 != 4.7; // var8 equals true
?
bool
?
any expression
—> unknown
?
(bool
, any expression
) —> unknown
It is used in combination with the : operator: if the left-hand operand evaluates to true, returns the value of the left-hand operand of the :, otherwise that of the right-hand operand of the :
These functional tests can be combined together.
list<string> var0 <- [10, 19, 43, 12, 7, 22] collect ((each > 20) ? 'above' : 'below'); // var0 equals ['below', 'below', 'above', 'below', 'below', 'above']
rgb color <- (flip(0.3) ? #red : (flip(0.9) ? #blue : #green));
:,
/
rgb
/
float
—> rgb
/
(rgb
, float
) —> rgb
float
/
int
—> float
/
(float
, int
) —> float
point
/
float
—> point
/
(point
, float
) —> point
int
/
int
—> float
/
(int
, int
) —> float
int
/
float
—> float
/
(int
, float
) —> float
matrix
/
float
—> matrix
/
(matrix
, float
) —> matrix
point
/
int
—> point
/
(point
, int
) —> point
matrix
/
matrix
—> matrix
/
(matrix
, matrix
) —> matrix
matrix
/
int
—> matrix
/
(matrix
, int
) —> matrix
float
/
float
—> float
/
(float
, float
) —> float
rgb
/
int
—> rgb
/
(rgb
, int
) —> rgb
Returns the division of the two operands.
rgb var0 <- rgb([255, 128, 32]) / 2.5; // var0 equals rgb([102,51,13])
point var1 <- {5, 7.5} / 2.5; // var1 equals {2, 3}
point var2 <- {2,5} / 4; // var2 equals {0.5,1.25}
float var3 <- 3 / 5.0; // var3 equals 0.6
rgb var4 <- rgb([255, 128, 32]) / 2; // var4 equals rgb([127,64,16])
.
matrix
.
matrix
—> matrix
.
(matrix
, matrix
) —> matrix
agent
.
any expression
—> unknown
.
(agent
, any expression
) —> unknown
It has two different uses: it can be the dot product between 2 matrices or return an evaluation of the expression (right-hand operand) in the scope the given agent.
matrix var0 <- matrix([[1,1],[1,2]]) . matrix([[1,1],[1,2]]); // var0 equals matrix([[2,3],[3,5]])
unknown var1 <- agent1.location; // var1 equals the location of the agent agent1
map(nil).keys
^
int
^
float
—> float
^
(int
, float
) —> float
float
^
float
—> float
^
(float
, float
) —> float
int
^
int
—> float
^
(int
, int
) —> float
float
^
int
—> float
^
(float
, int
) —> float
Returns the value (always a float) of the left operand raised to the power of the right operand.
float var1 <- 2 ^ 3; // var1 equals 8.0
float var0 <- 4.84 ^ 0.5; // var0 equals 2.2
[](OperatorsAC#), sqrt,
@
Same signification as at
*
int
*
int
—> int
*
(int
, int
) —> int
matrix
*
int
—> matrix
*
(matrix
, int
) —> matrix
point
*
point
—> float
*
(point
, point
) —> float
int
*
float
—> float
*
(int
, float
) —> float
float
*
float
—> float
*
(float
, float
) —> float
matrix
*
matrix
—> matrix
*
(matrix
, matrix
) —> matrix
point
*
int
—> point
*
(point
, int
) —> point
float
*
matrix
—> matrix
*
(float
, matrix
) —> matrix
geometry
*
point
—> geometry
*
(geometry
, point
) —> geometry
point
*
float
—> point
*
(point
, float
) —> point
int
*
matrix
—> matrix
*
(int
, matrix
) —> matrix
float
*
int
—> float
*
(float
, int
) —> float
rgb
*
int
—> rgb
*
(rgb
, int
) —> rgb
matrix
*
float
—> matrix
*
(matrix
, float
) —> matrix
geometry
*
float
—> geometry
*
(geometry
, float
) —> geometry
Returns the product of the two operands.
int var1 <- 1 * 1; // var1 equals 1
float var2 <- {2,5} * {4.5, 5}; // var2 equals 34.0
point var3 <- {2,5} * 4; // var3 equals {8.0, 20.0}
point var4 <- {2, 4} * 2.5; // var4 equals {5.0, 10.0}
geometry var5 <- shape * {0.5,0.5,2}; // var5 equals a geometry corresponding to the geometry of the agent applying the operator scaled by a coefficient of 0.5 in x, 0.5 in y and 2 in z
matrix<float> m <- (3.5 * matrix([[2,5],[3,4]])); //m equals matrix([[7.0,17.5],[10.5,14]])
rgb var7 <- rgb([255, 128, 32]) * 2; // var7 equals rgb([255,255,64])
geometry var8 <- circle(10) * 2; // var8 equals circle(20)
float var0 <- 2.5 * 2; // var0 equals 5.0
+
string
+
string
—> string
+
(string
, string
) —> string
date
+
float
—> date
+
(date
, float
) —> date
map
+
pair
—> map
+
(map
, pair
) —> map
int
+
matrix
—> matrix
+
(int
, matrix
) —> matrix
point
+
int
—> point
+
(point
, int
) —> point
rgb
+
rgb
—> rgb
+
(rgb
, rgb
) —> rgb
geometry
+
float
—> geometry
+
(geometry
, float
) —> geometry
matrix
+
float
—> matrix
+
(matrix
, float
) —> matrix
geometry
+
geometry
—> geometry
+
(geometry
, geometry
) —> geometry
map
+
map
—> map
+
(map
, map
) —> map
float
+
float
—> float
+
(float
, float
) —> float
float
+
int
—> float
+
(float
, int
) —> float
matrix
+
matrix
—> matrix
+
(matrix
, matrix
) —> matrix
date
+
string
—> string
+
(date
, string
) —> string
matrix
+
int
—> matrix
+
(matrix
, int
) —> matrix
int
+
int
—> int
+
(int
, int
) —> int
string
+
unknown
—> string
+
(string
, unknown
) —> string
point
+
point
—> point
+
(point
, point
) —> point
float
+
matrix
—> matrix
+
(float
, matrix
) —> matrix
int
+
float
—> float
+
(int
, float
) —> float
point
+
float
—> point
+
(point
, float
) —> point
rgb
+
int
—> rgb
+
(rgb
, int
) —> rgb
date
+
int
—> date
+
(date
, int
) —> date
container
+
container
—> container
+
(container
, container
) —> container
container
+
unknown
—> container
+
(container
, unknown
) —> container
+
(geometry
, float
, int
) —> geometry
+
(geometry
, float
, int
, int
) —> geometry
Returns the sum, union or concatenation of the two operands.
geometry var4 <- circle(5) + (5,32); // var4 equals circle(10)
matrix var5 <- 3.5 + matrix([[2,5],[3,4]]); // var5 equals matrix([[5.5,8.5],[6.5,7.5]])
rgb var6 <- rgb([255, 128, 32]) + rgb('red'); // var6 equals rgb([255,128,32])
geometry var7 <- circle(5) + 5; // var7 equals circle(10)
geometry var8 <- geom1 + geom2; // var8 equals a geometry corresponding to union between geom1 and geom2
int var9 <- 1 + 1; // var9 equals 2
int var10 <- 1.0 + 1; // var10 equals 2.0
int var11 <- 1.0 + 2.5; // var11 equals 3.5
string var12 <- "hello " + 12; // var12 equals "hello 12"
point var13 <- {1, 2} + {4, 5}; // var13 equals {5.0, 7.0}
point var14 <- {1, 2} + 4; // var14 equals {5.0, 6.0,4.0}
point var15 <- {1, 2} + 4.5; // var15 equals {5.5, 6.5,4.5}
rgb var16 <- rgb([255, 128, 32]) + 3; // var16 equals rgb([255,131,35])
geometry var17 <- circle(5) + (5,32,#round); // var17 equals circle(10)
date1 + 200
list<int> var19 <- [1,2,3,4,5,6] + [2,4,9]; // var19 equals [1,2,3,4,5,6,2,4,9]
list<int> var20 <- [1,2,3,4,5,6] + [0,8]; // var20 equals [1,2,3,4,5,6,0,8]
list<int> var21 <- [1,2,3,4,5,6] + 2; // var21 equals [1,2,3,4,5,6,2]
list<int> var22 <- [1,2,3,4,5,6] + 0; // var22 equals [1,2,3,4,5,6,0]
map var0 <- ['a'::1,'b'::2] + ('c'::3); // var0 equals ['a'::1,'b'::2,'c'::3]
map var1 <- ['a'::1,'b'::2] + ('c'::3); // var1 equals ['a'::1,'b'::2,'c'::3]
map var2 <- ['a'::1,'b'::2] + ['c'::3]; // var2 equals ['a'::1,'b'::2,'c'::3]
map var3 <- ['a'::1,'b'::2] + [5::3.0]; // var3 equals ['a'::1.0,'b'::2.0,5::3.0]
<
float
<
int
—> bool
<
(float
, int
) —> bool
int
<
int
—> bool
<
(int
, int
) —> bool
point
<
point
—> bool
<
(point
, point
) —> bool
int
<
float
—> bool
<
(int
, float
) —> bool
date
<
date
—> bool
<
(date
, date
) —> bool
float
<
float
—> bool
<
(float
, float
) —> bool
string
<
string
—> bool
<
(string
, string
) —> bool
true if the left-hand operand is less than the right-hand operand, false otherwise.
bool var5 <- {5,7} < {4,6}; // var5 equals false
bool var6 <- {5,7} < {4,8}; // var6 equals false
bool var7 <- 'abc' < 'aeb'; // var7 equals true
bool var0 <- 3.5 < 7; // var0 equals true
bool var1 <- 3 < 7; // var1 equals true
bool var2 <- 3 < 2.5; // var2 equals false
#now < #now minus_hours 1 :- false
bool var4 <- 3.5 < 7.6; // var4 equals true
<=
string
<=
string
—> bool
<=
(string
, string
) —> bool
date
<=
date
—> bool
<=
(date
, date
) —> bool
float
<=
float
—> bool
<=
(float
, float
) —> bool
int
<=
int
—> bool
<=
(int
, int
) —> bool
int
<=
float
—> bool
<=
(int
, float
) —> bool
float
<=
int
—> bool
<=
(float
, int
) —> bool
point
<=
point
—> bool
<=
(point
, point
) —> bool
true if the left-hand operand is less or equal than the right-hand operand, false otherwise.
bool var5 <- 'abc' <= 'aeb'; // var5 equals true
bool var6 <- {5,7} <= {4,6}; // var6 equals false
bool var7 <- {5,7} <= {4,8}; // var7 equals false
#now <= #now minus_hours 1 :- false
bool var1 <- 3.5 <= 3.5; // var1 equals true
bool var2 <- 3 <= 7; // var2 equals true
bool var3 <- 3 <= 2.5; // var3 equals false
bool var4 <- 7.0 <= 7; // var4 equals true
<>
Same signification as !=
=
date
=
date
—> bool
=
(date
, date
) —> bool
int
=
float
—> bool
=
(int
, float
) —> bool
unknown
=
unknown
—> bool
=
(unknown
, unknown
) —> bool
float
=
float
—> bool
=
(float
, float
) —> bool
float
=
int
—> bool
=
(float
, int
) —> bool
int
=
int
—> bool
=
(int
, int
) —> bool
returns true if both operands are equal, false otherwise returns true if both operands are equal, false otherwise
bool var0 <- [2,3] = [2,3]; // var0 equals true
#now = #now minus_hours 1 :- false
bool var2 <- 3 = 3.0; // var2 equals true
bool var3 <- 4 = 4.7; // var3 equals false
bool var4 <- 4.5 = 4.7; // var4 equals false
bool var5 <- 4.7 = 4; // var5 equals false
bool var6 <- 4 = 5; // var6 equals false
>
int
>
float
—> bool
>
(int
, float
) —> bool
float
>
float
—> bool
>
(float
, float
) —> bool
string
>
string
—> bool
>
(string
, string
) —> bool
int
>
int
—> bool
>
(int
, int
) —> bool
date
>
date
—> bool
>
(date
, date
) —> bool
point
>
point
—> bool
>
(point
, point
) —> bool
float
>
int
—> bool
>
(float
, int
) —> bool
true if the left-hand operand is greater than the right-hand operand, false otherwise.
bool var0 <- 'abc' > 'aeb'; // var0 equals false
bool var1 <- {5,7} > {4,6}; // var1 equals true
bool var2 <- {5,7} > {4,8}; // var2 equals false
bool var3 <- 3 > 2.5; // var3 equals true
bool var4 <- 3.5 > 7.6; // var4 equals false
bool var5 <- 3 > 7; // var5 equals false
#now > #now minus_hours 1 :- true
bool var7 <- 3.5 > 7; // var7 equals false
>=
float
>=
int
—> bool
>=
(float
, int
) —> bool
int
>=
int
—> bool
>=
(int
, int
) —> bool
int
>=
float
—> bool
>=
(int
, float
) —> bool
string
>=
string
—> bool
>=
(string
, string
) —> bool
date
>=
date
—> bool
>=
(date
, date
) —> bool
float
>=
float
—> bool
>=
(float
, float
) —> bool
point
>=
point
—> bool
>=
(point
, point
) —> bool
true if the left-hand operand is greater or equal than the right-hand operand, false otherwise.
bool var5 <- 'abc' >= 'aeb'; // var5 equals false
bool var6 <- 'abc' >= 'abc'; // var6 equals true
bool var7 <- {5,7} >= {4,6}; // var7 equals true
bool var8 <- {5,7} >= {4,8}; // var8 equals false
bool var0 <- 3.5 >= 7; // var0 equals false
bool var1 <- 3 >= 7; // var1 equals false
bool var2 <- 3 >= 2.5; // var2 equals true
#now >= #now minus_hours 1 :- true
bool var4 <- 3.5 >= 3.5; // var4 equals true
abs
abs
(int
) —> int
abs
(float
) —> float
Returns the absolute value of the operand (so a positive int or float depending on the type of the operand).
int var0 <- abs (-10); // var0 equals 10
int var1 <- abs (10); // var1 equals 10
float var3 <- abs (200 * -1 + 0.5); // var3 equals 199.5
accumulate
container
accumulate
any expression
—> container
accumulate
(container
, any expression
) —> container
returns a new flat list, in which each element is the evaluation of the right-hand operand. If this evaluation returns a list, the elements of this result are added directly to the list returned
accumulate is dedicated to the application of a same computation on each element of a container (and returns a list). In the right-hand operand, the keyword each can be used to represent, in turn, each of the left-hand operand elements.
container var0 <- [a1,a2,a3] accumulate (each neighbors_at 10); // var0 equals a flat list of all the neighbors of these three agents
list<int> var1 <- [1,2,4] accumulate ([2,4]); // var1 equals [2,4,2,4,2,4]
list<int> var2 <- [1,2,4] accumulate (each * 2); // var2 equals [2,4,8]
acos
acos
(float
) —> float
acos
(int
) —> float
Returns the value (in the interval [0,180], in decimal degrees) of the arccos of the operand (which should be in [-1,1]).
float var0 <- acos (0); // var0 equals 90.0
action
action
(any
) —> action
Casts the operand into the type action
add_days
Same signification as plus_days
add_edge
graph
add_edge
pair
—> graph
add_edge
(graph
, pair
) —> graph
add an edge between a source vertex and a target vertex (resp. the left and the right element of the pair operand)
if the edge already exists, the graph is unchanged
graph <- graph add_edge (source::target);
add_hours
Same signification as plus_hours
add_minutes
Same signification as plus_minutes
add_months
Same signification as plus_months
add_ms
Same signification as plus_ms
add_node
graph
add_node
geometry
—> graph
add_node
(graph
, geometry
) —> graph
adds a node in a graph.
graph var0 <- graph add_node node(0) ; // var0 equals the graph with node(0)
add_point
geometry
add_point
point
—> geometry
add_point
(geometry
, point
) —> geometry
A new geometry resulting from the addition of the right point (coordinate) to the left-hand geometry. Note that adding a point to a line or polyline will always return a closed contour. Also note that the position at which the added point will appear in the geometry is not necessarily the last one, as points are always ordered in a clockwise fashion in geometries
geometry var0 <- polygon([{10,10},{10,20},{20,20}]) add_point {20,10}; // var0 equals polygon([{10,10},{10,20},{20,20},{20,10}])
add_seconds
Same signification as +
add_weeks
Same signification as plus_weeks
add_years
Same signification as plus_years
adjacency
adjacency
(graph
) —> matrix<float>
adjacency matrix of the given graph.
after
after
(date
) —> bool
any expression
after
date
—> bool
after
(any expression
, date
) —> bool
Returns true if the current_date of the model is strictly after the date passed in argument. Synonym of ‘current_date > argument’. Can be used in its composed form with 2 arguments to express the lower boundary for the computation of a frequency. Note that only dates strictly after this one will be tested against the frequency
reflex when: after(starting_date) {} -: will always be run after the first step
reflex when: false after(starting date + #10days) {} -: will not be run after this date. Better to use 'until' or 'before' in that case
every(2#days) after (starting_date + 1#day) // the computation will return true every two days (using the starting_date of the model as the starting point) only for the dates strictly after this starting_date + 1#day
agent
agent
(any
) —> agent
Casts the operand into the type agent
agent_closest_to
agent_closest_to
(unknown
) —> agent
An agent, the closest to the operand (casted as a geometry).
the distance is computed in the topology of the calling agent (the agent in which this operator is used), with the distance algorithm specific to the topology.
agent var0 <- agent_closest_to(self); // var0 equals the closest agent to the agent applying the operator.
neighbors_at, neighbors_of, agents_inside, agents_overlapping, closest_to, inside, overlapping,
agent_farthest_to
agent_farthest_to
(unknown
) —> agent
An agent, the farthest to the operand (casted as a geometry).
the distance is computed in the topology of the calling agent (the agent in which this operator is used), with the distance algorithm specific to the topology.
agent var0 <- agent_farthest_to(self); // var0 equals the farthest agent to the agent applying the operator.
neighbors_at, neighbors_of, agents_inside, agents_overlapping, closest_to, inside, overlapping, agent_closest_to, farthest_to,
agent_from_geometry
path
agent_from_geometry
geometry
—> agent
agent_from_geometry
(path
, geometry
) —> agent
returns the agent corresponding to given geometry (right-hand operand) in the given path (left-hand operand).
geometry line <- one_of(path_followed.segments);
road ag <- road(path_followed agent_from_geometry line);
path,
agents_at_distance
agents_at_distance
(float
) —> container
A list of agents situated at a distance lower than the right argument.
container var0 <- agents_at_distance(20); // var0 equals all the agents (excluding the caller) which distance to the caller is lower than 20
neighbors_at, neighbors_of, agent_closest_to, agents_inside, closest_to, inside, overlapping, at_distance,
agents_inside
agents_inside
(unknown
) —> list<agent>
A list of agents covered by the operand (casted as a geometry).
list<agent> var0 <- agents_inside(self); // var0 equals the agents that are covered by the shape of the agent applying the operator.
agent_closest_to, agents_overlapping, closest_to, inside, overlapping,
agents_overlapping
agents_overlapping
(unknown
) —> list<agent>
A list of agents overlapping the operand (casted as a geometry).
list<agent> var0 <- agents_overlapping(self); // var0 equals the agents that overlap the shape of the agent applying the operator.
neighbors_at, neighbors_of, agent_closest_to, agents_inside, closest_to, inside, overlapping, at_distance,
all_pairs_shortest_path
all_pairs_shortest_path
(graph
) —> matrix<int>
returns the successor matrix of shortest paths between all node pairs (rows: source, columns: target): a cell (i,j) will thus contains the next node in the shortest path between i and j.
matrix<int> var0 <- all_pairs_shortest_paths(my_graph); // var0 equals shortest_paths_matrix will contain all pairs of shortest paths
alpha_index
alpha_index
(graph
) —> float
returns the alpha index of the graph (measure of connectivity which evaluates the number of cycles in a graph in comparison with the maximum number of cycles. The higher the alpha index, the more a network is connected: alpha = nb_cycles / (2*
S-5) - planar graph)
float var1 <- alpha_index(graphEpidemio); // var1 equals the alpha index of the graph
beta_index, gamma_index, nb_cycles, connectivity_index,
among
int
among
container
—> container
among
(int
, container
) —> container
Returns a list of length the value of the left-hand operand, containing random elements from the right-hand operand. As of GAMA 1.6, the order in which the elements are returned can be different than the order in which they appear in the right-hand container
list<int> var0 <- 3 among [1,2,4,3,5,7,6,8]; // var0 equals [1,2,8] (for example)
container var1 <- 3 among g2; // var1 equals [node6,node11,node7]
container var2 <- 3 among list(node); // var2 equals [node1,node11,node4]
list<int> var3 <- 1 among [1::2,3::4]; // var3 equals 2 or 4
and
bool
and
any expression
—> bool
and
(bool
, any expression
) —> bool
a bool value, equal to the logical and between the left-hand operand and the right-hand operand.
both operands are always casted to bool before applying the operator. Thus, an expression like (1 and 0) is accepted and returns false.
and
predicate
and
predicate
—> predicate
and
(predicate
, predicate
) —> predicate
create a new predicate from two others by including them as subintentions
predicate1 and predicate2
angle_between
angle_between
(point
, point
, point
) —> int
the angle between vectors P0P1 and P0P2 (P0, P1, P2 being the three point operands)
int var0 <- angle_between({5,5},{10,5},{5,10}); // var0 equals 90
any
Same signification as one_of
any_location_in
any_location_in
(geometry
) —> point
A point inside (or touching) the operand-geometry.
point var0 <- any_location_in(square(5)); // var0 equals a point in the square, for example : {3,4.6}.
closest_points_with, farthest_point_to, points_at,
any_point_in
Same signification as any_location_in
append_horizontally
matrix
append_horizontally
matrix
—> matrix
append_horizontally
(matrix
, matrix
) —> matrix
matrix
append_horizontally
matrix
—> matrix
append_horizontally
(matrix
, matrix
) —> matrix
A matrix resulting from the concatenation of the rows of the two given matrices. If not both numerical or both object matrices, returns the first matrix.
matrix var0 <- matrix([[1.0,2.0],[3.0,4.0]]) append_horizontally matrix([[1,2],[3,4]]); // var0 equals matrix([[1.0,2.0],[3.0,4.0],[1.0,2.0],[3.0,4.0]])
append_vertically
matrix
append_vertically
matrix
—> matrix
append_vertically
(matrix
, matrix
) —> matrix
matrix
append_vertically
matrix
—> matrix
append_vertically
(matrix
, matrix
) —> matrix
A matrix resulting from the concatenation of the columns of the two given matrices. If not both numerical or both object matrices, returns the first matrix.
matrix var0 <- matrix([[1,2],[3,4]]) append_vertically matrix([[1,2],[3,4]]); // var0 equals matrix([[1,2,1,2],[3,4,3,4]])
arc
arc
(float
, float
, float
) —> geometry
arc
(float
, float
, float
, bool
) —> geometry
An arc, which radius is equal to the first operand, heading to the second and amplitude the third An arc, which radius is equal to the first operand, heading to the second, amplitude to the third and a boolean indicating whether to return a linestring or a polygon to the fourth
the center of the arc is by default the location of the current agent in which has been called this operator. This operator returns a polygon by default.the center of the arc is by default the location of the current agent in which has been called this operator.
geometry var0 <- arc(4,45,90); // var0 equals a geometry as an arc of radius 4, in a direction of 45° and an amplitude of 90°
geometry var1 <- arc(4,45,90, false); // var1 equals a geometry as an arc of radius 4, in a direction of 45° and an amplitude of 90°, which only contains the points on the arc
around, cone, line, link, norm, point, polygon, polyline, super_ellipse, rectangle, square, circle, ellipse, triangle,
around
float
around
unknown
—> geometry
around
(float
, unknown
) —> geometry
A geometry resulting from the difference between a buffer around the right-operand casted in geometry at a distance left-operand (right-operand buffer left-operand) and the right-operand casted as geometry.
geometry var0 <- 10 around circle(5); // var0 equals the ring geometry between 5 and 10.
circle, cone, line, link, norm, point, polygon, polyline, rectangle, square, triangle,
as
unknown
as
any expression
—> unknown
as
(unknown
, any expression
) —> unknown
casting of the first argument into a given type
It is equivalent to the application of the type operator on the left operand.
int var0 <- 3.5 as int; // var0 equals int(3.5)
as_4_grid
geometry
as_4_grid
point
—> matrix
as_4_grid
(geometry
, point
) —> matrix
A matrix of square geometries (grid with 4-neighborhood) with dimension given by the right-hand operand ({nb_cols, nb_lines}) corresponding to the square tessellation of the left-hand operand geometry (geometry, agent)
matrix var0 <- self as_4_grid {10, 5}; // var0 equals the matrix of square geometries (grid with 4-neighborhood) with 10 columns and 5 lines corresponding to the square tessellation of the geometry of the agent applying the operator.
as_distance_graph
container
as_distance_graph
map
—> graph
as_distance_graph
(container
, map
) —> graph
container
as_distance_graph
float
—> graph
as_distance_graph
(container
, float
) —> graph
as_distance_graph
(container
, float
, species
) —> graph
creates a graph from a list of vertices (left-hand operand). An edge is created between each pair of vertices close enough (less than a distance, right-hand operand).
as_distance_graph is more efficient for a list of points than as_intersection_graph.
list(ant) as_distance_graph 3.0
as_intersection_graph, as_edge_graph,
as_driving_graph
container
as_driving_graph
container
—> graph
as_driving_graph
(container
, container
) —> graph
creates a graph from the list/map of edges given as operand and connect the node to the edge
as_driving_graph(road,node) --: build a graph while using the road agents as edges and the node agents as nodes
as_intersection_graph, as_distance_graph, as_edge_graph,
as_edge_graph
as_edge_graph
(map
) —> graph
as_edge_graph
(container
) —> graph
container
as_edge_graph
float
—> graph
as_edge_graph
(container
, float
) —> graph
creates a graph from the list/map of edges given as operand
graph var0 <- as_edge_graph([{1,5}::{12,45},{12,45}::{34,56}]); // var0 equals a graph with these three vertices and two edges
graph var1 <- as_edge_graph([line([{1,5},{12,45}]),line([{13,45},{34,56}])],1);; // var1 equals a graph with two edges and three vertices
graph var2 <- as_edge_graph([line([{1,5},{12,45}]),line([{12,45},{34,56}])]); // var2 equals a graph with two edges and three vertices
as_intersection_graph, as_distance_graph,
as_grid
geometry
as_grid
point
—> matrix
as_grid
(geometry
, point
) —> matrix
A matrix of square geometries (grid with 8-neighborhood) with dimension given by the right-hand operand ({nb_cols, nb_lines}) corresponding to the square tessellation of the left-hand operand geometry (geometry, agent)
matrix var0 <- self as_grid {10, 5}; // var0 equals a matrix of square geometries (grid with 8-neighborhood) with 10 columns and 5 lines corresponding to the square tessellation of the geometry of the agent applying the operator.
as_hexagonal_grid
geometry
as_hexagonal_grid
point
—> list<geometry>
as_hexagonal_grid
(geometry
, point
) —> list<geometry>
A list of geometries (hexagonal) corresponding to the hexagonal tesselation of the first operand geometry
list<geometry> var0 <- self as_hexagonal_grid {10, 5}; // var0 equals list of geometries (hexagonal) corresponding to the hexagonal tesselation of the first operand geometry
as_int
string
as_int
int
—> int
as_int
(string
, int
) —> int
parses the string argument as a signed integer in the radix specified by the second argument.
int var0 <- '20' as_int 10; // var0 equals 20
int var1 <- '20' as_int 8; // var1 equals 16
int var2 <- '20' as_int 16; // var2 equals 32
int var3 <- '1F' as_int 16; // var3 equals 31
int var4 <- 'hello' as_int 32; // var4 equals 18306744
int,
as_intersection_graph
container
as_intersection_graph
float
—> graph
as_intersection_graph
(container
, float
) —> graph
creates a graph from a list of vertices (left-hand operand). An edge is created between each pair of vertices with an intersection (with a given tolerance).
as_intersection_graph is more efficient for a list of geometries (but less accurate) than as_distance_graph.
list(ant) as_intersection_graph 0.5
as_distance_graph, as_edge_graph,
as_map
container
as_map
any expression
—> map
as_map
(container
, any expression
) —> map
produces a new map from the evaluation of the right-hand operand for each element of the left-hand operand
the right-hand operand should be a pair
map<int,int> var0 <- [1,2,3,4,5,6,7,8] as_map (each::(each * 2)); // var0 equals [1::2, 2::4, 3::6, 4::8, 5::10, 6::12, 7::14, 8::16]
map<int,int> var1 <- [1::2,3::4,5::6] as_map (each::(each * 2)); // var1 equals [2::4, 4::8, 6::12]
as_matrix
unknown
as_matrix
point
—> matrix
as_matrix
(unknown
, point
) —> matrix
casts the left operand into a matrix with right operand as preferred size
This operator is very useful to cast a file containing raster data into a matrix.Note that both components of the right operand point should be positive, otherwise an exception is raised.The operator as_matrix creates a matrix of preferred size. It fills in it with elements of the left operand until the matrix is full If the size is to short, some elements will be omitted. Matrix remaining elements will be filled in by nil.
as_path
list<geometry>
as_path
graph
—> path
as_path
(list<geometry>
, graph
) —> path
create a graph path from the list of shape
path var0 <- [road1,road2,road3] as_path my_graph; // var0 equals a path road1->road2->road3 of my_graph
asin
asin
(float
) —> float
asin
(int
) —> float
the arcsin of the operand
float var0 <- asin (0); // var0 equals 0.0
float var1 <- asin (90); // var1 equals #nan
at
string
at
int
—> string
at
(string
, int
) —> string
container<KeyType,ValueType>
at
KeyType
—> ValueType
at
(container<KeyType,ValueType>
, KeyType
) —> ValueType
the element at the right operand index of the container
The first element of the container is located at the index 0. In addition, if the user tries to get the element at an index higher or equals than the length of the container, he will get an IndexOutOfBoundException.The at operator behavior depends on the nature of the operand
int var1 <- [1, 2, 3] at 2; // var1 equals 3
point var2 <- [{1,2}, {3,4}, {5,6}] at 0; // var2 equals {1.0,2.0}
string var0 <- 'abcdef' at 0; // var0 equals 'a'
at_distance
container<agent>
at_distance
float
—> list<geometry>
at_distance
(container<agent>
, float
) —> list<geometry>
A list of agents or geometries among the left-operand list that are located at a distance <= the right operand from the caller agent (in its topology)
list<geometry> var0 <- [ag1, ag2, ag3] at_distance 20; // var0 equals the agents of the list located at a distance <= 20 from the caller agent (in the same order).
neighbors_at, neighbors_of, agent_closest_to, agents_inside, closest_to, inside, overlapping,
at_location
geometry
at_location
point
—> geometry
at_location
(geometry
, point
) —> geometry
A geometry resulting from the tran of a translation to the right-hand operand point of the left-hand operand (geometry, agent, point)
geometry var0 <- self at_location {10, 20}; // var0 equals the geometry resulting from a translation to the location {10, 20} of the left-hand geometry (or agent).
atan
atan
(float
) —> float
atan
(int
) —> float
Returns the value (in the interval [-90,90], in decimal degrees) of the arctan of the operand (which can be any real number).
float var0 <- atan (1); // var0 equals 45.0
atan2
float
atan2
float
—> float
atan2
(float
, float
) —> float
the atan2 value of the two operands.
The function atan2 is the arctangent function with two arguments. The purpose of using two arguments instead of one is to gather information on the signs of the inputs in order to return the appropriate quadrant of the computed angle, which is not possible for the single-argument arctangent function.
float var0 <- atan2 (0,0); // var0 equals 0.0
attributes
attributes
(any
) —> attributes
Casts the operand into the type attributes
BDIPlan
BDIPlan
(any
) —> BDIPlan
Casts the operand into the type BDIPlan
before
before
(date
) —> bool
any expression
before
date
—> bool
before
(any expression
, date
) —> bool
Returns true if the current_date of the model is strictly before the date passed in argument. Synonym of ‘current_date < argument’
reflex when: before(starting_date) {} -: will never be run
beta_index
beta_index
(graph
) —> float
returns the beta index of the graph (Measures the level of connectivity in a graph and is expressed by the relationship between the number of links (e) over the number of nodes (v) : beta = e/v.
graph graphEpidemio <- graph([]);
float var1 <- beta_index(graphEpidemio); // var1 equals the beta index of the graph
alpha_index, gamma_index, nb_cycles, connectivity_index,
between
date
between
date
—> bool
between
(date
, date
) —> bool
between
(int
, int
, int
) —> bool
between
(any expression
, date
, date
) —> bool
between
(float
, float
, float
) —> bool
between
(date
, date
, date
) —> bool
returns true the first integer operand is bigger than the second integer operand and smaller than the third integer operand returns true if the first float operand is bigger than the second float operand and smaller than the third float operand
(date('2016-01-01') between(date('2000-01-01'), date('2020-02-02') -: true
every #day between(date('2000-01-01'), date('2020-02-02') // will return true every new day between these two dates, taking the first one as the starting point
(date('2016-01-01') between(date('2000-01-01'), date('2020-02-02') -: true
between(date('2000-01-01'), date('2020-02-02') // will return true if the current_date of the model is in_between the 2
bool var0 <- between(5, 1, 10); // var0 equals true
bool var1 <- between(5.0, 1.0, 10.0); // var1 equals true
betweenness_centrality
betweenness_centrality
(graph
) —> map
returns a map containing for each vertex (key), its betweenness centrality (value): number of shortest paths passing through each vertex
graph graphEpidemio <- graph([]);
map var1 <- betweenness_centrality(graphEpidemio); // var1 equals the betweenness centrality index of the graph
biggest_cliques_of
biggest_cliques_of
(graph
) —> list<list>
returns the biggest cliques of a graph using the Bron-Kerbosch clique detection algorithm
graph my_graph <- graph([]);
list<list> var1 <- biggest_cliques_of (my_graph); // var1 equals the list of the biggest cliques as list
binomial
int
binomial
float
—> int
binomial
(int
, float
) —> int
A value from a random variable following a binomial distribution. The operands represent the number of experiments n and the success probability p.
The binomial distribution is the discrete probability distribution of the number of successes in a sequence of n independent yes/no experiments, each of which yields success with probability p, cf. Binomial distribution on Wikipedia.
int var0 <- binomial(15,0.6); // var0 equals a random positive integer
blend
rgb
blend
rgb
—> rgb
blend
(rgb
, rgb
) —> rgb
blend
(rgb
, rgb
, float
) —> rgb
Blend two colors with an optional ratio (c1 *
r + c2 *
(1 - r)) between 0 and 1
rgb var3 <- blend(#red, #blue); // var3 equals to a color very close to the purple
rgb var1 <- blend(#red, #blue, 0.3); // var1 equals to a color between the purple and the blue
bool
bool
(any
) —> bool
Casts the operand into the type bool
box
box
(point
) —> geometry
box
(float
, float
, float
) —> geometry
A box geometry which side sizes are given by the operands.
the center of the box is by default the location of the current agent in which has been called this operator.the center of the box is by default the location of the current agent in which has been called this operator.
geometry var0 <- box(10, 5 , 5); // var0 equals a geometry as a rectangle with width = 10, height = 5 depth= 5.
geometry var1 <- box({10, 5 , 5}); // var1 equals a geometry as a rectangle with width = 10, height = 5 depth= 5.
around, circle, sphere, cone, line, link, norm, point, polygon, polyline, square, cube, triangle,
brewer_colors
brewer_colors
(string
) —> list<rgb>
string
brewer_colors
int
—> list<rgb>
brewer_colors
(string
, int
) —> list<rgb>
Build a list of colors of a given type (see website http://colorbrewer2.org/) Build a list of colors of a given type (see website http://colorbrewer2.org/) with a given number of classes
list<rgb> var0 <- list<rgb> colors <- brewer_colors("OrRd");; // var0 equals a list of 6 blue colors
list<rgb> var1 <- list<rgb> colors <- brewer_colors("Pastel1", 10);; // var1 equals a list of 10 sequential colors
brewer_palettes
brewer_palettes
(int
) —> list<string>
int
brewer_palettes
int
—> list<string>
brewer_palettes
(int
, int
) —> list<string>
returns the list a palette with a given min number of classes and max number of classes) returns the list a palette with a given min number of classes and max number of classes)
list<string> var0 <- list<rgb> colors <- brewer_palettes(5,10);; // var0 equals a list of palettes that are composed of a min of 5 colors and a max of 10 colors
list<string> var1 <- list<rgb> colors <- brewer_palettes();; // var1 equals a list of palettes that are composed of a min of 5 colors
buffer
Same signification as +
build
build
(matrix<float>
) —> regression
matrix<float>
build
string
—> regression
build
(matrix<float>
, string
) —> regression
returns the regression build from the matrix data (a row = an instance, the last value of each line is the y value) while using the given ordinary least squares method. Usage: build(data) returns the regression build from the matrix data (a row = an instance, the last value of each line is the y value) while using the given method (“GLS” or “OLS”). Usage: build(data,method)
matrix([[1,2,3,4],[2,3,4,2]])
build(matrix([[1,2,3,4],[2,3,4,2]]),"GLS")
ceil
ceil
(float
) —> float
Maps the operand to the smallest following integer, i.e. the smallest integer not less than x.
float var0 <- ceil(3); // var0 equals 3.0
float var1 <- ceil(3.5); // var1 equals 4.0
float var2 <- ceil(-4.7); // var2 equals -4.0
centroid
centroid
(geometry
) —> point
Centroid (weighted sum of the centroids of a decomposition of the area into triangles) of the operand-geometry. Can be different to the location of the geometry
point var0 <- centroid(world); // var0 equals the centroid of the square, for example : {50.0,50.0}.
any_location_in, closest_points_with, farthest_point_to, points_at,
char
char
(int
) —> string
string var0 <- char (34); // var0 equals '"'
circle
circle
(float
) —> geometry
float
circle
point
—> geometry
circle
(float
, point
) —> geometry
A circle geometry which radius is equal to the first operand, and the center has the location equal to the second operand. A circle geometry which radius is equal to the operand.
the center of the circle is by default the location of the current agent in which has been called this operator.
geometry var0 <- circle(10,{80,30}); // var0 equals a geometry as a circle of radius 10, the center will be in the location {80,30}.
geometry var1 <- circle(10); // var1 equals a geometry as a circle of radius 10.
around, cone, line, link, norm, point, polygon, polyline, rectangle, square, triangle,
clean
clean
(geometry
) —> geometry
A geometry corresponding to the cleaning of the operand (geometry, agent, point)
The cleaning corresponds to a buffer with a distance of 0.0
geometry var0 <- clean(self); // var0 equals returns the geometry resulting from the cleaning of the geometry of the agent applying the operator.
closest_points_with
geometry
closest_points_with
geometry
—> list<point>
closest_points_with
(geometry
, geometry
) —> list<point>
A list of two closest points between the two geometries.
list<point> var0 <- geom1 closest_points_with(geom2); // var0 equals [pt1, pt2] with pt1 the closest point of geom1 to geom2 and pt1 the closest point of geom2 to geom1
any_location_in, any_point_in, farthest_point_to, points_at,
closest_to
container<agent>
closest_to
geometry
—> geometry
closest_to
(container<agent>
, geometry
) —> geometry
An agent or a geometry among the left-operand list of agents, species or meta-population (addition of species), the closest to the operand (casted as a geometry).
the distance is computed in the topology of the calling agent (the agent in which this operator is used), with the distance algorithm specific to the topology.
geometry var0 <- [ag1, ag2, ag3] closest_to(self); // var0 equals return the closest agent among ag1, ag2 and ag3 to the agent applying the operator.
(species1 + species2) closest_to self
neighbors_at, neighbors_of, inside, overlapping, agents_overlapping, agents_inside, agent_closest_to,
collect
container
collect
any expression
—> container
collect
(container
, any expression
) —> container
returns a new list, in which each element is the evaluation of the right-hand operand.
collect is similar to accumulate except that accumulate always produces flat lists if the right-hand operand returns a list.In addition, collect can be applied to any container.
container var0 <- [1,2,4] collect (each *2); // var0 equals [2,4,8]
container var1 <- [1,2,4] collect ([2,4]); // var1 equals [[2,4],[2,4],[2,4]]
container var2 <- [1::2, 3::4, 5::6] collect (each + 2); // var2 equals [4,6,8]
container var3 <- (list(node) collect (node(each).location.x * 2); // var3 equals the list of nodes with their x multiplied by 2
column_at
matrix
column_at
int
—> list
column_at
(matrix
, int
) —> list
returns the column at a num_col (right-hand operand)
list var0 <- matrix([["el11","el12","el13"],["el21","el22","el23"],["el31","el32","el33"]]) column_at 2; // var0 equals ["el31","el32","el33"]
columns_list
columns_list
(matrix
) —> list<list>
returns a list of the columns of the matrix, with each column as a list of elements
list<list> var0 <- columns_list(matrix([["el11","el12","el13"],["el21","el22","el23"],["el31","el32","el33"]])); // var0 equals [["el11","el12","el13"],["el21","el22","el23"],["el31","el32","el33"]]
command
command
(string
) —> string
command allows GAMA to issue a system command using the system terminal or shell and to receive a string containing the outcome of the command or script executed. By default, commands are blocking the agent calling them, unless the sequence ‘ &’ is used at the end. In this case, the result of the operator is an empty string
cone
cone
(point
) —> geometry
int
cone
int
—> geometry
cone
(int
, int
) —> geometry
A cone geometry which min and max angles are given by the operands. A cone geometry which min and max angles are given by the operands.
the center of the cone is by default the location of the current agent in which has been called this operator.the center of the cone is by default the location of the current agent in which has been called this operator.
geometry var0 <- cone({0, 45}); // var0 equals a geometry as a cone with min angle is 0 and max angle is 45.
geometry var1 <- cone(0, 45); // var1 equals a geometry as a cone with min angle is 0 and max angle is 45.
around, circle, line, link, norm, point, polygon, polyline, rectangle, square, triangle,
cone3D
float
cone3D
float
—> geometry
cone3D
(float
, float
) —> geometry
A cone geometry which base radius size is equal to the first operand, and which the height is equal to the second operand.
the center of the cone is by default the location of the current agent in which has been called this operator.
geometry var0 <- cone3D(10.0,5.0); // var0 equals a geometry as a cone with a base circle of radius 10 and a height of 5.
around, cone, line, link, norm, point, polygon, polyline, rectangle, square, triangle,
connected_components_of
connected_components_of
(graph
) —> list<list>
returns the connected components of of a graph, i.e. the list of all vertices that are in the maximally connected component together with the specified vertex.
graph my_graph <- graph([]);
list<list> var1 <- connected_components_of (my_graph); // var1 equals the list of all the components as list
alpha_index, connectivity_index, nb_cycles,
connectivity_index
connectivity_index
(graph
) —> float
returns a simple connectivity index. This number is estimated through the number of nodes (v) and of sub-graphs (p) : IC = (v - p) /(v - 1).
graph graphEpidemio <- graph([]);
float var1 <- connectivity_index(graphEpidemio); // var1 equals the connectivity index of the graph
alpha_index, beta_index, gamma_index, nb_cycles,
container
container
(any
) —> container
Casts the operand into the type container
contains
container<KeyType,ValueType>
contains
unknown
—> bool
contains
(container<KeyType,ValueType>
, unknown
) —> bool
string
contains
string
—> bool
contains
(string
, string
) —> bool
true, if the container contains the right operand, false otherwise
the contains operator behavior depends on the nature of the operand
bool var0 <- [1, 2, 3] contains 2; // var0 equals true
bool var1 <- [{1,2}, {3,4}, {5,6}] contains {3,4}; // var1 equals true
bool var2 <- 'abcded' contains 'bc'; // var2 equals true
contains_all
container
contains_all
container
—> bool
contains_all
(container
, container
) —> bool
string
contains_all
list
—> bool
contains_all
(string
, list
) —> bool
true if the left operand contains all the elements of the right operand, false otherwise
the definition of contains depends on the container
bool var4 <- "abcabcabc" contains_all ["ca","xy"]; // var4 equals false
bool var0 <- [1,2,3,4,5,6] contains_all [2,4]; // var0 equals true
bool var1 <- [1,2,3,4,5,6] contains_all [2,8]; // var1 equals false
bool var2 <- [1::2, 3::4, 5::6] contains_all [1,3]; // var2 equals false
bool var3 <- [1::2, 3::4, 5::6] contains_all [2,4]; // var3 equals true
contains_any
container
contains_any
container
—> bool
contains_any
(container
, container
) —> bool
string
contains_any
list
—> bool
contains_any
(string
, list
) —> bool
true if the left operand contains one of the elements of the right operand, false otherwise
the definition of contains depends on the container
bool var0 <- [1,2,3,4,5,6] contains_any [2,4]; // var0 equals true
bool var1 <- [1,2,3,4,5,6] contains_any [2,8]; // var1 equals true
bool var2 <- [1::2, 3::4, 5::6] contains_any [1,3]; // var2 equals false
bool var3 <- [1::2, 3::4, 5::6] contains_any [2,4]; // var3 equals true
bool var4 <- "abcabcabc" contains_any ["ca","xy"]; // var4 equals true
contains_edge
graph
contains_edge
unknown
—> bool
contains_edge
(graph
, unknown
) —> bool
graph
contains_edge
pair
—> bool
contains_edge
(graph
, pair
) —> bool
returns true if the graph(left-hand operand) contains the given edge (righ-hand operand), false otherwise
bool var2 <- graphEpidemio contains_edge (node(0)::node(3)); // var2 equals true
graph graphFromMap <- as_edge_graph([{1,5}::{12,45},{12,45}::{34,56}]);
bool var1 <- graphFromMap contains_edge link({1,5}::{12,45}); // var1 equals true
contains_vertex
graph
contains_vertex
unknown
—> bool
contains_vertex
(graph
, unknown
) —> bool
returns true if the graph(left-hand operand) contains the given vertex (righ-hand operand), false otherwise
graph graphFromMap<- as_edge_graph([{1,5}::{12,45},{12,45}::{34,56}]);
bool var1 <- graphFromMap contains_vertex {1,5}; // var1 equals true
conversation
conversation
(unknown
) —> conversation
convex_hull
convex_hull
(geometry
) —> geometry
A geometry corresponding to the convex hull of the operand.
geometry var0 <- convex_hull(self); // var0 equals the convex hull of the geometry of the agent applying the operator
copy
copy
(unknown
) —> unknown
returns a copy of the operand.
copy_between
copy_between
(string
, int
, int
) —> string
copy_between
(container
, int
, int
) —> container
Returns a copy of the first operand between the indexes determined by the second (inclusive) and third operands (exclusive)
string var0 <- copy_between("abcabcabc", 2,6); // var0 equals "cabc"
container var1 <- copy_between ([4, 1, 6, 9 ,7], 1, 3); // var1 equals [1, 6]
corR
container
corR
container
—> unknown
corR
(container
, container
) —> unknown
returns the Pearson correlation coefficient of two given vectors (right-hand operands) in given variable (left-hand operand).
list X <- [1, 2, 3];
list Y <- [1, 2, 4];
unknown var2 <- corR(X, Y); // var2 equals 0.981980506061966
cos
cos
(int
) —> float
cos
(float
) —> float
Returns the value (in [-1,1]) of the cosinus of the operand (in decimal degrees). The argument is casted to an int before being evaluated.
float var0 <- cos (0); // var0 equals 1.0
float var1 <- cos(360); // var1 equals 1.0
float var2 <- cos(-720); // var2 equals 1.0
cos_rad
cos_rad
(float
) —> float
Returns the value (in [-1,1]) of the cosinus of the operand (in decimal degrees). The argument is casted to an int before being evaluated.
count
container
count
any expression
—> int
count
(container
, any expression
) —> int
returns an int, equal to the number of elements of the left-hand operand that make the right-hand operand evaluate to true.
in the right-hand operand, the keyword each can be used to represent, in turn, each of the elements.
int var0 <- [1,2,3,4,5,6,7,8] count (each > 3); // var0 equals 5
// Number of nodes of graph g2 without any out edge
graph g2 <- graph([]);
int var3 <- g2 count (length(g2 out_edges_of each) = 0 ) ; // var3 equals the total number of out edges
// Number of agents node with x > 32
int n <- (list(node) count (round(node(each).location.x) > 32);
int var6 <- [1::2, 3::4, 5::6] count (each > 4); // var6 equals 1
covers
geometry
covers
geometry
—> bool
covers
(geometry
, geometry
) —> bool
A boolean, equal to true if the left-geometry (or agent/point) covers the right-geometry (or agent/point).
bool var0 <- square(5) covers square(2); // var0 equals true
disjoint_from, crosses, overlaps, partially_overlaps, touches,
cross
cross
(float
) —> geometry
float
cross
float
—> geometry
cross
(float
, float
) —> geometry
A cross, which radius is equal to the first operand A cross, which radius is equal to the first operand and the width of the lines for the second
geometry var0 <- cross(10); // var0 equals a geometry as a cross of radius 10
geometry var1 <- cross(10,2); // var1 equals a geometry as a cross of radius 10, and with a width of 2 for the lines
around, cone, line, link, norm, point, polygon, polyline, super_ellipse, rectangle, square, circle, ellipse, triangle,
crosses
geometry
crosses
geometry
—> bool
crosses
(geometry
, geometry
) —> bool
A boolean, equal to true if the left-geometry (or agent/point) crosses the right-geometry (or agent/point).
bool var0 <- polyline([{10,10},{20,20}]) crosses polyline([{10,20},{20,10}]); // var0 equals true
bool var1 <- polyline([{10,10},{20,20}]) crosses {15,15}; // var1 equals true
bool var2 <- polyline([{0,0},{25,25}]) crosses polygon([{10,10},{10,20},{20,20},{20,10}]); // var2 equals true
disjoint_from, intersects, overlaps, partially_overlaps, touches,
crs
crs
(file
) —> string
the Coordinate Reference System (CRS) of the GIS file
string var0 <- crs(my_shapefile); // var0 equals the crs of the shapefile
CRS_transform
CRS_transform
(geometry
) —> geometry
geometry
CRS_transform
string
—> geometry
CRS_transform
(geometry
, string
) —> geometry
geometry var0 <- shape CRS_transform("EPSG:4326"); // var0 equals a geometry corresponding to the agent geometry transformed into the EPSG:4326 CRS
geometry var1 <- CRS_transform(shape); // var1 equals a geometry corresponding to the agent geometry transformed into the current CRS
csv_file
csv_file
(string
) —> file
Constructs a file of type csv. Allowed extensions are limited to csv, tsv
cube
cube
(float
) —> geometry
A cube geometry which side size is equal to the operand.
the center of the cube is by default the location of the current agent in which has been called this operator.
geometry var0 <- cube(10); // var0 equals a geometry as a square of side size 10.
around, circle, cone, line, link, norm, point, polygon, polyline, rectangle, triangle,
curve
curve
(point
, point
, point
) —> geometry
curve
(point
, point
, point
, int
) —> geometry
curve
(point
, point
, point
, point
) —> geometry
curve
(point
, point
, point
, point
, int
) —> geometry
A quadratic Bezier curve geometry built from the three given points composed of a given numnber of points. A quadratic Bezier curve geometry built from the three given points composed of 10 points. A cubic Bezier curve geometry built from the four given points composed of a given number of points. A cubic Bezier curve geometry built from the four given points composed of 10 points.
geometry var0 <- curve({0,0}, {0,10}, {10,10}, 20); // var0 equals a quadratic Bezier curve geometry composed of 20 points from p0 to p2.
geometry var1 <- curve({0,0}, {0,10}, {10,10}); // var1 equals a quadratic Bezier curve geometry composed of 10 points from p0 to p2.
geometry var2 <- curve({0,0}, {0,10}, {10,10}); // var2 equals a cubic Bezier curve geometry composed of 10 points from p0 to p3.
geometry var3 <- curve({0,0}, {0,10}, {10,10}); // var3 equals a cubic Bezier curve geometry composed of 10 points from p0 to p3.
around, circle, cone, link, norm, point, polygone, rectangle, square, triangle, line,
cylinder
float
cylinder
float
—> geometry
cylinder
(float
, float
) —> geometry
A cylinder geometry which radius is equal to the operand.
the center of the cylinder is by default the location of the current agent in which has been called this operator.
geometry var0 <- cylinder(10,10); // var0 equals a geometry as a circle of radius 10.
around, cone, line, link, norm, point, polygon, polyline, rectangle, square, triangle,
IDW
IDW
(container<agent>
, map<point,float>
, int
) —> map<agent,float>
Inverse Distance Weighting (IDW) is a type of deterministic method for multivariate interpolation with a known scattered set of points. The assigned values to each geometry are calculated with a weighted average of the values available at the known points. See: http://en.wikipedia.org/wiki/Inverse_distance_weighting Usage: IDW (list of geometries, map of points (key: point, value: value), power parameter)
map<agent,float> var0 <- IDW([ag1, ag2, ag3, ag4, ag5],[{10,10}::25.0, {10,80}::10.0, {100,10}::15.0], 2); // var0 equals for example, can return [ag1::12.0, ag2::23.0,ag3::12.0,ag4::14.0,ag5::17.0]
R_correlation
Same signification as corR
R_file
R_file
(string
) —> file
Constructs a file of type R. Allowed extensions are limited to r
R_mean
Same signification as meanR
TGauss
Same signification as truncated_gauss
URL_file
URL_file
(string
) —> file
Constructs a file of type URL. Allowed extensions are limited to url