Skip to main content
Version: 1.9.3

Operators (S to Z)


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 and or (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, deserialize, field_with, font, from_gaml, from_json, is, is_skill, list_with, matrix_with, serialize, species_of, to_gaml, to_geojson, to_json, to_list, with_size, with_style,


-, /, *, +, blend, brewer_colors, brewer_palettes, gradient, grayscale, hsb, mean, median, palette, rgb, rnd_color, scale, sum, to_hsb,


Comparison operators​

!=, <, <=, =, >, >=, between,


-, ::, +, 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,


-, !=, +, <, <=, =, >, >=, 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​

horizontal, stack, vertical,


edge​

edge_between, strahler,


diff, diff2,


agent_file, 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_agent, 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_shape, is_simulation, is_svg, is_text, is_threeds, is_xml, json_file, new_folder, obj_file, osm_file, pgm_file, property_file, read, rename_file, shape_file, simulation_file, step_sub_model, svg_file, text_file, threeds_file, unzip, writable, xml_file, zip,


GamaMetaType​

type_of,


GamaSVGFile​

image,


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,


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,


ImageOperators​

*, antialiased, blend, blurred, brighter, clipped_with, darker, grayscale, horizontal_flip, image, matrix, rotated_by, sharpened, snapshot, tinted_with, vertical_flip, with_height, with_size, with_width,


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,


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,


as_map, create_map, index_of, last_index_of,


-, /, ., *, +, append_horizontally, append_vertically, column_at, columns_list, determinant, eigenvalues, flatten, 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,


agent_from_geometry, all_pairs_shortest_path, as_path, load_shortest_paths, max_flow_between, path_between, path_to, paths_between, use_cache,


Pedestrian​

generate_pedestrian_network,


-, /, *, +, <, <=, >, >=, 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, exp_density, exp_rnd, 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,


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, k_nearest_neighbors, 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, k_nearest_neighbors, 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,


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, k_nearest_neighbors, kmeans, kurtosis, log_gamma, max, mean, mean_deviation, median, min, moment, moran, morrisAnalysis, mul, normal_area, normal_density, normal_inverse, predict, pValue_for_fStat, pValue_for_tStat, quantile, quantile_inverse, rank_interpolated, residuals, rms, rSquare, simple_clustering_by_distance, skewness, sobolAnalysis, split, split_in, split_using, standard_deviation, student_area, student_t_inverse, sum, t_test, variance,


+, <, <=, >, >=, at, capitalize, char, compress, 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, uncompress, upper_case,


SubModel​

load_sub_model,


System​

., choose, command, copy, copy_from_clipboard, copy_to_clipboard, copy_to_clipboard, dead, enter, every, from_gaml, is_error, is_reachable, is_warning, play_sound, user_confirm, user_input_dialog, wizard, wizard_page,


date, string,


action, agent, BDIPlan, bool, container, conversation, directory, emotion, file, float, gaml_type, geometry, graph, int, kml, list, map, matrix, mental_state, message, Norm, pair, path, point, predicate, regression, rgb, Sanction, skill, social_link, species, topology, unknown,


User control operators​

choose, enter, user_confirm, user_input_dialog, wizard, wizard_page,


Operators​


sample​

Possible uses:​

  • sample (any expression) ---> string
  • string sample any expression ---> string
  • sample (string , any expression) ---> string
  • sample (list, int, bool) ---> list
  • sample (list, int, bool, list) ---> list

Result:​

takes a sample of the specified size from the elements of x using either with or without replacement takes a sample of the specified size from the elements of x using either with or without replacement with given weights

Examples:​

list var0 <- sample([2,10,1],2,false); // var0 equals [10,1] 
list var1 <- sample([2,10,1],2,false,[0.1,0.7,0.2]); // var1 equals [10,2]

Sanction​

Possible uses:​

  • Sanction (any) ---> Sanction

Result:​

casts the operand in a Sanction object.


scale​

Possible uses:​

  • scale (map<rgb,unknown>) ---> map<float,rgb>
  • scale (map<rgb,unknown>, float, float) ---> map<float,rgb>

Result:​

Similar to gradient(map<rgb, float>) but reorders the colors based on their weight and does not normalize them, so as to effectively represent a color scale (i.e. a correspondance between a range of value and a color that implicitly begins with the lowest value). For instance scale([#red::10, #green::0, #blue::30]) would produce the reverse map and associate #green to the interval 0-10, #red to 10-30, and #blue above 30. The main difference in usages is that, for instance in the definition of a mesh to display, a gradient will produce interpolated colors to accomodate for the intermediary values, while a scale will stick to the colors defined. Expects a gradient, i.e. a map<rgb,float>, where values represent the different stops of the colors. First normalizes the passed gradient, and then applies the resulting weights to the interval represented by min and max, so as to return a scale (i.e. absolute values instead of the stops)

See also: gradient,


scaled_by​

Same signification as *


scaled_to​

Possible uses:​

  • geometry scaled_to point ---> geometry
  • scaled_to (geometry , point) ---> geometry

Result:​

allows to restrict the size of a geometry so that it fits in the envelope {width, height, depth} defined by the second operand

Examples:​

geometry var0 <- shape scaled_to {10,10}; // var0 equals a geometry corresponding to the geometry of the agent applying the operator scaled so that it fits a square of 10x10

select​

Same signification as where


serialize​

Possible uses:​

  • serialize (unknown) ---> string

Result:​

Serializes any object/agent/simulation into a string, using the 'binary' formatThe result of this operator can be then used in the from: facet of restore or create statements in case of agents, or using deserialize for other items

See also: to_json, to_gaml,


set_about​

Possible uses:​

  • emotion set_about predicate ---> emotion
  • set_about (emotion , predicate) ---> emotion

Result:​

change the about value of the given emotion

Examples:​

emotion set_about predicate1

set_agent​

Possible uses:​

  • social_link set_agent agent ---> social_link
  • set_agent (social_link , agent) ---> social_link

Result:​

change the agent value of the given social link

Examples:​

social_link set_agent agentA

set_agent_cause​

Possible uses:​

  • emotion set_agent_cause agent ---> emotion
  • set_agent_cause (emotion , agent) ---> emotion
  • predicate set_agent_cause agent ---> predicate
  • set_agent_cause (predicate , agent) ---> predicate

Result:​

change the agentCause value of the given emotion change the agentCause value of the given predicate

Examples:​

new_emotion set_agent_cause agentA 
predicate set_agent_cause agentA

set_decay​

Possible uses:​

  • emotion set_decay float ---> emotion
  • set_decay (emotion , float) ---> emotion

Result:​

change the decay value of the given emotion

Examples:​

emotion set_decay 12

set_dominance​

Possible uses:​

  • social_link set_dominance float ---> social_link
  • set_dominance (social_link , float) ---> social_link

Result:​

change the dominance value of the given social link

Examples:​

social_link set_dominance 0.4

set_familiarity​

Possible uses:​

  • social_link set_familiarity float ---> social_link
  • set_familiarity (social_link , float) ---> social_link

Result:​

change the familiarity value of the given social link

Examples:​

social_link set_familiarity 0.4

set_intensity​

Possible uses:​

  • emotion set_intensity float ---> emotion
  • set_intensity (emotion , float) ---> emotion

Result:​

change the intensity value of the given emotion

Examples:​

emotion set_intensity 12

set_lifetime​

Possible uses:​

  • mental_state set_lifetime int ---> mental_state
  • set_lifetime (mental_state , int) ---> mental_state

Result:​

change the lifetime value of the given mental state

Examples:​

mental state set_lifetime 1

set_liking​

Possible uses:​

  • social_link set_liking float ---> social_link
  • set_liking (social_link , float) ---> social_link

Result:​

change the liking value of the given social link

Examples:​

social_link set_liking 0.4

set_modality​

Possible uses:​

  • mental_state set_modality string ---> mental_state
  • set_modality (mental_state , string) ---> mental_state

Result:​

change the modality value of the given mental state

Examples:​

mental state set_modality belief

set_predicate​

Possible uses:​

  • mental_state set_predicate predicate ---> mental_state
  • set_predicate (mental_state , predicate) ---> mental_state

Result:​

change the predicate value of the given mental state

Examples:​

mental state set_predicate pred1

set_solidarity​

Possible uses:​

  • social_link set_solidarity float ---> social_link
  • set_solidarity (social_link , float) ---> social_link

Result:​

change the solidarity value of the given social link

Examples:​

social_link set_solidarity 0.4

set_strength​

Possible uses:​

  • mental_state set_strength float ---> mental_state
  • set_strength (mental_state , float) ---> mental_state

Result:​

change the strength value of the given mental state

Examples:​

mental state set_strength 1.0

set_trust​

Possible uses:​

  • social_link set_trust float ---> social_link
  • set_trust (social_link , float) ---> social_link

Result:​

change the trust value of the given social link

Examples:​

social_link set_familiarity 0.4

set_truth​

Possible uses:​

  • predicate set_truth bool ---> predicate
  • set_truth (predicate , bool) ---> predicate

Result:​

change the is_true value of the given predicate

Examples:​

predicate set_truth false

set_z​

Possible uses:​

  • geometry set_z container<unknown,float> ---> geometry
  • set_z (geometry , container<unknown,float>) ---> geometry
  • set_z (geometry, int, float) ---> geometry

Result:​

Sets the z ordinate of the n-th point of a geometry to the value provided by the third argument

Examples:​

triangle(3) set_z [5,10,14] 
set_z (triangle(3), 1, 3.0)

shape_file​

Possible uses:​

  • shape_file (string) ---> file
  • string shape_file int ---> file
  • shape_file (string , int) ---> file
  • string shape_file string ---> file
  • shape_file (string , string) ---> file
  • string shape_file bool ---> file
  • shape_file (string , bool) ---> file
  • shape_file (string, int, bool) ---> file
  • shape_file (string, string, bool) ---> file

Result:​

Constructs a file of type shape. Allowed extensions are limited to shp, SHP

Special cases:​

  • shape_file(string): This file constructor allows to read a shapefile (.shp) file
file f <- shape_file("file.shp");
  • shape_file(string,int): This file constructor allows to read a shapefile (.shp) file and specifying the coordinates system code, as an int (epsg code)
file f <- shape_file("file.shp", "32648");
  • shape_file(string,string): This file constructor allows to read a shapefile (.shp) file and specifying the coordinates system code (epg,...,), as a string
file f <- shape_file("file.shp", "EPSG:32648");
  • shape_file(string,bool): This file constructor allows to read a shapefile (.shp) file and take a potential z value (not taken in account by default)
file f <- shape_file("file.shp", true);
  • shape_file(string,int,bool): This file constructor allows to read a shapefile (.shp) file and specifying the coordinates system code, as an int (epsg code) and take a potential z value (not taken in account by default)
file f <- shape_file("file.shp", "32648", true);
  • shape_file(string,string,bool): This file constructor allows to read a shapefile (.shp) file and specifying the coordinates system code (epg,...,), as a string and take a potential z value (not taken in account by default)
file f <- shape_file("file.shp", "EPSG:32648",true);

See also: is_shape,


sharpened​

Possible uses:​

  • sharpened (image) ---> image
  • image sharpened int ---> image
  • sharpened (image , int) ---> image

Result:​

Application of a sharpening filter to the image passed in parameter. This operation can be applied multiple times. The original image is left untouched Application of a sharpening filter to the image passed in parameter. This operation is applied multiple times if the last argument is > 0. The original image is left untouched


shuffle​

Possible uses:​

  • shuffle (container) ---> list
  • shuffle (string) ---> string
  • shuffle (matrix) ---> matrix

Result:​

Returns a new list containing the randomly shuffled elements of the container. Returns a new string with randomly shuffled letters Returns a new matrix of the same size as the operand, with randomly shuffled elements

Special cases:​

  • if the operand is empty, returns an empty list (or string, matrix)

Examples:​

list var0 <- shuffle ([12, 13, 14]); // var0 equals [14,12,13] (for example) 
string var1 <- shuffle ('abc'); // var1 equals 'bac' (for example)
matrix var2 <- shuffle (matrix([["c11","c12","c13"],["c21","c22","c23"]])); // var2 equals matrix([["c12","c21","c11"],["c13","c22","c23"]]) (for example)

See also: reverse,


signum​

Possible uses:​

  • signum (int) ---> int
  • signum (float) ---> int

Result:​

Returns -1 if the argument is negative, +1 if it is positive, 0 if it is equal to zero or not a number Returns -1 if the argument is negative, +1 if it is positive, 0 if it is equal to zero or not a number

Examples:​

int var0 <- signum(-12); // var0 equals -1 
int var1 <- signum(14); // var1 equals 1
int var2 <- signum(0); // var2 equals 0
int var3 <- signum(-12.8); // var3 equals -1
int var4 <- signum(14.5); // var4 equals 1
int var5 <- signum(0.0); // var5 equals 0

simple_clustering_by_distance​

Possible uses:​

  • container<unknown,agent> simple_clustering_by_distance float ---> list<list<agent>>
  • simple_clustering_by_distance (container<unknown,agent> , float) ---> list<list<agent>>

Result:​

A list of agent groups clustered by distance considering a distance min between two groups.

Examples:​

list<list<agent>> var0 <- [ag1, ag2, ag3, ag4, ag5] simpleClusteringByDistance 20.0; // var0 equals for example, can return [[ag1, ag3], [ag2], [ag4, ag5]]

See also: hierarchical_clustering,


simple_clustering_by_envelope_distance​

Same signification as simple_clustering_by_distance


simplification​

Possible uses:​

  • geometry simplification float ---> geometry
  • simplification (geometry , float) ---> geometry

Result:​

A geometry corresponding to the simplification of the operand (geometry, agent, point) considering a tolerance distance.

Comment:​

The algorithm used for the simplification is Douglas-Peucker

Examples:​

geometry var0 <- self simplification 0.1; // var0 equals the geometry resulting from the application of the Douglas-Peuker algorithm on the geometry of the agent applying the operator with a tolerance distance of 0.1.

simulation_file​

Possible uses:​

  • simulation_file (string) ---> file

Result:​

Constructs a file of type simulation. Allowed extensions are limited to gsim, simulation

Special cases:​

  • simulation_file(string): File containing a saved simulation in the java binary serialisation protocol

See also: is_simulation,


sin​

Possible uses:​

  • sin (float) ---> float
  • sin (int) ---> float

Result:​

Returns the value (in [-1,1]) of the sinus of the operand (in decimal degrees). The argument is casted to an int before being evaluated.

Special cases:​

  • Operand values out of the range [0-359] are normalized.

Examples:​

float var0 <- sin(360) with_precision 10 with_precision 10; // var0 equals 0.0 
float var1 <- sin (0); // var1 equals 0.0

See also: cos, tan,


sin_rad​

Possible uses:​

  • sin_rad (float) ---> float

Result:​

Returns the value (in [-1,1]) of the sinus of the operand (in radians).

Examples:​

float var0 <- sin_rad(0); // var0 equals 0.0 
float var1 <- sin_rad(#pi/2); // var1 equals 1.0

See also: cos_rad, tan_rad,


since​

Possible uses:​

  • since (date) ---> bool
  • any expression since date ---> bool
  • since (any expression , date) ---> bool

Result:​

Returns true if the current_date of the model is after (or equal to) the date passed in argument. Synonym of 'current_date >= argument'. Can be used, like 'after', in its composed form with 2 arguments to express the lowest boundary of the computation of a frequency. However, contrary to 'after', there is a subtle difference: the lowest boundary will be tested against the frequency as well

Examples:​

reflex when: since(starting_date) {}  	// this reflex will always be run 
every(2#days) since (starting_date + 1#day) // the computation will return true 1 day after the starting date and every two days after this reference date

skeletonize​

Possible uses:​

  • skeletonize (geometry) ---> list<geometry>
  • geometry skeletonize float ---> list<geometry>
  • skeletonize (geometry , float) ---> list<geometry>
  • skeletonize (geometry, float, float) ---> list<geometry>
  • skeletonize (geometry, float, float, bool) ---> list<geometry>

Result:​

A list of geometries (polylines) corresponding to the skeleton of the operand geometry (geometry, agent)

Special cases:​

  • It can be used with 1 additional float operand: the tolerance for the clipping.
  • It can be used with 2 additional float operands: the tolerances for the clipping and for the triangulation
  • It can be used with 3 additional float operands: the tolerance for the clipping, the tolerance for the triangulation, and the approximation for the clipping.

Examples:​

list<geometry> var0 <- skeletonize(self); // var0 equals the list of geometries corresponding to the skeleton of the geometry of the agent applying the operator.

skew​

Same signification as skewness


skew_gauss​

Possible uses:​

  • skew_gauss (float, float, float, float) ---> float

Result:​

A value from a skew normally distributed random variable with min value (the minimum skewed value possible), max value (the maximum skewed value possible), skew (the degree to which the values cluster around the mode of the distribution; higher values mean tighter clustering) and bias (the tendency of the mode to approach the min, max or midpoint value; positive values bias toward max, negative values toward min).The algorithm was taken from http://stackoverflow.com/questions/5853187/skewing-java-random-number-generation-toward-a-certain-number

Examples:​

float var0 <- skew_gauss(0.0, 1.0, 0.7,0.1); // var0 equals 0.1729218460343077

See also: binomial, gamma_rnd, gauss_rnd, lognormal_rnd, poisson, rnd, truncated_gauss, weibull_rnd,


skewness​

Possible uses:​

  • skewness (list) ---> float

Result:​

returns skewness value computed from the operand list of values

Special cases:​

  • if the length of the list is lower than 3, returns NaN

Examples:​

float var0 <- skewness ([1,2,3,4,5]); // var0 equals 0.0

skill​

Possible uses:​

  • skill (any) ---> skill

Result:​

casts the operand in a skill object.


smooth​

Possible uses:​

  • geometry smooth float ---> geometry
  • smooth (geometry , float) ---> geometry

Result:​

Returns a 'smoothed' geometry, where straight lines are replaces by polynomial (bicubic) curves. The first parameter is the original geometry, the second is the 'fit' parameter which can be in the range 0 (loose fit) to 1 (tightest fit).

Examples:​

geometry var0 <- smooth(square(10), 0.0); // var0 equals a 'rounded' square

snapshot​

Possible uses:​

  • snapshot (string) ---> image
  • agent snapshot string ---> image
  • snapshot (agent , string) ---> image
  • snapshot (agent, string, point) ---> image

Result:​

Takes a snapshot of the display whose name is passed in parameter and returns the image. The search for the display begins in the agent passed in parameter and, if not found, its experiment. The size of the snapshot will be that of the viewReturns nil if no display can be found or the snapshot cannot be taken. Takes a snapshot of the display whose name is passed in parameter and returns the image. The search for the display begins in the agent passed in parameter and, if not found, its experiment. A custom size (a point representing width x height) can be given Returns nil if no display can be found or the snapshot cannot be taken. Takes a snapshot of the display whose name is passed in parameter and returns the image. The search for the display begins in the current agent's simulation and, if not found, its experiment. Returns nil if no display can be found or the snapshot cannot be taken.


sobolAnalysis​

Possible uses:​

  • sobolAnalysis (string, string, int) ---> string

Result:​

Return a string containing the Report of the sobol analysis for the corresponding .csv file and save this report in a txt/csv file.


Possible uses:​

  • social_link (any) ---> social_link

Result:​

casts the operand in a social_link object.


solid​

Same signification as without_holes


sort​

Same signification as sort_by


sort_by​

Possible uses:​

  • container sort_by any expression ---> list
  • sort_by (container , any expression) ---> list

Result:​

Returns a list, containing the elements of the left-hand operand sorted in ascending order by the value of the right-hand operand when it is evaluated on them.

Comment:​

the left-hand operand is casted to a list before applying the operator. 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, sort_by throws an error. If the sorting function returns values that cannot be compared, an error will be thrown as well

Examples:​

list var0 <- [1,2,4,3,5,7,6,8] sort_by (each); // var0 equals [1,2,3,4,5,6,7,8] 
list var2 <- g2 sort_by (length(g2 out_edges_of each) ); // var2 equals [node9, node7, node10, node8, node11, node6, node5, node4]
list var3 <- (list(node) sort_by (round(node(each).location.x)); // var3 equals [node5, node1, node0, node2, node3]
list var4 <- [1::2, 5::6, 3::4] sort_by (each); // var4 equals [2, 4, 6]

See also: group_by,


source_of​

Possible uses:​

  • graph source_of unknown ---> unknown
  • source_of (graph , unknown) ---> unknown

Result:​

returns the source of the edge (right-hand operand) contained in the graph given in left-hand operand.

Special cases:​

  • if the lef-hand operand (the graph) is nil, throws an Exception

Examples:​

graph graphEpidemio <- generate_barabasi_albert( ["edges_species"::edge,"vertices_specy"::node,"size"::3,"m"::5] ); 
unknown var1 <- graphEpidemio source_of(edge(3)); // var1 equals node1
graph graphFromMap <- as_edge_graph([{1,5}::{12,45},{12,45}::{34,56}]);
point var3 <- graphFromMap source_of(link({1,5},{12,45})); // var3 equals {1,5}

See also: target_of,


spatial_graph​

Possible uses:​

  • spatial_graph (container) ---> graph

Result:​

allows to create a spatial graph from a container of vertices, without trying to wire them. The container can be empty. Emits an error if the contents of the container are not geometries, points or agents

See also: graph,


species​

Possible uses:​

  • species (any) ---> species

Result:​

casts the operand in a species object.

Special cases:​

  • if the operand is nil, returns nil;
  • if the operand is an agent, returns its species;
  • if the operand is a string, returns the species with this name (nil if not found);
  • otherwise, returns nil

Examples:​

species var0 <- species(self); // var0 equals the species of the current agent 
species var1 <- species('node'); // var1 equals node
species var2 <- species([1,5,9,3]); // var2 equals nil
species var3 <- species(node1); // var3 equals node

species_of​

Possible uses:​

  • species_of (unknown) ---> species

Result:​

casting of the operand to a species.

Special cases:​

  • if the operand is nil, returns nil;
  • if the operand is an agent, returns its species;
  • if the operand is a string, returns the species with this name (nil if not found);
  • otherwise, returns nil

Examples:​

species var0 <- species(self); // var0 equals the species of the current agent 
species var1 <- species('node'); // var1 equals node
species var2 <- species([1,5,9,3]); // var2 equals nil
species var3 <- species(node1); // var3 equals node

sphere​

Possible uses:​

  • sphere (float) ---> geometry

Result:​

A sphere geometry which radius is equal to the operand.

Comment:​

the centre of the sphere is by default the location of the current agent in which has been called this operator.

Special cases:​

  • returns a point if the operand is lower or equal to 0.

Examples:​

geometry var0 <- sphere(10); // var0 equals a geometry as a circle of radius 10 but displays a sphere.

See also: around, cone, line, link, norm, point, polygon, polyline, rectangle, square, triangle,


split​

Possible uses:​

  • split (list<unknown>) ---> list<list<unknown>>

Result:​

Splits a list of numbers into n=(1+3.3*log10(elements)) bins. The splitting is strict (i.e. elements are in the ith bin if they are strictly smaller than the ith bound)

Examples:​

list<list<unknown>> var0 <- split([1.0,2.0,1.0,3.0,1.0,2.0]); // var0 equals [[1.0,1.0,1.0],[2.0,2.0],[3.0]]

See also: split_in, split_using,


split_at​

Possible uses:​

  • geometry split_at point ---> list<geometry>
  • split_at (geometry , point) ---> list<geometry>

Result:​

The two part of the left-operand lines split at the given right-operand point

Special cases:​

  • if the left-operand is a point or a polygon, returns an empty list

Examples:​

list<geometry> var0 <- polyline([{1,2},{4,6}]) split_at {7,6}; // var0 equals [polyline([{1.0,2.0},{7.0,6.0}]), polyline([{7.0,6.0},{4.0,6.0}])]

split_geometry​

Possible uses:​

  • geometry split_geometry float ---> list<geometry>
  • split_geometry (geometry , float) ---> list<geometry>
  • geometry split_geometry point ---> list<geometry>
  • split_geometry (geometry , point) ---> list<geometry>
  • split_geometry (geometry, int, int) ---> list<geometry>

Result:​

A list of geometries that result from the decomposition of the geometry by square cells of the given side size (geometry, size). It can be used to split in rectangles by giving a point or 2 integer values as operand.

Examples:​

list<geometry> var0 <- to_squares(self, 10.0); // var0 equals the list of the geometries corresponding to the decomposition of the geometry by squares of side size 10.0 
list<geometry> var1 <- to_rectangles(self, {10.0, 15.0}); // var1 equals the list of the geometries corresponding to the decomposition of the geometry by rectangles of size 10.0, 15.0
list<geometry> var2 <- to_rectangles(self, 10,20); // var2 equals the list of the geometries corresponding to the decomposition of the geometry of the agent applying the operator

split_in​

Possible uses:​

  • list<unknown> split_in int ---> list<list<unknown>>
  • split_in (list<unknown> , int) ---> list<list<unknown>>
  • split_in (list<unknown>, int, bool) ---> list<list<unknown>>

Result:​

Splits a list of numbers into n bins defined by n-1 bounds between the minimum and maximum values found in the first argument. The boolean argument controls whether or not the splitting is strict (if true, elements are in the ith bin if they are strictly smaller than the ith bound) Splits a list of numbers into n bins defined by n-1 bounds between the minimum and maximum values found in the first argument. The splitting is strict (i.e. elements are in the ith bin if they are strictly smaller than the ith bound)

Examples:​

list<float> l <- [1.0,3.1,5.2,6.0,9.2,11.1,12.0,13.0,19.9,35.9,40.0]; 
list<list<unknown>> var1 <- split_in(l,3, true); // var1 equals [[1.0,3.1,5.2,6.0,9.2,11.1,12.0,13.0],[19.9],[35.9,40.0]]
list<float> li <- [1.0,3.1,5.2,6.0,9.2,11.1,12.0,13.0,19.9,35.9,40.0];
list<list<unknown>> var3 <- split_in(li,3); // var3 equals [[1.0,3.1,5.2,6.0,9.2,11.1,12.0,13.0],[19.9],[35.9,40.0]]

See also: split, split_using,


split_lines​

Possible uses:​

  • split_lines (container<unknown,geometry>) ---> list<geometry>
  • container<unknown,geometry> split_lines bool ---> list<geometry>
  • split_lines (container<unknown,geometry> , bool) ---> list<geometry>

Result:​

A list of geometries resulting after cutting the lines at their intersections. if the last boolean operand is set to true, the split lines will import the attributes of the initial lines A list of geometries resulting after cutting the lines at their intersections.

Examples:​

list<geometry> var0 <- split_lines([line([{0,10}, {20,10}]), line([{0,10}, {20,10}])]); // var0 equals a list of four polylines: line([{0,10}, {10,10}]), line([{10,10}, {20,10}]), line([{10,0}, {10,10}]) and line([{10,10}, {10,20}]) 
list<geometry> var1 <- split_lines([line([{0,10}, {20,10}]), line([{0,10}, {20,10}])]); // var1 equals a list of four polylines: line([{0,10}, {10,10}]), line([{10,10}, {20,10}]), line([{10,0}, {10,10}]) and line([{10,10}, {10,20}])

split_using​

Possible uses:​

  • list<unknown> split_using list<unknown> ---> list<list<unknown>>
  • split_using (list<unknown> , list<unknown>) ---> list<list<unknown>>
  • split_using (list<unknown>, list<unknown>, bool) ---> list<list<unknown>>

Result:​

Splits a list of numbers into n+1 bins using a set of n bounds passed as the second argument. The splitting is strict (i.e. elements are in the ith bin if they are strictly smaller than the ith bound), when no boolean attribute is specified.

Examples:​

list<float> l <- [1.0,3.1,5.2,6.0,9.2,11.1,12.0,13.0,19.9,35.9,40.0]; 
list<list<unknown>> var1 <- split_using(l,[1.0,3.0,4.2], true); // var1 equals [[],[1.0],[3.1],[5.2,6.0,9.2,11.1,12.0,13.0,19.9,35.9,40.0]]
list<float> li <- [1.0,3.1,5.2,6.0,9.2,11.1,12.0,13.0,19.9,35.9,40.0];
list<list<unknown>> var3 <- split_using(li,[1.0,3.0,4.2]); // var3 equals [[],[1.0],[3.1],[5.2,6.0,9.2,11.1,12.0,13.0,19.9,35.9,40.0]]

See also: split, split_in,


split_with​

Possible uses:​

  • string split_with string ---> list
  • split_with (string , string) ---> list
  • split_with (string, string, bool) ---> list

Result:​

Returns a list containing the sub-strings (tokens) of the left-hand operand delimited by each of the characters of the right-hand operand.

Comment:​

Delimiters themselves are excluded from the resulting list.

Special cases:​

  • when used with an additional boolean operand, it returns a list containing the sub-strings (tokens) of the left-hand operand delimited either by each of the characters of the right-hand operand (false) or by the whole right-hand operand (true).

Examples:​

list var0 <- 'aa::bb:cc' split_with ('::', true); // var0 equals ['aa','bb:cc'] 
list var1 <- 'aa::bb:cc' split_with ('::', false); // var1 equals ['aa','bb','cc']
list var2 <- 'to be or not to be,that is the question' split_with ' ,'; // var2 equals ['to','be','or','not','to','be','that','is','the','question']

sqrt​

Possible uses:​

  • sqrt (float) ---> float
  • sqrt (int) ---> float

Result:​

Returns the square root of the operand.

Special cases:​

  • if the operand is negative, an exception is raised

Examples:​

float var0 <- sqrt(4); // var0 equals 2.0 
float var1 <- sqrt(4); // var1 equals 2.0

square​

Possible uses:​

  • square (float) ---> geometry

Result:​

A square geometry which side size is equal to the operand.

Comment:​

the centre of the square is by default the location of the current agent in which has been called this operator.

Special cases:​

  • returns nil if the operand is nil.

Examples:​

geometry var0 <- square(10); // var0 equals a geometry as a square of side size 10. 
float var1 <- var0.area; // var1 equals 100.0

See also: around, circle, cone, line, link, norm, point, polygon, polyline, rectangle, triangle,


squircle​

Possible uses:​

  • float squircle float ---> geometry
  • squircle (float , float) ---> geometry

Result:​

A mix of square and circle geometry (see : http://en.wikipedia.org/wiki/Squircle), which side size is equal to the first operand and power is equal to the second operand

Comment:​

the center of the ellipse is by default the location of the current agent in which has been called this operator.

Special cases:​

  • returns a point if the side operand is lower or equal to 0.

Examples:​

geometry var0 <- squircle(4,4); // var0 equals a geometry as a squircle of side 4 with a power of 4.

See also: around, cone, line, link, norm, point, polygon, polyline, super_ellipse, rectangle, square, circle, ellipse, triangle,


stack​

Possible uses:​

  • stack (map<unknown,int>) ---> unknown<string>
  • stack (list<int>) ---> unknown<string>

Result:​

Creates a stack layout node. Accepts the same argument as horizontal or vertical (a map of display indices and weights) but the weights are not taken into account Creates a stack layout node. Stacks can only contain one or several indices of displays (without weight)


standard_deviation​

Possible uses:​

  • standard_deviation (container) ---> float

Result:​

the standard deviation on the elements of the operand. See Standard_deviation for more details.

Comment:​

The operator casts all the numerical element of the list into float. The elements that are not numerical are discarded.

Examples:​

float var0 <- standard_deviation ([4.5, 3.5, 5.5, 7.0]); // var0 equals 1.2930100540985752

See also: mean, mean_deviation,


step_sub_model​

Possible uses:​

  • step_sub_model (agent) ---> int

Result:​

Load a submodel

Comment:​

loaded submodel


strahler​

Possible uses:​

  • strahler (graph) ---> map

Result:​

retur for each edge, its strahler number


string​

Possible uses:​

  • date string string ---> string
  • string (date , string) ---> string
  • string (date, string, string) ---> string

Result:​

converts a date to astring following a custom pattern. The pattern can use "%Y %M %N %D %E %h %m %s %z" for outputting years, months, name of month, days, name of days, hours, minutes, seconds and the time-zone. A null or empty pattern will return the complete date as defined by the ISO date & time format. The pattern can also follow the pattern definition found here, which gives much more control over the format of the date: https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html#patterns. Different patterns are available by default as constants: #iso_local, #iso_simple, #iso_offset, #iso_zoned and #custom, which can be changed in the preferences

Examples:​

string(#now, 'yyyy-MM-dd') 
string(#now, 'yyyy-MM-dd', 'en')

student_area​

Possible uses:​

  • float student_area int ---> float
  • student_area (float , int) ---> float

Result:​

Returns the area to the left of x in the Student T distribution with the given degrees of freedom.

Examples:​

float var0 <- student_area(1.64,3) with_precision(2); // var0 equals 0.9

student_t_inverse​

Possible uses:​

  • float student_t_inverse int ---> float
  • student_t_inverse (float , int) ---> float

Result:​

Returns the value, t, for which the area under the Student-t probability density function (integrated from minus infinity to t) is equal to x.

Examples:​

float var0 <- student_t_inverse(0.9,3) with_precision(2); // var0 equals 1.64

subtract_days​

Same signification as minus_days


subtract_hours​

Same signification as minus_hours


subtract_minutes​

Same signification as minus_minutes


subtract_months​

Same signification as minus_months


subtract_ms​

Same signification as minus_ms


subtract_seconds​

Same signification as -


subtract_weeks​

Same signification as minus_weeks


subtract_years​

Same signification as minus_years


successors_of​

Possible uses:​

  • graph successors_of unknown ---> list
  • successors_of (graph , unknown) ---> list

Result:​

returns the list of successors (i.e. targets of out edges) of the given vertex (right-hand operand) in the given graph (left-hand operand)

Examples:​

list var1 <- graphEpidemio successors_of ({1,5}); // var1 equals [{12,45}] 
list var2 <- graphEpidemio successors_of node({34,56}); // var2 equals []

See also: predecessors_of, neighbors_of,


sum​

Possible uses:​

  • sum (container) ---> unknown
  • sum (graph) ---> float

Result:​

the sum of all the elements of the operand

Comment:​

the behavior depends on the nature of the operand

Special cases:​

  • if it is a population or a list of other types: sum transforms all elements into float and sums them
  • if it is a map, sum returns the sum of the value of all elements
  • if it is a file, sum returns the sum of the content of the file (that is also a container)
  • if it is a graph, sum returns the total weight of the graph
  • if it is a matrix of int, float or object, sum returns the sum of all the numerical elements (i.e. all elements for integer and float matrices)
  • if it is a matrix of other types: sum transforms all elements into float and sums them
  • if it is a list of colors: sum will sum them and return the blended resulting color
  • if it is a list of int or float: sum returns the sum of all the elements
int var0 <- sum ([12,10,3]); // var0 equals 25
  • if it is a list of points: sum returns the sum of all points as a point (each coordinate is the sum of the corresponding coordinate of each element)
unknown var1 <- sum([{1.0,3.0},{3.0,5.0},{9.0,1.0},{7.0,8.0}]); // var1 equals {20.0,17.0}

See also: mul,


sum_of​

Possible uses:​

  • container sum_of any expression ---> unknown
  • sum_of (container , any expression) ---> unknown

Result:​

the sum of the right-hand expression evaluated on each of the elements of the left-hand operand

Comment:​

in the right-hand operand, the keyword each can be used to represent, in turn, each of the right-hand operand elements.

Special cases:​

  • if the left-operand is a map, the keyword each will contain each value
unknown var1 <- [1::2, 3::4, 5::6] sum_of (each + 3); // var1 equals 21

Examples:​

unknown var0 <- [1,2] sum_of (each * 100 ); // var0 equals 300

See also: min_of, max_of, product_of, mean_of,


svg_file​

Possible uses:​

  • svg_file (string) ---> file

Result:​

Constructs a file of type svg. Allowed extensions are limited to svg

Special cases:​

  • svg_file(string): This file constructor allows to read a svg file
file f <-svg_file("file.svg");

See also: is_svg,


t_test​

Possible uses:​

  • list t_test list ---> float
  • t_test (list , list) ---> float

Result:​

Returns the observed significance level, or p-value, associated with a two-sample, two-tailed t-test comparing the means of the two input lists.The number returned is the smallest significance level at which one can reject the null hypothesis

Examples:​

float var0 <- t_test([10.0,5.0,1.0, 3.0],[1.0,10.0,5.0,1.0]); // var0 equals 0.01

tan​

Possible uses:​

  • tan (int) ---> float
  • tan (float) ---> float

Result:​

Returns the value (in [-1,1]) of the trigonometric tangent of the operand (in decimal degrees).

Special cases:​

  • Operand values out of the range [0-359] are normalized. Notice that tan(360) does not return 0.0 but -2.4492935982947064E-16
  • The tangent is only defined for any real number except 90 + k * 180 (k an positive or negative integer). Nevertheless notice that tan(90) returns 1.633123935319537E16 (whereas we could except infinity).

Examples:​

float var0 <- tan (0); // var0 equals 0.0 
float var1 <- tan(90); // var1 equals 1.633123935319537E16

See also: cos, sin,


tan_rad​

Possible uses:​

  • tan_rad (float) ---> float

Result:​

Returns the value (in [-1,1]) of the trigonometric tangent of the operand (in radians).

Examples:​

float var0 <- tan_rad(0); // var0 equals 0.0

See also: cos_rad, sin_rad,


tanh​

Possible uses:​

  • tanh (int) ---> float
  • tanh (float) ---> float

Result:​

Returns the value (in the interval [-1,1]) of the hyperbolic tangent of the operand (which can be any real number, expressed in decimal degrees).

Examples:​

float var0 <- tanh(0); // var0 equals 0.0 
float var1 <- tanh(100); // var1 equals 1.0

target_of​

Possible uses:​

  • graph target_of unknown ---> unknown
  • target_of (graph , unknown) ---> unknown

Result:​

returns the target of the edge (right-hand operand) contained in the graph given in left-hand operand.

Special cases:​

  • if the lef-hand operand (the graph) is nil, returns nil

Examples:​

graph graphEpidemio <- generate_barabasi_albert( ["edges_species"::edge,"vertices_specy"::node,"size"::3,"m"::5] ); 
unknown var1 <- graphEpidemio source_of(edge(3)); // var1 equals node1
graph graphFromMap <- as_edge_graph([{1,5}::{12,45},{12,45}::{34,56}]);
unknown var3 <- graphFromMap target_of(link({1,5},{12,45})); // var3 equals {12,45}

See also: source_of,


teapot​

Possible uses:​

  • teapot (float) ---> geometry

Result:​

A teapot geometry which radius is equal to the operand.

Comment:​

the centre of the teapot is by default the location of the current agent in which has been called this operator.

Special cases:​

  • returns a point if the operand is lower or equal to 0.

Examples:​

geometry var0 <- teapot(10); // var0 equals a geometry as a circle of radius 10 but displays a teapot.

See also: around, cone, line, link, norm, point, polygon, polyline, rectangle, square, triangle,


text_file​

Possible uses:​

  • text_file (string) ---> file
  • string text_file list<string> ---> file
  • text_file (string , list<string>) ---> file

Result:​

Constructs a file of type text. Allowed extensions are limited to txt, data, text

Special cases:​

  • text_file(string): This file constructor allows to read a text file (.txt, .data, .text)
file f <-text_file("file.txt");
  • text_file(string,list<string>): This file constructor allows to store a list of string in a text file (it does not save it - just store it in memory)
file f <-text_file("file.txt", ["item1","item2","item3"]);

See also: is_text,


TGauss​

Same signification as truncated_gauss


threeds_file​

Possible uses:​

  • threeds_file (string) ---> file

Result:​

Constructs a file of type threeds. Allowed extensions are limited to 3ds, max

Special cases:​

  • threeds_file(string): This file constructor allows to read a 3DS Max file. Only loads vertices and faces
threeds_file f <- threeds_file("file");

See also: is_threeds,


tinted_with​

Possible uses:​

  • image tinted_with rgb ---> image
  • tinted_with (image , rgb) ---> image
  • tinted_with (image, rgb, float) ---> image

Result:​

Returns the image tinted using the color passed in parameter. This effectively multiplies the colors of the image by it. The original image is left untouched Returns the image tinted using the color passed in parameter and a factor between 0 and 1, determining the transparency of the dyeing to apply. The original image is left untouched


to​

Same signification as until

Possible uses:​

  • date to date ---> list<date>
  • to (date , date) ---> list<date>

Result:​

builds an interval between two dates (the first inclusive and the second exclusive, which behaves like a read-only list of dates. The default step between two dates is the step of the model

Comment:​

The default step can be overruled by using the every operator applied to this interval

Examples:​

date('2000-01-01') to date('2010-01-01') // builds an interval between these two dates 
(date('2000-01-01') to date('2010-01-01')) every (#day) // builds an interval between these two dates which contains all the days starting from the beginning of the interval. Beware that using every with #month or #year will produce odd results, as these pseudo-constants are not constant; only the first value will be used to compute the intervals (if current_date is set to a month of February, #month will only represent 28 or 29 days depending on whether it is a leap year or not !). If such intervals need to be built, it is recommended to usea generative way, for instance a loop using the 'plus_years' or 'plus_months' operators to build a list of dates

See also: every,


to_binary​

Same signification as serialize


to_GAMA_CRS​

Possible uses:​

  • to_GAMA_CRS (geometry) ---> geometry
  • geometry to_GAMA_CRS string ---> geometry
  • to_GAMA_CRS (geometry , string) ---> geometry

Special cases:​

  • returns the geometry corresponding to the transformation of the given geometry to the GAMA CRS (Coordinate Reference System) assuming the given geometry is referenced by the current CRS, the one corresponding to the world's agent one
geometry var0 <- to_GAMA_CRS({121,14}); // var0 equals a geometry corresponding to the agent geometry transformed into the GAMA CRS
  • returns the geometry corresponding to the transformation of the given geometry to the GAMA CRS (Coordinate Reference System) assuming the given geometry is referenced by given CRS
geometry var1 <- to_GAMA_CRS({121,14}, "EPSG:4326"); // var1 equals a geometry corresponding to the agent geometry transformed into the GAMA CRS

to_gaml​

Possible uses:​

  • to_gaml (unknown) ---> string

Result:​

Returns the literal description of an expression in gaml, in a format suitable to be reinterpreted and return a similar object

Examples:​

string var0 <- to_gaml(0); // var0 equals '0' 
string var1 <- to_gaml(3.78); // var1 equals '3.78'
string var2 <- to_gaml({23, 4.0}); // var2 equals '{23.0,4.0,0.0}'
string var3 <- to_gaml(rgb(255,0,125)); // var3 equals 'rgb (255, 0, 125,255)'
string var4 <- to_gaml('hello'); // var4 equals "'hello'"
string var5 <- to_gaml(a_graph); // var5 equals ([((1 as node)::(3 as node))::(5 as edge),((0 as node)::(3 as node))::(3 as edge),((1 as node)::(2 as node))::(1 as edge),((0 as node)::(2 as node))::(2 as edge),((0 as node)::(1 as node))::(0 as edge),((2 as node)::(3 as node))::(4 as edge)] as map ) as graph
string var6 <- to_gaml(node1); // var6 equals 1 as node

to_geojson​

Possible uses:​

  • to_geojson (any expression, string, any expression) ---> string

Result:​

Returns a geojson representation of a population, a list of agents/geometries or an agent/geometry, provided with a CRS and a list of attributes to save

Examples:​

string var0 <- to_geojson(boat,"EPSG:4326",["color"]); // var0 equals {"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":[100.51155642068785,3.514781609095577E-4,0.0]},"properties":{},"id":"0"}]}

to_hsb​

Possible uses:​

  • to_hsb (rgb) ---> list<float>

Result:​

Converts a Gama color to hsb (h=hue, s=saturation, b=brightness) value

Examples:​

list<float> var0 <- to_hsb (#cyan); // var0 equals [0.5,1.0,1.0]

to_json​

Possible uses:​

  • to_json (unknown) ---> string
  • unknown to_json bool ---> string
  • to_json (unknown , bool) ---> string

Result:​

Serializes any object/agent/simulation into a string, using the json format and no pretty printing.The format used by GAMA follows simple rules. int, float, bool, string values are outputted as they are. nil is outputted as 'null'. A list is outputted as a json array. Any other object or agent is outputted as a json object. If this object possesses the "gaml_type" attribute, it is an instance of the corresponding type, and the members that follow contain the attributes and the values necessary to reconstruct it. If it has the "agent_reference" attribute, its value represent the reference to an agent. If any reference to an agent is found, the json string returned will be an object with two attributes: "gama_object", the object containing the references, and "reference_table" a dictionary mapping the references to the json description of the agents (their species, name, index, and list of attributes). This choice allows to manage cross references between agents Serializes any object/agent/simulation into a string, using the json format. A flag can be passed to enable/disable pretty printing (false by default).The format used by GAMA follows simple rules. int, float, bool, string values are outputted as they are. nil is outputted as 'null'. A list is outputted as a json array. Any other object or agent is outputted as a json object. If this object possesses the "gaml_type" attribute, it is an instance of the corresponding type, and the members that follow contain the attributes and the values necessary to reconstruct it. If it has the "agent_reference" attribute, its value represent the reference to an agent. If any reference to an agent is found, the json string returned will be an object with two attributes: "gama_object", the object containing the references, and "reference_table" a dictionary mapping the references to the json description of the agents (their species, name, index, and list of attributes). This choice allows to manage cross references between agents

See also: serialize, to_gaml,


to_list​

Possible uses:​

  • to_list (unknown) ---> list

Result:​

casts the operand to a list, making an explicit copy if it is already a list or a subtype of list (interval, population, etc.)

See also: list,


to_rectangles​

Possible uses:​

  • to_rectangles (geometry, point, bool) ---> list<geometry>
  • to_rectangles (geometry, int, int, bool) ---> list<geometry>

Result:​

A list of rectangles of the size corresponding to the given dimension that result from the decomposition of the geometry into rectangles (geometry, dimension, overlaps), if overlaps = true, add the rectangles that overlap the border of the geometry

Examples:​

list<geometry> var0 <- to_rectangles(self, 5, 20, true); // var0 equals the list of rectangles corresponding to the discretization by a grid of 5 columns and 20 rows into rectangles of the geometry of the agent applying the operator. The rectangles overlapping the border of the geometry are kept 
list<geometry> var1 <- to_rectangles(self, {10.0, 15.0}, true); // var1 equals the list of rectangles of size {10.0, 15.0} corresponding to the discretization into rectangles of the geometry of the agent applying the operator. The rectangles overlapping the border of the geometry are kept

to_segments​

Possible uses:​

  • to_segments (geometry) ---> list<geometry>

Result:​

A list of a segments resulting from the decomposition of the geometry (or its contours for polygons) into sgements

Examples:​

list<geometry> var0 <- to_segments(line([{10,10},{80,10},{80,80}])); // var0 equals [line([{10,10},{80,10}]), line([{80,10},{80,80}])]

to_squares​

Same signification as split_geometry

Possible uses:​

  • to_squares (geometry, int, bool) ---> list<geometry>
  • to_squares (geometry, float, bool) ---> list<geometry>
  • to_squares (geometry, int, bool, float) ---> list<geometry>

Result:​

A list of a given number of squares from the decomposition of the geometry into squares (geometry, nb_square, overlaps, precision_coefficient), if overlaps = true, add the squares that overlap the border of the geometry, coefficient_precision should be close to 1.0 A list of a given number of squares from the decomposition of the geometry into squares (geometry, nb_square, overlaps), if overlaps = true, add the squares that overlap the border of the geometry A list of squares of the size corresponding to the given size that result from the decomposition of the geometry into squares (geometry, size, overlaps), if overlaps = true, add the squares that overlap the border of the geometry

Examples:​

list<geometry> var0 <- to_squares(self, 10, true, 0.99); // var0 equals the list of 10 squares corresponding to the discretization into squares of the geometry of the agent applying the operator. The squares overlapping the border of the geometry are kept 
list<geometry> var1 <- to_squares(self, 10, true); // var1 equals the list of 10 squares corresponding to the discretization into squares of the geometry of the agent applying the operator. The squares overlapping the border of the geometry are kept
list<geometry> var2 <- to_squares(self, 10.0, true); // var2 equals the list of squares of side size 10.0 corresponding to the discretization into squares of the geometry of the agent applying the operator. The squares overlapping the border of the geometry are kept

to_sub_geometries​

Possible uses:​

  • geometry to_sub_geometries list<float> ---> list<geometry>
  • to_sub_geometries (geometry , list<float>) ---> list<geometry>
  • to_sub_geometries (geometry, list<float>, float) ---> list<geometry>

Result:​

A list of geometries resulting after spliting the geometry into sub-geometries.

Examples:​

list<geometry> var0 <- to_sub_geometries(rectangle(10, 50), [0.1, 0.5, 0.4], 1.0); // var0 equals a list of three geometries corresponding to 3 sub-geometries using cubes of 1m size 
list<geometry> var1 <- to_sub_geometries(rectangle(10, 50), [0.1, 0.5, 0.4]); // var1 equals a list of three geometries corresponding to 3 sub-geometries

to_triangles​

Same signification as triangulate


tokenize​

Same signification as split_with


topology​

Possible uses:​

  • topology (any) ---> topology

Result:​

casts the operand in a topology object.

Special cases:​

  • if the operand is a topology, returns the topology itself;
  • if the operand is a spatial graph, returns the graph topology associated;
  • if the operand is a population, returns the topology of the population;
  • if the operand is a shape or a geometry, returns the continuous topology bounded by the geometry;
  • if the operand is a matrix, returns the grid topology associated
  • if the operand is another kind of container, returns the multiple topology associated to the container
  • otherwise, casts the operand to a geometry and build a topology from it.

Examples:​

topology var0 <- topology(0); // var0 equals nil 
topology(a_graph) --: Multiple topology in POLYGON ((24.712119771887785 7.867357373616512, 24.712119771887785 61.283226839310565, 82.4013676510046 7.867357373616512)) at location[53.556743711446195;34.57529210646354]

See also: geometry,


touches​

Possible uses:​

  • geometry touches geometry ---> bool
  • touches (geometry , geometry) ---> bool

Result:​

A boolean, equal to true if the left-geometry (or agent/point) touches the right-geometry (or agent/point).

Comment:​

returns true when the left-operand only touches the right-operand. When one geometry covers partially (or fully) the other one, it returns false.

Special cases:​

  • if one of the operand is null, returns false.

Examples:​

bool var0 <- {15,15} touches {15,15}; // var0 equals false 
bool var1 <- polyline([{10,10},{20,20}]) touches {10,10}; // var1 equals true
bool var2 <- polyline([{10,10},{20,20}]) touches polyline([{10,10},{5,5}]); // var2 equals true
bool var3 <- polygon([{10,10},{10,20},{20,20},{20,10}]) touches polygon([{15,15},{15,25},{25,25},{25,15}]); // var3 equals false
bool var4 <- polygon([{10,10},{10,20},{20,20},{20,10}]) touches {10,15}; // var4 equals true

See also: disjoint_from, crosses, overlaps, partially_overlaps, intersects,


touching​

Possible uses:​

  • container<unknown,geometry> touching geometry ---> list<geometry>
  • touching (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), touching the operand (casted as a geometry).

Examples:​

list<geometry> var0 <- [ag1, ag2, ag3] toucing(self); // var0 equals the agents among ag1, ag2 and ag3 that touch the shape of the right-hand argument. 
list<geometry> var1 <- (species1 + species2) touching (self); // var1 equals the agents among species species1 and species2 that touch the shape of the right-hand argument.

See also: neighbors_at, neighbors_of, closest_to, overlapping, agents_overlapping, inside, agents_inside, agent_closest_to,


towards​

Possible uses:​

  • geometry towards geometry ---> float
  • towards (geometry , geometry) ---> float

Result:​

The direction (in degree) between the two geometries (geometries, agents, points) considering the topology of the agent applying the operator.

Examples:​

float var0 <- ag1 towards ag2; // var0 equals the direction between ag1 and ag2 and ag3 considering the topology of the agent applying the operator

See also: distance_between, distance_to, direction_between, path_between, path_to,


trace​

Possible uses:​

  • trace (matrix) ---> float

Result:​

The trace of the given matrix (the sum of the elements on the main diagonal).

Examples:​

float var0 <- trace(matrix([[1,2],[3,4]])); // var0 equals 5

transformed_by​

Possible uses:​

  • geometry transformed_by point ---> geometry
  • transformed_by (geometry , point) ---> geometry

Result:​

A geometry resulting from the application of a rotation and a scaling (right-operand : point {angle(degree), scale factor} of the left-hand operand (geometry, agent, point)

Examples:​

geometry var0 <- self transformed_by {45, 0.5}; // var0 equals the geometry resulting from 45 degrees rotation and 50% scaling of the geometry of the agent applying the operator.

See also: rotated_by, translated_by,


translated_by​

Possible uses:​

  • geometry translated_by point ---> geometry
  • translated_by (geometry , point) ---> geometry

Result:​

A geometry resulting from the application of a translation by the right-hand operand distance to the left-hand operand (geometry, agent, point)

Examples:​

geometry var0 <- self translated_by {10,10,10}; // var0 equals the geometry resulting from applying the translation to the left-hand geometry (or agent).

See also: rotated_by, transformed_by,


translated_to​

Same signification as at_location


transpose​

Possible uses:​

  • transpose (matrix) ---> matrix

Result:​

The transposition of the given matrix

Examples:​

matrix var0 <- transpose(matrix([[5,-3],[6,-4]])); // var0 equals matrix([[5,6],[-3,-4]])

triangle​

Possible uses:​

  • triangle (float) ---> geometry
  • float triangle float ---> geometry
  • triangle (float , float) ---> geometry

Result:​

A triangle geometry which the base and height size are given by the operand. A triangle geometry which side size is given by the operand.

Comment:​

the center of the triangle is by default the location of the current agent in which has been called this operator.the center of the triangle is by default the location of the current agent in which has been called this operator.

Special cases:​

  • returns nil if one of the operand is nil.
  • returns nil if the operand is nil.

Examples:​

geometry var0 <- triangle(5, 10); // var0 equals a geometry as a triangle with a base of 5m and a height of 10m. 
geometry var1 <- triangle(5); // var1 equals a geometry as a triangle with side_size = 5.

See also: around, circle, cone, line, link, norm, point, polygon, polyline, rectangle, square,


triangulate​

Possible uses:​

  • triangulate (geometry) ---> list<geometry>
  • triangulate (list<geometry>) ---> list<geometry>
  • geometry triangulate float ---> list<geometry>
  • triangulate (geometry , float) ---> list<geometry>
  • triangulate (geometry, float, float) ---> list<geometry>
  • triangulate (geometry, float, float, bool) ---> list<geometry>

Result:​

A list of geometries (triangles) corresponding to the Delaunay triangulation of the operand geometry (geometry, agent, point, use_approx_clipping) with the given tolerance for the clipping and for the triangulation with using an approximate clipping is the last operand is true A list of geometries (triangles) corresponding to the Delaunay triangulation of the operand geometry (geometry, agent, point) A list of geometries (triangles) corresponding to the Delaunay triangulation of the operand geometry (geometry, agent, point) with the given tolerance for the clipping A list of geometries (triangles) corresponding to the Delaunay triangulation computed from the list of polylines A list of geometries (triangles) corresponding to the Delaunay triangulation of the operand geometry (geometry, agent, point) with the given tolerance for the clipping and for the triangulation

Examples:​

list<geometry> var0 <- triangulate(self,0.1, 1.0, true); // var0 equals the list of geometries (triangles) corresponding to the Delaunay triangulation of the geometry of the agent applying the operator. 
list<geometry> var1 <- triangulate(self); // var1 equals the list of geometries (triangles) corresponding to the Delaunay triangulation of the geometry of the agent applying the operator.
list<geometry> var2 <- triangulate(self, 0.1); // var2 equals the list of geometries (triangles) corresponding to the Delaunay triangulation of the geometry of the agent applying the operator.
list<geometry> var3 <- triangulate([line([{0,50},{100,50}]), line([{50,0},{50,100}])); // var3 equals the list of geometries (triangles) corresponding to the Delaunay triangulation of the geometry of the agent applying the operator.
list<geometry> var4 <- triangulate(self,0.1, 1.0); // var4 equals the list of geometries (triangles) corresponding to the Delaunay triangulation of the geometry of the agent applying the operator.

truncated_gauss​

Possible uses:​

  • truncated_gauss (list) ---> float
  • truncated_gauss (point) ---> float

Result:​

A random value from a normally distributed random variable in the interval ]mean - standardDeviation; mean + standardDeviation[.

Special cases:​

  • if the operand is a list, only the two first elements are taken into account as [mean, standardDeviation]
  • when truncated_gauss is called with a list of only one element mean, it will always return 0.0
  • when the operand is a point, it is read as {mean, standardDeviation}

Examples:​

float var0 <- truncated_gauss ([0.5, 0.0]); // var0 equals 0.5 
float var1 <- truncated_gauss ({0, 0.3}); // var1 equals a float between -0.3 and 0.3

See also: binomial, gamma_rnd, gauss_rnd, lognormal_rnd, poisson, rnd, skew_gauss, weibull_rnd, gamma_trunc_rnd, weibull_trunc_rnd, lognormal_trunc_rnd,


type_of​

Possible uses:​

  • type_of (unknown) ---> any GAML type<unknown>

Result:​

Returns the GAML type of the operand

Examples:​

string var0 <- string(type_of("a string")); // var0 equals "string" 
string var1 <- string(type_of([1,2,3,4,5])); // var1 equals "list<int>"
geometry g0 <- to_GAMA_CRS({121,14}, "EPSG:4326");
string var3 <- string(type_of(g0)); // var3 equals "point"

uncompress​

Possible uses:​

  • uncompress (string) ---> string

Result:​

Returns a string that represents the uncompressed form (using gzip) of the argument

See also: compress,


undirected​

Possible uses:​

  • undirected (graph) ---> graph

Result:​

the operand graph becomes an undirected graph.

Comment:​

WARNING / side effect: this operator modifies the operand and does not create a new graph.

See also: directed,


union​

Possible uses:​

  • union (container<unknown,geometry>) ---> geometry
  • container union container ---> list
  • union (container , container) ---> list

Result:​

returns a new list containing all the elements of both containers without duplicated elements.

Special cases:​

  • if the left or right operand is nil, union throws an error
  • if the right-operand is a container of points, geometries or agents, returns the geometry resulting from the union all the geometries

Examples:​

list var0 <- [1,2,3,4,5,6] union [2,4,9]; // var0 equals [1,2,3,4,5,6,9] 
list var1 <- [1,2,3,4,5,6] union [0,8]; // var1 equals [1,2,3,4,5,6,0,8]
list var2 <- [1,3,2,4,5,6,8,5,6] union [0,8]; // var2 equals [1,3,2,4,5,6,8,0]
geometry var3 <- union([geom1, geom2, geom3]); // var3 equals a geometry corresponding to union between geom1, geom2 and geom3

See also: inter, +,


unknown​

Possible uses:​

  • unknown (any) ---> unknown

Result:​

casts the operand in a unknown object.


until​

Possible uses:​

  • until (date) ---> bool
  • any expression until date ---> bool
  • until (any expression , date) ---> bool

Result:​

Returns true if the current_date of the model is before (or equel to) the date passed in argument. Synonym of 'current_date <= argument'

Examples:​

reflex when: until(starting_date) {} 	// This reflex will be run only once at the beginning of the simulation

unzip​

Possible uses:​

  • string unzip string ---> bool
  • unzip (string , string) ---> bool

Result:​

Unzip a given zip file into a given folder. Returns true if the file is well unzipped

Examples:​

bool unzip_ok <- unzip(["../includes/my_folder"], "folder.zip";

upper_case​

Possible uses:​

  • upper_case (string) ---> string

Result:​

Converts all of the characters in the string operand to upper case

Examples:​

string var0 <- upper_case("Abc"); // var0 equals 'ABC'

See also: lower_case,


use_cache​

Possible uses:​

  • graph use_cache bool ---> graph
  • use_cache (graph , bool) ---> graph

Result:​

if the second operand is true, the operand graph will store in a cache all the previously computed shortest path (the cache be cleared if the graph is modified).

Comment:​

WARNING / side effect: this operator modifies the operand and does not create a new graph.

See also: path_between,


user_confirm​

Possible uses:​

  • string user_confirm string ---> bool
  • user_confirm (string , string) ---> bool

Result:​

Asks the user to confirm a choice. The two string are used to specify the title and the message of the dialog box.

Examples:​

bool confirm <- user_confirm("Confirm","Please confirm");

user_input_dialog​

Possible uses:​

  • user_input_dialog (list) ---> map<string,unknown>
  • string user_input_dialog list ---> map<string,unknown>
  • user_input_dialog (string , list) ---> map<string,unknown>
  • user_input_dialog (string, list, font) ---> map<string,unknown>
  • user_input_dialog (string, list, font, rgb) ---> map<string,unknown>
  • user_input_dialog (string, list, font, rgb, bool) ---> map<string,unknown>

Result:​

Asks the user for some values and returns a map containing these values. Takes a string and a list of calls to the enter() or choose() operators as arguments. The string is used to specify the message of the dialog box. The list is used to specify the parameters the user can enter. Finally, the font of the title can be specified, as well as the background color and whether the title and close button of the dialog should be displayed or not

Examples:​

map<string,unknown> values2 <- user_input_dialog('Enter number of agents and locations',[enter('Number',100), enter('Location',point, {10, 10})], font('Helvetica', 18), #blue, true); 
create bug number: int(values2 at "Number") with: [location:: (point(values2 at "Location"))];
map<string,unknown> values_no_title <- user_input_dialog([enter('Number',100), enter('Location',point, {10, 10})]);
create bug number: int(values2 at "Number") with: [location:: (point(values2 at "Location"))];
map<string,unknown> values2 <- user_input_dialog('Enter number of agents and locations',[enter('Number',100), enter('Location',point, {10, 10})], font('Helvetica', 18));
create bug number: int(values2 at "Number") with: [location:: (point(values2 at "Location"))];
map<string,unknown> values2 <- user_input_dialog('Enter number of agents and locations',[enter('Number',100), enter('Location',point, {10, 10})], font('Helvetica', 18));
create bug number: int(values2 at "Number") with: [location:: (point(values2 at "Location"))];
map<string,unknown> values2 <- user_input_dialog('Enter number of agents and locations',[enter('Number',100), enter('Location',point, {10, 10})]);
create bug number: int(values2 at "Number") with: [location:: (point(values2 at "Location"))];

using​

Possible uses:​

  • any expression using topology ---> unknown
  • using (any expression , topology) ---> unknown

Result:​

Allows to specify in which topology a spatial computation should take place.

Special cases:​

  • has no effect if the topology passed as a parameter is nil

Examples:​

unknown var0 <- (agents closest_to self) using topology(world); // var0 equals the closest agent to self (the caller) in the continuous topology of the world

values_in​

Possible uses:​

  • field values_in geometry ---> list<float>
  • values_in (field , geometry) ---> list<float>

variance​

Possible uses:​

  • variance (container) ---> float
  • variance (float) ---> float
  • variance (int, float, float) ---> float

Result:​

the variance of the elements of the operand. See Variance for more details. Returns the variance of a data sequence. That is (sumOfSquares - mean*sum) / size with mean = sum/size. Returns the variance from a standard deviation.

Comment:​

The operator casts all the numerical element of the list into float. The elements that are not numerical are discarded. In the example we consider variance of [1,3,5,7]. The size is 4, the sum is 1+3+5+7=16 and the sum of squares is 84.The variance is (84- 16^2/4)/4. CQFD.

Examples:​

float var0 <- variance ([4.5, 3.5, 5.5, 7.0]); // var0 equals 1.671875 
int var1 <- int(variance(4,16,84)); // var1 equals 5
int var2 <- int(variance([1,3,5,6,9,11,12,13])); // var2 equals 17

See also: mean, median,


variance_of​

Possible uses:​

  • container variance_of any expression ---> unknown
  • variance_of (container , any expression) ---> unknown

Result:​

the variance of the right-hand expression evaluated on each of the elements of the left-hand operand

Comment:​

in the right-hand operand, the keyword each can be used to represent, in turn, each of the right-hand operand elements.

Examples:​

float var0 <- [1,2,3,4,5,6] variance_of each with_precision 2; // var0 equals 2.92

See also: min_of, max_of, sum_of, product_of,


vertical​

Possible uses:​

  • vertical (map<unknown,int>) ---> unknown<string>

Result:​

Creates a vertical layout node (a sash). Sashes can contain any number (> 1) of other elements: stacks, horizontal or vertical sashes, or display indices. Each element is represented by a pair in the map, where the key is the element and the value its weight within the sash


vertical_flip​

Possible uses:​

  • vertical_flip (image) ---> image

Result:​

Returns an image flipped vertically by reflecting the original image around the x axis. The original image is left untouched


voronoi​

Possible uses:​

  • voronoi (list<point>) ---> list<geometry>
  • list<point> voronoi geometry ---> list<geometry>
  • voronoi (list<point> , geometry) ---> list<geometry>

Result:​

A list of geometries corresponding to the Voronoi diagram built from the list of points (with eventually a given clip).

Examples:​

list<geometry> var0 <- voronoi([{10,10},{50,50},{90,90},{10,90},{90,10}]); // var0 equals the list of geometries corresponding to the Voronoi Diagram built from the list of points. 
list<geometry> var1 <- voronoi([{10,10},{50,50},{90,90},{10,90},{90,10}], square(300)); // var1 equals the list of geometries corresponding to the Voronoi Diagram built from the list of points with a square of 300m side size as clip.

weibull_density​

Possible uses:​

  • weibull_density (float, float, float) ---> float

Result:​

weibull_density(x,shape,scale) returns the probability density function (PDF) at the specified point x of the Weibull distribution with the given shape and scale.

Examples:​

float var0 <- weibull_rnd(1,2,3) ; // var0 equals 0.731

See also: binomial, gamma_rnd, gauss_rnd, lognormal_rnd, poisson, rnd, skew_gauss, lognormal_density, gamma_density,


weibull_rnd​

Possible uses:​

  • float weibull_rnd float ---> float
  • weibull_rnd (float , float) ---> float

Result:​

returns a random value from a Weibull distribution with specified values of the shape (alpha) and scale (beta) parameters. See https://mathworld.wolfram.com/WeibullDistribution.html for more details (equations 1 and 2).

Examples:​

float var0 <- weibull_rnd(2,3) ; // var0 equals 0.731

See also: binomial, gamma_rnd, gauss_rnd, lognormal_rnd, poisson, rnd, skew_gauss, truncated_gauss, weibull_trunc_rnd,


weibull_trunc_rnd​

Possible uses:​

  • weibull_trunc_rnd (float, float, float, float) ---> float
  • weibull_trunc_rnd (float, float, float, bool) ---> float

Result:​

returns a random value from a truncated Weibull distribution (in a range or given only one boundary) with specified values of the shape (alpha) and scale (beta) parameters. See https://mathworld.wolfram.com/WeibullDistribution.html for more details (equations 1 and 2).

Special cases:​

  • when 2 float operands are specified, they are taken as mininimum and maximum values for the result
weibull_trunc_rnd(2,3,0.0,5.0)
  • when 1 float and a boolean (isMax) operands are specified, the float value represents the single boundary (max if the boolean is true, min otherwise),
weibull_trunc_rnd(2,3,5,true)

See also: weibull_rnd, gamma_trunc_rnd, lognormal_trunc_rnd, truncated_gauss,


weight_of​

Possible uses:​

  • graph weight_of unknown ---> float
  • weight_of (graph , unknown) ---> float

Result:​

returns the weight of the given edge (right-hand operand) contained in the graph given in right-hand operand.

Comment:​

In a localized graph, an edge has a weight by default (the distance between both vertices).

Special cases:​

  • if the left-operand (the graph) is nil, returns nil
  • if the right-hand operand is not an edge of the given graph, weight_of checks whether it is a node of the graph and tries to return its weight
  • if the right-hand operand is neither a node, nor an edge, returns 1.

Examples:​

graph graphFromMap <-  as_edge_graph([{1,5}::{12,45},{12,45}::{34,56}]); 
float var1 <- graphFromMap weight_of(link({1,5},{12,45})); // var1 equals 1.0

weighted_means_DM​

Possible uses:​

  • list<list> weighted_means_DM list<map<string,unknown>> ---> int
  • weighted_means_DM (list<list> , list<map<string,unknown>>) ---> int

Result:​

The index of the candidate that maximizes the weighted mean of its criterion values. The first operand is the list of candidates (a candidate is a list of criterion values); the second operand the list of criterion (list of map)

Special cases:​

  • returns -1 is the list of candidates is nil or empty

Examples:​

int var0 <- weighted_means_DM([[1.0, 7.0],[4.0,2.0],[3.0, 3.0]], [["name"::"utility", "weight" :: 2.0],["name"::"price", "weight" :: 1.0]]); // var0 equals 1

See also: promethee_DM, electre_DM, evidence_theory_DM,


where​

Possible uses:​

  • container where any expression ---> list
  • where (container , any expression) ---> list
  • species where any expression ---> list
  • where (species , any expression) ---> list
  • list where any expression ---> list
  • where (list , any expression) ---> list

Result:​

a list containing all the elements of the left-hand operand that make the right-hand operand evaluate to true.

Comment:​

in the right-hand operand, the keyword each can be used to represent, in turn, each of the right-hand operand elements.

Special cases:​

  • if the left-hand operand is nil, where throws an error
  • if the left-operand is a map, the keyword each will contain each value
list var4 <- [1::2, 3::4, 5::6] where (each >= 4); // var4 equals [4, 6]

Examples:​

list var0 <- [1,2,3,4,5,6,7,8] where (each > 3); // var0 equals [4, 5, 6, 7, 8]  
list var2 <- g2 where (length(g2 out_edges_of each) = 0 ); // var2 equals [node9, node7, node10, node8, node11]
list var3 <- (list(node) where (round(node(each).location.x) > 32); // var3 equals [node2, node3]

See also: first_with, last_with,


with_alpha​

Same signification as rgb


with_height​

Possible uses:​

  • image with_height int ---> image
  • with_height (image , int) ---> image

Result:​

Applies a proportional scaling to the image passed in parameter to return a new scaled image with the corresponding height. A height of 0 will return nil, a height equal to the height of the image will return the original image. Automatic scaling and resizing methods are used. The original image is left untouched


with_k_shortest_path_algorithm​

Possible uses:​

  • graph with_k_shortest_path_algorithm string ---> graph
  • with_k_shortest_path_algorithm (graph , string) ---> graph

Result:​

changes the K shortest paths computation algorithm of the given graph

Comment:​

the right-hand operand can be #Yen and #Bhandari to use the associated algorithm.

Examples:​

the_graph <- the_graph with_k_shortest_path_algorithm #Yen;

with_max_of​

Possible uses:​

  • container with_max_of any expression ---> unknown
  • with_max_of (container , any expression) ---> unknown

Result:​

one of elements of the left-hand operand that maximizes the value of the right-hand operand

Comment:​

in the right-hand operand, the keyword each can be used to represent, in turn, each of the right-hand operand elements.

Special cases:​

  • if the left-hand operand is nil, with_max_of returns the default value of the right-hand operand

Examples:​

unknown var0 <- [1,2,3,4,5,6,7,8] with_max_of (each ); // var0 equals 8 
unknown var2 <- g2 with_max_of (length(g2 out_edges_of each) ) ; // var2 equals node4
unknown var3 <- (list(node) with_max_of (round(node(each).location.x)); // var3 equals node3
unknown var4 <- [1::2, 3::4, 5::6] with_max_of (each); // var4 equals 6

See also: where, with_min_of,


with_min_of​

Possible uses:​

  • container with_min_of any expression ---> unknown
  • with_min_of (container , any expression) ---> unknown

Result:​

one of elements of the left-hand operand that minimizes the value of the right-hand operand

Comment:​

in the right-hand operand, the keyword each can be used to represent, in turn, each of the right-hand operand elements.

Special cases:​

  • if the left-hand operand is nil, with_max_of returns the default value of the right-hand operand

Examples:​

unknown var0 <- [1,2,3,4,5,6,7,8] with_min_of (each ); // var0 equals 1 
unknown var2 <- g2 with_min_of (length(g2 out_edges_of each) ); // var2 equals node11
unknown var3 <- (list(node) with_min_of (round(node(each).location.x)); // var3 equals node0
unknown var4 <- [1::2, 3::4, 5::6] with_min_of (each); // var4 equals 2

See also: where, with_max_of,


with_precision​

Possible uses:​

  • float with_precision int ---> float
  • with_precision (float , int) ---> float
  • point with_precision int ---> point
  • with_precision (point , int) ---> point
  • geometry with_precision int ---> geometry
  • with_precision (geometry , int) ---> geometry

Result:​

Rounds off the value of left-hand operand to the precision given by the value of right-hand operand Rounds off the ordinates of the left-hand point to the precision given by the value of right-hand operand A geometry corresponding to the rounding of points of the operand considering a given precison.

Examples:​

float var0 <- 12345.78943 with_precision 2; // var0 equals 12345.79 
float var1 <- 123 with_precision 2; // var1 equals 123.00
point var2 <- {12345.78943, 12345.78943, 12345.78943} with_precision 2 ; // var2 equals {12345.79, 12345.79, 12345.79}
geometry var3 <- self with_precision 2; // var3 equals the geometry resulting from the rounding of points of the geometry with a precision of 0.1.

See also: round,


with_shortest_path_algorithm​

Possible uses:​

  • graph with_shortest_path_algorithm string ---> graph
  • with_shortest_path_algorithm (graph , string) ---> graph

Result:​

changes the shortest path computation algorithm of the given graph

Comment:​

the right-hand operand can be #Djikstra, #BidirectionalDijkstra, #BellmannFord, #FloydWarshall, #Astar, #NBAStar, #NBAStarApprox, #DeltaStepping, #CHBidirectionalDijkstra, #TransitNodeRouting to use the associated algorithm.

Examples:​

road_network <- road_network with_shortestpath_algorithm #TransitNodeRouting;

with_size​

Possible uses:​

  • font with_size int ---> font
  • with_size (font , int) ---> font

Result:​

Creates a new font from an existing font, with a new size in points

Examples:​

font var0 <- font ('Helvetica Neue',12, #bold + #italic) with_size 24; // var0 equals a bold and italic face of the Helvetica Neue family with a size of 24 points

with_size​

Possible uses:​

  • with_size (image, int, int) ---> image

Result:​

Applies a non-proportional scaling to the image passed in parameter to return a new scaled image with the corresponding width and height. A height of 0 or a width of 0 will return nil. If the width and height parameters are repectively equal to the width and height of the original image, it is returned. Automatic scaling and resizing methods are used. The original image is left untouched


with_style​

Possible uses:​

  • font with_style int ---> font
  • with_style (font , int) ---> font

Result:​

Creates a new font from an existing font, with a new style: either #bold, #italic or #plain or a combination (addition) of them.

Examples:​

font var0 <- font ('Helvetica Neue',12, #bold + #italic) with_style #plain; // var0 equals a plain face of the Helvetica Neue family with a size of 12 points

with_values​

Possible uses:​

  • predicate with_values map ---> predicate
  • with_values (predicate , map) ---> predicate

Result:​

change the parameters of the given predicate

Examples:​

predicate with_values ["time"::10]

with_weights​

Possible uses:​

  • graph with_weights list ---> graph
  • with_weights (graph , list) ---> graph
  • graph with_weights map ---> graph
  • with_weights (graph , map) ---> graph

Result:​

returns the graph (left-hand operand) with weight given in the map (right-hand operand).

Comment:​

WARNING / side effect: this operator modifies the operand and does not create a new graph. It also re-initializes the path finder

Special cases:​

  • if the right-hand operand is a list, assigns the n elements of the list to the n first edges. Note that the ordering of edges may change overtime, which can create some problems...
  • if the left-hand operand is a map, the map should contains pairs such as: vertex/edge::double
graph_from_edges (list(ant) as_map each::one_of (list(ant))) with_weights (list(ant) as_map each::each.food)

with_width​

Possible uses:​

  • image with_width int ---> image
  • with_width (image , int) ---> image

Result:​

Applies a proportional scaling to the image passed in parameter to return a new scaled image with the corresponding width. A width of 0 will return nil, a width equal to the width of the image will return the original image. Automatic scaling and resizing methods are used. The original image is left untouched


without_holes​

Possible uses:​

  • without_holes (geometry) ---> geometry

Result:​

A geometry corresponding to the operand geometry (geometry, agent, point) without its holes

Examples:​

geometry var0 <- solid(self); // var0 equals the geometry corresponding to the geometry of the agent applying the operator without its holes. 
float var1 <- without_holes(polygon([{0,50}, {0,0}, {50,0}, {50,50}, {0,50}]) - square(10) at_location {10,10}).area; // var1 equals 2500.0

wizard​

Possible uses:​

  • string wizard list<map<string,unknown>> ---> map<string,map<string,unknown>>
  • wizard (string , list<map<string,unknown>>) ---> map<string,map<string,unknown>>
  • wizard (string, action, list<map<string,unknown>>) ---> map<string,map<string,unknown>>

Result:​

Build a wizard and return the values enter by the user as a map of map ["title page 1"::["var1"::1,"var2"::2]]. Takes a string, a list of calls to the wizard_page() operator. The first string is used to specify the title. The list is to specify the wizard pages. Build a wizard and return the values enter by the user as a map of map ["title page 1"::["var1"::1,"var2"::2]]. Takes a string, an action and a list of calls to the wizard_page() operator. The first string is used to specify the title. The action to describe when the wizard is supposed to be finished. A classic way of defining the action is bool eval_finish(map<string,map> input_map) {return input_map["page1"]["file"] != nil;}. The list is to specify the wizard pages.

Examples:​

map results <-  wizard("My wizard",[wizard_page("page1","enter info" ,[enter("var1",string)], font("Arial", 10))]); 
map results <- wizard("My wizard",eval_finish, [wizard_page("page1","enter info" ,[enter("var1",string)], font("Arial", 10))]);

wizard_page​

Possible uses:​

  • wizard_page (string, string, list) ---> map<string,unknown>
  • wizard_page (string, string, list, font) ---> map<string,unknown>

Result:​

Build a wizard page. Takes two strings, a list of calls to the enter() or choose() operators and a font as arguments. The first string is used to specify the title, the second the description of the dialog box. The list is to specify the parameters the user can enter. The font is used to specify the font Build a wizard page. Takes two strings and a list of calls to the enter() or choose() operators. The first string is used to specify the title, the second the description of the dialog box. The list is to specify the parameters the user can enter

Examples:​

map results <-  wizard("My wizard",[wizard_page("page1","enter info" ,[enter("var1",string)], font("Arial", 10))]); 
map results <- wizard("My wizard",[wizard_page("page1","enter info" ,[enter("var1",string)])]);

writable​

Possible uses:​

  • file writable bool ---> file
  • writable (file , bool) ---> file

Result:​

Marks the file as read-only or not, depending on the second boolean argument, and returns the first argument

Comment:​

A file is created using its native flags. This operator can change them. Beware that this change is system-wide (and not only restrained to GAMA): changing a file to read-only mode (e.g. "writable(f, false)")

Examples:​

file var0 <- shape_file("../images/point_eau.shp") writable false; // var0 equals returns a file in read-only mode

See also: file,


xml_file​

Possible uses:​

  • xml_file (string) ---> file

Result:​

Constructs a file of type xml. Allowed extensions are limited to xml

Special cases:​

  • xml_file(string): This file constructor allows to read a xml file
file f <-xml_file("file.xml");

See also: is_xml,


xor​

Possible uses:​

  • bool xor bool ---> bool
  • xor (bool , bool) ---> bool

Result:​

a bool value, equal to the logical xor between the left-hand operand and the right-hand operand. False when they are equal

Comment:​

both operands are always casted to bool before applying the operator. Thus, an expression like 1 xor 0 is accepted and returns true.

Examples:​

bool var0 <- xor(true,false); // var0 equals true 
bool var1 <- xor(false,false); // var1 equals false
bool var2 <- xor(false,true); // var2 equals true
bool var3 <- xor(true,true); // var3 equals false
bool var4 <- true xor true; // var4 equals false

See also: or, and, !,


years_between​

Possible uses:​

  • date years_between date ---> int
  • years_between (date , date) ---> int

Result:​

Provide the exact number of years between two dates. This number can be positive or negative (if the second operand is smaller than the first one)

Examples:​

int var0 <- years_between(date('2000-01-01'), date('2010-01-01')); // var0 equals 10

zip​

Same signification as compress

Possible uses:​

  • list<string> zip string ---> bool
  • zip (list<string> , string) ---> bool

Result:​

Zip a given list of files or folders. Returns true if the files are well zipped

Examples:​

bool zip_ok <- zip(["../includes/my_folder"], "folder.zip";