OperatorsNR - gama-platform/gama GitHub Wiki

Operators (N to R)


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


Operators


nb_cycles

Possible uses:

  • nb_cycles (graph) ---> int

Result:

returns the maximum number of independent cycles in a graph. This number (u) is estimated through the number of nodes (v), links (e) and of sub-graphs (p): u = e - v + p.

Examples:

graph graphEpidemio <- graph([]); 
int var1 <- nb_cycles(graphEpidemio); // var1 equals the number of cycles in the graph

See also: alpha_index, beta_index, gamma_index, connectivity_index, connected_components_of,


neighbors_at

Possible uses:

  • geometry neighbors_at float ---> list
  • neighbors_at (geometry , float) ---> list

Result:

a list, containing all the agents of the same species than the left argument (if it is an agent) located at a distance inferior or equal to the right-hand operand to the left-hand operand (geometry, agent, point).

Comment:

The topology used to compute the neighborhood is the one of the left-operand if this one is an agent; otherwise the one of the agent applying the operator.

Examples:

list var0 <- (self neighbors_at (10)); // var0 equals all the agents located at a distance lower or equal to 10 to the agent applying the operator.

See also: neighbors_of, closest_to, overlapping, agents_overlapping, agents_inside, agent_closest_to, at_distance, agent_farthest_to, covering, agents_at_distance, partially_overlapping, inside, crossing, touching, farthest_to,


neighbors_of

Possible uses:

  • graph neighbors_of unknown ---> list
  • neighbors_of (graph , unknown) ---> list
  • topology neighbors_of agent ---> list
  • neighbors_of (topology , agent) ---> list
  • field neighbors_of point ---> list<point>
  • neighbors_of (field , point) ---> list<point>
  • neighbors_of (topology, geometry, float) ---> list

Result:

a list, containing all the agents of the same species than the argument (if it is an agent) located at a distance inferior or equal to 1 to the right-hand operand agent considering the left-hand operand topology.

Special cases:

  • Returns an empty list for an isolated vertex (a vertex with no incident edges).
  • Returns an empty list if the vertex is not present in the graph.
  • On a directed graph, returns all vertices connected by any edge (both incoming and outgoing), i.e. the union of predecessors and successors.
  • Returns an empty list if no neighbors are found within the default distance of 1.
  • The calling agent itself is excluded from the results.
  • Returns an empty list if no neighbors are found within the specified distance.
  • The calling agent itself is excluded from the results when the second argument is an agent.
  • a list, containing all the agents of the same species than the left argument (if it is an agent) located at a distance inferior or equal to the third argument to the second argument (agent, geometry or point) considering the first operand topology.
list var3 <- neighbors_of (topology(self), self,10); // var3 equals all the agents located at a distance lower or equal to 10 to the agent applying the operator considering its topology.

Examples:

list var0 <- graphEpidemio neighbors_of (node(3)); // var0 equals [node0,node2] 
list var1 <- graphFromMap neighbors_of node({12,45}); // var1 equals [{1.0,5.0},{34.0,56.0}] 
list var2 <- topology(self) neighbors_of self; // var2 equals returns all the agents located at a distance lower or equal to 1 to the agent applying the operator considering its topology.

See also: predecessors_of, successors_of, neighbors_at, closest_to, overlapping, agents_overlapping, agents_inside, agent_closest_to, agent_farthest_to, at_distance, covering, agents_at_distance, partially_overlapping, inside, crossing, touching, farthest_to,


new_emotion

Possible uses:

  • new_emotion (string) ---> emotion
  • string new_emotion predicate ---> emotion
  • new_emotion (string , predicate) ---> emotion
  • string new_emotion agent ---> emotion
  • new_emotion (string , agent) ---> emotion
  • string new_emotion float ---> emotion
  • new_emotion (string , float) ---> emotion
  • new_emotion (string, float, predicate) ---> emotion
  • new_emotion (string, float, float) ---> emotion
  • new_emotion (string, predicate, agent) ---> emotion
  • new_emotion (string, float, agent) ---> emotion
  • new_emotion (string, float, predicate, agent) ---> emotion
  • new_emotion (string, float, float, agent) ---> emotion
  • new_emotion (string, float, predicate, float) ---> emotion
  • new_emotion (string, float, predicate, float, agent) ---> emotion

Result:

a new emotion with the given properties (at least its name, and eventually intensity, parameters...)

Special cases:

  • Various combinations are possible to create the emotion: (name,intensity,about), (name,about,cause), (name,intensity,cause)...
new_emotion("joy",12.3,eatFood) 
new_emotion("joy",eatFood,agent1) 
new_emotion("joy",12.3,agent1)
  • a new emotion with a given name and the predicate it is about
new_emotion("joy",estFood) 
new_emotion("joy",agent1)
  • A decay value value can be added to define a new emotion.
new_emotion("joy",12.3,4.0)
  • a new emotion with a given name and the agent which has caused this emotion
new_emotion("joy",agent1)
  • a new emotion with a name and an initial intensity:
new_emotion("joy",12.3)

Examples:

new_emotion("joy",12.3,eatFood,agent1) 
emotion("joy", 12.3, 4, agent1) 
new_emotion("joy") 
new_emotion("joy",12.3,eatFood,4.0) 
emotion("joy",12.3,eatFood,4,agent1)

new_folder

Possible uses:

  • new_folder (string) ---> gama.api.types.file.GamaFolderFile

Result:

opens an existing repository or create a new folder if it does not exist.

Special cases:

  • If the specified string does not refer to an existing repository, the repository is created.
  • If the string refers to an existing file, an exception is risen.

Examples:

file dirNewT <- new_folder("incl/");   	// dirNewT represents the repository "../incl/" 
															// eventually creates the directory ../incl

See also: folder, file, folder_exists, directory,


new_mental_state

Possible uses:

  • new_mental_state (string) ---> mental_state
  • string new_mental_state mental_state ---> mental_state
  • new_mental_state (string , mental_state) ---> mental_state
  • string new_mental_state predicate ---> mental_state
  • new_mental_state (string , predicate) ---> mental_state
  • string new_mental_state emotion ---> mental_state
  • new_mental_state (string , emotion) ---> mental_state
  • new_mental_state (string, emotion, agent) ---> mental_state
  • new_mental_state (string, predicate, float) ---> mental_state
  • new_mental_state (string, mental_state, int) ---> mental_state
  • new_mental_state (string, predicate, int) ---> mental_state
  • new_mental_state (string, emotion, float) ---> mental_state
  • new_mental_state (string, predicate, agent) ---> mental_state
  • new_mental_state (string, emotion, int) ---> mental_state
  • new_mental_state (string, mental_state, float) ---> mental_state
  • new_mental_state (string, mental_state, agent) ---> mental_state
  • new_mental_state (string, mental_state, float, int) ---> mental_state
  • new_mental_state (string, emotion, float, agent) ---> mental_state
  • new_mental_state (string, emotion, int, agent) ---> mental_state
  • new_mental_state (string, predicate, int, agent) ---> mental_state
  • new_mental_state (string, predicate, float, agent) ---> mental_state
  • new_mental_state (string, mental_state, int, agent) ---> mental_state
  • new_mental_state (string, predicate, float, int) ---> mental_state
  • new_mental_state (string, emotion, float, int) ---> mental_state
  • new_mental_state (string, mental_state, float, agent) ---> mental_state
  • new_mental_state (string, predicate, float, int, agent) ---> mental_state
  • new_mental_state (string, mental_state, float, int, agent) ---> mental_state
  • new_mental_state (string, emotion, float, int, agent) ---> mental_state

Result:

creates a new mental state with a given modality (e.g. belief or desire) and various properties (a predicate it is about, a strength, a lifetime, an ower agent and an emotion it is about

Examples:

new_mental_state("belief", mental_state1, 12.3, 10) 
new_mental_state("belief", my_joy, agent1) 
new_mental_state("belief", raining, 0.5) 
new_mental_state("belief",raining, 12.3, 10, agent1) 
new_mental_state("belief", mental_state1) 
new_mental_state("belief", my_joy, 12.3, agent1) 
new_mental_state("belief", my_joy, 10, agent1) 
new_mental_state("belief", mental_state1, 12.3, 10, agent1) 
new_mental_state("belief", mental_state1, 10) 
new_mental_state("belief", raining, 10, agent1) 
new_mental_state("belief", raining, 10) 
new_mental_state("belief", my_joy, 12.3) 
new_mental_state("belief", raining) 
new_mental_state("belief", raining, agent1) 
new_mental_state("belief", raining, 12.3, agent1) 
new_mental_state("belief",  my_joy, 10) 
new_mental_state("belief", mental_state1, 10, agent1) 
new_mental_state("belief", mental_state1, 12.3) 
new_mental_state("belief") 
new_mental_state("belief", mental_state1, agent1) 
new_mental_state("belief", raining, 12.4, 10) 
new_mental_state("belief", my_joy, 12.3, 10) 
new_mental_state("belief", mental_state1, 12.2, agent1) 
new_mental_state("belief", my_joy, 12.3, 10, agent1) 
new_mental_state("belief", my_joy)

new_predicate

Possible uses:

  • new_predicate (string) ---> predicate
  • string new_predicate agent ---> predicate
  • new_predicate (string , agent) ---> predicate
  • string new_predicate map ---> predicate
  • new_predicate (string , map) ---> predicate
  • string new_predicate bool ---> predicate
  • new_predicate (string , bool) ---> predicate
  • new_predicate (string, map, agent) ---> predicate
  • new_predicate (string, map, bool) ---> predicate
  • new_predicate (string, map, bool, agent) ---> predicate

Result:

creates a new predicate with a given name and adidtional properties (values, agent causing the predicate, whether it is true...)

Examples:

new_predicate("people to meet", ["time"::10], true, agentA) 
new_predicate("people to meet", agent1) 
new_predicate("people to meet", map(["val1"::23]) ) 
new_predicate("people to meet", ["time"::10], agentA) 
new_predicate("people to meet") 
new_predicate("people to meet", ["time"::10], true) 
new_predicate("hasWater", true)

new_social_link

Possible uses:

  • new_social_link (agent) ---> social_link
  • new_social_link (agent, float, float, float, float) ---> social_link

Result:

creates a new social link with another agent (eventually given additional parameters such as the appreciation, dominance, solidarity, and familiarity values).

Examples:

new_social_link(agentA) 
new_social_link(agentA,0.0,-0.1,0.2,0.1)

node

Possible uses:

  • node (unknown) ---> unknown
  • unknown node float ---> unknown
  • node (unknown , float) ---> unknown

Result:

Allows to create a wrapper (of type unknown) that wraps an actual object and indicates it should be considered as a node of a graph. The second (optional) parameter indicates which weight the node should have in the graph

Comment:

Useful only in graph-related operations (addition, removal of nodes, creation of graphs)


nodes

Possible uses:

  • nodes (container) ---> container

Result:

Allows to create a wrapper (of type list) that wraps a list of objects and indicates they should be considered as nodes of a graph


none_matches

Possible uses:

  • none_matches (string, container, any expression) ---> bool

Result:

Returns true if none of the elements of the left-hand operand make the right-hand operand evaluate to true. 'c none_matches each.property' is strictly equivalent to '(c count each.property) = 0'

Comment:

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

Special cases:

  • If the left-hand operand is nil, none_matches throws an error.
  • If the left-hand operand is empty, none_matches returns true.

Examples:

bool var0 <- [1,2,3,4,5,6,7,8] none_matches (each > 3); // var0 equals false 
bool var1 <- [1::2, 3::4, 5::6] none_matches (each > 4); // var1 equals false

See also: one_matches, all_match, count,


none_verifies

Same signification as none_matches


norm

Possible uses:

  • norm (point) ---> float

Result:

the norm of the vector with the coordinates of the point operand.

Examples:

float var0 <- norm({3,4}); // var0 equals 5.0

Norm

Possible uses:

  • Norm (any) ---> Norm

Result:

casts the operand in a Norm object.


normal_area

Possible uses:

  • normal_area (float, float, float) ---> float

Result:

Returns the area to the left of x in the normal distribution with the given mean and standard deviation.

Examples:

float var0 <- normal_area(0.9,0,1) with_precision(3); // var0 equals 0.816

normal_density

Possible uses:

  • normal_density (float, float, float) ---> float

Result:

Returns the probability of x in the normal distribution with the given mean and standard deviation.

Examples:

float var0 <- (normal_density(2,1,1)*100) with_precision 2; // var0 equals 24.2

normal_inverse

Possible uses:

  • normal_inverse (float, float, float) ---> float

Result:

Returns the x in the normal distribution with the given mean and standard deviation, to the left of which lies the given area. normal.

Examples:

float var0 <- normal_inverse(0.98,0,1) with_precision(2); // var0 equals 2.05

normalized_rotation

Possible uses:

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

Result:

The rotation normalized according to Euler formalism with a positive angle, such that each rotation has a unique set of parameters (positive angle, normalize axis rotation).

Examples:

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

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


not

Same signification as !


not

Possible uses:

  • not (predicate) ---> predicate

Result:

create a new predicate with the inverse truth value

Examples:

not predicate1

obj_file

Possible uses:

  • obj_file (string) ---> file
  • string obj_file pair<float,point> ---> file
  • obj_file (string , pair<float,point>) ---> file
  • string obj_file string ---> file
  • obj_file (string , string) ---> file
  • obj_file (string, string, pair<float,point>) ---> file

Result:

Constructs a file of type obj. Allowed extensions are limited to obj, OBJ

Special cases:

  • obj_file(string): This file constructor allows to read an obj file. The associated mlt file have to have the same name as the file to be read.
file f <- obj_file("file.obj");
  • obj_file(string,pair<float,point>): This file constructor allows to read an obj file and apply an init rotation to it. The rotationis a pair angle::rotation vector. The associated mlt file have to have the same name as the file to be read.
file f <- obj_file("file.obj", 90.0::{-1,0,0});
  • obj_file(string,string): This file constructor allows to read an obj file, using a specific mlt file
file f <- obj_file("file.obj","file.mlt");
  • obj_file(string,string,pair<float,point>): This file constructor allows to read an obj file, using a specific mlt file, and apply an init rotation to it. The rotationis a pair angle::rotation vector
file f <- obj_file("file.obj","file.mlt", 90.0::{-1,0,0});

See also: is_obj,


object

Possible uses:

  • object (any) ---> object

Result:

casts the operand in a object object.


of

Same signification as .


of_generic_species

Possible uses:

  • container of_generic_species species ---> list
  • of_generic_species (container , species) ---> list

Result:

a list, containing the agents of the left-hand operand whose species is that denoted by the right-hand operand and whose species extends the right-hand operand species

Examples:

// species speciesA {} 
// species sub_speciesA parent: speciesA {} 
list var2 <- [sub_speciesA(0),sub_speciesA(1),speciesA(2),speciesA(3)] of_generic_species speciesA; // var2 equals [sub_speciesA0,sub_speciesA1,speciesA0,speciesA1] 
list var3 <- [sub_speciesA(0),sub_speciesA(1),speciesA(2),speciesA(3)] of_generic_species sous_test; // var3 equals [sub_speciesA0,sub_speciesA1] 
list var4 <- [sub_speciesA(0),sub_speciesA(1),speciesA(2),speciesA(3)] of_species speciesA; // var4 equals [speciesA0,speciesA1] 
list var5 <- [sub_speciesA(0),sub_speciesA(1),speciesA(2),speciesA(3)] of_species sous_test; // var5 equals [sub_speciesA0,sub_speciesA1]

See also: of_species,


of_species

Possible uses:

  • container of_species species ---> list
  • of_species (container , species) ---> list

Result:

a list, containing the agents of the left-hand operand whose species is the one denoted by the right-hand operand.The expression agents of_species (species self) is equivalent to agents where (species each = species self); however, the advantage of using the first syntax is that the resulting list is correctly typed with the right species, whereas, in the second syntax, the parser cannot determine the species of the agents within the list (resulting in the need to cast it explicitly if it is to be used in an ask statement, for instance).

Special cases:

  • if the right operand is nil, of_species returns the right operand

Examples:

list var0 <- (self neighbors_at 10) of_species (species (self)); // var0 equals all the neighboring agents of the same species. 
list var1 <- [test(0),test(1),node(1),node(2)] of_species test; // var1 equals [test0,test1]

See also: of_generic_species,


one_matches

Possible uses:

  • one_matches (string, container, any expression) ---> bool

Result:

Returns true if at least one of the elements of the left-hand operand make the right-hand operand evaluate to true. Returns false if the left-hand operand is empty. 'c one_matches each.property' is strictly equivalent to '(c count each.property) > 0' but faster in most cases (as it is a shortcircuited operator)

Comment:

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

Special cases:

  • if the left-hand operand is nil, one_matches throws an error

Examples:

bool var0 <- [1,2,3,4,5,6,7,8] one_matches (each > 3); // var0 equals true 
bool var1 <- [1::2, 3::4, 5::6] one_matches (each > 4); // var1 equals true

See also: none_matches, all_match, count,


one_of

Possible uses:

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

Result:

one of the values stored in this container at a random key

Comment:

the one_of operator behavior depends on the nature of the operand

Special cases:

  • if the operand is empty, one_of returns nil
  • if it is a graph, one_of returns one of the lists of edges
  • if it is a file, one_of returns one of the elements of the content of the file (that is also a container)
  • if it is a list or a matrix, one_of returns one of the values of the list or of the matrix
inti <- any ([1,2,3]);  // i equals 1, 2 or 3 
string sMat <- one_of(matrix([["c11","c12","c13"],["c21","c22","c23"]])); 	// sMat equals "c11","c12","c13", "c21","c22" or "c23"
  • if it is a map, one_of returns one the value of a random pair of the map
int im <- one_of ([2::3, 4::5, 6::7]);	// im equals 3, 5 or 7 
bool var3 <- [2::3, 4::5, 6::7].values contains im; // var3 equals true
  • if it is a population, one_of returns one of the agents of the population
bug b <- one_of(bug);  	// Given a previously defined species bug, b is one of the created bugs, e.g. bug3

See also: contains,


one_verifies

Same signification as one_matches


or

Possible uses:

  • bool or any expression ---> bool
  • or (bool , any expression) ---> bool

Result:

Returns the logical OR of the two boolean operands.

Comment:

Both operands are cast to {@code bool} before the operator is applied. An expression like {@code 1 or 0} is therefore accepted and returns {@code true}. The operator uses short-circuit evaluation: if the left operand is already {@code true}, the right operand is not evaluated.

Special cases:

  • If the left operand is {@code nil}, it is treated as {@code false} and the right operand is evaluated.
  • If the right operand is {@code nil}, it is cast to {@code false}.

Examples:

bool var0 <- true or false; // var0 equals true 
bool var1 <- false or true; // var1 equals true 
bool var2 <- false or false; // var2 equals false 
bool var3 <- true or true; // var3 equals true 
 int a <- 3 ; int b <- 4; int c <- 7; 
bool var5 <- ((a+b) = c ) or ((a+b) > c ); // var5 equals true

See also: bool, and, !, xor,


or

Possible uses:

  • predicate or predicate ---> predicate
  • or (predicate , predicate) ---> predicate

Result:

create a new predicate from two others by including them as subintentions. It's an exclusive "or"

Examples:

predicate1 or predicate2

osm_file

Possible uses:

  • osm_file (string) ---> file
  • string osm_file map<string,list> ---> file
  • osm_file (string , map<string,list>) ---> file

Result:

Constructs a file of type osm. Allowed extensions are limited to osm, pbf, bz2, gz

Special cases:

  • osm_file(string): This file constructor allows to read a osm (.osm, .pbf, .bz2, .gz) file (using WGS84 coordinate system for the data)
file f <- osm_file("file");
  • osm_file(string,map<string,list>): This file constructor allows to read an osm (.osm, .pbf, .bz2, .gz) file (using WGS84 coordinate system for the data)The map is used to filter the objects in the file according their attributes: for each key (string) of the map, only the objects that have a value for the attribute contained in the value set are kept. For an exhaustive list of the attibute of OSM data, see: http://wiki.openstreetmap.org/wiki/Map_Features
void var1 <- file f <- osm_file("file", map(["highway"::["primary", "secondary"], "building"::["yes"], "amenity"::[]]));; // var1 equals f will contain all the objects of file that have the attibute 'highway' with the value 'primary' or 'secondary', and the objects that have the attribute 'building' with the value 'yes', and all the objects that have the attribute 'aminity' (whatever the value).

See also: is_osm,


out_degree_of

Possible uses:

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

Result:

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

Special cases:

  • Returns 0 for an isolated vertex (a vertex with no outgoing edges).
  • On an undirected graph, both out_degree_of and in_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 out_degree_of (node(3)); // var1 equals 4

See also: in_degree_of, degree_of,


out_edges_of

Possible uses:

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

Result:

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

Examples:

list var1 <- graphFromMap out_edges_of (node(3)); // var1 equals 3

See also: in_edges_of, edge_between,


overlapping

Possible uses:

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

Result:

A list of agents or geometries among the left-operand list, species or meta-population (addition of species), overlapping the operand (casted as a geometry).

Examples:

list<geometry> var0 <- [ag1, ag2, ag3] overlapping(self); // var0 equals return the agents among ag1, ag2 and ag3 that overlap the shape of the agent applying the operator. 
(species1 + species2) overlapping self

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


overlaps

Possible uses:

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

Result:

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

Special cases:

  • if one of the operand is null, returns false.
  • if one operand is a point, returns true if the point is included in the geometry
  • Note: unlike the strict JTS {@code overlaps} predicate, this GAML operator uses intersection semantics (equivalent to {@code intersects}): two geometries that only touch at a boundary point or line will still return true.

Examples:

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

See also: disjoint_from, crosses, intersects, partially_overlaps, touches, covers, equals,


pair

Possible uses:

  • pair (any) ---> pair

Result:

casts the operand in a pair object.


pair

Same signification as ::


palette

Possible uses:

  • palette (list<rgb>) ---> list<rgb>

Result:

transforms a list of n colors into a palette (necessary for some layers)


parallel_list_with

Possible uses:

  • int parallel_list_with any expression ---> list
  • parallel_list_with (int , any expression) ---> list

Result:

Creates a list with a size provided by the first operand, and filled with the second operand, the list is filled in parallel.

Comment:

Note that the first operand should be positive, and that the second one is evaluated for each position in the list.\nSome exception can happen in case the expression uses a random number generator that doesn't support parallel execution like mersenne.

Examples:

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

See also: list,


parallel_matrix_with

Possible uses:

  • any expression parallel_matrix_with point ---> matrix
  • parallel_matrix_with (any expression , point) ---> 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 and is done in parallel.

Comment:

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

If run in parallel, some exception can happen in case the expression uses a random number generator that doesn't support parallel execution like mersenne.

See also: matrix, as_matrix,


partially_overlapping

Possible uses:

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

Result:

A list of agents or geometries among the left-operand list, species or meta-population (addition of species), partially_overlapping the operand (casted as a geometry).

Examples:

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

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


partially_overlaps

Possible uses:

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

Result:

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

Comment:

if one geometry operand fully covers the other geometry operand, returns false (contrarily to the overlaps operator).

Special cases:

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

Examples:

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

See also: disjoint_from, crosses, overlaps, intersects, touches, covers, equals,


path

Possible uses:

  • path (any) ---> path

Result:

casts the operand in a path object.

Special cases:

  • if the operand is a path, returns this path
  • if the operand is a geometry of an agent, returns a path from the list of points of the geometry
  • if the operand is a list, cast each element of the list as a point and create a path from these points
path p <- path([{12,12},{30,30},{50,50}]);

path_between

Possible uses:

  • topology path_between container<unknown,geometry> ---> path
  • path_between (topology , container<unknown,geometry>) ---> path
  • list<agent> path_between container<unknown,geometry> ---> path
  • path_between (list<agent> , container<unknown,geometry>) ---> path
  • map<agent,unknown> path_between container<unknown,geometry> ---> path
  • path_between (map<agent,unknown> , container<unknown,geometry>) ---> path
  • path_between (list<agent>, geometry, geometry) ---> path
  • path_between (graph, unknown, unknown) ---> path
  • path_between (map<agent,unknown>, geometry, geometry) ---> path
  • path_between (topology, geometry, geometry) ---> path

Result:

The shortest path between two objects according to set of cells

The shortest path between a list of two objects in a graph

The shortest path between two objects according to set of cells with corresponding weights

The shortest path between several objects according to set of cells

The shortest path between several objects according to set of cells with corresponding weights

Special cases:

  • Returns nil if no path exists between the two nodes (e.g. the graph is disconnected and source/target belong to different components).
  • Returns nil if either the source or the target node is not present in the graph.
  • On an empty graph (no vertices, no edges), always returns nil.

Examples:

path var0 <- my_topology path_between [ag1, ag2]; // var0 equals A path between ag1 and ag2 
path var1 <- path_between (cell_grid where each.is_free, ag1, ag2); // var1 equals A path between ag1 and ag2 passing through the given cell_grid agents 
path var2 <- path_between (my_graph, ag1, ag2); // var2 equals A path between ag1 and ag2 
path var3 <- path_between (cell_grid as_map (each::each.is_obstacle ? 9999.0 : 1.0), ag1, ag2); // var3 equals A path between ag1 and ag2 passing through the given cell_grid agents with a minimal cost 
path var4 <- my_topology path_between (ag1, ag2); // var4 equals A path between ag1 and ag2 
path var5 <- path_between (cell_grid where each.is_free, [ag1, ag2, ag3]); // var5 equals A path between ag1 and ag2 and ag3 passing through the given cell_grid agents 
path var6 <- path_between (cell_grid as_map (each::each.is_obstacle ? 9999.0 : 1.0), [ag1, ag2, ag3]); // var6 equals A path between ag1 and ag2 and ag3 passing through the given cell_grid agents with minimal cost

See also: towards, direction_to, distance_between, direction_between, path_to, distance_to, use_cache,


path_to

Possible uses:

  • geometry path_to geometry ---> path
  • path_to (geometry , geometry) ---> path
  • point path_to point ---> path
  • path_to (point , point) ---> path

Result:

A path between two geometries (geometries, agents or points) considering the topology of the agent applying the operator.

Examples:

path var0 <- ag1 path_to ag2; // var0 equals the path between ag1 and ag2 considering the topology of the agent applying the operator

See also: towards, direction_to, distance_between, direction_between, path_between, distance_to,


paths_between

Possible uses:

  • paths_between (gama.api.types.graph.IGraphEventProvider, pair, int) ---> list<path>

Result:

The K shortest paths between a list of two objects in a graph

Examples:

list<path> var0 <- paths_between(my_graph, ag1:: ag2, 2); // var0 equals the 2 shortest paths (ordered by length) between ag1 and ag2

pbinom

Same signification as binomial_sum


pchisq

Same signification as chi_square


percent_absolute_deviation

Possible uses:

  • list<float> percent_absolute_deviation list<float> ---> float
  • percent_absolute_deviation (list<float> , list<float>) ---> float

Result:

percent absolute deviation indicator for 2 series of values: percent_absolute_deviation(list_vals_observe,list_vals_sim)

Examples:

float var0 <- percent_absolute_deviation([200,300,150,150,200],[250,250,100,200,200]); // var0 equals 20.0

percentile

Same signification as quantile_inverse


pgamma

Same signification as gamma_distribution


pgm_file

Possible uses:

  • pgm_file (string) ---> file

Result:

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

Special cases:

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

See also: is_pgm,


pivot

Possible uses:

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

Result:

Pivots the dataframe: the index column becomes row labels, the pivot column values become new column names, and the value column provides the cell values. When multiple values exist for a combination, the first is kept.

Special cases:

  • Pivot a sales dataframe
dataframe pivoted <- pivot(sales_df, "product", "quarter", "revenue");

See also: filter, select_columns, join,


plan

Possible uses:

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

Result:

A polyline geometry from the given list of points.

Special cases:

  • if the operand is nil, returns the point geometry {0,0}
  • if the operand is composed of a single point, returns a point geometry.

Examples:

geometry var0 <- polyplan([{0,0}, {0,10}, {10,10}, {10,0}],10); // var0 equals a polyline geometry composed of the 4 points with a depth of 10.

See also: around, circle, cone, link, norm, point, polygone, rectangle, square, triangle,


play_sound

Possible uses:

  • play_sound (string) ---> bool

Result:

Play a wave file

Examples:

bool sound_ok <- play_sound('beep.wav');

plus_days

Possible uses:

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

Result:

Add a given number of days to a date

Examples:

date var0 <- date('2000-01-01') plus_days 12; // var0 equals date('2000-01-13')

plus_hours

Possible uses:

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

Result:

Add a given number of hours to a date

Examples:

// equivalent to date1 + 15 #h 
date var1 <- date('2000-01-01') plus_hours 24; // var1 equals date('2000-01-02')

plus_minutes

Possible uses:

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

Result:

Add a given number of minutes to a date

Examples:

// equivalent to date1 + 5 #mn 
date var1 <- date('2000-01-01') plus_minutes 5 ; // var1 equals date('2000-01-01 00:05:00')

plus_months

Possible uses:

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

Result:

Add a given number of months to a date

Examples:

date var0 <- date('2000-01-01') plus_months 5; // var0 equals date('2000-06-01')

plus_ms

Possible uses:

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

Result:

Add a given number of milliseconds to a date

Examples:

// equivalent to date('2000-01-01') + 15 #ms 
date var1 <- date('2000-01-01') plus_ms 1000 ; // var1 equals date('2000-01-01 00:00:01')

plus_seconds

Same signification as +


plus_weeks

Possible uses:

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

Result:

Add a given number of weeks to a date

Examples:

date var0 <- date('2000-01-01') plus_weeks 15; // var0 equals date('2000-04-15')

plus_years

Possible uses:

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

Result:

Add a given number of years to a date

Examples:

date var0 <- date('2000-01-01') plus_years 15; // var0 equals date('2015-01-01')

pnorm

Same signification as normal_area


point

Possible uses:

  • point (any) ---> point

Result:

casts the operand in a point object.


points_along

Possible uses:

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

Result:

A list of points along the operand-geometry given its location in terms of rate of distance from the starting points of the geometry.

Examples:

list var0 <-  line([{10,10},{80,80}]) points_along ([0.3, 0.5, 0.9]); // var0 equals the list of following points: [{31.0,31.0,0.0},{45.0,45.0,0.0},{73.0,73.0,0.0}]

See also: closest_points_with, farthest_point_to, points_at, points_on,


points_at

Possible uses:

  • int points_at float ---> list<point>
  • points_at (int , float) ---> list<point>

Result:

A list of left-operand number of points located at a the right-operand distance to the agent location.

Examples:

list<point> var0 <- 3 points_at(20.0); // var0 equals returns [pt1, pt2, pt3] with pt1, pt2 and pt3 located at a distance of 20.0 to the agent location

See also: any_location_in, any_point_in, closest_points_with, farthest_point_to, points_along, points_on, centroid,


points_in

Possible uses:

  • field points_in geometry ---> list<point>
  • points_in (field , geometry) ---> list<point>

points_on

Possible uses:

  • geometry points_on float ---> list
  • points_on (geometry , float) ---> list

Result:

A list of points of the operand-geometry distant from each other to the float right-operand .

Examples:

list var0 <-  square(5) points_on(2); // var0 equals a list of points belonging to the exterior ring of the square distant from each other of 2.

See also: closest_points_with, farthest_point_to, points_at, points_along,


poisson

Possible uses:

  • poisson (float) ---> int

Result:

A value from a random variable following a Poisson distribution (with the positive expected number of occurence lambda as operand).

Comment:

The Poisson distribution is a discrete probability distribution that expresses the probability of a given number of events occurring in a fixed interval of time and/or space if these events occur with a known average rate and independently of the time since the last event, cf. Poisson distribution on Wikipedia.

Special cases:

  • The expected value (lambda) must be positive. If lambda is 0 or negative, behavior is undefined.
  • Returns a non-negative integer.

Examples:

int var0 <- poisson(3.5); // var0 equals a random positive integer

See also: binomial, gamma_rnd, gauss_rnd, lognormal_rnd, rnd, skew_gauss, truncated_gauss, weibull_rnd, gauss,


polygon

Possible uses:

  • polygon (container<unknown,geometry>) ---> geometry

Result:

A polygon geometry from the given list of points.

Special cases:

  • if the operand is nil, returns the point geometry {0,0}
  • if the operand is composed of a single point, returns a point geometry
  • if the operand is composed of 2 points, returns a polyline geometry.
  • An empty list returns a point at {0,0,0}.
  • A list with fewer than 3 distinct points may return a line or a point geometry.
  • Duplicate consecutive points are removed before the polygon is built.

Examples:

geometry var0 <- polygon([{0,0}, {0,10}, {10,10}, {10,0}]); // var0 equals a polygon geometry composed of the 4 points. 
float var1 <- polygon([{0,0}, {0,10}, {10,10}, {10,0}]).area; // var1 equals 100.0 
point var2 <- polygon([{0,0}, {0,10}, {10,10}, {10,0}]).location; // var2 equals point(5.0,5.0,0.0)

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


polyhedron

Possible uses:

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

Result:

A polyhedron geometry from the given list of points.

Special cases:

  • if the operand is nil, returns the point geometry {0,0}
  • if the operand is composed of a single point, returns a point geometry
  • if the operand is composed of 2 points, returns a polyline geometry.

Examples:

geometry var0 <- polyhedron([{0,0}, {0,10}, {10,10}, {10,0}],10); // var0 equals a polygon geometry composed of the 4 points and of depth 10.

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


polyline

Same signification as line


polyplan

Same signification as plan


power_test

Possible uses:

  • power_test (list<float>, float, float, float) ---> int

Result:

Return the number of observation to satisfy power test given a critical effect size, tAlpha and tBeta.see reference: https://rseri.me/publication/b016/B016.pdf (accessible as of 04/2026).


predecessors_of

Possible uses:

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

Result:

returns the list of predecessors (i.e. sources of in edges) of the given vertex (right-hand operand) in the given graph (left-hand operand)

Special cases:

  • Returns an empty list for a vertex with no incoming edges (in-degree 0).
  • Returns an empty list if the vertex is not present in the graph.
  • On an undirected graph, predecessors_of is equivalent to neighbors_of (all adjacent vertices are returned).

Examples:

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

See also: neighbors_of, successors_of,


predicate

Possible uses:

  • predicate (any) ---> predicate

Result:

casts the operand in a predicate object.


predict

Possible uses:

  • regression predict list ---> float
  • predict (regression , list) ---> float

Result:

returns the value predicted by the regression parameters for a given instance. Usage: predict(regression, instance)

Examples:

predict(my_regression, [1,2,3])

pretty_print

Possible uses:

  • pretty_print (dataframe) ---> string
  • pretty_print (dataframe, int, int, int) ---> string

Result:

Creates a string representing the dataframe in a human readable format. The number of rows and columns is limited to 10 and the number of characters per cell to 50.

Creates a string representing the dataframe in a human readable format. The maximum number of rows, columns and the number of characters per cell to print is defined by the parameters.


product

Same signification as mul


product_of

Possible uses:

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

Result:

the product 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] product_of (each); // var1 equals 48

Examples:

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

See also: min_of, max_of, sum_of, mean_of, variance_of,


promethee_DM

Possible uses:

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

Result:

The index of the best candidate according to the Promethee II method. This method is based on a comparison per pair of possible candidates along each criterion: all candidates are compared to each other by pair and ranked. More information about this method can be found in Behzadian, M., Kazemzadeh, R., Albadvi, A., M., A.: PROMETHEE: A comprehensive literature review on methodologies and applications. European Journal of Operational Research(2010). The first operand is the list of candidates (a candidate is a list of criterion values); the second operand the list of criterion: A criterion is a map that contains fours elements: a name, a weight, a preference value (p) and an indifference value (q). The preference value represents the threshold from which the difference between two criterion values allows to prefer one vector of values over another. The indifference value represents the threshold from which the difference between two criterion values is considered significant.

Special cases:

  • Returns -1 if the candidate list is nil or empty.

Examples:

int var0 <- promethee_DM([[1.0, 7.0],[4.0,2.0],[3.0, 3.0]], [["name"::"utility", "weight" :: 2.0,"p"::0.5, "q"::0.0, "s"::1.0, "maximize" :: true],["name"::"price", "weight" :: 1.0,"p"::0.5, "q"::0.0, "s"::1.0, "maximize" :: false]]); // var0 equals 1

See also: weighted_means_DM, electre_DM, evidence_theory_DM, fuzzy_choquet_DM,


property_file

Possible uses:

  • property_file (string) ---> file
  • string property_file map<string,string> ---> file
  • property_file (string , map<string,string>) ---> file

Result:

Constructs a file of type property. Allowed extensions are limited to properties

Special cases:

  • property_file(string): This file constructor allows to read a property file (.properties)
file f <-property_file("file.properties");
  • property_file(string,map<string,string>): This file constructor allows to store a map in a property file (it does not save it - just store it in memory)
file f <-property_file("file.properties", map(["param1"::1.0,"param3"::10.0 ]));

See also: is_property,


pValue_for_fStat

Possible uses:

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

Result:

Returns the P value of F statistic fstat with numerator degrees of freedom dfn and denominator degress of freedom dfd. Uses the incomplete Beta function.

Examples:

float var0 <- pValue_for_fStat(1.9,10,12) with_precision(3); // var0 equals 0.145

pValue_for_tStat

Possible uses:

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

Result:

Returns the P value of the T statistic tstat with df degrees of freedom. This is a two-tailed test so we just double the right tail which is given by studentT of -|tstat|.

Examples:

float var0 <- pValue_for_tStat(0.9,10) with_precision(3); // var0 equals 0.389

pyramid

Possible uses:

  • pyramid (float) ---> geometry

Result:

A square geometry which side size is given by the operand.

Comment:

the center of the pyramid 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 <- pyramid(5); // var0 equals a geometry as a square with side_size = 5.

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


quantile

Possible uses:

  • container quantile float ---> float
  • quantile (container , float) ---> float

Result:

Returns the phi-quantile; that is, an element elem for which holds that phi percent of data elements are less than elem. The quantile does not need necessarily to be contained in the data sequence, it can be a linear interpolation. Note that the container holding the values must be sorted first

Examples:

float var0 <- quantile([1,3,5,6,9,11,12,13,19,21,22,32,35,36,45,44,55,68,79,80,81,88,90,91,92,100], 0.5); // var0 equals 35.5

quantile_inverse

Possible uses:

  • container quantile_inverse float ---> float
  • quantile_inverse (container , float) ---> float

Result:

Returns how many percent of the elements contained in the receiver are <= element. Does linear interpolation if the element is not contained but lies in between two contained elements. Note that the container holding the values must be sorted first

Examples:

float var0 <- quantile_inverse([1,3,5,6,9,11,12,13,19,21,22,32,35,36,45,44,55,68,79,80,81,88,90,91,92,100], 35.5) with_precision(2); // var0 equals 0.52

range

Possible uses:

  • range (int) ---> list
  • int range int ---> list
  • range (int , int) ---> list
  • range (int, int, int) ---> list

Result:

builds a list of int representing all contiguous values from zero to the argument included. The range can be increasing or decreasing.

Special cases:

  • Passing 0 will return a singleton list with 0.
  • When used with 3 operands, it returns a list of int representing all contiguous values from the first to the second argument, using the step represented by the third argument. The range can be increasing or decreasing. Passing the same value for both will return a singleton list with this value. Passing a step of 0 will result in an exception. Attempting to build infinite ranges (e.g. end > start with a negative step) will similarly not be accepted and yield an exception
list var3 <- range(0,6,2); // var3 equals [0,2,4,6]
  • When passing the same value for both arguments the operator will return a list containing only this value
list var4 <- range(0,2); // var4 equals [0,1,2] 
list var5 <- range(2,0); // var5 equals [2,1,0] 
list var6 <- range(0,0); // var6 equals [0]

Examples:

list var0 <- range(2); // var0 equals [0,1,2] 
list var1 <- range(-2); // var1 equals [0,-1,-2] 
list var2 <- range(1) collect(i: range(1) collect(j: i + j)); // var2 equals [[0,1],[1,2]]

rank_interpolated

Possible uses:

  • container rank_interpolated float ---> float
  • rank_interpolated (container , float) ---> float

Result:

Returns the linearly interpolated number of elements in a list less or equal to a given element. The rank is the number of elements <= element. Ranks are of the form {0, 1, 2,..., sortedList.size()}. If no element is <= element, then the rank is zero. If the element lies in between two contained elements, then linear interpolation is used and a non integer value is returned. Note that the container holding the values must be sorted first

Examples:

float var0 <- rank_interpolated([1,3,5,6,9,11,12,13,19,21,22,32,35,36,45,44,55,68,79,80,81,88,90,91,92,100], 35); // var0 equals 13.0

read

Possible uses:

  • read (string) ---> unknown

Result:

Reads an attribute of the agent. The attribute's name is specified by the operand.

Examples:

unknownagent_name <- read ('name');  // agent_name equals reads the 'name' variable of agent then assigns the returned value to the 'agent_name' variable. 

rectangle

Possible uses:

  • rectangle (point) ---> geometry
  • point rectangle point ---> geometry
  • rectangle (point , point) ---> geometry
  • float rectangle float ---> geometry
  • rectangle (float , float) ---> geometry

Result:

A rectangle geometry, computed from the operands values (e.g. the 2 side sizes).

Comment:

the center of the rectangle is by default the location of the current agent in which has been called this operator.the center of the rectangle 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.
  • If either dimension is ≤ 0, the resulting geometry degenerates (width or height of 0 produces a line; both ≤ 0 produces a point).

Examples:

geometry var0 <- rectangle({10, 5}); // var0 equals a geometry as a rectangle with width = 10 and height = 5. 
geometry var1 <- rectangle({0.0,0.0}, {10.0,10.0}); // var1 equals a geometry as a rectangle with {1.0,1.0} as the upper-left corner, {10.0,10.0} as the lower-right corner. 
geometry var2 <- rectangle(10, 5); // var2 equals a geometry as a rectangle with width = 10 and height = 5.

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


reduced_by

Same signification as -


regex_matches

Possible uses:

  • string regex_matches string ---> list<string>
  • regex_matches (string , string) ---> list<string>

Result:

Returns the list of sub-strings of the first operand that match the regular expression provided in the second operand

Examples:

list<string> var0 <- regex_matches("colour, color", "colou?r"); // var0 equals ['colour','color']

See also: replace_regex,


regression

Possible uses:

  • regression (any) ---> regression

Result:

casts the operand in a regression object.


remove_duplicates

Possible uses:

  • remove_duplicates (container) ---> list

Result:

produces a set from the elements of the operand (i.e. a list without duplicated elements)

Special cases:

  • if the operand is a graph, remove_duplicates returns the set of nodes
  • If the container has no duplicates, returns an equivalent copy.
  • If the container is empty, returns an empty list.
  • Order of first occurrences is preserved.
  • if the operand is empty, remove_duplicates returns an empty list
list var1 <- remove_duplicates([]); // var1 equals []
  • if the operand is a map, remove_duplicates returns the set of values without duplicate
list var2 <- remove_duplicates([1::3,2::4,3::3,5::7]); // var2 equals [3,4,7]
  • if the operand is a matrix, remove_duplicates returns a list containing all the elments with duplicated.
list var3 <- remove_duplicates([["c11","c12","c13","c13"],["c21","c22","c23","c23"]]); // var3 equals [["c11","c12","c13","c21","c22","c23"]]

Examples:

list var0 <- remove_duplicates([3,2,5,1,2,3,5,5,5]); // var0 equals [3,2,5,1]

remove_empty

Possible uses:

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

Result:

Returns a new dataframe with rows removed where the specified column has null or empty values.

Special cases:

  • Remove rows with empty 'name' values
dataframe df2 <- remove_empty(my_df, "name");

See also: filter, select_columns,


remove_node_from

Possible uses:

  • geometry remove_node_from graph ---> graph
  • remove_node_from (geometry , graph) ---> graph

Result:

removes a node from a graph.

Comment:

WARNING / side effect: this operator modifies the operand and does not create a new graph. All the edges containing this node are also removed.

Examples:

graph var0 <- node(0) remove_node_from graphEpidemio; // var0 equals the graph without node(0)

rename_file

Possible uses:

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

Result:

rename/move a file or a folder

Examples:

bool rename_file_ok <- rename_file("../includes/my_folder","../includes/my_new_folder");

replace

Possible uses:

  • replace (string, string, string) ---> string

Result:

Returns the string obtained by replacing by the third operand, in the first operand, all the sub-strings equal to the second operand

Examples:

string var0 <- replace('to be or not to be,that is the question','to', 'do'); // var0 equals 'do be or not do be,that is the question'

See also: replace_regex,


replace_first

Possible uses:

  • replace_first (string, string, string) ---> string

Result:

Returns a string where the first occurrence of the right-hand string is replaced by the third one

Examples:

string var0 <- replace_first("abcabc", "a", "d"); // var0 equals "dbcabc"

replace_regex

Possible uses:

  • replace_regex (string, string, string) ---> string

Result:

Returns the string obtained by replacing by the third operand, in the first operand, all the sub-strings that match the regular expression of the second operand

Examples:

string var0 <- replace_regex("colour, color", "colou?r", "col"); // var0 equals 'col, col'

See also: replace, regex_matches,


residuals

Possible uses:

  • residuals (regression) ---> list<float>

Result:

Return the list of residuals for a given regression model

Examples:

residuals(my_regression)

reverse

Possible uses:

  • reverse (map<K,V>) ---> map
  • reverse (container<KeyType,ValueType>) ---> container<unknown,unknown>

Result:

the operand elements in the reversed order in a copy of the operand.

Comment:

the reverse operator behavior depends on the nature of the operand

Special cases:

  • if it is a file, reverse returns a copy of the file with a reversed content
  • if it is a population, reverse returns a copy of the population with elements in the reversed order
  • if it is a graph, reverse returns a copy of the graph (with all edges and vertexes), with all of the edges reversed
  • if it is a list, reverse returns a copy of the operand list with elements in the reversed order
list<int> var2 <- reverse ([10,12,14]); // var2 equals [14, 12, 10]
  • if it is a map, reverse returns a copy of the operand map with each pair in the reversed order (i.e. all keys become values and values become keys)
map<int,string> var3 <- reverse (['k1'::44, 'k2'::32, 'k3'::12]); // var3 equals [44::'k1', 32::'k2', 12::'k3']
  • if it is a matrix, reverse returns a new matrix containing the transpose of the operand.
matrix<string> var4 <- reverse(matrix([["c11","c12","c13"],["c21","c22","c23"]])); // var4 equals matrix([["c11","c21"],["c12","c22"],["c13","c23"]])

Examples:

map<int,int> m <- [1::111,2::222, 3::333, 4::444]; 
map var1 <- reverse(m); // var1 equals map([111::1,222::2,333::3,444::4])

reverse

Possible uses:

  • reverse (string) ---> string

Special cases:

  • if it is a string, reverse returns a new string with characters in the reversed order
string var0 <- reverse ('abcd'); // var0 equals 'dcba'

rewire_n

Possible uses:

  • graph rewire_n int ---> graph
  • rewire_n (graph , int) ---> graph

Result:

rewires the given count of edges.

Comment:

WARNING / side effect: this operator modifies the operand and does not create a new graph. If there are too many edges, all the edges will be rewired.

Examples:

graph var1 <- graphEpidemio rewire_n 10; // var1 equals the graph with 3 edges rewired

rgb

Possible uses:

  • rgb (any) ---> rgb

Result:

casts the operand in a rgb object.


rgb

Possible uses:

  • rgb rgb int ---> rgb
  • rgb (rgb , int) ---> rgb
  • rgb rgb float ---> rgb
  • rgb (rgb , float) ---> rgb
  • string rgb int ---> rgb
  • rgb (string , int) ---> rgb
  • rgb (int, int, int) ---> rgb
  • rgb (int, int, int, int) ---> rgb
  • rgb (int, int, int, float) ---> rgb

Result:

Returns a color defined by red, green, blue components and an alpha blending value.

Special cases:

  • It can be used with a color and an alpha between 0 and 255
  • It can be used with r=red, g=green, b=blue (each between 0 and 255), a=alpha (between 0 and 255)
  • It can be used with r=red, g=green, b=blue, each between 0 and 255
  • rgb(0,0,0) produces black (#black).
  • rgb(255,255,255) produces white (#white).
  • rgb(255,0,0) produces red (#red).
  • It can be used with r=red, g=green, b=blue (each between 0 and 255), a=alpha (between 0.0 and 1.0)
  • It can be used with a color and an alpha between 0 and 1
  • It can be used with a name of color and alpha (between 0 and 255)

Examples:

rgb var0 <- rgb(rgb(255,0,0),125); // var0 equals a light red color 
rgb var1 <- rgb (255,0,0,125); // var1 equals a light red color 
rgb var2 <- rgb (255,0,0); // var2 equals #red 
rgb var3 <- rgb (255,0,0,0.5); // var3 equals a light red color 
rgb var4 <- rgb(rgb(255,0,0),0.5); // var4 equals a light red color 
rgb var5 <- rgb ("red"); // var5 equals rgb(255,0,0)

See also: hsb, rnd_color, grayscale, blend,


rms

Possible uses:

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

Result:

Returns the RMS (Root-Mean-Square) of a data sequence. The RMS of data sequence is the square-root of the mean of the squares of the elements in the data sequence. It is a measure of the average size of the elements of a data sequence.

Examples:

 list<float> data_sequence <- [6.0, 7.0, 8.0, 9.0];  
 list<float> squares <- data_sequence collect (each*each);  
float var2 <-  rms(length(data_sequence),sum(squares)) with_precision(4) ; // var2 equals 7.5829

rnd

Possible uses:

  • rnd (float) ---> float
  • rnd (point) ---> point
  • rnd (int) ---> int
  • float rnd float ---> float
  • rnd (float , float) ---> float
  • point rnd point ---> point
  • rnd (point , point) ---> point
  • int rnd int ---> int
  • rnd (int , int) ---> int
  • rnd (point, point, float) ---> point
  • rnd (int, int, int) ---> int
  • rnd (float, float, float) ---> float

Result:

returns a random value in a range (the type value depends on the operand type): when called with an integer, it returns a random integer in the interval [0, operand]

Comment:

to obtain a probability between 0 and 1, use the expression (rnd n) / n, where n is used to indicate the precision

Special cases:

  • If min equals max, always returns that value.
  • If min equals max, always returns that value.
  • if the operand is a float, returns an uniformly distributed float random number in [0.0, to]
  • If max is 0.0, returns 0.0.
  • if the operand is a point, returns a point with three random float ordinates, each in the interval [0, ordinate of argument]
  • If min equals max, always returns that value.
  • If min equals max, always returns that value.
  • If the max is 0, returns 0.
  • If max is negative, raises a runtime error.
  • If min equals max, always returns that value.
  • If min equals max, always returns that value.

Examples:

point var0 <- rnd ({2.0, 4.0}, {2.0, 5.0, 10.0}, 1); // var0 equals a point with x = 2.0, y equal to 2.0, 3.0 or 4.0 and z between 0.0 and 10.0 every 1.0 
float var1 <- rnd (2.0, 4.0); // var1 equals a float number between 2.0 and 4.0 
float var2 <- rnd(3.4); // var2 equals a random float between 0.0 and 3.4 
point var3 <- rnd ({2.5,3, 0.0}); // var3 equals {x,y} with x in [0.0,2.0], y in [0.0,3.0], z = 0.0 
int var4 <- rnd (2, 12, 4); // var4 equals 2, 6 or 10 
point var5 <- rnd ({2.0, 4.0}, {2.0, 5.0, 10.0}); // var5 equals a point with x = 2.0, y between 2.0 and 4.0 and z between 0.0 and 10.0 
int var6 <- rnd (2); // var6 equals 0, 1 or 2 
int var7 <- rnd (2, 4); // var7 equals 2, 3 or 4 
float var8 <- rnd (2.0, 4.0, 0.5); // var8 equals a float number between 2.0 and 4.0 every 0.5

See also: binomial, gamma_rnd, gauss_rnd, lognormal_rnd, poisson, skew_gauss, truncated_gauss, weibull_rnd, rnd_choice, flip, gauss,


rnd_choice

Possible uses:

  • rnd_choice (list) ---> int
  • rnd_choice (map<unknown,float>) ---> unknown

Result:

returns an index of the given list with a probability following the (normalized) distribution described in the list (a form of lottery)

returns a key from the map with a probability following the (normalized) distribution described in map values (a form of lottery)

Special cases:

  • The list of weights must not be empty.
  • All weights are assumed to be non-negative; negative weights lead to undefined behavior.
  • The weight list is normalized automatically.

Examples:

int var0 <- rnd_choice([0.2,0.5,0.3]); // var0 equals 2/10 chances to return 0, 5/10 chances to return 1, 3/10 chances to return 2 
unknown var1 <- rnd_choice(["toto"::0.2,"tata"::0.5,"tonton"::0.3]); // var1 equals 2/10 chances to return "toto", 5/10 chances to return "tata", 3/10 chances to return "tonton"

See also: rnd,


rnd_color

Possible uses:

  • rnd_color (int) ---> rgb
  • int rnd_color int ---> rgb
  • rnd_color (int , int) ---> rgb

Result:

rgb color

Return a random color equivalent to rgb(rnd(first_op, last_op),rnd(first_op, last_op),rnd(first_op, last_op))

Comment:

Return a random color equivalent to rgb(rnd(operand),rnd(operand),rnd(operand))

Examples:

rgb var0 <- rnd_color(255); // var0 equals a random color, equivalent to rgb(rnd(255),rnd(255),rnd(255)) 
rgb var1 <- rnd_color(100, 200); // var1 equals a random color, equivalent to rgb(rnd(100, 200),rnd(100, 200),rnd(100, 200))

See also: rgb, hsb,


rolling_se

Possible uses:

  • rolling_se (list<float>) ---> list<float>

Result:

Return the list of standard error according to the number of observations, i.e. value at index i is the standard error for the first i observations.


rolling_vc

Possible uses:

  • rolling_vc (list<float>) ---> list<float>

Result:

Return the list of rolling coefficient of variance according to the number of observations, i.e. value at index i is the coefficient of variance for the first i observations.


rotated_by

Possible uses:

  • geometry rotated_by float ---> geometry
  • rotated_by (geometry , float) ---> geometry
  • point rotated_by pair ---> point
  • rotated_by (point , pair) ---> point
  • geometry rotated_by pair ---> geometry
  • rotated_by (geometry , pair) ---> geometry
  • geometry rotated_by int ---> geometry
  • rotated_by (geometry , int) ---> geometry
  • rotated_by (geometry, float, point) ---> geometry

Result:

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

A geometry resulting from the application of a rotation by the operand angles (degree) along the operand axis (last operand) to the left-hand operand (geometry, agent, point)

Special cases:

  • When used with a point and a pair angle::point, it returns a point resulting from the application of the right-hand rotation operand (angles in degree) to the left-hand operand point
  • the right-hand operand representing the angle can be a float or an integer

Examples:

geometry var0 <- self rotated_by 45; // var0 equals the geometry resulting from a 45 degrees rotation to the geometry of the agent applying the operator. 
geometry var1 <- rotated_by(pyramid(10),45.0::{1,0,0}); // var1 equals the geometry resulting from a 45 degrees rotation along the {1,0,0} vector to the geometry of the agent applying the operator. 
geometry var2 <- rotated_by(pyramid(10),45.0, {1,0,0}); // var2 equals the geometry resulting from a 45 degrees rotation along the {1,0,0} vector to the geometry of the agent applying the operator.

See also: transformed_by, translated_by,


rotated_by

Possible uses:

  • image rotated_by float ---> image
  • rotated_by (image , float) ---> image

Result:

Returns the image rotated using the angle in degrees passed in parameter. A positive angle means a clockwise rotation, and a negative one a counter-clockwise. The original image is left untouched


rotation_composition

Possible uses:

  • rotation_composition (list<pair>) ---> pair<float,point>

Result:

The rotation resulting from the composition of the rotations in the list. Rotations will be applied in the order of the list: if R=[R1,...,Rn], Rx = Rn...R1x. Angles are in degrees.

Examples:

pair<float,point> var0 <- rotation_composition([38.0::{1,1,1},90.0::{1,0,0}]); // var0 equals 115.22128507898105::{0.9491582126366207,0.31479943993669307,-0.0}

See also: inverse_rotation,


round

Possible uses:

  • round (point) ---> point

Result:

Returns the rounded value of the operand.

Examples:

point var0 <- {12345.78943,  12345.78943, 12345.78943} with_precision 2; // var0 equals {12345.79,12345.79,12345.79}

See also: round, with_precision,


round

Possible uses:

  • round (float) ---> int
  • round (int) ---> int

Result:

Returns the nearest integer value of the operand, rounding half-up (away from zero for negative values).

Special cases:

  • round(0.5) = 1 (half-up convention).
  • round(-0.5) = -1 (half-away-from-zero: -0.5 rounds down to -1).
  • round(0.0) = 0.
  • if the operand is an int, round returns it unchanged.

Examples:

int var0 <- round (0.51); // var0 equals 1 
int var1 <- round (100.2); // var1 equals 100 
int var2 <- round(-0.51); // var2 equals -1

See also: int, with_precision, floor, ceil,


row_at

Possible uses:

  • matrix<unknown> row_at int ---> list<unknown>
  • row_at (matrix<unknown> , int) ---> list<unknown>

Result:

returns the row at a num_line (right-hand operand)

Examples:

list<unknown> var0 <- matrix([["el11","el12","el13"],["el21","el22","el23"],["el31","el32","el33"]]) row_at 2; // var0 equals ["el13","el23","el33"]

See also: column_at, columns_list,


row_at

Possible uses:

  • dataframe row_at int ---> list
  • row_at (dataframe , int) ---> list

Result:

Returns the row of the dataframe at the given index as a list of values. Overloads the matrix 'row_at' operator for dataframes.

Special cases:

  • Get the row at index 1
my_df row_at 1

See also: column_at, rows_list, iloc, cell,


rows_list

Possible uses:

  • rows_list (matrix<unknown>) ---> list<list<unknown>>

Result:

returns a list of the rows of the matrix, with each row as a list of elements

Examples:

list<list<unknown>> var0 <- rows_list(matrix([["el11","el12","el13"],["el21","el22","el23"],["el31","el32","el33"]])); // var0 equals [["el11","el21","el31"],["el12","el22","el32"],["el13","el23","el33"]]

See also: columns_list, column_at, as_list,


rows_list

Possible uses:

  • rows_list (dataframe) ---> list

Result:

Returns the list of the rows of the dataframe, each row being a list of its cell values. Overloads the matrix 'rows_list' operator for dataframes.

See also: columns_list, row_at,


rSquare

Possible uses:

  • rSquare (regression) ---> float

Result:

Return the value of the adjusted R square for a given regression model

Examples:

rSquare(my_regression)
⚠️ **GitHub.com Fallback** ⚠️