OperatorsIM - gama-platform/gama GitHub Wiki

Operators (I to M)


This file is automatically generated from java files. Do Not Edit It.


Operators


IDW

Possible uses:

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

Result:

Inverse Distance Weighting (IDW) is a type of deterministic method for multivariate interpolation with a known scattered set of points. The assigned values to each geometry are calculated with a weighted average of the values available at the known points. See: http://en.wikipedia.org/wiki/Inverse_distance_weighting Usage: IDW (list of geometries, map of points (key: point, value: value), power parameter)

Examples:

map<geometry,float> var0 <- IDW([ag1, ag2, ag3, ag4, ag5],[{10,10}::25.0, {10,80}::10.0, {100,10}::15.0], 2); // var0 equals for example, can return [ag1::12.0, ag2::23.0,ag3::12.0,ag4::14.0,ag5::17.0]

iloc

Possible uses:

  • dataframe iloc list<int> ---> dataframe
  • iloc (dataframe , list<int>) ---> dataframe
  • dataframe iloc int ---> list<unknown>
  • iloc (dataframe , int) ---> list<unknown>
  • iloc (dataframe, list<int>, list<int>) ---> dataframe
  • iloc (dataframe, int, list<int>) ---> list<unknown>
  • iloc (dataframe, int, int) ---> unknown
  • iloc (dataframe, list<int>, int) ---> list<unknown>

Result:

Pandas-style df.iloci, ...: returns a new dataframe containing only the rows at the given integer indices (in that order). All columns are kept. Negative indices are supported.

Pandas-style df.iloci, ...], [j, ...: returns a new dataframe containing only the rows and columns at the given integer indices, in the order of the input indices. Negative indices are supported on both axes.

Pandas-style df.iloc[i, [j, ...]]: returns the values of row i taken from the selected columns, in the order of the input column indices. Negative indices are supported.

Pandas-style df.iloc[i, j]: returns the cell value at integer (row, col) position. Negative indices are supported on both axes.

Pandas-style df.iloc[[i, ...], j]: returns the values of column j taken from the selected rows, in the order of the input row indices. Negative indices are supported.

Pandas-style df.iloc[i]: returns the row at integer position i as a list of values. Negative indices are supported (-1 is the last row).

Special cases:

  • Select rows 0 and 2
dataframe sub <- iloc(my_df, [0, 2]);
  • Select rows 0 and 2, columns 0 and 1
dataframe sub <- iloc(my_df, [0, 2], [0, 1]);
  • Get cells [0] and [2] of row 1
list values <- iloc(my_df, 1, [0, 2]);
  • Get the cell at row 1, column 0
unknown v <- iloc(my_df, 1, 0);
  • Get column 1 values at rows 0 and 2
list values <- iloc(my_df, [0, 2], 1);
  • Get the last row
list row <- iloc(my_df, -1);

See also: row_at, filter, select_columns, cell, column_at,


image

Possible uses:

  • int image int ---> image
  • image (int , int) ---> image
  • image (int, int, rgb) ---> image
  • image (file, int, int) ---> image
  • image (int, int, bool) ---> image

Result:

Builds a new blank image of the specified dimensions, which does not accept transparency

Builds a new image with the specified dimensions and already filled with the given rgb color

Builds a new image from the specified file, passing the width and height in parameter

Builds a new blank image with the specified dimensions and indicates if it will support transparency or not


image_file

Possible uses:

  • image_file (string) ---> file
  • string image_file string ---> file
  • image_file (string , string) ---> file
  • string image_file matrix<int> ---> file
  • image_file (string , matrix<int>) ---> file
  • string image_file java.awt.image.BufferedImage ---> file
  • image_file (string , java.awt.image.BufferedImage) ---> file

Result:

Constructs a file of type image. Allowed extensions are limited to tiff, jpg, jpeg, png, pict, bmp

Special cases:

  • image_file(string,java.awt.image.BufferedImage):
  • image_file(string): This file constructor allows to read an image file (tiff, jpg, jpeg, png, pict, bmp)
file f <-image_file("file.png");
  • image_file(string,string): This file constructor allows to read an image file (tiff, jpg, jpeg, png, pict, bmp) and to force the extension of the file (can be useful for images coming from URL)
file f <-image_file("http://my_url", "png");
  • image_file(string,matrix): This file constructor allows to store a matrix in a image file (it does not save it - just store it in memory)
file f <-image_file("file.png");

See also: is_image,


in

Possible uses:

  • unknown in container ---> bool
  • in (unknown , container) ---> bool
  • string in string ---> bool
  • in (string , string) ---> bool

Result:

true if the right operand contains the left operand, false otherwise

Returns true if the left-hand string is contained in the right-hand string.

Comment:

the definition of in depends on the container

Special cases:

  • if the right operand is nil or empty, in returns false
  • if both operands are strings, returns true if the left-hand operand patterns is included in to the right-hand string;
  • If the left operand is the empty string, returns true (the empty string is contained in any string).
  • The test is case-sensitive.

Examples:

bool var0 <- 2 in [1,2,3,4,5,6]; // var0 equals true 
bool var1 <- 7 in [1,2,3,4,5,6]; // var1 equals false 
bool var2 <- 3 in [1::2, 3::4, 5::6]; // var2 equals false 
bool var3 <- 6 in [1::2, 3::4, 5::6]; // var3 equals true 
bool var4 <-  'bc' in 'abcded'; // var4 equals true

See also: contains,


in_degree_of

Possible uses:

  • graph in_degree_of unknown ---> int
  • in_degree_of (graph , unknown) ---> int

Result:

returns the in degree of a vertex (right-hand operand) in the graph given as left-hand operand.

Special cases:

  • Returns 0 for an isolated vertex (a vertex with no incoming edges).
  • On an undirected graph, both in_degree_of and out_degree_of return the total degree of the vertex (number of incident edges).
  • Returns 0 if the vertex is not present in the graph.

Examples:

int var1 <- graphFromMap in_degree_of (node(3)); // var1 equals 2

See also: out_degree_of, degree_of,


in_edges_of

Possible uses:

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

Result:

returns the list of the in-edges of a vertex (right-hand operand) in the graph given as left-hand operand.

Examples:

list var1 <- graphFromMap in_edges_of node({12,45}); // var1 equals [LineString]

See also: out_edges_of, edge_between,


incomplete_beta

Possible uses:

  • incomplete_beta (float, float, float) ---> float

Result:

Returns the regularized integral of the beta function with arguments a and b, from zero to x.

Examples:

float var0 <- incomplete_beta(2,3,0.9) with_precision(3); // var0 equals 0.996

incomplete_gamma

Possible uses:

  • float incomplete_gamma float ---> float
  • incomplete_gamma (float , float) ---> float

Result:

Returns the regularized integral of the Gamma function with argument a to the integration end point x.

Examples:

float var0 <- incomplete_gamma(1,5.3) with_precision(3); // var0 equals 0.995

incomplete_gamma_complement

Possible uses:

  • float incomplete_gamma_complement float ---> float
  • incomplete_gamma_complement (float , float) ---> float

Result:

Returns the complemented regularized incomplete Gamma function of the argument a and integration start point x.

Comment:

Is the complement to 1 of incomplete_gamma.

Examples:

float var0 <- incomplete_gamma_complement(1,5.3) with_precision(3); // var0 equals 0.005

indented_by

Possible uses:

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

Result:

Converts a (possibly multiline) string by indenting it by a number -- specified by the second operand -- of tabulations to the right

Examples:

string var0 <- "my" + indented_by("text", 1); // var0 equals "my	text"

index_by

Possible uses:

  • index_by (string, container, any expression) ---> map

Result:

produces a new map from the evaluation of the right-hand operand for each element of the left-hand operand

Special cases:

  • if the left-hand operand is nil, index_by throws an error. If the operation results in duplicate keys, only the first value corresponding to the key is kept

Examples:

map var0 <- [1,2,3,4,5,6,7,8] index_by (each - 1); // var0 equals [0::1, 1::2, 2::3, 3::4, 4::5, 5::6, 6::7, 7::8]

index_of

Possible uses:

  • matrix index_of unknown ---> point
  • index_of (matrix , unknown) ---> point
  • string index_of string ---> int
  • index_of (string , string) ---> int
  • species index_of unknown ---> int
  • index_of (species , unknown) ---> int
  • list index_of unknown ---> int
  • index_of (list , unknown) ---> int
  • map<unknown,unknown> index_of unknown ---> unknown
  • index_of (map<unknown,unknown> , unknown) ---> unknown

Result:

the index of the first occurence of the right operand in the left operand container, or -1 if this list does not contain the element

Comment:

The definition of index_of and the type of the index depend on the container

Special cases:

  • If the pattern is not found, returns -1.
  • If the pattern is the empty string, returns 0.
  • if the left operator is a species, returns the index of an agent in a species. If the argument is not an agent of this species, returns -1. Use int(agent) instead
  • if the left operand is a map, index_of returns the index of a value or nil if the value is not mapped
  • if the left operand is a matrix, index_of returns the index as a point
point var0 <- matrix([[1,2,3],[4,5,6]]) index_of 4; // var0 equals {1.0,0.0}
  • if both operands are strings, returns the index within the left-hand string of the first occurrence of the given right-hand string
int var1 <- "abcabcabc" index_of "ca"; // var1 equals 2
  • if the left operand is a list, index_of returns the index as an integer
int var2 <- [1,2,3,4,5,6] index_of 4; // var2 equals 3 
int var3 <- [4,2,3,4,5,4] index_of 4; // var3 equals 0

Examples:

unknown var4 <- [1::2, 3::4, 5::6] index_of 4; // var4 equals 3

See also: at, last_index_of, all_indexes_of,


inside

Possible uses:

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

Examples:

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

See also: neighbors_at, neighbors_of, closest_to, overlapping, agents_overlapping, agents_inside, agent_closest_to, agents_touching, agent_farthest_to, at_distance, covering, agents_covering, agents_at_distance, partially_overlapping, crossing, agents_crossing, touching, farthest_to, agents_partially_overlapping,


int

Possible uses:

  • int (any) ---> int

Result:

casts the operand in a int object.


inter

Possible uses:

  • container inter container ---> list
  • inter (container , container) ---> list
  • geometry inter geometry ---> geometry
  • inter (geometry , geometry) ---> geometry

Result:

the intersection of the two operands

A geometry resulting from the intersection between the two geometries

Comment:

both containers are transformed into sets (so without duplicated element, cf. remove_deplicates operator) before the set intersection is computed.

Special cases:

  • if an operand is a graph, it will be transformed into the set of its nodes
  • Returns nil if one of the operands is nil.
  • Returns an empty geometry (i.e. nil) if the two operands do not overlap.
  • if an operand is a map, it will be transformed into the set of its values
list var0 <- [1::2, 3::4, 5::6] inter [2,4]; // var0 equals [2,4] 
list var1 <- [1::2, 3::4, 5::6] inter [1,3]; // var1 equals []
  • if an operand is a matrix, it will be transformed into the set of the lines
list var2 <- matrix([[3,2,1],[4,5,4]]) inter [3,4]; // var2 equals [3,4]

Examples:

list var3 <- [1,2,3,4,5,6] inter [2,4]; // var3 equals [2,4] 
list var4 <- [1,2,3,4,5,6] inter [0,8]; // var4 equals [] 
geometry var5 <- square(10) inter circle(5); // var5 equals circle(5)

See also: remove_duplicates, union, +, -,


interleave

Possible uses:

  • interleave (container) ---> list

Result:

Returns a new list containing the interleaved elements of the containers contained in the operand

Comment:

the operand should be a list of lists of elements. The result is a list of elements.

Examples:

list var0 <- interleave([1,2,4,3,5,7,6,8]); // var0 equals [1,2,4,3,5,7,6,8] 
list var1 <- interleave([['e11','e12','e13'],['e21','e22','e23'],['e31','e32','e33']]); // var1 equals ['e11','e21','e31','e12','e22','e32','e13','e23','e33']

internal_integrated_value

Possible uses:

  • any expression internal_integrated_value any expression ---> list
  • internal_integrated_value (any expression , any expression) ---> list

Result:

For internal use only. Corresponds to the implementation, for agents, of the access to containers with [index]


intersecting

Same signification as overlapping


intersection

Same signification as inter


intersects

Possible uses:

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

Result:

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

Special cases:

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

Examples:

bool var0 <- square(5) intersects {10,10}; // var0 equals false

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


inverse

Possible uses:

  • inverse (matrix) ---> matrix<float>

Result:

The inverse matrix of the given matrix. If no inverse exists, returns a matrix that has properties that resemble that of an inverse.

Examples:

matrix<float> var0 <- inverse(matrix([[4,3],[3,2]])); // var0 equals matrix([[-2.0,3.0],[3.0,-4.0]])

inverse_distance_weighting

Same signification as IDW


inverse_rotation

Possible uses:

  • inverse_rotation (pair<float,point>) ---> pair<float,point>

Result:

The inverse rotation. It is a rotation around the same axis with the opposite angle.

Examples:

pair<float,point> var0 <- inverse_rotation(38.0::{1,1,1}); // var0 equals -38.0::{1,1,1}

See also: [rotation_composition, normalized_rotation](OperatorsSZ#rotation_composition, normalized_rotation), rotation_composition,


is

Possible uses:

  • unknown is any expression ---> bool
  • is (unknown , any expression) ---> bool

Result:

Return true if the left operand is an instance of the specified type, false otherwise. Note that this operator only accepts simple types, object types and agent types (e.g., int, float, list, node, etc.). Parametric types such as list are not supported.


is_agent

Possible uses:

  • is_agent (any) ---> bool

Result:

Tests whether the operand is a agent file.

See also: agent_file,


is_alpha

Possible uses:

  • is_alpha (string) ---> bool

Result:

Returns true if the string is alphabetical

Examples:

bool var0 <- is_alpha("ab"); // var0 equals true

is_alphanum

Possible uses:

  • is_alphanum (string) ---> bool

Result:

Returns true if the string is alphanumerical

Examples:

bool var0 <- is_alphanum("a1"); // var0 equals true

is_ascii

Possible uses:

  • is_ascii (string) ---> bool

Result:

Returns true if the string contains only ASCII characters

Examples:

bool var0 <- is_ascii("ab"); // var0 equals true

is_csv

Possible uses:

  • is_csv (any) ---> bool

Result:

Tests whether the operand is a csv file.

See also: csv_file,


is_dataframe

Possible uses:

  • is_dataframe (any) ---> bool

Result:

Tests whether the operand is a dataframe file.

See also: dataframe_file,


is_decimal

Possible uses:

  • is_decimal (string) ---> bool

Result:

Returns true if the string contains only decimal characters

Examples:

bool var0 <- is_decimal("12"); // var0 equals true

is_digit

Possible uses:

  • is_digit (string) ---> bool

Result:

Returns true if the string contains only digit characters

Examples:

bool var0 <- is_digit("12"); // var0 equals true

is_dxf

Possible uses:

  • is_dxf (any) ---> bool

Result:

Tests whether the operand is a dxf file.

See also: dxf_file,


is_error

Possible uses:

  • is_error (any expression) ---> bool

Result:

Returns whether or not the argument raises an error when evaluated

Special cases:

  • is_error evaluates the expression in a try-catch manner; if an error is raised, it returns true without propagating the error.
  • is_error(1/0) = true (integer division by zero is an error in GAML).

is_finite

Possible uses:

  • is_finite (float) ---> bool

Result:

Returns whether the argument is a finite number or not

Examples:

bool var0 <- is_finite(4.66); // var0 equals true 
bool var1 <- is_finite(#infinity); // var1 equals false

is_gaml

Possible uses:

  • is_gaml (any) ---> bool

Result:

Tests whether the operand is a gaml file.

See also: gaml_file,


is_geojson

Possible uses:

  • is_geojson (any) ---> bool

Result:

Tests whether the operand is a geojson file.

See also: geojson_file,


is_gif

Possible uses:

  • is_gif (any) ---> bool

Result:

Tests whether the operand is a gif file.

See also: gif_file,


is_gml

Possible uses:

  • is_gml (any) ---> bool

Result:

Tests whether the operand is a gml file.

See also: gml_file,


is_graph6

Possible uses:

  • is_graph6 (any) ---> bool

Result:

Tests whether the operand is a graph6 file.

See also: graph6_file,


is_graphdimacs

Possible uses:

  • is_graphdimacs (any) ---> bool

Result:

Tests whether the operand is a graphdimacs file.

See also: graphdimacs_file,


is_graphdot

Possible uses:

  • is_graphdot (any) ---> bool

Result:

Tests whether the operand is a graphdot file.

See also: graphdot_file,


is_graphgexf

Possible uses:

  • is_graphgexf (any) ---> bool

Result:

Tests whether the operand is a graphgexf file.

See also: graphgexf_file,


is_graphgml

Possible uses:

  • is_graphgml (any) ---> bool

Result:

Tests whether the operand is a graphgml file.

See also: graphgml_file,


is_graphml

Possible uses:

  • is_graphml (any) ---> bool

Result:

Tests whether the operand is a graphml file.

See also: graphml_file,


is_graphtsplib

Possible uses:

  • is_graphtsplib (any) ---> bool

Result:

Tests whether the operand is a graphtsplib file.

See also: graphtsplib_file,


is_grid

Possible uses:

  • is_grid (any) ---> bool

Result:

Tests whether the operand is a grid file.

See also: grid_file,


is_image

Possible uses:

  • is_image (any) ---> bool

Result:

Tests whether the operand is a image file.

See also: image_file,


is_json

Possible uses:

  • is_json (any) ---> bool

Result:

Tests whether the operand is a json file.

See also: json_file,


is_lower

Possible uses:

  • is_lower (string) ---> bool

Result:

Returns true if the string is in all lowercase

Examples:

bool var0 <- is_lower("ab"); // var0 equals true

is_number

Possible uses:

  • is_number (string) ---> bool
  • is_number (float) ---> bool

Result:

tests whether the operand represents a numerical value

Returns whether the argument is a real number or not

Comment:

Note that the symbol . should be used for a float value (a string with , will not be considered as a numeric value). Symbols e and E are also accepted. A hexadecimal value should begin with #.

Examples:

bool var0 <- is_number("test"); // var0 equals false 
bool var1 <- is_number("123.56"); // var1 equals true 
bool var2 <- is_number("-1.2e5"); // var2 equals true 
bool var3 <- is_number("1,2"); // var3 equals false 
bool var4 <- is_number("#12FA"); // var4 equals true 
bool var5 <- is_number(4.66); // var5 equals true 
bool var6 <- is_number(#infinity); // var6 equals true 
bool var7 <- is_number(#nan); // var7 equals false

is_obj

Possible uses:

  • is_obj (any) ---> bool

Result:

Tests whether the operand is a obj file.

See also: obj_file,


is_osm

Possible uses:

  • is_osm (any) ---> bool

Result:

Tests whether the operand is a osm file.

See also: osm_file,


is_pgm

Possible uses:

  • is_pgm (any) ---> bool

Result:

Tests whether the operand is a pgm file.

See also: pgm_file,


is_property

Possible uses:

  • is_property (any) ---> bool

Result:

Tests whether the operand is a property file.

See also: property_file,


is_reachable

Possible uses:

  • string is_reachable int ---> bool
  • is_reachable (string , int) ---> bool
  • is_reachable (string, int, int) ---> bool

Result:

Returns whether or not the given web address is reachable or not before a time_out time in milliseconds. Uses port 80 (HTTP) by default.

Returns whether or not the given web address is reachable or not before a time_out time in milliseconds

Special cases:

  • Uses port 80 (HTTP) by default for the TCP connection check.
  • Returns false if the host is unreachable, the port is closed, or the DNS lookup fails.
  • A timeout value in milliseconds is passed as the third argument to limit the connection attempt.
  • Returns false if the host is unreachable, the port is closed, or the DNS lookup fails.

Examples:

write sample(is_reachable("www.google.com", 200)); 
write sample(is_reachable("www.google.com", 200));

is_shape

Possible uses:

  • is_shape (any) ---> bool

Result:

Tests whether the operand is a shape file.

See also: shape_file,


is_simulation

Possible uses:

  • is_simulation (any) ---> bool

Result:

Tests whether the operand is a simulation file.

See also: simulation_file,


is_skill

Possible uses:

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

Result:

returns true if the left operand is an agent whose species implements the right-hand skill name


is_svg

Possible uses:

  • is_svg (any) ---> bool

Result:

Tests whether the operand is a svg file.

See also: svg_file,


is_text

Possible uses:

  • is_text (any) ---> bool

Result:

Tests whether the operand is a text file.

See also: text_file,


is_threeds

Possible uses:

  • is_threeds (any) ---> bool

Result:

Tests whether the operand is a threeds file.

See also: threeds_file,


is_upper

Possible uses:

  • is_upper (string) ---> bool

Result:

Returns true if the string is in all uppercase

Examples:

bool var0 <- is_upper("AB"); // var0 equals true

is_warning

Possible uses:

  • is_warning (any expression) ---> bool

Result:

Returns whether or not the argument raises a warning when evaluated


is_whitespace

Same signification as whitespace


is_xml

Possible uses:

  • is_xml (any) ---> bool

Result:

Tests whether the operand is a xml file.

See also: xml_file,


join

Same signification as concatenate

Possible uses:

  • join (dataframe, dataframe, list<string>) ---> dataframe
  • join (dataframe, dataframe, string) ---> dataframe
  • join (dataframe, dataframe, list<string>, string) ---> dataframe

Result:

Inner-joins two dataframes on the given list of common key columns.

Inner-joins two dataframes on the given common key column: only the rows whose key matches in both dataframes are kept.

Joins two dataframes on the given key columns using an explicit join type: "inner" (default), "left", "right" or "full".

Special cases:

  • Join two dataframes on two key columns
join(df1, df2, ["country", "year"])
  • Join two dataframes on the 'id' column
join(df_people, df_scores, "id")
  • Left-join two dataframes on 'id' (keeps every row of the left dataframe)
join(df1, df2, ["id"], "left")

See also: join, pivot, +,


json_file

Possible uses:

  • json_file (string) ---> file
  • string json_file map<string,unknown> ---> file
  • json_file (string , map<string,unknown>) ---> file

Result:

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

Special cases:

  • json_file(string): This file constructor allows to read a json file
file f <-json_file("file.json");
  • json_file(string,map<string,unknown>): This constructor allows to store a map in a json file (it does not save it). The file can then be saved later using the save statement
file f <-json_file("file.json", map(["var1"::1.0, "var2"::3.0]));

See also: is_json,


k_nearest_neighbors

Possible uses:

  • k_nearest_neighbors (agent, map<agent,unknown>, int) ---> unknown

Result:

This operator allows user to find the attribute of an agent basing on its k-nearest agents

Comment:

In order to use this operator, users have to create a map which map the agents with one of their attributes (for example color or size,..). In the example below, 'map' is the map that I mention above, 'k' is the number of the nearest agents that we areconsidering

Examples:

unknown var0 <- self k_nearest_neighbors (map,k); // var0 equals this will return the attribute which has highest frequency in the k-nearest neighbors of our agent 

k_spanning_tree_clustering

Possible uses:

  • graph k_spanning_tree_clustering int ---> list
  • k_spanning_tree_clustering (graph , int) ---> list

Result:

The algorithm finds a minimum spanning tree T using Prim's algorithm, then executes Kruskal's algorithm only on the edges of T until k trees are formed. The resulting trees are the final clusters.It returns a list of list of vertices and takes as operand the graph and the number of clusters


kappa

Possible uses:

  • kappa (list<unknown>, list<unknown>, list<unknown>) ---> float
  • kappa (list<unknown>, list<unknown>, list<unknown>, list<unknown>) ---> float

Result:

kappa indicator for 2 map comparisons: kappa(list_vals1,list_vals2,categories, weights). Reference: Cohen, J. A coefficient of agreement for nominal scales. Educ. Psychol. Meas. 1960, 20.

kappa indicator for 2 map comparisons: kappa(list_vals1,list_vals2,categories). Reference: Cohen, J. A coefficient of agreement for nominal scales. Educ. Psychol. Meas. 1960, 20.

Examples:

float var0 <- kappa(["cat1","cat3","cat2","cat1","cat3"],["cat1","cat3","cat2","cat3","cat1"],["cat1","cat2","cat3"], [1.0, 2.0, 3.0, 1.0, 5.0]); // var0 equals 0.29411764705882354 
kappa([cat1,cat1,cat2,cat3,cat2],[cat2,cat1,cat2,cat1,cat2],[cat1,cat2,cat3]) 
float var2 <- kappa([1,3,5,1,5],[1,1,1,1,5],[1,3,5]); // var2 equals 0.3333333333333334 
float var3 <- kappa([1,1,1,1,5],[1,1,1,1,5],[1,3,5]); // var3 equals 1.0

kappa_sim

Possible uses:

  • kappa_sim (list<unknown>, list<unknown>, list<unknown>, list<unknown>) ---> float
  • kappa_sim (list<unknown>, list<unknown>, list<unknown>, list<unknown>, list<unknown>) ---> float

Result:

Kappa simulation indicator for 2 map comparisons. Reference: van Vliet, J., Bregt, A.K. & Hagen-Zanker, A. (2011). Revisiting Kappa to account for change in the accuracy assessment of land-use change models, Ecological Modelling 222(8).

Special cases:

  • kappa_sim can be used with an additional weights operand
float var1 <- kappa_sim(["cat1","cat1","cat2","cat2","cat2"],["cat1","cat3","cat2","cat1","cat3"],["cat1","cat3","cat2","cat3","cat1"],["cat1","cat2","cat3"], [1.0, 2.0, 3.0, 1.0, 5.0]); // var1 equals 0.2702702702702703

Examples:

float var0 <- kappa_sim(["cat1","cat1","cat2","cat2","cat2"],["cat1","cat3","cat2","cat1","cat3"],["cat1","cat3","cat2","cat3","cat1"],["cat1","cat2","cat3"]); // var0 equals 0.3333333333333335

kmeans

Possible uses:

  • list kmeans int ---> list<list>
  • kmeans (list , int) ---> list<list>
  • kmeans (list, int, int) ---> list<list>

Result:

returns the list of clusters (list of instance indices) computed with the kmeans++ algorithm from the first operand data according to the number of clusters to split the data into (k) and the maximum number of iterations to run the algorithm.(If negative, no maximum will be used) (maxIt). Usage: kmeans(data,k,maxit)

Special cases:

  • The maximum number of (third operand) can be omitted.
list<list> var0 <- kmeans ([[2,4,5], [3,8,2], [1,1,3], [4,3,4]],2); // var0 equals [[0,2,3],[1]]

Examples:

list<list> var1 <- kmeans ([[2,4,5], [3,8,2], [1,1,3], [4,3,4]],2,10); // var1 equals [[0,2,3],[1]]

kml

Possible uses:

  • kml (any) ---> kml

Result:

casts the operand in a kml object.


kurtosis

Possible uses:

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

Result:

Returns the kurtosis from a moment and a standard deviation

Returns the kurtosis (aka excess) of a list of values (kurtosis = { [n(n+1) / (n -1)(n - 2)(n-3)] sum[(x_i - mean)^4] / std^4 } - [3(n-1)^2 / (n-2)(n-3)])

Special cases:

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

Examples:

float var0 <- kurtosis(3,12) with_precision(4); // var0 equals -2.9999 
float var1 <- kurtosis ([1,2,3,4,5]); // var1 equals -1.200000000000002 
float var2 <- kurtosis([13,2,1,4,1,2]) with_precision(4); // var2 equals 4.8083

label_propagation_clustering

Possible uses:

  • graph label_propagation_clustering int ---> list
  • label_propagation_clustering (graph , int) ---> list

Result:

The algorithm is a near linear time algorithm capable of discovering communities in large graphs. It is described in detail in the following: Raghavan, U. N., Albert, R., and Kumara, S. (2007). Near linear time algorithm to detect

  • community structures in large-scale networks. Physical review E, 76(3), 036106.It returns a list of list of vertices and takes as operand the graph and maximal number of iteration

last

Possible uses:

  • last (container<KeyType,ValueType>) ---> ValueType

Result:

the last element of the operand

Comment:

the last operator behavior depends on the nature of the operand

Special cases:

  • if it is a map, last returns the value of the last pair (in insertion order)
  • if it is a file, last returns the last element of the content of the file (that is also a container)
  • if it is a population, last returns the last agent of the population
  • if it is a graph, last returns a list containing the last edge created
  • if it is a matrix, last returns the element at {length-1,length-1} in the matrix
  • for a matrix of int or float, it will return 0 if the matrix is empty
  • for a matrix of object or geometry, it will return nil if the matrix is empty
  • if it is a list, last returns the last element of the list, or nil if the list is empty
int var0 <- last ([1, 2, 3]); // var0 equals 3

See also: first,


last

Possible uses:

  • last (string) ---> string
  • int last container ---> list
  • last (int , container) ---> list

Result:

Returns the nth last elements of the container. If n is greater than the list size, returns the container cast as a list. If it is equal or less than zero, returns an empty list

Special cases:

  • If the container is empty, returns an empty list.
  • If the container is nil, raises a runtime error.
  • If n is greater than the container size, returns all elements as a list.
  • if it is a string, last returns a string composed of its last character, or an empty string if the operand is empty
string var0 <- last ('abce'); // var0 equals 'e'

last_index_of

Possible uses:

  • species last_index_of unknown ---> int
  • last_index_of (species , unknown) ---> int
  • string last_index_of string ---> int
  • last_index_of (string , string) ---> int
  • map<unknown,unknown> last_index_of unknown ---> unknown
  • last_index_of (map<unknown,unknown> , unknown) ---> unknown
  • list last_index_of unknown ---> int
  • last_index_of (list , unknown) ---> int
  • matrix last_index_of unknown ---> point
  • last_index_of (matrix , unknown) ---> point

Result:

the index of the last occurence of the right operand in the left operand container

Comment:

The definition of last_index_of and the type of the index depend on the container

Special cases:

  • if the left operand is a species, the last index of an agent is the same as its index
  • if both operands are strings, returns the index within the left-hand string of the rightmost occurrence of the given right-hand string
int var0 <- "abcabcabc" last_index_of "ca"; // var0 equals 5
  • if the left operand is a map, last_index_of returns the index as an int (the key of the pair)
unknown var1 <- [1::2, 3::4, 5::4] last_index_of 4; // var1 equals 5
  • if the left operand is a list, last_index_of returns the index as an integer
int var2 <- [1,2,3,4,5,6] last_index_of 4; // var2 equals 3 
int var3 <- [4,2,3,4,5,4] last_index_of 4; // var3 equals 5
  • if the left operand is a matrix, last_index_of returns the index as a point
point var4 <- matrix([[1,2,3],[4,5,4]]) last_index_of 4; // var4 equals {1.0,2.0}

See also: at, index_of, last_index_of, all_indexes_of,


last_of

Same signification as last


last_with

Possible uses:

  • last_with (string, container, any expression) ---> unknown

Result:

the last element of the left-hand operand that makes 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, last_with throws an error.
  • If there is no element that satisfies the condition, it returns nil
  • if the left-operand is a map, the keyword each will contain each value
unknown var4 <- [1::2, 3::4, 5::6] last_with (each >= 4); // var4 equals 6 
unknown var5 <- [1::2, 3::4, 5::6].pairs last_with (each.value >= 4); // var5 equals (5::6)

Examples:

int var0 <- [1,2,3,4,5,6,7,8] last_with (each > 3); // var0 equals 8 
unknown var2 <- g2 last_with (length(g2 out_edges_of each) = 0 ); // var2 equals a node 
unknown var3 <- (list(node) last_with (round(node(each).location.x) > 32); // var3 equals node3

See also: group_by, first_with, where,


layout_circle

Possible uses:

  • layout_circle (graph, geometry, bool) ---> graph

Result:

layouts a Gama graph on a circle with equidistance between nodes. For now there is no optimization on node ordering.

Special cases:

  • Usage: layoutCircle(graph, bound, shuffle) => graph : the graph to layout, bound : the geometry to display the graph within, shuffle : if true shuffle the nodes, then render same ordering

Examples:

layout_circle(graph, world.shape, false);

layout_force

Possible uses:

  • layout_force (graph, geometry, float, float, int) ---> graph
  • layout_force (graph, geometry, float, float, int, float) ---> graph

Result:

layouts a GAMA graph using Force model (in a given spatial bound and given coeff_force, cooling_rate, max_iteration, and equilibirum criterion parameters).

Special cases:

  • usage: layoutForce(graph, bounds, coeff_force, cooling_rate, max_iteration). graph is the graph to which applied the layout; bounds is the shape (geometry) in which the graph should be located; coeff_force is the coefficient used to compute the force, typical value is 0.4; cooling rate is the decreasing coefficient of the temperature, typical value is 0.01; max_iteration is the maximal number of iterationsdistance of displacement for a vertice to be considered as in equilibrium
  • usage: layoutForce(graph, bounds, coeff_force, cooling_rate, max_iteration, equilibirum criterion). graph is the graph to which applied the layout; bounds is the shape (geometry) in which the graph should be located; coeff_force is the coefficien use to compute the force, typical value is 0.4; cooling rate is the decreasing coefficient of the temperature, typical value is 0.01; max_iteration is the maximal number of iterations; equilibirum criterion is the maximaldistance of displacement for a vertice to be considered as in equilibrium

layout_force_FR

Possible uses:

  • layout_force_FR (graph, geometry, float, int) ---> graph

Result:

layouts a GAMA graph using Fruchterman and Reingold Force-Directed Placement Algorithm (in a given spatial bound, normalization factor and max_iteration parameters).

Special cases:

  • usage: layoutForce(graph, bounds, normalization_factor, max_iteration, equilibirum criterion). graph is the graph to which applied the layout; bounds is the shape (geometry) in which the graph should be located; normalization_factor is the normalization factor for the optimal distance, typical value is 1.0; max_iteration is the maximal number of iterations

layout_force_FR_indexed

Possible uses:

  • layout_force_FR_indexed (graph, geometry, float, float, int) ---> graph

Result:

layouts a GAMA graph using Fruchterman and Reingold Force-Directed Placement Algorithm with The Barnes-Hut indexing technique(in a given spatial bound, theta, normalization factor and max_iteration parameters).

Special cases:

  • usage: layoutForce(graph, bounds, normalization_factor, max_iteration, equilibirum criterion). graph is the graph to which applied the layout; bounds is the shape (geometry) in which the graph should be located; theta value for approximation using the Barnes-Hut technique, typical value is 0.5; normalization_factor is the normalization factor for the optimal distance, typical value is 1.0; max_iteration is the maximal number of iterations

layout_grid

Possible uses:

  • layout_grid (graph, geometry, float) ---> graph

Result:

layouts a Gama graph based on a grid latice. usage: layoutForce(graph, bounds, coeff_nb_cells). graph is the graph to which the layout is applied; bounds is the shape (geometry) in which the graph should be located; coeff_nb_cellsthe coefficient for the number of cells to locate the vertices (nb of places = coeff_nb_cells * nb of vertices).

Examples:

layout_grid(graph, world.shape);

length

Possible uses:

  • length (container<KeyType,ValueType>) ---> int

Result:

the number of elements contained in the operand

Comment:

the length operator behavior depends on the nature of the operand

Special cases:

  • if it is a population, length returns number of agents of the population
  • if it is a graph, length returns the number of vertexes or of edges (depending on the way it was created)
  • if it is a list or a map, length returns the number of elements in the list or map
int var0 <- length([12,13]); // var0 equals 2 
int var1 <- length([]); // var1 equals 0
  • if it is a matrix, length returns the number of cells
int var2 <- length(matrix([["c11","c12","c13"],["c21","c22","c23"]])); // var2 equals 6

length

Possible uses:

  • length (string) ---> int

Special cases:

  • if it is a string, length returns the number of characters
int var0 <- length ("I am an agent"); // var0 equals 13

lgamma

Same signification as log_gamma


line

Possible uses:

  • line (container<unknown,geometry>) ---> geometry
  • container<unknown,geometry> line float ---> geometry
  • line (container<unknown,geometry> , float) ---> geometry

Result:

A polyline geometry from the given list of points.

Special cases:

  • if the points list operand is nil, returns the point geometry {0,0}
  • if the points list operand is composed of a single point, returns a point geometry.
  • An empty list returns the point geometry {0,0,0}.
  • A single-point list returns a degenerate point geometry (not a line).
  • if a radius is added, the given list of points represented as a cylinder of radius r
geometry var0 <- polyline([{0,0}, {0,10}, {10,10}, {10,0}],0.2); // var0 equals a polyline geometry composed of the 4 points.

Examples:

geometry var1 <- polyline([{0,0}, {0,10}, {10,10}]); // var1 equals a polyline geometry composed of the 3 points. 
geometry var2 <- line([{10,10}, {10,0}]); // var2 equals a line from 2 points. 
string var3 <- string(polyline([{0,0}, {0,10}, {10,10}])+line([{10,10}, {10,0}])); // var3 equals "MULTILINESTRING ((0 0, 0 10, 10 10), (10 10, 10 0))"

See also: around, circle, cone, link, norm, point, polygone, rectangle, square, triangle, ellipse, squircle, polygon, cube, cylinder, cross, arc, hexagon, pyramid, teapot, cone3D, sphere, elliptical_arc, geometry_collection, polyhedron, curve, box,


link

Possible uses:

  • geometry link geometry ---> geometry
  • link (geometry , geometry) ---> geometry

Result:

A dynamic line geometry between the location of the two operands

Comment:

The geometry of the link is a line between the locations of the two operands, which is built and maintained dynamically

Special cases:

  • if one of the operands is nil, link returns a point geometry at the location of the other. If both are null, it returns a point geometry at {0,0}

Examples:

geometry var0 <- link (geom1,geom2); // var0 equals a link geometry between geom1 and geom2.

See also: around, circle, cone, line, norm, point, polygon, polyline, rectangle, square, triangle, ellipse, squircle, cube, cylinder, cross, arc, hexagon, pyramid, teapot, cone3D, sphere, elliptical_arc, geometry_collection, polyhedron, plan, curve, box,


list

Possible uses:

  • list (any) ---> list

Result:

casts the operand in a list object.


list_with

Possible uses:

  • list_with (string, int, any expression) ---> list

Result:

creates a list with a size provided by the first operand, and filled with the evaluation of the second operand. As with any iterator, the value of the current index can be retrieved with each or explicitly set using the (x: ... syntax

Comment:

Note that the first operand should be positive, otherwise an empty list is returned, and that the second one is evaluated for each position in the list.

Examples:

list var0 <- list_with(5,2); // var0 equals [2,2,2,2,2]

See also: list,


ln

Possible uses:

  • ln (float) ---> float
  • ln (int) ---> float

Result:

Returns the natural logarithm (base e) of the operand.

Special cases:

  • an exception is raised if the operand is less than zero.
  • ln(1) = 0.0
  • ln(e) = 1.0
  • If the operand is 0 or negative, a runtime warning is raised.
  • If the operand is 0 or negative, a runtime warning is raised.

Examples:

float var0 <- ln(exp(1)); // var0 equals 1.0 
float var1 <- ln(1); // var1 equals 0.0 
float var2 <- ln(10); // var2 equals 2.302585092994046

See also: exp, log,


load_shortest_paths

Possible uses:

  • graph load_shortest_paths matrix ---> graph
  • load_shortest_paths (graph , matrix) ---> graph

Result:

put in the graph cache the computed shortest paths contained in the matrix (rows: source, columns: target)

Examples:

graph var0 <- load_shortest_paths(shortest_paths_matrix); // var0 equals return my_graph with all the shortest paths computed

load_sql

Possible uses:

  • load_sql (string, string, string, string) ---> dataframe

Result:

Runs a SQL query on a database via JDBC and returns the result as a dataframe. Arguments: the JDBC URL, the user, the password, and the SQL query. Pass empty strings for user/password if the database does not require credentials. The corresponding JDBC driver must be available on the classpath.

Special cases:

  • Run a SQL query on a PostgreSQL database
dataframe df <- load_sql("jdbc:postgresql://localhost:5432/mydb", "user", "pwd", "SELECT name, age FROM people WHERE age > 18");

See also: load_table, save_table,


load_sub_model

Possible uses:

  • string load_sub_model string ---> agent
  • load_sub_model (string , string) ---> agent

Result:

Load a submodel

Comment:

loaded submodel


load_table

Possible uses:

  • load_table (string, string, string, string) ---> dataframe

Result:

Loads a whole database table into a dataframe via JDBC. Arguments: the JDBC URL, the user, the password, and the table name. Pass empty strings for user/password if the database does not require credentials. The corresponding JDBC driver must be available on the classpath.

Special cases:

  • Load a PostgreSQL table
dataframe df <- load_table("jdbc:postgresql://localhost:5432/mydb", "user", "pwd", "people");

See also: load_sql, save_table,


log

Possible uses:

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

Result:

Returns the logarithm (base 10) of the operand.

Special cases:

  • If the operand is 0 or negative, a runtime warning is raised.
  • an exception is raised if the operand is equals or less than zero.
  • log(1) = 0.0
  • If the operand is 0 or negative, a runtime warning is raised.
  • If x is 0 or negative, a runtime warning is raised.
  • If b equals 1, the result is ±Infinity (undefined).

Examples:

float var0 <- log(1); // var0 equals 0.0 
float var1 <- log(10); // var1 equals 1.0 
float var2 <- log(10); // var2 equals 1.0 
float var3 <- log(1); // var3 equals 0.0 
float var4 <- log(100); // var4 equals 2.0 
float var5 <- log(100.0, 100.0); // var5 equals 1.0 
float var6 <- log(100.0, 100); // var6 equals 1.0 
float var7 <- log(100, 100.0); // var7 equals 1.0 
float var8 <- log(100, 100); // var8 equals 1.0 
float var9 <- log(8, 2); // var9 equals 3.0 
float var10 <- log(1, 10); // var10 equals 0.0

See also: ln,


log_gamma

Possible uses:

  • log_gamma (float) ---> float

Result:

Returns the log of the value of the Gamma function at x.

Examples:

float var0 <- log_gamma(0.6) with_precision(4); // var0 equals 0.3982

lognormal_density

Possible uses:

  • lognormal_density (float, float, float) ---> float

Result:

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

Examples:

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

See also: binomial, gamma_rnd, gauss_rnd, poisson, rnd, skew_gauss, truncated_gauss, weibull_rnd, weibull_density, gamma_density, exp_density,


lognormal_rnd

Possible uses:

  • float lognormal_rnd float ---> float
  • lognormal_rnd (float , float) ---> float

Result:

returns a random value from a Log-Normal distribution with specified values of the expected value (or mean) of the variable's natural logarithm (shape) and the standard deviation of the variable's natural logarithm (scale) parameters. See https://en.wikipedia.org/wiki/Log-normal_distribution for more details.

Examples:

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

See also: binomial, gamma_rnd, gauss_rnd, poisson, rnd, skew_gauss, truncated_gauss, weibull_rnd, lognormal_trunc_rnd, exp_density, gamma_density, exp_rnd, weibull_density,


lognormal_trunc_rnd

Possible uses:

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

Result:

returns a random value from a truncated Log-Normal distribution (in a range or given only one boundary) with specified values of the shape (alpha) and scale (beta) parameters. See https://en.wikipedia.org/wiki/Log-normal_distribution for more details.

Special cases:

  • 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),
lognormal_trunc_rnd(2,3,5,true)
  • when 2 float operands are specified, they are taken as mininimum and maximum values for the result
lognormal_trunc_rnd(2,3,0,5)

See also: lognormal_rnd, gamma_trunc_rnd, weibull_trunc_rnd, truncated_gauss,


lower_case

Possible uses:

  • lower_case (string) ---> string

Result:

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

Examples:

string var0 <- lower_case("Abc"); // var0 equals 'abc'

See also: upper_case, capitalize,


main_connected_component

Possible uses:

  • main_connected_component (graph) ---> graph

Result:

returns the sub-graph corresponding to the main connected components of the graph

Examples:

graph var0 <- main_connected_component(my_graph); // var0 equals the sub-graph corresponding to the main connected components of the graph

See also: connected_components_of,


map

Possible uses:

  • map (any) ---> map

Result:

casts the operand in a map object.


map_with

Possible uses:

  • map_with (string, int, any expression) ---> map

Result:

creates a map with a size provided by the first operand, and filled with the keys and values computed by the second pair operand. As any iterator, the second operand can make use of the index (obtained with each or explicitly set using the (x: ... syntax)

Comment:

Note that the first operand should be positive, otherwise an empty map is returned, and that the second is reevaluated for each new pair in the map.

See also: map,


masked_by

Possible uses:

  • geometry masked_by container<unknown,geometry> ---> geometry
  • masked_by (geometry , container<unknown,geometry>) ---> geometry
  • masked_by (geometry, container<unknown,geometry>, int) ---> geometry

Examples:

geometry var0 <- perception_geom masked_by obstacle_list; // var0 equals the geometry representing the part of perception_geom visible from the agent position considering the list of obstacles obstacle_list. 
geometry var1 <- perception_geom masked_by obstacle_list; // var1 equals the geometry representing the part of perception_geom visible from the agent position considering the list of obstacles obstacle_list.

matrix

Possible uses:

  • matrix (any) ---> matrix

Result:

casts the operand in a matrix object.


matrix

Possible uses:

  • matrix (image) ---> matrix

Result:

Returns the matrix value of the image passed in parameter, where each pixel is represented by the RGB int value. The dimensions of the matrix are those of the image.


matrix_with

Possible uses:

  • matrix_with (string, point, any expression) ---> matrix

Result:

creates a matrix with a size provided by the first operand, and filled with the second operand. The given expression, unless constant, is evaluated for each cell. As in any iterator, the value of 'each' represents the index of the current cell (a point (col, row)) and can be retrieved using 'each' or explicitly using the '(:x...' syntax

Comment:

Note that both components of the right operand point should be positive, otherwise an exception is raised.

See also: matrix, as_matrix,


max

Possible uses:

  • max (container) ---> unknown

Result:

the maximum element found in the operand

Comment:

the max operator behavior depends on the nature of the operand

Special cases:

  • if it is a population of a list of other type: max transforms all elements into integer and returns the maximum of them
  • if it is a map, max returns the maximum among the list of all elements value
  • if it is a file, max returns the maximum of the content of the file (that is also a container)
  • if it is a graph, max returns the maximum of the list of the elements of the graph (that can be the list of edges or vertexes depending on the graph)
  • if it is a matrix of int, float or object, max returns the maximum of all the numerical elements (thus all elements for integer and float matrices)
  • if it is a matrix of geometry, max returns the maximum of the list of the geometries
  • if it is a matrix of another type, max returns the maximum of the elements transformed into float
  • if it is a list of int of float, max returns the maximum of all the elements
unknown var0 <- max ([100, 23.2, 34.5]); // var0 equals 100.0
  • if it is a list of points: max returns the maximum of all points as a point (i.e. the point with the greatest coordinate on the x-axis, in case of equality the point with the greatest coordinate on the y-axis is chosen. If all the points are equal, the first one is returned. )
unknown var1 <- max([{1.0,3.0},{3.0,5.0},{9.0,1.0},{7.0,8.0}]); // var1 equals {9.0,1.0}

See also: min,


max_flow_between

Possible uses:

  • max_flow_between (graph, unknown, unknown) ---> map<unknown,float>

Result:

The max flow (map<edge,flow> in a graph between the source and the sink using Edmonds-Karp algorithm

Examples:

max_flow_between(my_graph, vertice1, vertice2)

max_of

Possible uses:

  • max_of (string, container, any expression) ---> unknown

Result:

the maximum value 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:

  • As of GAMA 1.6, if the left-hand operand is nil or empty, max_of throws an error
  • if the left-operand is a map, the keyword each will contain each value
unknown var4 <- [1::2, 3::4, 5::6] max_of (each + 3); // var4 equals 9

Examples:

unknown var0 <- [1,2,4,3,5,7,6,8] max_of (each * 100 ); // var0 equals 800 
graph g2 <- as_edge_graph([{1,5}::{12,45},{12,45}::{34,56}]); 
unknown var2 <- g2.vertices max_of (g2 degree_of( each )); // var2 equals 2 
unknown var3 <- (list(node) max_of (round(node(each).location.x)); // var3 equals 96

See also: min_of, product_of, mean_of, variance_of,


maximal_cliques_of

Possible uses:

  • maximal_cliques_of (graph) ---> list<list>

Result:

returns the maximal cliques of a graph using the Bron-Kerbosch clique detection algorithm: A clique is maximal if it is impossible to enlarge it by adding another vertex from the graph. Note that a maximal clique is not necessarily the biggest clique in the graph.

Special cases:

  • On an empty graph (no vertices), returns an empty list.
  • Every isolated vertex (degree 0) is itself a clique of size 1 and will appear as a singleton list in the result.

Examples:

graph my_graph <- graph([]); 
list<list> var1 <- maximal_cliques_of (my_graph); // var1 equals the list of all the maximal cliques as list

See also: biggest_cliques_of,


mean

Possible uses:

  • mean (container) ---> unknown

Result:

the mean of all the elements of the operand

Comment:

the elements of the operand are summed (see sum for more details about the sum of container elements ) and then the sum value is divided by the number of elements.

Special cases:

  • If the container contains points, the result will be a point. If the container contains rgb values, the result will be a rgb color
  • If the container is empty, the behavior depends on the element type: the sum step may raise a runtime error for untyped empty containers.
  • For numeric elements (int or float), the result is always a float.

Examples:

unknown var0 <- mean ([4.5, 3.5, 5.5, 7.0]); // var0 equals 5.125 

See also: sum,


mean_deviation

Possible uses:

  • mean_deviation (container) ---> float

Result:

the deviation from the mean of all the elements of the operand. See Mean_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 <- mean_deviation ([4.5, 3.5, 5.5, 7.0]); // var0 equals 1.125

See also: mean, standard_deviation,


mean_of

Possible uses:

  • mean_of (string, container, any expression) ---> unknown

Result:

the mean 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] mean_of (each); // var1 equals 4

Examples:

unknown var0 <- [1,2] mean_of (each * 10 ); // var0 equals 15

See also: min_of, max_of, sum_of, product_of,


median

Possible uses:

  • median (container) ---> unknown

Result:

the median of all the elements of the operand.

Special cases:

  • if the container contains points, the result will be a point. If the container contains rgb values, the result will be a rgb color

Examples:

unknown var0 <- median ([4.5, 3.5, 5.5, 3.4, 7.0]); // var0 equals 4.5

See also: mean, geometric_mean, variance, harmonic_mean,


mental_state

Possible uses:

  • mental_state (any) ---> mental_state

Result:

casts the operand in a mental_state object.


message

Possible uses:

  • message (any) ---> message

Result:

casts the operand in a message object.


milliseconds_between

Possible uses:

  • date milliseconds_between date ---> float
  • milliseconds_between (date , date) ---> float

Result:

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

Special cases:

  • If both dates are equal, returns 0.
  • If date1 is after date2, returns a negative value.

Examples:

float var0 <- milliseconds_between(date('2000-01-01'), date('2000-02-01')); // var0 equals 2.6784E9

min

Possible uses:

  • min (container) ---> unknown

Result:

the minimum element found in the operand.

Comment:

the min operator behavior depends on the nature of the operand

Special cases:

  • if it is a list of points: min returns the minimum of all points as a point (i.e. the point with the smallest coordinate on the x-axis, in case of equality the point with the smallest coordinate on the y-axis is chosen. If all the points are equal, the first one is returned. )
  • if it is a population of a list of other types: min transforms all elements into integer and returns the minimum of them
  • if it is a map, min returns the minimum among the list of all elements value
  • if it is a file, min returns the minimum of the content of the file (that is also a container)
  • if it is a graph, min returns the minimum of the list of the elements of the graph (that can be the list of edges or vertexes depending on the graph)
  • if it is a matrix of int, float or object, min returns the minimum of all the numerical elements (thus all elements for integer and float matrices)
  • if it is a matrix of geometry, min returns the minimum of the list of the geometries
  • if it is a matrix of another type, min returns the minimum of the elements transformed into float
  • if it is a list of int or float: min returns the minimum of all the elements
unknown var0 <- min ([100, 23.2, 34.5]); // var0 equals 23.2

See also: max,


min_of

Possible uses:

  • min_of (string, container, any expression) ---> unknown

Result:

the minimum value 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-hand operand is nil or empty, min_of throws an error
  • if the left-operand is a map, the keyword each will contain each value
unknown var4 <- [1::2, 3::4, 5::6] min_of (each + 3); // var4 equals 5

Examples:

unknown var0 <- [1,2,4,3,5,7,6,8] min_of (each * 100 ); // var0 equals 100 
graph g2 <- as_edge_graph([{1,5}::{12,45},{12,45}::{34,56}]); 
unknown var2 <- g2 min_of (length(g2 out_edges_of each) ); // var2 equals 0 
unknown var3 <- (list(node) min_of (round(node(each).location.x)); // var3 equals 4

See also: max_of, product_of, mean_of, variance_of,


minus_days

Possible uses:

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

Result:

Subtract a given number of days from a date

Examples:

date var0 <- date('2000-01-01') minus_days 20; // var0 equals date('1999-12-12')

minus_hours

Possible uses:

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

Result:

Remove a given number of hours from a date

Examples:

// equivalent to date1 - 15 #h 
date var1 <- date('2000-01-01') minus_hours 15 ; // var1 equals date('1999-12-31 09:00:00')

minus_minutes

Possible uses:

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

Result:

Subtract a given number of minutes from a date

Examples:

// date('2000-01-01') to date1 - 5#mn 
date var1 <- date('2000-01-01') minus_minutes 5 ; // var1 equals date('1999-12-31 23:55:00')

minus_months

Possible uses:

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

Result:

Subtract a given number of months from a date

Examples:

date var0 <- date('2000-01-01') minus_months 5; // var0 equals date('1999-08-01')

minus_ms

Possible uses:

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

Result:

Remove a given number of milliseconds from a date

Examples:

// equivalent to date1 - 15 #ms 
date var1 <- date('2000-01-01') minus_ms 1000 ; // var1 equals date('1999-12-31 23:59:59')

minus_seconds

Same signification as -


minus_weeks

Possible uses:

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

Result:

Subtract a given number of weeks from a date

Examples:

date var0 <- date('2000-01-01') minus_weeks 15; // var0 equals date('1999-09-18')

minus_years

Possible uses:

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

Result:

Subtract a given number of year from a date

Examples:

date var0 <- date('2000-01-01') minus_years 3; // var0 equals date('1997-01-01')

mod

Possible uses:

  • int mod int ---> int
  • mod (int , int) ---> int

Result:

Returns the remainder of the integer division of the left-hand operand by the right-hand operand.

Special cases:

  • if operands are float, they are truncated
  • if the right-hand operand is equal to zero, raises an exception.
  • For a negative dividend, the result is negative: (-7) mod 3 = -1.
  • If the right-hand operand is equal to zero, a runtime exception is raised.

Examples:

int var0 <- 40 mod 3; // var0 equals 1 
int var1 <- (-7) mod 3; // var1 equals -1 
int var2 <- 7 mod 3; // var2 equals 1

See also: div,


moment

Possible uses:

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

Result:

Returns the moment of k-th order with constant c of a data sequence

Examples:

float var0 <- moment([13,2,1,4,1,2], 2, 1.2) with_precision(4); // var0 equals 24.74

months_between

Possible uses:

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

Result:

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

Special cases:

  • If both dates are equal, returns 0.
  • If date1 is after date2, returns a negative value.

Examples:

int var0 <- months_between(date('2000-01-01'), date('2000-02-01')); // var0 equals 1

moran

Possible uses:

  • list<float> moran matrix<float> ---> float
  • moran (list<float> , matrix<float>) ---> float

Special cases:

  • return the Moran Index of the given list of interest points (list of floats) and the weight matrix (matrix of float)
float var0 <- moran([1.0, 0.5, 2.0], weight_matrix); // var0 equals the Moran index is computed

morris_analysis

Possible uses:

  • morris_analysis (unknown, int, int) ---> string

Result:

Return a string containing the Report of the morris analysis for the corresponding data (path, map or matrix)


mul

Possible uses:

  • mul (container) ---> unknown

Result:

the product of all the elements of the operand

Comment:

the mul operator behavior depends on the nature of the operand

Special cases:

  • if it is a list of points: mul returns the product of all points as a point (each coordinate is the product of the corresponding coordinate of each element)
  • if it is a list of other types: mul transforms all elements into integer and multiplies them
  • if it is a map, mul returns the product of the value of all elements
  • if it is a file, mul returns the product of the content of the file (that is also a container)
  • if it is a graph, mul returns the product of the list of the elements of the graph (that can be the list of edges or vertexes depending on the graph)
  • if it is a matrix of int, float or object, mul returns the product of all the numerical elements (thus all elements for integer and float matrices)
  • if it is a matrix of geometry, mul returns the product of the list of the geometries
  • if it is a matrix of other types: mul transforms all elements into float and multiplies them
  • if it is a list of int or float: mul returns the product of all the elements
unknown var0 <- mul ([100, 23.2, 34.5]); // var0 equals 80040.0

See also: sum,


multi_anova

Possible uses:

  • multi_anova (list<float>, list<unknown>, list<unknown>) ---> gama.extension.stats.analysis.GamaAnova

Result:

Performs a two-way ANOVA test with interactions on a response variable and two factors. Uses Type III Sum of Squares (orthogonal to order).

Examples:

multi_anova([1.0, 2.0, 5.0, 6.0], ['a', 'a', 'b', 'b'], ['x', 'y', 'x', 'y'])
⚠️ **GitHub.com Fallback** ⚠️