Operators (N to R)
This file is automatically generated from java files. Do Not Edit It.
Definition​
Operators in the GAML language are used to compose complex expressions. An operator performs a function on one, two, or n operands (which are other expressions and thus may be themselves composed of operators) and returns the result of this function.
Most of them use a classical prefixed functional syntax (i.e. operator_name(operand1, operand2, operand3)
, see below), with the exception of arithmetic (e.g. +
, /
), logical (and
, or
), comparison (e.g. >
, <
), access (.
, [..]
) and pair (::
) operators, which require an infixed notation (i.e. operand1 operator_symbol operand1
).
The ternary functional if-else operator, ? :
, uses a special infixed syntax composed with two symbols (e.g. operand1 ? operand2 : operand3
). Two unary operators (-
and !
) use a traditional prefixed syntax that does not require parentheses unless the operand is itself a complex expression (e.g. - 10
, ! (operand1 or operand2)
).
Finally, special constructor operators ({...}
for constructing points, [...]
for 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:
- if they only have one operand, the functional prefixed syntax is mandatory (e.g.
operator_name(operand1)
) - if they have two arguments, either the functional prefixed syntax (e.g.
operator_name(operand1, operand2)
) or the infixed syntax (e.g.operand1 operator_name operand2
) can be used. - if they have more than two arguments, either the functional prefixed syntax (e.g.
operator_name(operand1, operand2, ..., operand)
) or a special infixed syntax with the first operand on the left-hand side of the operator name (e.g.operand1 operator_name(operand2, ..., operand)
) can be used.
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.
Priority between operators​
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:
- the constructor operators, like
::
, used to compose pairs of operands, have the lowest priority of all operators (e.g.a > b :: b > c
will return a pair of boolean values, which means that the two comparisons are evaluated before the operator applies. Similarly,[a > 10, b > 5]
will return a list of boolean values. - it is followed by the
?:
operator, the functional if-else (e.g.a > b ? a + 10 : a - 10
will return the result of the if-else). - next are the logical operators,
and
andor
(e.g.a > b or b > c
will return the value of the test) - next are the comparison operators (i.e.
>
,<
,<=
,>=
,=
,!=
) - next the arithmetic operators in their logical order (multiplicative operators have a higher priority than additive operators)
- next the unary operators
-
and!
- next the access operators
.
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) - and finally the functional operators, which have the highest priority of all.
Using actions as operators​
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).
Table of Contents​
Operators by categories​
3D​
box, cone3D, cube, cylinder, hexagon, pyramid, set_z, sphere, teapot,
Arithmetic operators​
-, /, ^, *, +, 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,
BDI​
add_values, and, eval_when, get_about, get_agent, get_agent_cause, get_belief_op, get_belief_with_name_op, get_beliefs_op, get_beliefs_with_name_op, get_current_intention_op, get_decay, get_desire_op, get_desire_with_name_op, get_desires_op, get_desires_with_name_op, get_dominance, get_familiarity, get_ideal_op, get_ideal_with_name_op, get_ideals_op, get_ideals_with_name_op, get_intensity, get_intention_op, get_intention_with_name_op, get_intentions_op, get_intentions_with_name_op, get_lifetime, get_liking, get_modality, get_obligation_op, get_obligation_with_name_op, get_obligations_op, get_obligations_with_name_op, get_plan_name, get_predicate, get_solidarity, get_strength, get_super_intention, get_trust, get_truth, get_uncertainties_op, get_uncertainties_with_name_op, get_uncertainty_op, get_uncertainty_with_name_op, get_values, has_belief_op, has_belief_with_name_op, has_desire_op, has_desire_with_name_op, has_ideal_op, has_ideal_with_name_op, has_intention_op, has_intention_with_name_op, has_obligation_op, has_obligation_with_name_op, has_uncertainty_op, has_uncertainty_with_name_op, new_emotion, new_mental_state, new_predicate, new_social_link, not, or, set_about, set_agent, set_agent_cause, set_decay, set_dominance, set_familiarity, set_intensity, set_lifetime, set_liking, set_modality, set_predicate, set_solidarity, set_strength, set_trust, set_truth, with_values,
Casting operators​
as, as_int, as_matrix, font, is, is_skill, list_with, matrix_with, species, to_gaml, topology,
Color-related operators​
-, /, *, +, blend, brewer_colors, brewer_palettes, gradient, grayscale, hsb, mean, median, palette, rgb, rnd_color, scale, sum,
Comparison operators​
Containers-related operators​
-, ::, +, accumulate, all_match, among, at, cartesian_product, collect, contains, contains_all, contains_any, contains_key, count, empty, every, first, first_with, get, group_by, in, index_by, inter, interleave, internal_integrated_value, last, last_with, length, max, max_of, mean, mean_of, median, min, min_of, mul, none_matches, one_matches, one_of, product_of, range, remove_duplicates, reverse, shuffle, sort_by, split, split_in, split_using, sum, sum_of, union, variance_of, where, with_max_of, with_min_of,
Date-related operators​
-, !=, +, <, <=, =, >, >=, after, before, between, every, milliseconds_between, minus_days, minus_hours, minus_minutes, minus_months, minus_ms, minus_weeks, minus_years, months_between, plus_days, plus_hours, plus_minutes, plus_months, plus_ms, plus_weeks, plus_years, since, to, until, years_between,
Dates​
Displays​
edge​
EDP-related operators​
Files-related operators​
copy_file, crs, csv_file, delete_file, dxf_file, evaluate_sub_model, file_exists, folder, folder_exists, gaml_file, geojson_file, get, gif_file, gml_file, graph6_file, graphdimacs_file, graphdot_file, graphgexf_file, graphgml_file, graphml_file, graphtsplib_file, grid_file, image_file, is_csv, is_dxf, is_gaml, is_geojson, is_gif, is_gml, is_graph6, is_graphdimacs, is_graphdot, is_graphgexf, is_graphgml, is_graphml, is_graphtsplib, is_grid, is_image, is_json, is_obj, is_osm, is_pgm, is_property, is_saved_simulation, is_shape, is_svg, is_text, is_threeds, is_xml, json_file, new_folder, obj_file, osm_file, pgm_file, property_file, read, rename_file, saved_simulation_file, shape_file, step_sub_model, svg_file, text_file, threeds_file, unzip, writable, xml_file, zip,
FIPA-related operators​
GamaMaterialType​
GamaMetaType​
Gen*​
add_attribute, add_census_file, add_mapper, add_marginals, add_range_attribute, with_generation_algo,
Graphs-related operators​
add_edge, add_node, adjacency, agent_from_geometry, all_pairs_shortest_path, alpha_index, as_distance_graph, as_edge_graph, as_intersection_graph, as_path, as_spatial_graph, 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_random_graph, generate_watts_strogatz, girvan_newman_clustering, grid_cells_to_graph, in_degree_of, in_edges_of, k_spanning_tree_clustering, label_propagation_clustering, layout_circle, layout_force, layout_force_FR, layout_force_FR_indexed, layout_grid, load_shortest_paths, main_connected_component, max_flow_between, 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, strahler, successors_of, sum, target_of, undirected, use_cache, weight_of, with_k_shortest_path_algorithm, with_shortest_path_algorithm, with_weights,
Grid-related operators​
as_4_grid, as_grid, as_hexagonal_grid, cell_at, cells_in, cells_overlapping, field, grid_at, neighbors_of, path_between, points_in, values_in,
Iterator operators​
accumulate, all_match, as_map, collect, count, create_map, first_with, frequency_of, group_by, index_by, last_with, max_of, mean_of, min_of, none_matches, one_matches, product_of, sort_by, sum_of, variance_of, where, where, where, with_max_of, with_min_of,
List-related operators​
all_indexes_of, copy_between, index_of, last_index_of,
Logical operators​
:, !, ?, add_3Dmodel, add_geometry, add_icon, and, or, xor,
Map comparaison operators​
fuzzy_kappa, fuzzy_kappa_sim, kappa, kappa_sim, percent_absolute_deviation,
Map-related operators​
as_map, create_map, index_of, last_index_of,
Matrix-related operators​
-, /, ., *, +, append_horizontally, append_vertically, column_at, columns_list, determinant, eigenvalues, index_of, inverse, last_index_of, row_at, rows_list, shuffle, trace, transpose,
multicriteria operators​
electre_DM, evidence_theory_DM, fuzzy_choquet_DM, promethee_DM, weighted_means_DM,
Path-related operators​
agent_from_geometry, all_pairs_shortest_path, as_path, load_shortest_paths, max_flow_between, path_between, path_to, paths_between, use_cache,
Points-related operators​
-, /, *, +, <, <=, >, >=, add_point, angle_between, any_location_in, centroid, closest_points_with, farthest_point_to, grid_at, norm, points_along, points_at, points_on,
Random operators​
binomial, flip, gamma_density, gamma_rnd, gamma_trunc_rnd, gauss, generate_terrain, lognormal_density, lognormal_rnd, lognormal_trunc_rnd, poisson, rnd, rnd_choice, sample, shuffle, skew_gauss, truncated_gauss, weibull_density, weibull_rnd, weibull_trunc_rnd,
ReverseOperators​
restore_simulation, restore_simulation_from_file, save_simulation, serialize, serialize_agent,
Shape​
arc, box, circle, cone, cone3D, cross, cube, curve, cylinder, ellipse, elliptical_arc, envelope, geometry_collection, hexagon, line, link, plan, polygon, polyhedron, pyramid, rectangle, sphere, square, squircle, teapot, triangle,
Spatial operators​
-, *, +, add_point, agent_closest_to, agent_farthest_to, agents_at_distance, agents_covering, agents_crossing, agents_inside, agents_overlapping, agents_partially_overlapping, agents_touching, angle_between, any_location_in, arc, around, as_4_grid, as_driving_graph, as_grid, as_hexagonal_grid, at_distance, at_location, box, centroid, circle, clean, clean_network, closest_points_with, closest_to, cone, cone3D, convex_hull, covering, covers, cross, crosses, crossing, crs, CRS_transform, cube, curve, cylinder, direction_between, disjoint_from, distance_between, distance_to, ellipse, elliptical_arc, envelope, farthest_point_to, farthest_to, geometry_collection, gini, hexagon, hierarchical_clustering, IDW, inside, inter, intersects, inverse_rotation, line, link, masked_by, moran, neighbors_at, neighbors_of, normalized_rotation, overlapping, overlaps, partially_overlapping, partially_overlaps, path_between, path_to, plan, points_along, points_at, points_on, polygon, polyhedron, pyramid, rectangle, rotated_by, rotation_composition, 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_segments, to_squares, to_sub_geometries, touches, touching, towards, transformed_by, translated_by, triangle, triangulate, union, using, voronoi, with_precision, without_holes,
Spatial properties operators​
covers, crosses, intersects, partially_overlaps, touches,
Spatial queries operators​
agent_closest_to, agent_farthest_to, agents_at_distance, agents_covering, agents_crossing, agents_inside, agents_overlapping, agents_partially_overlapping, agents_touching, at_distance, closest_to, covering, crossing, farthest_to, inside, neighbors_at, neighbors_of, overlapping, partially_overlapping, touching,
Spatial relations operators​
direction_between, distance_between, distance_to, path_between, path_to, towards,
Spatial statistical operators​
hierarchical_clustering, simple_clustering_by_distance,
Spatial transformations operators​
-, *, +, as_4_grid, as_grid, as_hexagonal_grid, at_location, clean, clean_network, convex_hull, CRS_transform, inverse_rotation, normalized_rotation, rotated_by, rotation_composition, scaled_to, simplification, skeletonize, smooth, split_geometry, split_lines, to_GAMA_CRS, to_rectangles, to_segments, to_squares, to_sub_geometries, transformed_by, translated_by, triangulate, voronoi, with_precision, without_holes,
Species-related operators​
index_of, last_index_of, of_generic_species, of_species,
Statistical operators​
auto_correlation, beta, binomial_coeff, binomial_complemented, binomial_sum, build, chi_square, chi_square_complemented, correlation, covariance, dbscan, distribution_of, distribution2d_of, dtw, durbin_watson, frequency_of, gamma, gamma_distribution, gamma_distribution_complemented, geometric_mean, gini, harmonic_mean, hierarchical_clustering, incomplete_beta, incomplete_gamma, incomplete_gamma_complement, kmeans, kurtosis, log_gamma, max, mean, mean_deviation, median, min, moment, moran, mul, normal_area, normal_density, normal_inverse, predict, pValue_for_fStat, pValue_for_tStat, quantile, quantile_inverse, rank_interpolated, rms, simple_clustering_by_distance, skewness, split, split_in, split_using, standard_deviation, student_area, student_t_inverse, sum, t_test, variance,
Strings-related operators​
+, <, <=, >, >=, at, capitalize, 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, regex_matches, replace, replace_regex, reverse, sample, shuffle, split_with, string, upper_case,
SubModel​
System​
., choose, command, copy, copy_to_clipboard, dead, enter, eval_gaml, every, is_error, is_reachable, is_warning, play_sound, user_confirm, user_input_dialog, wizard, wizard_page,
Time-related operators​
Types-related operators​
action, agent, attributes, BDIPlan, bool, container, directory, emotion, file, float, gaml_type, gen_population_generator, gen_range, geometry, graph, int, kml, list, map, matrix, mental_state, Norm, pair, path, point, predicate, regression, rgb, Sanction, skill, social_link, topology, unknown,
User control operators​
choose, enter, user_confirm, user_input_dialog, wizard, wizard_page,
Operators​
nb_cycles
​
Possible uses:​
nb_cycles
(graph
) --->int
Result:​
returns the maximum number of independent cycles in a graph. This number (u) is estimated through the number of nodes (v), links (e) and of sub-graphs (p): u = e - v + p.
Examples:​
graph graphEpidemio <- graph([]);
int var1 <- nb_cycles(graphEpidemio); // var1 equals the number of cycles in the graph
See also: alpha_index, beta_index, gamma_index, connectivity_index,
neighbors_at
​
Possible uses:​
geometry
neighbors_at
float
--->list
neighbors_at
(geometry
,float
) --->list
Result:​
a list, containing all the agents of the same species than the left argument (if it is an agent) located at a distance inferior or equal to the right-hand operand to the left-hand operand (geometry, agent, point).
Comment:​
The topology used to compute the neighborhood is the one of the left-operand if this one is an agent; otherwise the one of the agent applying the operator.
Examples:​
list var0 <- (self neighbors_at (10)); // var0 equals all the agents located at a distance lower or equal to 10 to the agent applying the operator.
See also: neighbors_of, closest_to, overlapping, agents_overlapping, agents_inside, agent_closest_to, at_distance,
neighbors_of
​
Possible uses:​
graph
neighbors_of
unknown
--->list
neighbors_of
(graph
,unknown
) --->list
field
neighbors_of
point
--->list<point>
neighbors_of
(field
,point
) --->list<point>
topology
neighbors_of
agent
--->list
neighbors_of
(topology
,agent
) --->list
neighbors_of
(topology
,geometry
,float
) --->list
Result:​
a list, containing all the agents of the same species than the argument (if it is an agent) located at a distance inferior or equal to 1 to the right-hand operand agent considering the left-hand operand topology.
Special cases:​
- a list, containing all the agents of the same species than the left argument (if it is an agent) located at a distance inferior or equal to the third argument to the second argument (agent, geometry or point) considering the first operand topology.
list var0 <- neighbors_of (topology(self), self,10); // var0 equals all the agents located at a distance lower or equal to 10 to the agent applying the operator considering its topology.
Examples:​
list var1 <- graphEpidemio neighbors_of (node(3)); // var1 equals [node0,node2]
list var2 <- graphFromMap neighbors_of node({12,45}); // var2 equals [{1.0,5.0},{34.0,56.0}]
list var3 <- topology(self) neighbors_of self; // var3 equals returns all the agents located at a distance lower or equal to 1 to the agent applying the operator considering its topology.
See also: predecessors_of, successors_of, neighbors_at, closest_to, overlapping, agents_overlapping, agents_inside, agent_closest_to,
new_emotion
​
Possible uses:​
new_emotion
(string
) --->emotion
string
new_emotion
float
--->emotion
new_emotion
(string
,float
) --->emotion
string
new_emotion
predicate
--->emotion
new_emotion
(string
,predicate
) --->emotion
string
new_emotion
agent
--->emotion
new_emotion
(string
,agent
) --->emotion
new_emotion
(string
,predicate
,agent
) --->emotion
new_emotion
(string
,float
,predicate
) --->emotion
new_emotion
(string
,float
,float
) --->emotion
new_emotion
(string
,float
,agent
) --->emotion
new_emotion
(string
,float
,float
,agent
) --->emotion
new_emotion
(string
,float
,predicate
,float
) --->emotion
new_emotion
(string
,float
,predicate
,agent
) --->emotion
new_emotion
(string
,float
,predicate
,float
,agent
) --->emotion
Result:​
a new emotion with the given properties (at least its name, and eventually intensity, parameters...)
Special cases:​
- a new emotion with a name and an initial intensity:
new_emotion("joy",12.3)
- a new emotion with a given name and the predicate it is about
new_emotion("joy",estFood)
new_emotion("joy",agent1)
- Various combinations are possible to create the emotion: (name,intensity,about), (name,about,cause), (name,intensity,cause)...
new_emotion("joy",12.3,eatFood)
new_emotion("joy",eatFood,agent1)
new_emotion("joy",12.3,agent1)
- a new emotion with a given name and the agent which has caused this emotion
new_emotion("joy",agent1)
- A decay value value can be added to define a new emotion.
new_emotion("joy",12.3,4.0)
Examples:​
emotion("joy",12.3,eatFood,4,agent1)
emotion("joy", 12.3, 4, agent1)
new_emotion("joy")
new_emotion("joy",12.3,eatFood,4.0)
new_emotion("joy",12.3,eatFood,agent1)
new_folder
​
Possible uses:​
new_folder
(string
) --->file
Result:​
opens an existing repository or create a new folder if it does not exist.
Special cases:​
- If the specified string does not refer to an existing repository, the repository is created.
- If the string refers to an existing file, an exception is risen.
Examples:​
file dirNewT <- new_folder("incl/"); // dirNewT represents the repository "../incl/"
// eventually creates the directory ../incl
See also: folder, file, folder_exists,
new_mental_state
​
Possible uses:​
new_mental_state
(string
) --->mental_state
string
new_mental_state
predicate
--->mental_state
new_mental_state
(string
,predicate
) --->mental_state
string
new_mental_state
emotion
--->mental_state
new_mental_state
(string
,emotion
) --->mental_state
string
new_mental_state
mental_state
--->mental_state
new_mental_state
(string
,mental_state
) --->mental_state
new_mental_state
(string
,predicate
,int
) --->mental_state
new_mental_state
(string
,predicate
,float
) --->mental_state
new_mental_state
(string
,mental_state
,agent
) --->mental_state
new_mental_state
(string
,mental_state
,float
) --->mental_state
new_mental_state
(string
,predicate
,agent
) --->mental_state
new_mental_state
(string
,emotion
,float
) --->mental_state
new_mental_state
(string
,emotion
,agent
) --->mental_state
new_mental_state
(string
,mental_state
,int
) --->mental_state
new_mental_state
(string
,emotion
,int
) --->mental_state
new_mental_state
(string
,predicate
,float
,int
) --->mental_state
new_mental_state
(string
,predicate
,int
,agent
) --->mental_state
new_mental_state
(string
,predicate
,float
,agent
) --->mental_state
new_mental_state
(string
,emotion
,int
,agent
) --->mental_state
new_mental_state
(string
,mental_state
,float
,int
) --->mental_state
new_mental_state
(string
,mental_state
,int
,agent
) --->mental_state
new_mental_state
(string
,emotion
,float
,int
) --->mental_state
new_mental_state
(string
,emotion
,float
,agent
) --->mental_state
new_mental_state
(string
,mental_state
,float
,agent
) --->mental_state
new_mental_state
(string
,emotion
,float
,int
,agent
) --->mental_state
new_mental_state
(string
,predicate
,float
,int
,agent
) --->mental_state
new_mental_state
(string
,mental_state
,float
,int
,agent
) --->mental_state
Result:​
creates a new mental state with a given modality (e.g. belief or desire) and various properties (a predicate it is about, a strength, a lifetime, an ower agent and an emotion it is about
Examples:​
new_mental_state("belief", raining)
new_mental_state("belief", raining, 10)
new_mental_state("belief", raining, 0.5)
new_mental_state("belief", raining, 12.4, 10)
new_mental_state("belief", my_joy, 12.3, 10, agent1)
new_mental_state("belief", mental_state1, agent1)
new_mental_state("belief", mental_state1, 12.3)
new_mental_state("belief", raining, agent1)
new_mental_state("belief", raining, 10, agent1)
new_mental_state("belief", my_joy, 12.3)
new_mental_state("belief", raining, 12.3, agent1)
new_mental_state("belief", my_joy, 10, agent1)
new_mental_state("belief",raining, 12.3, 10, agent1)
new_mental_state("belief", mental_state1, 12.3, 10)
new_mental_state("belief")
new_mental_state("belief", my_joy, agent1)
new_mental_state("belief", mental_state1, 10)
new_mental_state("belief", mental_state1, 10, agent1)
new_mental_state("belief", my_joy, 10)
new_mental_state("belief", my_joy, 12.3, 10)
new_mental_state("belief", my_joy, 12.3, agent1)
new_mental_state("belief", my_joy)
new_mental_state("belief", mental_state1, 12.3, 10, agent1)
new_mental_state("belief", mental_state1)
new_mental_state("belief", mental_state1, 12.2, agent1)
new_predicate
​
Possible uses:​
new_predicate
(string
) --->predicate
string
new_predicate
agent
--->predicate
new_predicate
(string
,agent
) --->predicate
string
new_predicate
bool
--->predicate
new_predicate
(string
,bool
) --->predicate
string
new_predicate
map
--->predicate
new_predicate
(string
,map
) --->predicate
new_predicate
(string
,map
,agent
) --->predicate
new_predicate
(string
,map
,bool
) --->predicate
new_predicate
(string
,map
,bool
,agent
) --->predicate
Result:​
creates a new predicate with a given name and adidtional properties (values, agent causing the predicate, whether it is true...)
Examples:​
new_predicate("people to meet", ["time"::10], true, agentA)
new_predicate("people to meet")
new_predicate("people to meet", ["time"::10], agentA)
new_predicate("people to meet", agent1)
new_predicate("people to meet", ["time"::10], true)
new_predicate("hasWater", true)
new_predicate("people to meet", map(["val1"::23]) )
new_social_link
​
Possible uses:​
new_social_link
(agent
) --->social_link
new_social_link
(agent
,float
,float
,float
,float
) --->social_link
Result:​
creates a new social link with another agent (eventually given additional parameters such as the appreciation, dominance, solidarity, and familiarity values).
Examples:​
new_social_link(agentA)
new_social_link(agentA,0.0,-0.1,0.2,0.1)
node
​
Possible uses:​
node
(unknown
) --->unknown
unknown
node
float
--->unknown
node
(unknown
,float
) --->unknown
Result:​
Allows to create a wrapper (of type unknown) that wraps an actual object and indicates it should be considered as a node of a graph. The second (optional) parameter indicates which weight the node should have in the graph
Comment:​
Useful only in graph-related operations (addition, removal of nodes, creation of graphs)
nodes
​
Possible uses:​
nodes
(container
) --->container
Result:​
Allows to create a wrapper (of type list) that wraps a list of objects and indicates they should be considered as nodes of a graph
none_matches
​
Possible uses:​
container
none_matches
any expression
--->bool
none_matches
(container
,any expression
) --->bool
Result:​
Returns true if none of the elements of the left-hand operand make the right-hand operand evaluate to true. 'c none_matches each.property' is strictly equivalent to '(c count each.property) = 0'
Comment:​
In the right-hand operand, the keyword each can be used to represent, in turn, each of the elements.
Special cases:​
- If the left-hand operand is nil, none_matches throws an error.
- If the left-hand operand is empty, none_matches returns true.
Examples:​
bool var0 <- [1,2,3,4,5,6,7,8] none_matches (each > 3); // var0 equals false
bool var1 <- [1::2, 3::4, 5::6] none_matches (each > 4); // var1 equals false
See also: one_matches, all_match, count,
none_verifies
​
Same signification as none_matches
norm
​
Possible uses:​
norm
(point
) --->float
Result:​
the norm of the vector with the coordinates of the point operand.
Examples:​
float var0 <- norm({3,4}); // var0 equals 5.0
Norm
​
Possible uses:​
Norm
(any
) --->Norm
Result:​
casts the operand in a Norm object.
normal_area
​
Possible uses:​
normal_area
(float
,float
,float
) --->float
Result:​
Returns the area to the left of x in the normal distribution with the given mean and standard deviation.
Examples:​
float var0 <- normal_area(0.9,0,1) with_precision(3); // var0 equals 0.816
normal_density
​
Possible uses:​
normal_density
(float
,float
,float
) --->float
Result:​
Returns the probability of x in the normal distribution with the given mean and standard deviation.
Examples:​
float var0 <- (normal_density(2,1,1)*100) with_precision 2; // var0 equals 24.2
normal_inverse
​
Possible uses:​
normal_inverse
(float
,float
,float
) --->float
Result:​
Returns the x in the normal distribution with the given mean and standard deviation, to the left of which lies the given area. normal.
Examples:​
float var0 <- normal_inverse(0.98,0,1) with_precision(2); // var0 equals 2.05
normalized_rotation
​
Possible uses:​
normalized_rotation
(pair
) --->pair<float,point>
Result:​
The rotation normalized according to Euler formalism with a positive angle, such that each rotation has a unique set of parameters (positive angle, normalize axis rotation).
Examples:​
pair<float,point> var0 <- normalized_rotation(-38.0::{1,1,1}); // var0 equals 38.0::{-0.5773502691896258,-0.5773502691896258,-0.5773502691896258}
See also: [rotation_composition, inverse_rotation](OperatorsSZ#rotation_composition, inverse_rotation),
not
​
Same signification as !
not
​
Possible uses:​
not
(predicate
) --->predicate
Result:​
create a new predicate with the inverse truth value
Examples:​
not predicate1
obj_file
​
Possible uses:​
obj_file
(string
) --->file
string
obj_file
pair<float,point>
--->file
obj_file
(string
,pair<float,point>
) --->file
string
obj_file
string
--->file
obj_file
(string
,string
) --->file
obj_file
(string
,string
,pair<float,point>
) --->file
Result:​
Constructs a file of type obj. Allowed extensions are limited to obj, OBJ
Special cases:​
- obj_file(string): This file constructor allows to read an obj file. The associated mlt file have to have the same name as the file to be read.
file f <- obj_file("file.obj");
- obj_file(string,pair<float,point>): This file constructor allows to read an obj file and apply an init rotation to it. The rotationis a pair angle::rotation vector. The associated mlt file have to have the same name as the file to be read.
file f <- obj_file("file.obj", 90.0::{-1,0,0});
- obj_file(string,string): This file constructor allows to read an obj file, using a specific mlt file
file f <- obj_file("file.obj","file.mlt");
- obj_file(string,string,pair<float,point>): This file constructor allows to read an obj file, using a specific mlt file, and apply an init rotation to it. The rotationis a pair angle::rotation vector
file f <- obj_file("file.obj","file.mlt", 90.0::{-1,0,0});
See also: is_obj,
of
​
Same signification as .
of_generic_species
​
Possible uses:​
container
of_generic_species
species
--->list
of_generic_species
(container
,species
) --->list
Result:​
a list, containing the agents of the left-hand operand whose species is that denoted by the right-hand operand and whose species extends the right-hand operand species
Examples:​
// species speciesA {}
// species sub_speciesA parent: speciesA {}
list var2 <- [sub_speciesA(0),sub_speciesA(1),speciesA(2),speciesA(3)] of_generic_species speciesA; // var2 equals [sub_speciesA0,sub_speciesA1,speciesA0,speciesA1]
list var3 <- [sub_speciesA(0),sub_speciesA(1),speciesA(2),speciesA(3)] of_generic_species sous_test; // var3 equals [sub_speciesA0,sub_speciesA1]
list var4 <- [sub_speciesA(0),sub_speciesA(1),speciesA(2),speciesA(3)] of_species speciesA; // var4 equals [speciesA0,speciesA1]
list var5 <- [sub_speciesA(0),sub_speciesA(1),speciesA(2),speciesA(3)] of_species sous_test; // var5 equals [sub_speciesA0,sub_speciesA1]
See also: of_species,
of_species
​
Possible uses:​
container
of_species
species
--->list
of_species
(container
,species
) --->list
Result:​
a list, containing the agents of the left-hand operand whose species is the one denoted by the right-hand operand.The expression agents of_species (species self) is equivalent to agents where (species each = species self); however, the advantage of using the first syntax is that the resulting list is correctly typed with the right species, whereas, in the second syntax, the parser cannot determine the species of the agents within the list (resulting in the need to cast it explicitly if it is to be used in an ask statement, for instance).
Special cases:​
- if the right operand is nil, of_species returns the right operand
Examples:​
list var0 <- (self neighbors_at 10) of_species (species (self)); // var0 equals all the neighboring agents of the same species.
list var1 <- [test(0),test(1),node(1),node(2)] of_species test; // var1 equals [test0,test1]
See also: of_generic_species,
one_matches
​
Possible uses:​
container
one_matches
any expression
--->bool
one_matches
(container
,any expression
) --->bool
Result:​
Returns true if at least one of the elements of the left-hand operand make the right-hand operand evaluate to true. Returns false if the left-hand operand is empty. 'c one_matches each.property' is strictly equivalent to '(c count each.property) > 0' but faster in most cases (as it is a shortcircuited operator)
Comment:​
in the right-hand operand, the keyword each can be used to represent, in turn, each of the elements.
Special cases:​
- if the left-hand operand is nil, one_matches throws an error
Examples:​
bool var0 <- [1,2,3,4,5,6,7,8] one_matches (each > 3); // var0 equals true
bool var1 <- [1::2, 3::4, 5::6] one_matches (each > 4); // var1 equals true
See also: none_matches, all_match, count,
one_of
​
Possible uses:​
one_of
(container<KeyType,ValueType>
) --->ValueType
Result:​
one of the values stored in this container at a random key
Comment:​
the one_of operator behavior depends on the nature of the operand
Special cases:​
- if the operand is empty, one_of returns nil
- if it is a graph, one_of returns one of the lists of edges
- if it is a file, one_of returns one of the elements of the content of the file (that is also a container)
- if it is a list or a matrix, one_of returns one of the values of the list or of the matrix
i <- any ([1,2,3]); //i equals 1, 2 or 3
string sMat <- one_of(matrix([["c11","c12","c13"],["c21","c22","c23"]])); // sMat equals "c11","c12","c13", "c21","c22" or "c23"
- if it is a map, one_of returns one the value of a random pair of the map
int im <- one_of ([2::3, 4::5, 6::7]); // im equals 3, 5 or 7
bool var3 <- [2::3, 4::5, 6::7].values contains im; // var3 equals true
- if it is a population, one_of returns one of the agents of the population
bug b <- one_of(bug); // Given a previously defined species bug, b is one of the created bugs, e.g. bug3
See also: contains,
one_verifies
​
Same signification as one_matches
or
​
Possible uses:​
bool
or
any expression
--->bool
or
(bool
,any expression
) --->bool
Result:​
a bool value, equal to the logical or between the left-hand operand and the right-hand operand.
Comment:​
both operands are always casted to bool before applying the operator. Thus, an expression like 1 or 0 is accepted and returns true.
Examples:​
bool var0 <- true or false; // var0 equals true
int a <-3 ; int b <- 4; int c <- 7;
bool var2 <- ((a+b) = c ) or ((a+b) > c ); // var2 equals true
or
​
Possible uses:​
predicate
or
predicate
--->predicate
or
(predicate
,predicate
) --->predicate
Result:​
create a new predicate from two others by including them as subintentions. It's an exclusive "or"
Examples:​
predicate1 or predicate2
osm_file
​
Possible uses:​
osm_file
(string
) --->file
string
osm_file
map<string,list>
--->file
osm_file
(string
,map<string,list>
) --->file
Result:​
Constructs a file of type osm. Allowed extensions are limited to osm, pbf, bz2, gz
Special cases:​
- osm_file(string): This file constructor allows to read a osm (.osm, .pbf, .bz2, .gz) file (using WGS84 coordinate system for the data)
file f <- osm_file("file");
- osm_file(string,map<string,list>): This file constructor allows to read an osm (.osm, .pbf, .bz2, .gz) file (using WGS84 coordinate system for the data)The map is used to filter the objects in the file according their attributes: for each key (string) of the map, only the objects that have a value for the attribute contained in the value set are kept. For an exhaustive list of the attibute of OSM data, see: http://wiki.openstreetmap.org/wiki/Map_Features
void var1 <- file f <- osm_file("file", map(["highway"::["primary", "secondary"], "building"::["yes"], "amenity"::[]]));; // var1 equals f will contain all the objects of file that have the attibute 'highway' with the value 'primary' or 'secondary', and the objects that have the attribute 'building' with the value 'yes', and all the objects that have the attribute 'aminity' (whatever the value).
See also: is_osm,
out_degree_of
​
Possible uses:​
graph
out_degree_of
unknown
--->int
out_degree_of
(graph
,unknown
) --->int
Result:​
returns the out degree of a vertex (right-hand operand) in the graph given as left-hand operand.
Examples:​
int var1 <- graphFromMap out_degree_of (node(3)); // var1 equals 4
See also: in_degree_of, degree_of,
out_edges_of
​
Possible uses:​
graph
out_edges_of
unknown
--->list
out_edges_of
(graph
,unknown
) --->list
Result:​
returns the list of the out-edges of a vertex (right-hand operand) in the graph given as left-hand operand.
Examples:​
list var1 <- graphFromMap out_edges_of (node(3)); // var1 equals 3
See also: in_edges_of,
overlapping
​
Possible uses:​
container<unknown,geometry>
overlapping
geometry
--->list<geometry>
overlapping
(container<unknown,geometry>
,geometry
) --->list<geometry>
Result:​
A list of agents or geometries among the left-operand list, species or meta-population (addition of species), overlapping the operand (casted as a geometry).
Examples:​
list<geometry> var0 <- [ag1, ag2, ag3] overlapping(self); // var0 equals return the agents among ag1, ag2 and ag3 that overlap the shape of the agent applying the operator.
(species1 + species2) overlapping self
See also: neighbors_at, neighbors_of, agent_closest_to, agents_inside, closest_to, inside, agents_overlapping,
overlaps
​
Possible uses:​
geometry
overlaps
geometry
--->bool
overlaps
(geometry
,geometry
) --->bool
Result:​
A boolean, equal to true if the left-geometry (or agent/point) overlaps the right-geometry (or agent/point).
Special cases:​
- if one of the operand is null, returns false.
- if one operand is a point, returns true if the point is included in the geometry
Examples:​
bool var0 <- polyline([{10,10},{20,20}]) overlaps polyline([{15,15},{25,25}]); // var0 equals true
bool var1 <- polygon([{10,10},{10,20},{20,20},{20,10}]) overlaps polygon([{15,15},{15,25},{25,25},{25,15}]); // var1 equals true
bool var2 <- polygon([{10,10},{10,20},{20,20},{20,10}]) overlaps polyline([{10,10},{20,20}]); // var2 equals true
bool var3 <- polygon([{10,10},{10,20},{20,20},{20,10}]) overlaps {15,15}; // var3 equals true
See also: disjoint_from, crosses, intersects, partially_overlaps, touches,
pair
​
Possible uses:​
pair
(any
) --->pair
Result:​
casts the operand in a pair object.
palette
​
Possible uses:​
palette
(list<rgb>
) --->list<rgb>
map<rgb,float>
palette
int
--->list<rgb>
palette
(map<rgb,float>
,int
) --->list<rgb>
Result:​
transforms a list of n colors into a palette (necessary for some layers) returns a list of n colors chosen in the gradient provided. Colors are chosen by interpolating the stops of the gradient (the colors) using their weight, in the order described in the gradient. In case the map<rgb, float> passed in argument is not a gradient but a scale, the colors will be chosen in the set of colors and might appear duplicated in the palette
partially_overlapping
​
Possible uses:​
container<unknown,geometry>
partially_overlapping
geometry
--->list<geometry>
partially_overlapping
(container<unknown,geometry>
,geometry
) --->list<geometry>
Result:​
A list of agents or geometries among the left-operand list, species or meta-population (addition of species), partially_overlapping the operand (casted as a geometry).
Examples:​
list<geometry> var0 <- [ag1, ag2, ag3] partially_overlapping(self); // var0 equals the agents among ag1, ag2 and ag3 that partially_overlap the shape of the right-hand argument.
list<geometry> var1 <- (species1 + species2) partially_overlapping (self); // var1 equals the agents among species species1 and species2 that partially_overlap the shape of the right-hand argument.
See also: neighbors_at, neighbors_of, closest_to, overlapping, agents_overlapping, inside, agents_inside, agent_closest_to,
partially_overlaps
​
Possible uses:​
geometry
partially_overlaps
geometry
--->bool
partially_overlaps
(geometry
,geometry
) --->bool
Result:​
A boolean, equal to true if the left-geometry (or agent/point) partially overlaps the right-geometry (or agent/point).
Comment:​
if one geometry operand fully covers the other geometry operand, returns false (contrarily to the overlaps operator).
Special cases:​
- if one of the operand is null, returns false.
Examples:​
bool var0 <- polyline([{10,10},{20,20}]) partially_overlaps polyline([{15,15},{25,25}]); // var0 equals true
bool var1 <- polygon([{10,10},{10,20},{20,20},{20,10}]) partially_overlaps polygon([{15,15},{15,25},{25,25},{25,15}]); // var1 equals true
bool var2 <- polygon([{10,10},{10,20},{20,20},{20,10}]) partially_overlaps {25,25}; // var2 equals false
bool var3 <- polygon([{10,10},{10,20},{20,20},{20,10}]) partially_overlaps polyline([{10,10},{20,20}]); // var3 equals false
See also: disjoint_from, crosses, overlaps, intersects, touches,
path
​
Possible uses:​
path
(any
) --->path
Result:​
casts the operand in a path object.
Special cases:​
- if the operand is a path, returns this path
- if the operand is a geometry of an agent, returns a path from the list of points of the geometry
- if the operand is a list, cast each element of the list as a point and create a path from these points
path p <- path([{12,12},{30,30},{50,50}]);
path_between
​
Possible uses:​
map<agent,unknown>
path_between
container<unknown,geometry>
--->path
path_between
(map<agent,unknown>
,container<unknown,geometry>
) --->path
topology
path_between
container<unknown,geometry>
--->path
path_between
(topology
,container<unknown,geometry>
) --->path
list<agent>
path_between
container<unknown,geometry>
--->path
path_between
(list<agent>
,container<unknown,geometry>
) --->path
path_between
(graph
,geometry
,geometry
) --->path
path_between
(map<agent,unknown>
,geometry
,geometry
) --->path
path_between
(topology
,geometry
,geometry
) --->path
path_between
(list<agent>
,geometry
,geometry
) --->path
Result:​
The shortest path between several objects according to set of cells with corresponding weights The shortest path between a list of two objects in a graph The shortest path between two objects according to set of cells with corresponding weights The shortest path between two objects according to set of cells The shortest path between several objects according to set of cells
Examples:​
path var0 <- path_between (cell_grid as_map (each::each.is_obstacle ? 9999.0 : 1.0), [ag1, ag2, ag3]); // var0 equals A path between ag1 and ag2 and ag3 passing through the given cell_grid agents with minimal cost
path var1 <- path_between (my_graph, ag1, ag2); // var1 equals A path between ag1 and ag2
path var2 <- path_between (cell_grid as_map (each::each.is_obstacle ? 9999.0 : 1.0), ag1, ag2); // var2 equals A path between ag1 and ag2 passing through the given cell_grid agents with a minimal cost
path var3 <- my_topology path_between (ag1, ag2); // var3 equals A path between ag1 and ag2
path var4 <- path_between (cell_grid where each.is_free, ag1, ag2); // var4 equals A path between ag1 and ag2 passing through the given cell_grid agents
path var5 <- my_topology path_between [ag1, ag2]; // var5 equals A path between ag1 and ag2
path var6 <- path_between (cell_grid where each.is_free, [ag1, ag2, ag3]); // var6 equals A path between ag1 and ag2 and ag3 passing through the given cell_grid agents
See also: towards, direction_to, distance_between, direction_between, path_to, distance_to,
path_to
​
Possible uses:​
geometry
path_to
geometry
--->path
path_to
(geometry
,geometry
) --->path
point
path_to
point
--->path
path_to
(point
,point
) --->path
Result:​
A path between two geometries (geometries, agents or points) considering the topology of the agent applying the operator.
Examples:​
path var0 <- ag1 path_to ag2; // var0 equals the path between ag1 and ag2 considering the topology of the agent applying the operator
See also: towards, direction_to, distance_between, direction_between, path_between, distance_to,
paths_between
​
Possible uses:​
paths_between
(graph
,pair
,int
) --->list<path>
Result:​
The K shortest paths between a list of two objects in a graph
Examples:​
list<path> var0 <- paths_between(my_graph, ag1:: ag2, 2); // var0 equals the 2 shortest paths (ordered by length) between ag1 and ag2
pbinom
​
Same signification as binomial_sum
pchisq
​
Same signification as chi_square
percent_absolute_deviation
​
Possible uses:​
list<float>
percent_absolute_deviation
list<float>
--->float
percent_absolute_deviation
(list<float>
,list<float>
) --->float
Result:​
percent absolute deviation indicator for 2 series of values: percent_absolute_deviation(list_vals_observe,list_vals_sim)