4.2.2. Standard Library

These functions and predicates define built-in operations of the MiniZinc language.

4.2.2.1. Language information

These functions return information about the MiniZinc system.

Parameters

opt int: mzn_min_version_required

If defined, this can be used to check that the MiniZinc compiler supports all the features used in the model.

Functions and Predicates

function int: mzn_compiler_version()

Return MiniZinc version encoded as an integer (major*10000+minor*1000+patch).

function string: mzn_version_to_string(int: v)

Return string representation of v given an integer major*10000+minor*1000+patch

More…

4.2.2.2. Compiler options

Parameters

opt bool: mzn_ignore_redundant_constraints

Whether to ignore redundant constraints

If not specified or set to false, it depends on the solver library whether constraints that are wrapped in a redundant_constraint call are in fact compiled. If set to true, they are not compiled, independent of the solver library.

opt bool: mzn_ignore_symmetry_breaking_constraints

Whether to ignore symmetry breaking constraints

If not specified or set to false, it depends on the solver library whether constraints that are wrapped in a symmetry_breaking_constraint call are in fact compiled. If set to true, they are not compiled, independent of the solver library.

opt bool: mzn_opt_annotate_defines_var

Whether to generate defines_var annotations

opt bool: mzn_opt_only_range_domains

Whether to only generate domains that are contiguous ranges

Functions and Predicates

test mzn_check_annotate_defines_var()

Check whether to generate defines_var annotations

More…

test mzn_check_ignore_redundant_constraints()

Check whether to ignore redundant constraints

More…

test mzn_check_ignore_symmetry_breaking_constraints()

Check whether to ignore symmetry breaking constraints

More…

test mzn_check_only_range_domains()

Check whether to only generate domains that are contiguous ranges

More…

4.2.2.3. Annotations

These annotations control evaluation and solving behaviour.

General annotations

Parameters

annotation add_to_output

Declare that the annotated variable should be added to the output of the model. This annotation only has an effect when the model does not have an output item.

annotation domain_change_constraint

Marks a constraint as a recorded domain changing constraint (when mzn2fzn called with -g flag

annotation is_defined_var

Declare the annotated variable as being functionally defined. This annotation is introduced into FlatZinc code by the compiler.

annotation is_reverse_map

Declare that the annotated expression is used to map an expression back from FlatZinc to MiniZinc.

annotation maybe_partial

Declare that expression may have undefined result (to avoid warnings)

annotation mzn_check_var

Declare that the annotated variable is required for checking solutions.

annotation mzn_rhs_from_assignment

Used internally by the compiler

annotation output_only

Declare that the annotated variable should be only used for output. This annotation can be used to define variables that are required for solution checkers, or that are necessary for the output item. The annotated variable must be par.

annotation output_var

Declare that the annotated variable should be printed by the solver. This annotation is introduced into FlatZinc code by the compiler.

annotation promise_total

Declare function as total, i.e. it does not put any constraints on its arguments.

annotation var_is_introduced

Declare a variable as being introduced by the compiler.

Functions and Predicates

annotation constraint_name(string: s)

Used to attach a name s to a constraint and its decomposition. String annotations on constraint keywords are re-written as constraint_name annotations

annotation defines_var(var $t: c)

Declare variable: c as being functionally defined by the annotated constraint. This annotation is introduced into FlatZinc code by the compiler.

annotation doc_comment(string: s)

Document the function or variable declaration item with the string s .

annotation expression_name(string: s)

Used to attach a name s to an expression, this should also propagate to any sub-expressions or decomposition of the annotated expression. String annotations on expressions are re-written as expression_name annotations

annotation mzn_check_enum_var(array [int] of set of int)

Declare that the annotated variable is required for checking solutions and has an enum type.

annotation mzn_constraint_name(string)

Declare a name for the annotated constraint.

annotation mzn_deprecated(string: version, string: explanation)

State that a function is deprecated.

annotation mzn_expression_name(string)

Declare a name for the annotated expression.

annotation mzn_path(string: s)

Representation of the call-stack when the annotated item was introduced, as a string s . Can be used to uniquely identify variables and constraints across different compilations of a model that may have different names. This annotations is introduced into FlatZinc code by the compiler and is retained if –keep-paths argument is used.

annotation output_array(array [$u] of set of int: a)

Declare that the annotated array should be printed by the solver with the given index sets a . This annotation is introduced into FlatZinc code by the compiler.

Propagation strength annotations

annotation bounds

Annotate a constraint to use bounds propagation

annotation domain

Annotate a constraint to use domain propagation

Search annotations

Variable selection annotations

annotation anti_first_fail

Choose the variable with the largest domain

annotation dom_w_deg

Choose the variable with largest domain, divided by the number of attached constraints weighted by how often they have caused failure

annotation first_fail

Choose the variable with the smallest domain

annotation impact

Choose the variable with the highest impact so far during the search

annotation input_order

Search variables in the given order

annotation largest

Choose the variable with the largest value in its domain

annotation max_regret

Choose the variable with largest difference between the two smallest values in its domain

annotation most_constrained

Choose the variable with the smallest domain, breaking ties using the number of attached constraints

annotation occurrence

Choose the variable with the largest number of attached constraints

annotation smallest

Choose the variable with the smallest value in its domain

Value choice annotations

annotation indomain

Assign values in ascending order

annotation indomain_interval

If the domain consists of several contiguous intervals, reduce the domain to the first interval. Otherwise bisect the domain.

annotation indomain_max

Assign the largest value in the domain

annotation indomain_median

Assign the middle value in the domain, or the smaller of the two middle values in case of an even number of elements in the domain

annotation indomain_middle

Assign the value in the domain closest to the mean of its current bounds

annotation indomain_min

Assign the smallest value in the domain

annotation indomain_random

Assign a random value from the domain

annotation indomain_reverse_split

Bisect the domain, excluding the lower half first

annotation indomain_split

Bisect the domain, excluding the upper half first

annotation indomain_split_random

Bisect the domain, randomly selecting which half to exclude first

annotation outdomain_max

Exclude the largest value from the domain

annotation outdomain_median

Exclude the middle value from the domain

annotation outdomain_min

Exclude the smallest value from the domain

annotation outdomain_random

Exclude a random value from the domain

Exploration strategy annotations

annotation complete

Perform a complete search

Restart annotations

Parameters
annotation restart_none

Do not restart

Functions and Predicates
annotation restart_constant(int: scale)

Restart after constant number of nodes scale

annotation restart_geometric(float: base, int: scale)

Restart with geometric sequence with parameters base and scale

annotation restart_linear(int: scale)

Restart with linear sequence scaled by scale

annotation restart_luby(int: scale)

Restart with Luby sequence scaled by scale

Other declarations

annotation bool_search(array [$X] of var bool: x,
                       ann: select,
                       ann: choice,
                       ann: explore)

Specify search on variables x , with variable selection strategy select , value choice strategy choice , and exploration strategy explore . If x is a multi-dimensional array, it is coerced to one-dimensional in row-major order (as with the array1d function).

annotation bool_search(array [$X] of var bool: x,
                       ann: select,
                       ann: choice)

Specify search on variables x , with variable selection strategy select , and value choice strategy choice . If x is a multi-dimensional array, it is coerced to one-dimensional in row-major order (as with the array1d function).

More…

annotation bool_search(array [int] of var opt bool: x,
                       ann: a1,
                       ann: a2,
                       ann: a3)

Search annotation for optional Boolean variables

More…

annotation bool_search(array [int] of var opt bool: x,
                       ann: a1,
                       ann: a2)

Search annotation for optional Boolean variables

More…

annotation float_search(array [$X] of var float: x,
                        float: prec,
                        ann: select,
                        ann: choice,
                        ann: explore)

Specify search on variables x , with precision prec , variable selection strategy select , value choice strategy choice , and exploration strategy explore . If x is a multi-dimensional array, it is coerced to one-dimensional in row-major order (as with the array1d function).

annotation float_search(array [$X] of var float: x,
                        float: prec,
                        ann: select,
                        ann: choice)

Specify search on variables x , with precision prec , variable selection strategy select , and value choice strategy choice . If x is a multi-dimensional array, it is coerced to one-dimensional in row-major order (as with the array1d function).

More…

annotation float_search(array [int] of var opt float: x,
                        ann: a1,
                        ann: a2,
                        ann: a3)

Search annotation for optional float variables

More…

annotation float_search(array [int] of var opt float: x,
                        ann: a1,
                        ann: a2)

Search annotation for optional float variables

More…

annotation int_search(array [$X] of var int: x,
                      ann: select,
                      ann: choice,
                      ann: explore)

Specify search on variables x , with variable selection strategy select , value choice strategy choice , and exploration strategy explore . If x is a multi-dimensional array, it is coerced to one-dimensional in row-major order (as with the array1d function).

annotation int_search(array [$X] of var int: x,
                      ann: select,
                      ann: choice)

Specify search on variables x , with variable selection strategy select , and value choice strategy choice . If x is a multi-dimensional array, it is coerced to one-dimensional in row-major order (as with the array1d function).

More…

annotation int_search(array [int] of var opt int: x,
                      ann: a1,
                      ann: a2,
                      ann: a3)

Search annotation for optional integer variables

More…

annotation int_search(array [int] of var opt int: x, ann: a1, ann: a2)

Search annotation for optional integer variables

More…

annotation seq_search(array [int] of ann: s)

Sequentially perform the searches specified in array s

annotation set_search(array [$X] of var set of int: x,
                      ann: select,
                      ann: choice,
                      ann: explore)

Specify search on variables x , with variable selection strategy select , value choice strategy choice , and exploration strategy explore . If x is a multi-dimensional array, it is coerced to one-dimensional in row-major order (as with the array1d function).

annotation set_search(array [$X] of var set of int: x,
                      ann: select,
                      ann: choice)

Specify search on variables x , with variable selection strategy select , and value choice strategy choice . If x is a multi-dimensional array, it is coerced to one-dimensional in row-major order (as with the array1d function).

More…

Warm start annotations

To be put on the solve item, similar to search annotations. A variable can be mentioned several times and in different annotations but only one of the values is taken

annotation warm_start(array [int] of var bool: x,
                      array [int] of bool: v)

Specify warm start values v for an array of booleans x

annotation warm_start(array [int] of var int: x, array [int] of int: v)

Specify warm start values v for an array of integers x

annotation warm_start(array [int] of var float: x,
                      array [int] of float: v)

Specify warm start values v for an array of floats x

annotation warm_start(array [int] of var set of int: x,
                      array [int] of set of int: v)

Specify warm start values v for an array of sets x

annotation warm_start_array(array [int] of ann: w)

Specify an array w of warm_start annotations or other warm_start_array annotations. Can be useful to keep the annotation order in FlatZinc for manual updating.

Note: if you have search annotations as well, put warm_starts into seq_search in order to have precedence between both, which may matter.

4.2.2.4. Special constraints

These predicates allow users to mark constraints as e.g. symmetry breaking or redundant, so that solvers can choose to implement them differently.

We cannot easily use annotations for this purpose, since annotations are propagated to all constraints in a decomposition, which may be incorrect for redundant or symmetry breaking constraints in the presence of common subexpression elimination (CSE).

predicate implied_constraint(var bool: b)

Mark b as an implied constraint (synonym for redundant_constraint)

predicate redundant_constraint(var bool: b)

Mark b as a redundant constraint

predicate symmetry_breaking_constraint(var bool: b)

Mark b as a symmetry breaking constraint

4.2.2.5. Option type support

These functions and predicates implement the standard library for working with option types. Note that option type support is still incomplete.

Option type support for Booleans

predicate absent(var opt bool: x)

True iff x is absent

More…

predicate deopt(var opt bool: x)

Return value of x (assumes that x is not absent)

More…

predicate occurs(var opt bool: x)

True iff x is not absent

More…

predicate ~=(var opt bool: x, var opt bool: y)

Weak equality. True if either x or y are absent, or present and equal.

More…

Option type support for integers

predicate absent(var opt int: x)

True iff x is absent

More…

function var $$E: deopt(var opt $$E: x)

Return value of x (assumes that x is not absent)

More…

predicate occurs(var opt int: x)

True iff x is not absent

More…

function var opt int: ~*(var opt int: x, var opt int: y)

Weak multiplication. Return product of x and y if both are present, otherwise return absent.

More…

function var opt int: ~+(var opt int: x, var opt int: y)

Weak addition. Return sum of x and y if both are present, otherwise return absent.

More…

function var opt int: ~-(var opt int: x, var opt int: y)

Weak subtraction. Return difference of x and y if both are present, otherwise return absent.

More…

predicate ~=(var opt int: x, var opt int: y)

Weak equality. True if either x or y are absent, or present and equal.

More…

Option type support for floats

predicate absent(var opt float: x)

True iff x is absent

More…

function var float: deopt(var opt float: x)

Return value of x (assumes that x is not absent)

More…

predicate occurs(var opt float: x)

True iff x is not absent

More…

function var opt float: ~*(var opt float: x, var opt float: y)

Weak multiplication. Return product of x and y if both are present, otherwise return absent.

More…

function var opt float: ~+(var opt float: x, var opt float: y)

Weak addition. Return sum of x and y if both are present, otherwise return absent.

More…

function var opt float: ~-(var opt float: x, var opt float: y)

Weak subtraction. Return difference of x and y if both are present, otherwise return absent.

More…

predicate ~=(var opt float: x, var opt float: y)

Weak equality. True if either x or y are absent, or present and equal.

More…

Other declarations

function $T: deopt(opt $T: x)

Return value of x if x is not absent. Aborts when evaluated on absent value.

function $$T: deopt(opt $$T: x)

Return value of x if x is not absent. Aborts when evaluated on absent value.

function var $T: deopt(var $T: x)

Return value x unchanged (since x is guaranteed to be non-optional).

More…

4.2.2.6. Comparison Builtins

These builtins implement comparison operations.
test '!='($T: x, $T: y)

Usage: x != y

Return if x is not equal to y

test '!='(opt $T: x, opt $T: y)

Usage: x != y

Return if x is not equal to y

More…

predicate '!='(var $T: x, var $T: y)

Usage: x != y

Return if x is not equal to y

predicate '!='(var opt $T: x, var opt $T: y)

Usage: x != y

Return if x is not equal to y

test '!='(array [$T] of int: x, array [$T] of int: y)

Usage: x != y

Return if array x is not equal to array y

More…

predicate '!='(array [$T] of var int: x, array [$T] of var int: y)

Usage: x != y

Return if array x is not equal to array y

More…

test '!='(array [$T] of bool: x, array [$T] of bool: y)

Usage: x != y

Return if array x is not equal to array y

More…

predicate '!='(array [$T] of var bool: x, array [$T] of var bool: y)

Usage: x != y

Return if array x is not equal to array y

More…

test '!='(array [$T] of set of int: x, array [$T] of set of int: y)

Usage: x != y

Return if array x is not equal to array y

More…

predicate '!='(array [$T] of var set of int: x,
               array [$T] of var set of int: y)

Usage: x != y

Return if array x is not equal to array y

More…

test '!='(array [$T] of float: x, array [$T] of float: y)

Usage: x != y

Return if array x is not equal to array y

More…

predicate '!='(array [$T] of var float: x, array [$T] of var float: y)

Usage: x != y

Return if array x is not equal to array y

More…

test '<'($T: x, $T: y)

Usage: x < y

Return if x is less than y

predicate '<'(var $T: x, var $T: y)

Usage: x < y

Return if x is less than y

predicate '<'(var opt int: x, var opt int: y)

Usage: x < y

Weak comparison: true iff either x or y is absent, or both occur and the value of x is less than the value of y .

More…

test '<'(opt int: x, opt int: y)

Usage: x < y

Weak comparison: true iff either x or y is absent, or both occur and the value of x is less than the value of y .

More…

test '<'(array [$U] of $T: x, array [$U] of $T: y)

Usage: x < y

Return if array x is lexicographically smaller than array y

predicate '<'(array [$U] of var $T: x, array [$U] of var $T: y)

Usage: x < y

Return if array x is lexicographically smaller than array y

test '<='($T: x, $T: y)

Usage: x <= y

Return if x is less than or equal to y

predicate '<='(var $T: x, var $T: y)

Usage: x <= y

Return if x is less than or equal to y

predicate '<='(var opt int: x, var opt int: y)

Usage: x <= y

Weak comparison: true iff either x or y is absent, or both occur and the value of x is less than or equal to the value of y .

More…

test '<='(opt int: x, opt int: y)

Usage: x <= y

Weak comparison: true iff either x or y is absent, or both occur and the value of x is less than or equal to the value of y .

More…

test '<='(array [$U] of $T: x, array [$U] of $T: y)

Usage: x <= y

Return if array x is lexicographically smaller than or equal to array y

predicate '<='(array [$U] of var $T: x, array [$U] of var $T: y)

Usage: x <= y

Return if array x is lexicographically smaller than or equal to array y

test '='($T: x, $T: y)

Usage: x = y

Return if x is equal to y

test '='(opt $T: x, opt $T: y)

Usage: x = y

Return if x is equal to y

More…

predicate '='(var $T: x, var $T: y)

Usage: x = y

Return if x is equal to y

predicate '='(var opt $T: x, var opt $T: y)

Usage: x = y

Return if x is equal to y

test '='(array [$T] of int: x, array [$T] of int: y)

Usage: x = y

Return if array x is equal to array y

More…

predicate '='(array [$T] of var int: x, array [$T] of var int: y)

Usage: x = y

Return if array x is equal to array y

More…

test '='(array [$T] of bool: x, array [$T] of bool: y)

Usage: x = y

Return if array x is equal to array y

More…

predicate '='(array [$T] of var bool: x, array [$T] of var bool: y)

Usage: x = y

Return if array x is equal to array y

More…

test '='(array [$T] of set of int: x, array [$T] of set of int: y)

Usage: x = y

Return if array x is equal to array y

More…

predicate '='(array [$T] of var set of int: x,
              array [$T] of var set of int: y)

Usage: x = y

Return if array x is equal to array y

More…

test '='(array [$T] of float: x, array [$T] of float: y)

Usage: x = y

Return if array x is equal to array y

More…

predicate '='(array [$T] of var float: x, array [$T] of var float: y)

Usage: x = y

Return if array x is equal to array y

More…

test '>'($T: x, $T: y)

Usage: x > y

Return if x is greater than y

predicate '>'(var $T: x, var $T: y)

Usage: x > y

Return if x is greater than y

predicate '>'(var opt int: x, var opt int: y)

Usage: x > y

Weak comparison: true iff either x or y is absent, or both occur and the value of x is greater than the value of y .

More…

test '>'(opt int: x, opt int: y)

Usage: x > y

Weak comparison: true iff either x or y is absent, or both occur and the value of x is greater than the value of y .

More…

test '>'(array [$U] of $T: x, array [$U] of $T: y)

Usage: x > y

Return if array x is lexicographically greater than array y

predicate '>'(array [$U] of var $T: x, array [$U] of var $T: y)

Usage: x > y

Return if array x is lexicographically greater than array y

test '>='($T: x, $T: y)

Usage: x >= y

Return if x is greater than or equal to y

predicate '>='(var $T: x, var $T: y)

Usage: x >= y

Return if x is greater than or equal to y

predicate '>='(var opt int: x, var opt int: y)

Usage: x >= y

Weak comparison: true iff either x or y is absent, or both occur and the value of x is greater than or equal to the value of y .

More…

test '>='(opt int: x, opt int: y)

Usage: x >= y

Weak comparison: true iff either x or y is absent, or both occur and the value of x is greater than or equal to the value of y .

More…

test '>='(array [$U] of $T: x, array [$U] of $T: y)

Usage: x >= y

Return if array x is lexicographically greater than or equal to array y

4.2.2.7. Arithmetic Builtins

These builtins implement arithmetic operations.
function int: '*'(int: x, int: y)

Usage: x * y

Return x * y

function var int: '*'(var int: x, var int: y)

Usage: x * y

Return x * y

function var int: '*'(var opt int: x, var opt int: y)

Usage: x * y

Optional multiplication. Return product of x and y , with absent replaced by 1.

More…

function int: '*'(opt int: x, opt int: y)

Usage: x * y

Optional multiplication. Return product of x and y , with absent replaced by 1.

More…

function var float: '*'(var opt float: x, var opt float: y)

Usage: x * y

Optional multiplication. Return product of x and y , with absent replaced by 1.

More…

function float: '*'(opt float: x, opt float: y)

Usage: x * y

Optional multiplication. Return product of x and y , with absent replaced by 1.

More…

function float: '*'(float: x, float: y)

Usage: x * y

Return x * y

function var float: '*'(var float: x, var float: y)

Usage: x * y

Return x * y

function int: '+'(int: x, int: y)

Usage: x + y

Return x + y

function var int: '+'(var int: x, var int: y)

Usage: x + y

Return x + y

function float: '+'(float: x, float: y)

Usage: x + y

Return x + y

function var float: '+'(var float: x, var float: y)

Usage: x + y

Return x + y

function var int: '+'(var opt int: x, var opt int: y)

Usage: x + y

Optional addition. Return sum of x and y , with absent replaced by 0.

More…

function int: '+'(opt int: x, opt int: y)

Usage: x + y

Optional addition. Return sum of x and y , with absent replaced by 0.

More…

function var float: '+'(var opt float: x, var opt float: y)

Usage: x + y

Optional addition. Return sum of x and y , with absent replaced by 0.

More…

function float: '+'(opt float: x, opt float: y)

Usage: x + y

Optional addition. Return sum of x and y , with absent replaced by 0.

More…

function int: '-'(int: x, int: y)

Usage: x - y

Return x - y

function var int: '-'(var int: x, var int: y)

Usage: x - y

Return x - y

function float: '-'(float: x, float: y)

Usage: x - y

Return x - y

function var float: '-'(var float: x, var float: y)

Usage: x - y

Return x - y

function var opt int: '-'(var opt int: x, var opt int: y)

Usage: x - y

Optional subtraction. Return absent if x is absent, x if y is absent, difference of x and y if both are present.

More…

function var opt float: '-'(var opt float: x, var opt float: y)

Usage: x - y

Optional subtraction. Return absent if x is absent, x if y is absent, difference of x and y if both are present.

More…

function opt int: '-'(opt int: x, opt int: y)

Usage: x - y

Optional subtraction. Return absent if x is absent, x if y is absent, difference of x and y if both are present.

More…

function opt float: '-'(opt float: x, opt float: y)

Usage: x - y

Optional subtraction. Return absent if x is absent, x if y is absent, difference of x and y if both are present.

More…

function int: '-'(int: x)

Usage: - x

Return negative x

function var int: '-'(var int: x)

Usage: - x

Return negative x

function float: '-'(float: x)

Usage: - x

Return negative x

function var float: '-'(var float: x)

Usage: - x

Return negative x

function float: '/'(float: x, float: y)

Usage: x / y

Return result of floating point division x / y

function var float: '/'(var float: x, var float: y)

Usage: x / y

Return result of floating point division x / y

More…

function var opt float: '/'(var opt float: x, var opt float: y)

Usage: x / y

Optional division. Return absent if x is absent, x if y is absent, x divided by y if both are present.

More…

function opt float: '/'(opt float: x, opt float: y)

Usage: x / y

Optional division. Return absent if x is absent, x if y is absent, x divided by y if both are present.

More…

predicate '<'(var opt float: x, var opt float: y)

Usage: x < y

Weak comparison: true iff either x or y is absent, or both occur and the value of x is less than the value of y .

More…

test '<'(opt float: x, opt float: y)

Usage: x < y

Weak comparison: true iff either x or y is absent, or both occur and the value of x is less than the value of y .

More…

predicate '<='(var opt float: x, var opt float: y)

Usage: x <= y

Weak comparison: true iff either x or y is absent, or both occur and the value of x is less than or equal to the value of y .

More…

test '<='(opt float: x, opt float: y)

Usage: x <= y

Weak comparison: true iff either x or y is absent, or both occur and the value of x is less than or equal to the value of y .

More…

predicate '>'(var opt float: x, var opt float: y)

Usage: x > y

Weak comparison: true iff either x or y is absent, or both occur and the value of x is greater than the value of y .

More…

test '>'(opt float: x, opt float: y)

Usage: x > y

Weak comparison: true iff either x or y is absent, or both occur and the value of x is greater than the value of y .

More…

predicate '>='(var opt float: x, var opt float: y)

Usage: x >= y

Weak comparison: true iff either x or y is absent, or both occur and the value of x is greater than or equal to the value of y .

More…

test '>='(opt float: x, opt float: y)

Usage: x >= y

Weak comparison: true iff either x or y is absent, or both occur and the value of x is greater than or equal to the value of y .

More…

function int: '^'(int: x, int: y)

Usage: x ^ y

Return \({\bf x} ^ {{\bf y}}\)

function var int: '^'(var int: x, var int: y)

Usage: x ^ y

Return \({\bf x} ^ {{\bf y}}\)

function float: '^'(float: x, float: y)

Usage: x ^ y

Return \({\bf x} ^ {{\bf y}}\)

function var float: '^'(var float: x, var float: y)

Usage: x ^ y

Return \({\bf x} ^ {{\bf y}}\)

function int: 'div'(int: x, int: y)

Usage: x div y

Return result of integer division x / y

function var int: 'div'(var int: x, var int: y)

Usage: x div y

Return result of integer division x / y

More…

function var opt int: 'div'(var opt int: x, var opt int: y)

Usage: x div y

Optional division. Return absent if x is absent, x if y is absent, x divided by y if both are present.

More…

function opt int: 'div'(opt int: x, opt int: y)

Usage: x div y

Optional division. Return absent if x is absent, x if y is absent, x divided by y if both are present.

More…

function int: 'mod'(int: x, int: y)

Usage: x mod y

Return remainder of integer division x % y

function var int: 'mod'(var int: x, var int: y)

Usage: x mod y

Return remainder of integer division x % y

More…

function var opt int: 'mod'(var opt int: x, var opt int: y)

Usage: x mod y

Optional modulo. Return absent if x or y is absent, x modulo y if both are present.

More…

function opt int: 'mod'(opt int: x, opt int: y)

Usage: x mod y

Optional modulo. Return absent if x or y is absent, x modulo y if both are present.

More…

function int: abs(int: x)

Return absolute value of x

function var int: abs(var int: x)

Return absolute value of x

More…

function float: abs(float: x)

Return absolute value of x

function var float: abs(var float: x)

Return absolute value of x

More…

function $$E: arg_max(array [$$E] of bool: x)

Returns the index of the maximum value in the array x . When breaking ties the least index is returned.

function $$E: arg_max(array [$$E] of int: x)

Returns the index of the maximum value in the array x . When breaking ties the least index is returned.

function $$E: arg_max(array [$$E] of float: x)

Returns the index of the maximum value in the array x . When breaking ties the least index is returned.

function $$E: arg_min(array [$$E] of bool: x)

Returns the index of the minimum value in the array x . When breaking ties the least index is returned.

function $$E: arg_min(array [$$E] of int: x)

Returns the index of the minimum value in the array x . When breaking ties the least index is returned.

function $$E: arg_min(array [$$E] of float: x)

Returns the index of the minimum value in the array x . When breaking ties the least index is returned.

function var opt float: bool2float(var opt bool: x)

Return optional 0/1 float that is absent iff x is absent, and 1 iff x occurs and is true.

More…

function int: count(array [$T] of bool: x)

Return number of true elments in array x

More…

function var int: count(array [$T] of var bool: x)

Return number of true elments in array x

More…

function var opt float: int2float(var opt int: x)

Return optional 0/1 integer that is absent iff x is absent, and 1 iff x occurs and is true.

More…

function $T: max($T: x, $T: y)

Return maximum of x and y

function $T: max(array [$U] of $T: x)

Return maximum of elements in array x

function var int: max(array [int] of var opt int: x)

Return maximum of elements in x that are not absent, or absent if all elements in x are absent.

More…

function $$E: max(set of $$E: x)

Return maximum of elements in set x

function var int: max(var int: x, var int: y)

Return maximum of x and y

More…

function var int: max(array [$U] of var int: x)

Return maximum of elements in array x

More…

function var float: max(array [int] of var opt float: x)

Return maximum of elements in x that are not absent.

More…

function var float: max(var float: x, var float: y)

Return maximum of x and y

More…

function var float: max(array [$U] of var float: x)

Return maximum of elements in array x

More…

function $T: min($T: x, $T: y)

Return minimum of x and y

function $T: min(array [$U] of $T: x)

Return minimum of elements in array x

function var int: min(array [int] of var opt int: x)

Return minimum of elements in x that are not absent.

More…

function var float: min(array [int] of var opt float: x)

Return minimum of elements in x that are not absent.

More…

function $$E: min(set of $$E: x)

Return minimum of elements in set x

function var int: min(var int: x, var int: y)

Return minimum of x and y

More…

function var int: min(array [$U] of var int: x)

Return minimum of elements in array x

More…

function var float: min(var float: x, var float: y)

Return minimum of x and y

More…

function var float: min(array [$U] of var float: x)

Return minimum of elements in array x

More…

function int: pow(int: x, int: y)

Return \({\bf x} ^ {{\bf y}}\)

function var int: pow(var int: x, var int: y)

Return \({\bf x} ^ {{\bf y}}\)

More…

function float: pow(float: x, float: y)

Return \({\bf x} ^ {{\bf y}}\)

function var float: pow(var float: x, var float: y)

Return \({\bf x} ^ {{\bf y}}\)

More…

function int: product(array [$T] of int: x)

Return product of elements in array x

function var int: product(array [$T] of var int: x)

Return product of elements in array x

More…

function var int: product(array [int] of var opt int: x)

Return product of non-absent elements of x .

More…

function int: product(array [int] of opt int: x)

Return product of non-absent elements of x .

More…

function float: product(array [$T] of float: x)

Return product of elements in array x

function var float: product(array [$T] of var float: x)

Return product of elements in array x

More…

function var float: product(array [int] of var opt float: x)

Return product of non-absent elements of x .

More…

function float: product(array [int] of opt float: x)

Return product of non-absent elements of x .

More…

function float: sqrt(float: x)

Return \(\sqrt{{\bf x}}\)

function var float: sqrt(var float: x)

Return \(\sqrt{{\bf x}}\)

More…

function int: sum(array [$T] of int: x)

Return sum of elements in array x

function var int: sum(array [$T] of var int: x)

Return sum of elements in array x

function float: sum(array [$T] of float: x)

Return sum of elements in array x

function var float: sum(array [$T] of var float: x)

Return sum of elements in array x

function var int: sum(array [int] of var opt int: x)

Return sum of non-absent elements of x .

More…

function int: sum(array [int] of opt int: x)

Return sum of non-absent elements of x .

More…

function var float: sum(array [int] of var opt float: x)

Return sum of non-absent elements of x .

More…

function float: sum(array [int] of opt float: x)

Return sum of non-absent elements of x .

More…

4.2.2.8. Exponential and logarithmic builtins

These builtins implement exponential and logarithmic functions.
function float: exp(float: x)

Return \(e ^ {{\bf x}}\)

function var float: exp(var float: x)

Return \(e ^ {{\bf x}}\)

More…

function float: ln(float: x)

Return \(\ln {\bf x}\)

function var float: ln(var float: x)

Return \(\ln {\bf x}\)

More…

function float: log(float: x, float: y)

Return \(\log_{{\bf x}} {\bf y}\)

function float: log10(float: x)

Return \(\log_{10} {\bf x}\)

function var float: log10(var float: x)

Return \(\log_{10} {\bf x}\)

More…

function float: log2(float: x)

Return \(\log_{2} {\bf x}\)

function var float: log2(var float: x)

Return \(\log_{2} {\bf x}\)

More…

4.2.2.9. Trigonometric functions

These builtins implement the standard trigonometric functions.
function float: acos(float: x)

Return \(\mbox{acos}\ {\bf x}\)

function var float: acos(var float: x)

Return \(\mbox{acos}\ {\bf x}\)

More…

function float: acosh(float: x)

Return \(\mbox{acosh}\ {\bf x}\)

function var float: acosh(var float: x)

Return \(\mbox{acosh}\ {\bf x}\)

More…

function float: asin(float: x)

Return \(\mbox{asin}\ {\bf x}\)

function var float: asin(var float: x)

Return \(\mbox{asin}\ {\bf x}\)

More…

function float: asinh(float: x)

Return \(\mbox{asinh}\ {\bf x}\)

function var float: asinh(var float: x)

Return \(\mbox{asinh}\ {\bf x}\)

More…

function float: atan(float: x)

Return \(\mbox{atan}\ {\bf x}\)

function var float: atan(var float: x)

Return \(\mbox{atan}\ {\bf x}\)

More…

function float: atanh(float: x)

Return \(\mbox{atanh}\ {\bf x}\)

function var float: atanh(var float: x)

Return \(\mbox{atanh}\ {\bf x}\)

More…

function float: cos(float: x)

Return \(\cos {\bf x}\)

function var float: cos(var float: x)

Return \(\cos {\bf x}\)

More…

function float: cosh(float: x)

Return \(\cosh {\bf x}\)

function var float: cosh(var float: x)

Return \(\cosh {\bf x}\)

More…

function float: sin(float: x)

Return \(\sin {\bf x}\)

function var float: sin(var float: x)

Return \(\sin {\bf x}\)

More…

function float: sinh(float: x)

Return \(\sinh {\bf x}\)

function var float: sinh(var float: x)

Return \(\sinh {\bf x}\)

More…

function float: tan(float: x)

Return \(\tan {\bf x}\)

function var float: tan(var float: x)

Return \(\tan {\bf x}\)

More…

function float: tanh(float: x)

Return \(\tanh {\bf x}\)

function var float: tanh(var float: x)

Return \(\tanh {\bf x}\)

More…

4.2.2.10. Logical operations

Logical operations are the standard operators of Boolean logic.
test '->'(bool: x, bool: y)

Usage: x -> y

Return truth value of x implies y

predicate '->'(var bool: x, var bool: y)

Usage: x -> y

Return truth value of x implies y

test '/\'(bool: x, bool: y)

Usage: x /\ y

Return truth value of x &and; y

test '/\'(opt bool: x, opt bool: y)

Usage: x /\ y

Return truth value of x &and; y with identity <> = True

More…

predicate '/\'(var bool: x, var bool: y)

Usage: x /\ y

Return truth value of x &and; y

predicate '/\'(var opt bool: x, var opt bool: y)

Usage: x /\ y

Return truth value of x &and; y with identity <> = True

More…

test '<-'(bool: x, bool: y)

Usage: x <- y

Return truth value of y implies x

predicate '<-'(var bool: x, var bool: y)

Usage: x <- y

Return truth value of y implies x

test '<->'(bool: x, bool: y)

Usage: x <-> y

Return truth value of x if-and-only-if y

predicate '<->'(var bool: x, var bool: y)

Usage: x <-> y

Return truth value of x if-and-only-if y

test '\/'(bool: x, bool: y)

Usage: x \/ y

Return truth value of x &or; y

test '\/'(opt bool: x, opt bool: y)

Usage: x \/ y

Return truth value of x &or; y with identity <> = False

More…

predicate '\/'(var bool: x, var bool: y)

Usage: x \/ y

Return truth value of x &or; y

predicate '\/'(var opt bool: x, var opt bool: y)

Usage: x \/ y

Return truth value of x &or; y with identity <> = False

More…

test 'not'(bool: x)

Usage: not x

Return truth value of the negation of x

function opt bool: 'not'(opt bool: x)

Usage: not x

Negation of x if it occurs, otherwise absent

More…

predicate 'not'(var bool: x)

Usage: not x

Return truth value of the negation of x

function var opt bool: 'not'(var opt bool: x)

Usage: not x

Negation of x if it occurs, otherwise absent

More…

test 'xor'(bool: x, bool: y)

Usage: x xor y

Return truth value of x xor y

predicate 'xor'(var bool: x, var bool: y)

Usage: x xor y

Return truth value of x xor y

predicate bool_not(var bool: b)

Return negation of b

predicate clause(array [$T] of var bool: x, array [$T] of var bool: y)

Return truth value of \((\bigvee_i {\bf x}[i]) \lor (\bigvee_j \lnot {\bf y}[j])\)

predicate clause(array [$T] of bool: x, array [$T] of bool: y)

Return truth value of \((\bigvee_i {\bf x}[i]) \lor (\bigvee_j \lnot {\bf y}[j])\)

test exists(array [$T] of bool: x)

Return truth value of \(\bigvee_i {\bf x}[i]\)

predicate exists(array [$T] of var bool: x)

Return truth value of \(\bigvee_i {\bf x}[i]\)

predicate exists(array [int] of var opt bool: x)

True iff for at least one i , x [i] occurs and is true

More…

test forall(array [$T] of bool: x)

Return truth value of \(\bigwedge_i {\bf x}[i]\)

predicate forall(array [$T] of var bool: x)

Return truth value of \(\bigwedge_i {\bf x}[i]\)

predicate forall(array [int] of var opt bool: x)

True iff for any i , x [i] is absent or true

More…

test iffall(array [$T] of bool: x)

Return truth value of \(\text{true}\oplus (\oplus_i {\bf x}[i])\)

predicate iffall(array [$T] of var bool: x)

Return truth value of \(\text{true}\oplus (\oplus_i {\bf x}[i])\)

More…

test xorall(array [$T] of bool: x)

Return truth value of \(\oplus_i {\bf x}[i]\)

predicate xorall(array [$T] of var bool: x)

Return truth value of \(\oplus_i {\bf x}[i]\)

More…

4.2.2.11. Set operations

These functions implement the basic operations on sets.
function set of $$E: '..'($$E: a, $$E: b)

Usage: a .. b

Return the set \(\{{\bf a},\ldots,{\bf b}\}\)

function set of float: '..'(float: a, float: b)

Usage: a .. b

Return the set \(\{{\bf a},\ldots,{\bf b}\}\)

function set of bool: '..'(bool: a, bool: b)

Usage: a .. b

Return the set \(\{{\bf a},\ldots,{\bf b}\}\)

More…

function set of $T: 'diff'(set of $T: x, set of $T: y)

Usage: x diff y

Return the set difference of sets \({\bf x} \setminus {\bf y}\)

function var set of $$T: 'diff'(var set of $$T: x, var set of $$T: y)

Usage: x diff y

Return the set difference of sets \({\bf x} \setminus {\bf y}\)

test 'in'(int: x, set of int: y)

Usage: x in y

Test if x is an element of the set y

predicate 'in'(var int: x, var set of int: y)

Usage: x in y

x is an element of the set y

test 'in'(float: x, set of float: y)

Usage: x in y

Test if x is an element of the set y

predicate 'in'(var float: x, set of float: y)

Usage: x in y

Test if x is an element of the set y

function set of $T: 'intersect'(set of $T: x, set of $T: y)

Usage: x intersect y

Return the intersection of sets x and y

function var set of $$T: 'intersect'(var set of $$T: x,
                                     var set of $$T: y)

Usage: x intersect y

Return the intersection of sets x and y

test 'subset'(set of $T: x, set of $T: y)

Usage: x subset y

Test if x is a subset of y

predicate 'subset'(var set of int: x, var set of int: y)

Usage: x subset y

x is a subset of y

test 'superset'(set of $T: x, set of $T: y)

Usage: x superset y

Test if x is a superset of y

predicate 'superset'(var set of int: x, var set of int: y)

Usage: x superset y

x is a superset of y

function set of $T: 'symdiff'(set of $T: x, set of $T: y)

Usage: x symdiff y

Return the symmetric set difference of sets x and y

function var set of $$T: 'symdiff'(var set of $$T: x,
                                   var set of $$T: y)

Usage: x symdiff y

Return the symmetric set difference of sets x and y

function set of $T: 'union'(set of $T: x, set of $T: y)

Usage: x union y

Return the union of sets x and y

function var set of $$T: 'union'(var set of $$T: x, var set of $$T: y)

Usage: x union y

Return the union of sets x and y

function set of $U: array_intersect(array [$T] of set of $U: x)

Return the intersection of the sets in array x

function var set of int: array_intersect(array [int] of var set of int: x)

Return the intersection of the sets in array x

More…

function set of $U: array_union(array [$T] of set of $U: x)

Return the union of the sets in array x

function var set of int: array_union(array [int] of var set of int: x)

Return the union of the sets in array x

More…

function int: card(set of $T: x)

Return the cardinality of the set x

function var int: card(var set of int: x)

Return the cardinality of the set x

More…

function var $$E: max(var set of $$E: s)

Return the maximum of the set s

function var $$E: min(var set of $$E: s)

Return the minimum of the set s

function array [int] of int: set_to_ranges(set of int: S)

Return a sorted list of the non-overlapping ranges in S

function array [int] of float: set_to_ranges(set of float: S)

Return a sorted list of the non-overlapping ranges in S

function array [int] of bool: set_to_ranges(set of bool: S)

Return a sorted list of the non-overlapping ranges in S

More…

4.2.2.12. Conditionals

These functions implement conditional (if-then-else-endif) constraints.
predicate if_then_else(array [int] of var bool: c,
                       array [int] of int: x,
                       var int: y)

Conditional constraint \(\{{\bf c}[i]\land\not\exists {\bf c}[1..i-1]\ \rightarrow\ y=x[i] \}\)

This constraint is generated by the compiler for if-then-else expressions. The last entry in the c array is always the constant true, corresponding to the else case.

More…

predicate if_then_else(array [int] of var bool: c,
                       array [int] of var int: x,
                       var int: y)

Conditional constraint \(\{{\bf c}[i]\land\not\exists {\bf c}[1..i-1]\ \rightarrow\ y=x[i] \}\)

This constraint is generated by the compiler for if-then-else expressions. The last entry in the c array is always the constant true, corresponding to the else case.

More…

predicate if_then_else(array [int] of var bool: c,
                       array [int] of opt int: x,
                       var opt int: y)

Conditional constraint \(\{{\bf c}[i]\land\not\exists {\bf c}[1..i-1]\ \rightarrow\ y=x[i] \}\)

This constraint is generated by the compiler for if-then-else expressions. The last entry in the c array is always the constant true, corresponding to the else case.

More…

predicate if_then_else(array [int] of var bool: c,
                       array [int] of var opt int: x,
                       var opt int: y)

Conditional constraint \(\{{\bf c}[i]\land\not\exists {\bf c}[1..i-1]\ \rightarrow\ y=x[i] \}\)

This constraint is generated by the compiler for if-then-else expressions. The last entry in the c array is always the constant true, corresponding to the else case.

More…

predicate if_then_else(array [int] of var bool: c,
                       array [int] of bool: x,
                       var bool: y)

Conditional constraint \(\{{\bf c}[i]\land\not\exists {\bf c}[1..i-1]\ \rightarrow\ y=x[i] \}\)

This constraint is generated by the compiler for if-then-else expressions. The last entry in the c array is always the constant true, corresponding to the else case.

More…

predicate if_then_else(array [int] of var bool: c,
                       array [int] of var bool: x,
                       var bool: y)

Conditional constraint \(\{{\bf c}[i]\land\not\exists {\bf c}[1..i-1]\ \rightarrow\ y=x[i] \}\)

This constraint is generated by the compiler for if-then-else expressions. The last entry in the c array is always the constant true, corresponding to the else case.

More…

predicate if_then_else(array [int] of var bool: c,
                       array [int] of opt bool: x,
                       var opt bool: y)

Conditional constraint \(\{{\bf c}[i]\land\not\exists {\bf c}[1..i-1]\ \rightarrow\ y=x[i] \}\)

This constraint is generated by the compiler for if-then-else expressions. The last entry in the c array is always the constant true, corresponding to the else case.

More…

predicate if_then_else(array [int] of var bool: c,
                       array [int] of var opt bool: x,
                       var opt bool: y)

Conditional constraint \(\{{\bf c}[i]\land\not\exists {\bf c}[1..i-1]\ \rightarrow\ y=x[i] \}\)

This constraint is generated by the compiler for if-then-else expressions. The last entry in the c array is always the constant true, corresponding to the else case.

More…

predicate if_then_else(array [int] of var bool: c,
                       array [int] of float: x,
                       var float: y)

Conditional constraint \(\{{\bf c}[i]\land\not\exists {\bf c}[1..i-1]\ \rightarrow\ y=x[i] \}\)

This constraint is generated by the compiler for if-then-else expressions. The last entry in the c array is always the constant true, corresponding to the else case.

More…

predicate if_then_else(array [int] of var bool: c,
                       array [int] of var float: x,
                       var float: y)

Conditional constraint \(\{{\bf c}[i]\land\not\exists {\bf c}[1..i-1]\ \rightarrow\ y=x[i] \}\)

This constraint is generated by the compiler for if-then-else expressions. The last entry in the c array is always the constant true, corresponding to the else case.

More…

predicate if_then_else(array [int] of var bool: c,
                       array [int] of opt float: x,
                       var opt float: y)

Conditional constraint \(\{{\bf c}[i]\land\not\exists {\bf c}[1..i-1]\ \rightarrow\ y=x[i] \}\)

This constraint is generated by the compiler for if-then-else expressions. The last entry in the c array is always the constant true, corresponding to the else case.

More…

predicate if_then_else(array [int] of var bool: c,
                       array [int] of set of int: x,
                       var set of int: y)

Conditional constraint \(\{{\bf c}[i]\land\not\exists {\bf c}[1..i-1]\ \rightarrow\ y=x[i] \}\)

This constraint is generated by the compiler for if-then-else expressions. The last entry in the c array is always the constant true, corresponding to the else case.

More…

predicate if_then_else(array [int] of var bool: c,
                       array [int] of var set of int: x,
                       var set of int: y)

Conditional constraint \(\{{\bf c}[i]\land\not\exists {\bf c}[1..i-1]\ \rightarrow\ y=x[i] \}\)

This constraint is generated by the compiler for if-then-else expressions. The last entry in the c array is always the constant true, corresponding to the else case.

More…

predicate if_then_else_partiality(array [int] of var bool: c,
                                  array [int] of var bool: d,
                                  var bool: b)

Conditional partiality constraint

This constraint is generated by the compiler for if-then-else expressions with potentially undefined cases. The last entry in the c array is always the constant true, corresponding to the else case. The d [i] variable represents whether case i is defined. Constrains that if b is defined, then the selected case must be defined, and if the selected case is undefined, then b must be undefined.

More…

4.2.2.13. Array operations

These functions implement the basic operations on arrays.

Parameters

annotation array_check_form

Forces a arrayNd call to throw an error if the new index sets are offsets of the current index sets.

Functions and Predicates

function array [int] of $T: '++'(array [int] of $T: x,
                                 array [int] of $T: y)

Usage: x ++ y

Return the concatenation of arrays x and y

function array [int] of opt $T: '++'(array [int] of opt $T: x,
                                     array [int] of opt $T: y)

Usage: x ++ y

Return the concatenation of arrays x and y

function array [int] of var $T: '++'(array [int] of var $T: x,
                                     array [int] of var $T: y)

Usage: x ++ y

Return the concatenation of arrays x and y

function array [int] of var opt $T: '++'(array [int] of var opt $T: x,
                                         array [int] of var opt $T: y)

Usage: x ++ y

Return the concatenation of arrays x and y

function array [int] of $V: array1d(array [$U] of $V: x)

Return array x coerced to index set 1..length( x ). Coercions are performed by considering the array x in row-major order.

function array [int] of opt $V: array1d(array [$U] of opt $V: x)

Return array x coerced to index set 1..length( x ). Coercions are performed by considering the array x in row-major order.

function array [int] of var $V: array1d(array [$U] of var $V: x)

Return array x coerced to index set 1..length( x ). Coercions are performed by considering the array x in row-major order.

function array [int] of var opt $V: array1d(array [$U] of var opt $V: x)

Return array x coerced to index set 1..length( x ). Coercions are performed by considering the array x in row-major order.

function array [$$E] of $V: array1d(set of $$E: S, array [$U] of $V: x)

Return array x coerced to one-dimensional array with index set S . Coercions are performed by considering the array x in row-major order.

function array [$$E] of opt $V: array1d(set of $$E: S,
                                        array [$U] of opt $V: x)

Return array x coerced to one-dimensional array with index set S . Coercions are performed by considering the array x in row-major order.

function array [$$E] of var $V: array1d(set of $$E: S,
                                        array [$U] of var $V: x)

Return array x coerced to one-dimensional array with index set S . Coercions are performed by considering the array x in row-major order.

function array [$$E] of var opt $V: array1d(set of $$E: S,
                                            array [$U] of var opt $V: x)

Return array x coerced to one-dimensional array with index set S . Coercions are performed by considering the array x in row-major order.

function array [$$E,$$F] of $V: array2d(set of $$E: S1,
                                        set of $$F: S2,
                                        array [$U] of $V: x)

Return array x coerced to two-dimensional array with index sets S1 and S2 . Coercions are performed by considering the array x in row-major order.

function array [$$E,$$F] of opt $V: array2d(set of $$E: S1,
                                            set of $$F: S2,
                                            array [$U] of opt $V: x)

Return array x coerced to two-dimensional array with index sets S1 and S2 . Coercions are performed by considering the array x in row-major order.

function array [$$E,$$F] of var $V: array2d(set of $$E: S1,
                                            set of $$F: S2,
                                            array [$U] of var $V: x)

Return array x coerced to two-dimensional array with index sets S1 and S2 . Coercions are performed by considering the array x in row-major order.

function array [$$E,$$F] of var opt $V: array2d(set of $$E: S1,
                                                set of $$F: S2,
                                                array [$U] of var opt $V: x)

Return array x coerced to two-dimensional array with index sets S1 and S2 . Coercions are performed by considering the array x in row-major order.

function var set of $$T: array2set(array [int] of var $$T: x)

Return the set containing the elements of x

More…

function set of $$T: array2set(array [int] of $$T: x)

Return the set containing the elements of x

More…

function set of $$T: array2set(array [int] of opt $$T: x)

Return the set containing the elements of x

More…

function set of bool: array2set(array [int] of bool: x)

Return the set containing the elements of x

More…

function set of float: array2set(array [int] of float: x)

Return the set containing the elements of x

More…

function array [$$E,$$F,$$G] of $V: array3d(set of $$E: S1,
                                            set of $$F: S2,
                                            set of $$G: S3,
                                            array [$U] of $V: x)

Return array x coerced to three-dimensional array with index sets S1 , S2 and S3 . Coercions are performed by considering the array x in row-major order.

function array [$$E,$$F,$$G] of opt $V: array3d(set of $$E: S1,
                                                set of $$F: S2,
                                                set of $$G: S3,
                                                array [$U] of opt $V: x)

Return array x coerced to three-dimensional array with index sets S1 , S2 and S3 . Coercions are performed by considering the array x in row-major order.

function array [$$E,$$F,$$G] of var $V: array3d(set of $$E: S1,
                                                set of $$F: S2,
                                                set of $$G: S3,
                                                array [$U] of var $V: x)

Return array x coerced to three-dimensional array with index sets S1 , S2 and S3 . Coercions are performed by considering the array x in row-major order.

function array [$$E,$$F,$$G] of var opt $V: array3d(set of $$E: S1,
                                                    set of $$F: S2,
                                                    set of $$G: S3,
                                                    array [$U] of var opt $V: x)

Return array x coerced to three-dimensional array with index sets S1 , S2 and S3 . Coercions are performed by considering the array x in row-major order.

function array [$$E,$$F,$$G,$$H] of $V: array4d(set of $$E: S1,
                                                set of $$F: S2,
                                                set of $$G: S3,
                                                set of $$H: S4,
                                                array [$U] of $V: x)

Return array x coerced to 4-dimensional array with index sets S1 , S2 , S3 and S4 . Coercions are performed by considering the array x in row-major order.

function array [$$E,$$F,$$G,$$H] of opt $V: array4d(set of $$E: S1,
                                                    set of $$F: S2,
                                                    set of $$G: S3,
                                                    set of $$H: S4,
                                                    array [$U] of opt $V: x)

Return array x coerced to 4-dimensional array with index sets S1 , S2 , S3 and S4 . Coercions are performed by considering the array x in row-major order.

function array [$$E,$$F,$$G,$$H] of var $V: array4d(set of $$E: S1,
                                                    set of $$F: S2,
                                                    set of $$G: S3,
                                                    set of $$H: S4,
                                                    array [$U] of var $V: x)

Return array x coerced to 4-dimensional array with index sets S1 , S2 , S3 and S4 . Coercions are performed by considering the array x in row-major order.

function array [$$E,$$F,$$G,$$H] of var opt $V: array4d(set of $$E: S1,
                                                        set of $$F: S2,
                                                        set of $$G: S3,
                                                        set of $$H: S4,
                                                        array [$U] of var opt $V: x)

Return array x coerced to 4-dimensional array with index sets S1 , S2 , S3 and S4 . Coercions are performed by considering the array x in row-major order.

function array [$$E,$$F,$$G,$$H,$$I] of $V: array5d(set of $$E: S1,
                                                    set of $$F: S2,
                                                    set of $$G: S3,
                                                    set of $$H: S4,
                                                    set of $$I: S5,
                                                    array [$U] of $V: x)

Return array x coerced to 5-dimensional array with index sets S1 , S2 , S3 , S4 and S5 . Coercions are performed by considering the array x in row-major order.

function array [$$E,$$F,$$G,$$H,$$I] of opt $V: array5d(set of $$E: S1,
                                                        set of $$F: S2,
                                                        set of $$G: S3,
                                                        set of $$H: S4,
                                                        set of $$I: S5,
                                                        array [$U] of opt $V: x)

Return array x coerced to 5-dimensional array with index sets S1 , S2 , S3 , S4 and S5 . Coercions are performed by considering the array x in row-major order.

function array [$$E,$$F,$$G,$$H,$$I] of var $V: array5d(set of $$E: S1,
                                                        set of $$F: S2,
                                                        set of $$G: S3,
                                                        set of $$H: S4,
                                                        set of $$I: S5,
                                                        array [$U] of var $V: x)

Return array x coerced to 5-dimensional array with index sets S1 , S2 , S3 , S4 and S5 . Coercions are performed by considering the array x in row-major order.

function array [$$E,$$F,$$G,$$H,$$I] of var opt $V: array5d(set of $$E: S1,
                                                            set of $$F: S2,
                                                            set of $$G: S3,
                                                            set of $$H: S4,
                                                            set of $$I: S5,
                                                            array [$U] of var opt $V: x)

Return array x coerced to 5-dimensional array with index sets S1 , S2 , S3 , S4 and S5 . Coercions are performed by considering the array x in row-major order.

function array [$$E,$$F,$$G,$$H,$$I,$$J] of $V: array6d(set of $$E: S1,
                                                        set of $$F: S2,
                                                        set of $$G: S3,
                                                        set of $$H: S4,
                                                        set of $$I: S5,
                                                        set of $$J: S6,
                                                        array [$U] of $V: x)

Return array x coerced to 6-dimensional array with index sets S1 , S2 , S3 , S4 , S5 and S6 . Coercions are performed by considering the array x in row-major order.

function array [$$E,$$F,$$G,$$H,$$I,$$J] of opt $V: array6d(set of $$E: S1,
                                                            set of $$F: S2,
                                                            set of $$G: S3,
                                                            set of $$H: S4,
                                                            set of $$I: S5,
                                                            set of $$J: S6,
                                                            array [$U] of opt $V: x)

Return array x coerced to 6-dimensional array with index sets S1 , S2 , S3 , S4 , S5 and S6 . Coercions are performed by considering the array x in row-major order.

function array [$$E,$$F,$$G,$$H,$$I,$$J] of var $V: array6d(set of $$E: S1,
                                                            set of $$F: S2,
                                                            set of $$G: S3,
                                                            set of $$H: S4,
                                                            set of $$I: S5,
                                                            set of $$J: S6,
                                                            array [$U] of var $V: x)

Return array x coerced to 6-dimensional array with index sets S1 , S2 , S3 , S4 , S5 and S6 . Coercions are performed by considering the array x in row-major order.

function array [$$E,$$F,$$G,$$H,$$I,$$J] of var opt $V: array6d(set of $$E: S1,
                                                                set of $$F: S2,
                                                                set of $$G: S3,
                                                                set of $$H: S4,
                                                                set of $$I: S5,
                                                                set of $$J: S6,
                                                                array [$U] of var opt $V: x)

Return array x coerced to 6-dimensional array with index sets S1 , S2 , S3 , S4 , S5 and S6 . Coercions are performed by considering the array x in row-major order.

function array [$T] of $V: arrayXd(array [$T] of var opt $X: x,
                                   array [$U] of $V: y)

Return array y coerced to array with same number of dimensions and same index sets as array x . Coercions are performed by considering the array y in row-major order.

function array [$T] of opt $V: arrayXd(array [$T] of var opt $X: x,
                                       array [$U] of opt $V: y)

Return array y coerced to array with same number of dimensions and same index sets as array x . Coercions are performed by considering the array y in row-major order.

function array [$T] of var $V: arrayXd(array [$T] of var opt $X: x,
                                       array [$U] of var $V: y)

Return array y coerced to array with same number of dimensions and same index sets as array x . Coercions are performed by considering the array y in row-major order.

function array [$T] of var opt $V: arrayXd(array [$T] of var opt $X: x,
                                           array [$U] of var opt $V: y)

Return array y coerced to array with same number of dimensions and same index sets as array x . Coercions are performed by considering the array y in row-major order.

function array [$$E] of $T: col(array [$$E,int] of $T: x, int: c)

Return column c of array x

More…

function array [$$E] of opt $T: col(array [$$E,int] of opt $T: x,
                                    int: c)

Return column c of array x

More…

function array [$$E] of var $T: col(array [$$E,int] of var $T: x,
                                    int: c)

Return column c of array x

More…

function array [$$E] of var opt $T: col(array [$$E,int] of var opt $T: x,
                                        int: c)

Return column c of array x

More…

test has_element($T: e, array [int] of $T: x)

Test if e is an element of array x

More…

test has_element($T: e, array [int] of opt $T: x)

Test if e is an element of array x

More…

predicate has_element($T: e, array [$$E] of var opt $T: x)

Test if e is an element of array x

More…

test has_index(int: i, array [int] of var opt $T: x)

Test if i is in the index set of x

More…

function set of $$E: index_set(array [$$E] of var opt $U: x)

Return index set of one-dimensional array x

function set of $$E: index_set_1of2(array [$$E,int] of var opt $U: x)

Return index set of first dimension of two-dimensional array x

function set of $$E: index_set_1of3(array [$$E,int,int] of var opt $U: x)

Return index set of first dimension of 3-dimensional array x

function set of $$E: index_set_1of4(array [$$E,int,int,int] of var opt $U: x)

Return index set of first dimension of 4-dimensional array x

function set of $$E: index_set_1of5(array [$$E,int,int,int,int] of var opt $U: x)

Return index set of first dimension of 5-dimensional array x

function set of $$E: index_set_1of6(array [$$E,int,int,int,int,int] of var opt $U: x)

Return index set of first dimension of 6-dimensional array x

function set of $$E: index_set_2of2(array [int,$$E] of var opt $U: x)

Return index set of second dimension of two-dimensional array x

function set of $$E: index_set_2of3(array [int,$$E,int] of var opt $U: x)

Return index set of second dimension of 3-dimensional array x

function set of $$E: index_set_2of4(array [int,$$E,int,int] of var opt $U: x)

Return index set of second dimension of 4-dimensional array x

function set of $$E: index_set_2of5(array [int,$$E,int,int,int] of var opt $U: x)

Return index set of second dimension of 5-dimensional array x

function set of $$E: index_set_2of6(array [int,$$E,int,int,int,int] of var opt $U: x)

Return index set of second dimension of 6-dimensional array x

function set of $$E: index_set_3of3(array [int,int,$$E] of var opt $U: x)

Return index set of third dimension of 3-dimensional array x

function set of $$E: index_set_3of4(array [int,int,$$E,int] of var opt $U: x)

Return index set of third dimension of 4-dimensional array x

function set of $$E: index_set_3of5(array [int,int,$$E,int,int] of var opt $U: x)

Return index set of third dimension of 5-dimensional array x

function set of $$E: index_set_3of6(array [int,int,$$E,int,int,int] of var opt $U: x)

Return index set of third dimension of 6-dimensional array x

function set of $$E: index_set_4of4(array [int,int,int,$$E] of var opt $U: x)

Return index set of fourth dimension of 4-dimensional array x

function set of $$E: index_set_4of5(array [int,int,int,$$E,int] of var opt $U: x)

Return index set of fourth dimension of 5-dimensional array x

function set of $$E: index_set_4of6(array [int,int,int,$$E,int,int] of var opt $U: x)

Return index set of fourth dimension of 6-dimensional array x

function set of $$E: index_set_5of5(array [int,int,int,int,$$E] of var opt $U: x)

Return index set of fifth dimension of 5-dimensional array x

function set of $$E: index_set_5of6(array [int,int,int,int,$$E,int] of var opt $U: x)

Return index set of fifth dimension of 6-dimensional array x

function set of $$E: index_set_6of6(array [int,int,int,int,int,$$E] of var opt $U: x)

Return index set of sixth dimension of 6-dimensional array x

test index_sets_agree(array [$T] of var opt $U: x,
                      array [$T] of var opt $W: y)

Test if x and y have the same index sets

function int: length(array [$T] of var opt $U: x)

Return the length of array x

Note that the length is defined as the number of elements in the array, regardless of its dimensionality.

function array [$$E] of $T: reverse(array [$$E] of $T: x)

Return the array x in reverse order

The resulting array has the same index set as x .

More…

function array [$$E] of opt $T: reverse(array [$$E] of opt $T: x)

Return the array x in reverse order

The resulting array has the same index set as x .

More…

function array [$$E] of var $T: reverse(array [$$E] of var $T: x)

Return the array x in reverse order

The resulting array has the same index set as x .

More…

function array [$$E] of var opt $T: reverse(array [$$E] of var opt $T: x)

Return the array x in reverse order

The resulting array has the same index set as x .

More…

function array [$$E] of $T: row(array [int,$$E] of $T: x, int: r)

Return row r of array x

More…

function array [$$E] of opt $T: row(array [int,$$E] of opt $T: x,
                                    int: r)

Return row r of array x

More…

function array [$$E] of var $T: row(array [int,$$E] of var $T: x,
                                    int: r)

Return row r of array x

More…

function array [$$E] of var opt $T: row(array [int,$$E] of var opt $T: x,
                                        int: r)

Return row r of array x

More…

function array [int] of $T: slice_1d(array [$E] of $T: x,
                                     array [int] of set of int: s,
                                     set of int: dims1)

Return slice of array x specified by sets s , coerced to new 1d array with index set dims1

function array [int] of opt $T: slice_1d(array [$E] of opt $T: x,
                                         array [int] of set of int: s,
                                         set of int: dims1)

Return slice of array x specified by sets s , coerced to new 1d array with index set dims1

function array [int] of var $T: slice_1d(array [$E] of var $T: x,
                                         array [int] of set of int: s,
                                         set of int: dims1)

Return slice of array x specified by sets s , coerced to new 1d array with index set dims1

function array [int] of var opt $T: slice_1d(array [$E] of var opt $T: x,
                                             array [int] of set of int: s,
                                             set of int: dims1)

Return slice of array x specified by sets s , coerced to new 1d array with index set dims1

function array [int,int] of $T: slice_2d(array [$E] of $T: x,
                                         array [int] of set of int: s,
                                         set of int: dims1,
                                         set of int: dims2)

Return slice of array x specified by sets s , coerced to new 2d array with index sets dims1 and dims2

function array [int,int] of opt $T: slice_2d(array [$E] of opt $T: x,
                                             array [int] of set of int: s,
                                             set of int: dims1,
                                             set of int: dims2)

Return slice of array x specified by sets s , coerced to new 2d array with index sets dims1 and dims2

function array [int,int] of var $T: slice_2d(array [$E] of var $T: x,
                                             array [int] of set of int: s,
                                             set of int: dims1,
                                             set of int: dims2)

Return slice of array x specified by sets s , coerced to new 2d array with index sets dims1 and dims2

function array [int,int] of var opt $T: slice_2d(array [$E] of var opt $T: x,
                                                 array [int] of set of int: s,
                                                 set of int: dims1,
                                                 set of int: dims2)

Return slice of array x specified by sets s , coerced to new 2d array with index sets dims1 and dims2

function array [int,int,int] of $T: slice_3d(array [$E] of $T: x,
                                             array [int] of set of int: s,
                                             set of int: dims1,
                                             set of int: dims2,
                                             set of int: dims3)

Return slice of array x specified by sets s , coerced to new 3d array with index sets dims1 , dims2 and dims3

function array [int,int,int] of opt $T: slice_3d(array [$E] of opt $T: x,
                                                 array [int] of set of int: s,
                                                 set of int: dims1,
                                                 set of int: dims2,
                                                 set of int: dims3)

Return slice of array x specified by sets s , coerced to new 3d array with index sets dims1 , dims2 and dims3

function array [int,int,int] of var $T: slice_3d(array [$E] of var $T: x,
                                                 array [int] of set of int: s,
                                                 set of int: dims1,
                                                 set of int: dims2,
                                                 set of int: dims3)

Return slice of array x specified by sets s , coerced to new 3d array with index sets dims1 , dims2 and dims3

function array [int,int,int] of var opt $T: slice_3d(array [$E] of var opt $T: x,
                                                     array [int] of set of int: s,
                                                     set of int: dims1,
                                                     set of int: dims2,
                                                     set of int: dims3)

Return slice of array x specified by sets s , coerced to new 3d array with index sets dims1 , dims2 and dims3

function array [int,int,int] of $T: slice_4d(array [$E] of $T: x,
                                             array [int] of set of int: s,
                                             set of int: dims1,
                                             set of int: dims2,
                                             set of int: dims3,
                                             set of int: dims4)

Return slice of array x specified by sets s , coerced to new 3d array with index sets dims1 , dims2 , dims3 , dims4

function array [int,int,int] of opt $T: slice_4d(array [$E] of opt $T: x,
                                                 array [int] of set of int: s,
                                                 set of int: dims1,
                                                 set of int: dims2,
                                                 set of int: dims3,
                                                 set of int: dims4)

Return slice of array x specified by sets s , coerced to new 3d array with index sets dims1 , dims2 , dims3 , dims4

function array [int,int,int] of var $T: slice_4d(array [$E] of var $T: x,
                                                 array [int] of set of int: s,
                                                 set of int: dims1,
                                                 set of int: dims2,
                                                 set of int: dims3,
                                                 set of int: dims4)

Return slice of array x specified by sets s , coerced to new 3d array with index sets dims1 , dims2 , dims3 , dims4

function array [int,int,int] of var opt $T: slice_4d(array [$E] of var opt $T: x,
                                                     array [int] of set of int: s,
                                                     set of int: dims1,
                                                     set of int: dims2,
                                                     set of int: dims3,
                                                     set of int: dims4)

Return slice of array x specified by sets s , coerced to new 3d array with index sets dims1 , dims2 , dims3 , dims4

function array [int,int,int] of $T: slice_5d(array [$E] of $T: x,
                                             array [int] of set of int: s,
                                             set of int: dims1,
                                             set of int: dims2,
                                             set of int: dims3,
                                             set of int: dims4,
                                             set of int: dims5)

Return slice of array x specified by sets s , coerced to new 3d array with index sets dims1 , dims2 , dims3 , dims4 , dims5

function array [int,int,int] of opt $T: slice_5d(array [$E] of opt $T: x,
                                                 array [int] of set of int: s,
                                                 set of int: dims1,
                                                 set of int: dims2,
                                                 set of int: dims3,
                                                 set of int: dims4,
                                                 set of int: dims5)

Return slice of array x specified by sets s , coerced to new 3d array with index sets dims1 , dims2 , dims3 , dims4 , dims5

function array [int,int,int] of var $T: slice_5d(array [$E] of var $T: x,
                                                 array [int] of set of int: s,
                                                 set of int: dims1,
                                                 set of int: dims2,
                                                 set of int: dims3,
                                                 set of int: dims4,
                                                 set of int: dims5)

Return slice of array x specified by sets s , coerced to new 3d array with index sets dims1 , dims2 , dims3 , dims4 , dims5

function array [int,int,int] of var opt $T: slice_5d(array [$E] of var opt $T: x,
                                                     array [int] of set of int: s,
                                                     set of int: dims1,
                                                     set of int: dims2,
                                                     set of int: dims3,
                                                     set of int: dims4,
                                                     set of int: dims5)

Return slice of array x specified by sets s , coerced to new 3d array with index sets dims1 , dims2 , dims3 , dims4 , dims5

function array [int,int,int] of $T: slice_6d(array [$E] of $T: x,
                                             array [int] of set of int: s,
                                             set of int: dims1,
                                             set of int: dims2,
                                             set of int: dims3,
                                             set of int: dims4,
                                             set of int: dims5,
                                             set of int: dims6)

Return slice of array x specified by sets s , coerced to new 3d array with index sets dims1 , dims2 , dims3 , dims4 , dims5 , dims6

function array [int,int,int] of opt $T: slice_6d(array [$E] of opt $T: x,
                                                 array [int] of set of int: s,
                                                 set of int: dims1,
                                                 set of int: dims2,
                                                 set of int: dims3,
                                                 set of int: dims4,
                                                 set of int: dims5,
                                                 set of int: dims6)

Return slice of array x specified by sets s , coerced to new 3d array with index sets dims1 , dims2 , dims3 , dims4 , dims5 , dims6

function array [int,int,int] of var $T: slice_6d(array [$E] of var $T: x,
                                                 array [int] of set of int: s,
                                                 set of int: dims1,
                                                 set of int: dims2,
                                                 set of int: dims3,
                                                 set of int: dims4,
                                                 set of int: dims5,
                                                 set of int: dims6)

Return slice of array x specified by sets s , coerced to new 3d array with index sets dims1 , dims2 , dims3 , dims4 , dims5 , dims6

function array [int,int,int] of var opt $T: slice_6d(array [$E] of var opt $T: x,
                                                     array [int] of set of int: s,
                                                     set of int: dims1,
                                                     set of int: dims2,
                                                     set of int: dims3,
                                                     set of int: dims4,
                                                     set of int: dims5,
                                                     set of int: dims6)

Return slice of array x specified by sets s , coerced to new 3d array with index sets dims1 , dims2 , dims3 , dims4 , dims5 , dims6

4.2.2.14. Array sorting operations

function array [int] of $$E: arg_sort(array [$$E] of int: x)

Returns the permutation p which causes x to be in sorted order hence x [ p [ i ]] <= x [ p [ i +1]].

The permutation is the stable sort hence x [ p [ i ]] = x [ p [ i +1]] \(\rightarrow\) p [ i ] < p [ i +1].

More…

function array [int] of $$E: arg_sort(array [$$E] of float: x)

Returns the permutation p which causes x to be in sorted order hence x [ p [ i ]] <= x [ p [ i +1]].

The permutation is the stable sort hence x [ p [ i ]] = x [ p [ i +1]] \(\rightarrow\) p [ i ] < p [ i +1].

More…

function array [$$E] of int: sort(array [$$E] of int: x)

Return values from array x sorted in non-decreasing order

function array [$$E] of float: sort(array [$$E] of float: x)

Return values from array x sorted in non-decreasing order

function array [$$E] of bool: sort(array [$$E] of bool: x)

Return values from array x sorted in non-decreasing order

function array [$$E] of var opt $T: sort_by(array [$$E] of var opt $T: x,
                                            array [$$E] of int: y)

Return array x sorted by the values in y in non-decreasing order

The sort is stable, i.e. if y [ i ] = y [ j ] with i < j , then x [ i ] will appear in the output before x [ j ].

function array [$$E] of var $T: sort_by(array [$$E] of var $T: x,
                                        array [$$E] of int: y)

Return array x sorted by the values in y in non-decreasing order

The sort is stable, i.e. if y [ i ] = y [ j ] with i < j , then x [ i ] will appear in the output before x [ j ].

function array [$$E] of $T: sort_by(array [$$E] of $T: x,
                                    array [$$E] of int: y)

Return array x sorted by the values in y in non-decreasing order

The sort is stable, i.e. if y [ i ] = y [ j ] with i < j , then x [ i ] will appear in the output before x [ j ].

function array [$$E] of var opt $T: sort_by(array [$$E] of var opt $T: x,
                                            array [$$E] of float: y)

Return array x sorted by the values in y in non-decreasing order

The sort is stable, i.e. if y [ i ] = y [ j ] with i < j , then x [ i ] will appear in the output before x [ j ].

function array [$$E] of var $T: sort_by(array [$$E] of var $T: x,
                                        array [$$E] of float: y)

Return array x sorted by the values in y in non-decreasing order

The sort is stable, i.e. if y [ i ] = y [ j ] with i < j , then x [ i ] will appear in the output before x [ j ].

function array [$$E] of $T: sort_by(array [$$E] of $T: x,
                                    array [$$E] of float: y)

Return array x sorted by the values in y in non-decreasing order

The sort is stable, i.e. if y [ i ] = y [ j ] with i < j , then x [ i ] will appear in the output before x [ j ].

4.2.2.15. Coercions

These functions implement coercions, or channeling, between different types.
function float: bool2float(bool: b)

Return Boolean b coerced to a float

More…

function opt float: bool2float(opt bool: b)

Return Boolean b coerced to a float

More…

function array [$T] of float: bool2float(array [$T] of bool: x)

Return array of Booleans x coerced to an array of floats

More…

function array [$T] of var float: bool2float(array [$T] of var bool: x)

Return array of Booleans x coerced to an array of floats

More…

function var float: bool2float(var bool: b)

Return Boolean b coerced to a float

More…

function array [$T] of opt float: bool2float(array [$T] of opt bool: x)

Return array of Booleans x coerced to an array of floats

More…

function array [$T] of var opt float: bool2float(array [$T] of var opt bool: x)

Return array of Booleans x coerced to an array of floats

More…

function int: bool2int(bool: b)

Return Boolean b coerced to an integer

function opt int: bool2int(opt bool: b)

Return Boolean b coerced to an integer

More…

function var opt int: bool2int(var opt bool: x)

Return optional 0/1 integer that is absent iff x is absent, and 1 iff x occurs and is true.

More…

function var int: bool2int(var bool: b)

Return Boolean b coerced to an integer

function array [$T] of var int: bool2int(array [$T] of var bool: b)

Return array of Booleans b coerced to an array of integers

function array [$T] of int: bool2int(array [$T] of bool: x)

Return array of Booleans x coerced to an array of integers

More…

function array [$T] of set of int: bool2int(array [$T] of set of bool: x)

Return array of sets of Booleans x coerced to an array of sets of integers

More…

function array [$T] of var int: bool2int(array [$T] of var bool: x)

Return array of Booleans x coerced to an array of integers

More…

function array [$T] of opt int: bool2int(array [$T] of opt bool: x)

Return array of Booleans x coerced to an array of integers

More…

function array [$T] of var opt int: bool2int(array [$T] of var opt bool: x)

Return array of Booleans x coerced to an array of integers

More…

function int: ceil(float: x)

Return \(\lceil{ {\bf x}} \rceil\)

function int: floor(float: x)

Return \(\lfloor{ {\bf x}} \rfloor\)

function float: int2float(int: x)

Return integer x coerced to a float

function opt float: int2float(opt int: x)

Return integer x coerced to a float

More…

function var float: int2float(var int: x)

Return integer x coerced to a float

function array [$T] of float: int2float(array [$T] of int: x)

Return array of integers x coerced to an array of floats

More…

function array [$T] of opt float: int2float(array [$T] of opt int: x)

Return array of integers x coerced to an array of floats

More…

function array [$T] of var float: int2float(array [$T] of var int: x)

Return array of integers x coerced to an array of floats

More…

function array [$T] of var opt float: int2float(array [$T] of var opt int: x)

Return array of optional integers x coerced to an array of optional floats

More…

function int: round(float: x)

Return x rounded to nearest integer

function array [int] of $$E: set2array(set of $$E: x)

Return a set of integers x coerced to an array of integers

4.2.2.16. String operations

These functions implement operations on strings.
function string: '++'(string: s1, string: s2)

Usage: s1 ++ s2

Return concatenation of s1 and s2

function string: concat(array [$T] of string: s)

Return concatenation of strings in array s

function string: file_path()

Return path of file where this function is called

function string: format(var opt $T: x)

Convert x into a string

function string: format(var opt set of $T: x)

Convert x into a string

function string: format(array [$U] of var opt $T: x)

Convert x into a string

function string: format(int: w, int: p, var opt $T: x)

Formatted to-string conversion

Converts the value x into a string right justified by the number of characters given by w , or left justified if w is negative.

The maximum length of the string representation of x is given by p , or the maximum number of digits after the decimal point for floating point numbers. It is a run-time error for p to be negative.

function string: format(int: w, int: p, var opt set of $T: x)

Formatted to-string conversion

Converts the value x into a string right justified by the number of characters given by w , or left justified if w is negative.

The maximum length of the string representation of x is given by p . It is a run-time error for p to be negative.

function string: format(int: w, int: p, array [$U] of var opt $T: x)

Formatted to-string conversion

Converts the value x into a string right justified by the number of characters given by w , or left justified if w is negative.

The maximum length of the string representation of x is given by p . It is a run-time error for p to be negative.

function string: format(int: w, var opt $T: x)

Formatted to-string conversion

Converts the value x into a string right justified by the number of characters given by w , or left justified if w is negative.

function string: format(int: w, var opt set of $T: x)

Formatted to-string conversion

Converts the value x into a string right justified by the number of characters given by w , or left justified if w is negative.

function string: format(int: w, array [$U] of var opt $T: x)

Formatted to-string conversion

Converts the value x into a string right justified by the number of characters given by w , or left justified if w is negative.

function string: format_justify_string(int: w, string: x)

String justification

Returns the string x right justified by the number of characters given by w , or left justified if w is negative.

function string: join(string: d, array [$T] of string: s)

Join string in array s using delimiter d

function array [int] of string: outputJSON()

Return array for output of all variables in JSON format

function array [int] of string: outputJSON(bool: b)

Return array for output of all variables in JSON format, including objective if b is true

function array [int] of string: outputJSONParameters()

Return array for output of all parameters in JSON format

function string: show(var opt set of $T: x)

Convert x into a string

function string: show(var opt $T: x)

Convert x into a string

function string: show(array [$U] of var opt $T: x)

Convert x into a string

function string: show2d(array [int,int] of var opt $T: x)

Convert two-dimensional array x into a string

More…

function string: show3d(array [int,int,int] of var opt $T: x)

Convert three-dimensional array x into a string

More…

function string: showJSON(var opt $T: x)

Convert x into JSON string

function string: showJSON(array [$U] of var opt $T: x)

Convert x into JSON string

function string: show_float(int: w, int: p, var float: x)

Formatted to-string conversion for floats.

Converts the float x into a string right justified by the number of characters given by w , or left justified if w is negative. The number of digits to appear after the decimal point is given by p . It is a run-time error for p to be negative.

function string: show_int(int: w, var int: x)

Formatted to-string conversion for integers

Converts the integer x into a string right justified by the number of characters given by w , or left justified if w is negative.

function int: string_length(string: s)

Return length of s

4.2.2.17. Reflection operations

These functions return information about declared or inferred variable bounds and domains.
test annotate(var opt $T: x, ann: a)

Annotate declaration of x with annotation a

test annotate(set of $T: x, ann: a)

Annotate declaration of x with annotation a

test annotate(var set of int: x, ann: a)

Annotate declaration of x with annotation a

function set of int: dom(var int: x)

Return domain of x

function set of int: dom(var opt int: x)

Return domain of x

function set of int: dom_array(array [$T] of var int: x)

Return union of all domains of the elements in array x

function set of int: dom_array(array [$T] of var opt int: x)

Return union of all domains of the elements in array x

function set of int: dom_bounds_array(array [$T] of var int: x)

Return approximation of union of all domains of the elements in array x

function set of int: dom_bounds_array(array [$T] of var opt int: x)

Return approximation of union of all domains of the elements in array x

function int: dom_size(var int: x)

Return cardinality of the domain of x

More…

function $T: fix(var opt $T: x)

Check if the value of x is fixed at this point in evaluation. If it is fixed, return its value, otherwise abort.

function array [$U] of $T: fix(array [$U] of var opt $T: x)

Check if the value of every element of the array x is fixed at this point in evaluation. If all are fixed, return an array of their values, otherwise abort.

test has_ann(var opt $T: x, ann: a)

Test if x is annotated a

test has_ann(var set of $T: x, ann: a)

Test if x is annotated a

test has_ann(var set of int: x, ann: a)

Test if x is annotated a

test has_bounds(var int: x)

Test if variable x has declared, finite bounds

test has_bounds(var float: x)

Test if variable x has declared, finite bounds

test has_ub_set(var set of int: x)

Test if variable x has a declared, finite upper bound

test is_fixed(var opt $T: x)

Test if x is fixed

test is_fixed(set of $T: x)

Test if x is fixed

test is_fixed(var set of int: x)

Test if x is fixed

test is_fixed(array [$U] of var opt $T: x)

Test if every element of array x is fixed

test is_same(var opt $T: x, var opt $U: y)

Test if x and y are the same variable

function int: lb(var int: x)

Return lower bound of x

function int: lb(var opt int: x)

Return lower bound of x

function float: lb(var float: x)

Return lower bound of x

function float: lb(var opt float: x)

Return lower bound of x

function set of int: lb(var set of int: x)

Return lower bound of x

function array [$U] of int: lb(array [$U] of var int: x)

Return array of lower bounds of the elements in array x

More…

function array [$U] of float: lb(array [$U] of var float: x)

Return array of lower bounds of the elements in array x

More…

function array [$U] of set of int: lb(array [$U] of var set of int: x)

Return array of lower bounds of the elements in array x

More…

function int: lb_array(array [$U] of var opt int: x)

Return minimum of all lower bounds of the elements in array x

function float: lb_array(array [$U] of var opt float: x)

Return minimum of all lower bounds of the elements in array x

function set of int: lb_array(array [$U] of var set of int: x)

Return intersection of all lower bounds of the elements in array x

function int: ub(var int: x)

Return upper bound of x

function int: ub(var opt int: x)

Return upper bound of x

function float: ub(var float: x)

Return upper bound of x

function float: ub(var opt float: x)

Return upper bound of x

function set of int: ub(var set of int: x)

Return upper bound of x

function array [$U] of int: ub(array [$U] of var int: x)

Return array of upper bounds of the elements in array x

More…

function array [$U] of float: ub(array [$U] of var float: x)

Return array of upper bounds of the elements in array x

More…

function array [$U] of set of int: ub(array [$U] of var set of int: x)

Return array of upper bounds of the elements in array x

More…

function int: ub_array(array [$U] of var opt int: x)

Return maximum of all upper bounds of the elements in array x

function float: ub_array(array [$U] of var opt float: x)

Return maximum of all upper bounds of the elements in array x

function set of int: ub_array(array [$U] of var set of int: x)

Return union of all upper bounds of the elements in array x

4.2.2.18. Assertions and debugging functions

These functions help debug models and check that input data conforms to the expectations.

Parameters

annotation mzn_break_here

With debug build of the MiniZinc compiler, call MiniZinc::mzn_break_here when flattening this expression to make debugging easier. This annotation is ignored by the release build.

Functions and Predicates

test abort(string: msg)

Abort evaluation and print message msg .

function $T: assert(bool: b, string: msg, $T: x)

If b is true, return x , otherwise abort with message msg .

function opt $T: assert(bool: b, string: msg, opt $T: x)

If b is true, return x , otherwise abort with message msg .

function var $T: assert(bool: b, string: msg, var $T: x)

If b is true, return x , otherwise abort with message msg .

function var opt $T: assert(bool: b, string: msg, var opt $T: x)

If b is true, return x , otherwise abort with message msg .

function array [$U] of $T: assert(bool: b,
                                  string: msg,
                                  array [$U] of $T: x)

If b is true, return x , otherwise abort with message msg .

function array [$U] of opt $T: assert(bool: b,
                                      string: msg,
                                      array [$U] of opt $T: x)

If b is true, return x , otherwise abort with message msg .

function array [$U] of var $T: assert(bool: b,
                                      string: msg,
                                      array [$U] of var $T: x)

If b is true, return x , otherwise abort with message msg .

function array [$U] of var opt $T: assert(bool: b,
                                          string: msg,
                                          array [$U] of var opt $T: x)

If b is true, return x , otherwise abort with message msg .

test assert(bool: b, string: msg)

If b is true, return true, otherwise abort with message msg .

function string: logstream_to_string()

Return logging stream as string

function $T: trace(string: msg, $T: x)

Return x , and print message msg .

function opt $T: trace(string: msg, opt $T: x)

Return x , and print message msg .

function var $T: trace(string: msg, var $T: x)

Return x , and print message msg .

function var opt $T: trace(string: msg, var opt $T: x)

Return x , and print message msg .

function array [$U] of $T: trace(string: msg, array [$U] of $T: x)

Return x , and print message msg .

function array [$U] of opt $T: trace(string: msg,
                                     array [$U] of opt $T: x)

Return x , and print message msg .

function array [$U] of var $T: trace(string: msg,
                                     array [$U] of var $T: x)

Return x , and print message msg .

function array [$U] of var opt $T: trace(string: msg,
                                         array [$U] of var opt $T: x)

Return x , and print message msg .

test trace(string: msg)

Return true, and print message msg .

function $T: trace_logstream(string: msg, $T: x)

Return x , and print message msg to logging stream.

function opt $T: trace_logstream(string: msg, opt $T: x)

Return x , and print message msg to logging stream.

function var $T: trace_logstream(string: msg, var $T: x)

Return x , and print message msg to logging stream.

function var opt $T: trace_logstream(string: msg, var opt $T: x)

Return x , and print message msg to logging stream.

function array [$U] of $T: trace_logstream(string: msg,
                                           array [$U] of $T: x)

Return x , and print message msg to logging stream.

function array [$U] of opt $T: trace_logstream(string: msg,
                                               array [$U] of opt $T: x)

Return x , and print message msg to logging stream.

function array [$U] of var $T: trace_logstream(string: msg,
                                               array [$U] of var $T: x)

Return x , and print message msg to logging stream.

function array [$U] of var opt $T: trace_logstream(string: msg,
                                                   array [$U] of var opt $T: x)

Return x , and print message msg to logging stream.

test trace_logstream(string: msg)

Return true, and print message msg to logging stream.

function $T: trace_stdout(string: msg, $T: x)

Return x , and print message msg .

function opt $T: trace_stdout(string: msg, opt $T: x)

Return x , and print message msg .

function var $T: trace_stdout(string: msg, var $T: x)

Return x , and print message msg .

function var opt $T: trace_stdout(string: msg, var opt $T: x)

Return x , and print message msg .

function array [$U] of $T: trace_stdout(string: msg,
                                        array [$U] of $T: x)

Return x , and print message msg .

function array [$U] of opt $T: trace_stdout(string: msg,
                                            array [$U] of opt $T: x)

Return x , and print message msg .

function array [$U] of var $T: trace_stdout(string: msg,
                                            array [$U] of var $T: x)

Return x , and print message msg .

function array [$U] of var opt $T: trace_stdout(string: msg,
                                                array [$U] of var opt $T: x)

Return x , and print message msg .

test trace_stdout(string: msg)

Return true, and print message msg .

4.2.2.19. Functions for enums

function $$E: enum_next(set of $$E: e, $$E: x)

Return next greater enum value of x in enum e

function opt $$E: enum_next(set of $$E: e, opt $$E: x)

Return next greater enum value of x in enum e

More…

function var $$E: enum_next(set of $$E: e, var $$E: x)

Return next greater enum value of x in enum e

More…

function var opt $$E: enum_next(set of $$E: e, var opt $$E: x)

Return next greater enum value of x in enum e

More…

function $$E: enum_prev(set of $$E: e, $$E: x)

Return next smaller enum value of x in enum e

function opt $$E: enum_prev(set of $$E: e, opt $$E: x)

Return next smaller enum value of x in enum e

More…

function var $$E: enum_prev(set of $$E: e, var $$E: x)

Return next smaller enum value of x in enum e

More…

function var opt $$E: enum_prev(set of $$E: e, var opt $$E: x)

Return next smaller enum value of x in enum e

More…

function $$E: to_enum(set of $$E: X, int: x)

Convert x to enum type X

function opt $$E: to_enum(set of $$E: X, opt int: x)

Convert x to enum type X

More…

function var $$E: to_enum(set of $$E: X, var int: x)

Convert x to enum type X

More…

function var opt $$E: to_enum(set of $$E: X, var opt int: x)

Convert x to enum type X

More…

function array [$U] of $$E: to_enum(set of $$E: X,
                                    array [$U] of int: x)

Convert x to enum type X

More…

function array [$U] of opt $$E: to_enum(set of $$E: X,
                                        array [$U] of opt int: x)

Convert x to enum type X

More…

function array [$U] of var $$E: to_enum(set of $$E: X,
                                        array [$U] of var int: x)

Convert x to enum type X

More…

function array [$U] of var opt $$E: to_enum(set of $$E: X,
                                            array [$U] of var opt int: x)

Convert x to enum type X

More…

function set of $$E: to_enum(set of $$E: X, set of int: x)

Convert x to enum type X

More…

function array [$U] of set of $$E: to_enum(set of $$E: X,
                                           array [$U] of set of int: x)

Convert x to enum type X

More…

function array [$U] of var set of $$E: to_enum(set of $$E: X,
                                               array [$U] of var set of int: x)

Convert x to enum type X

More…

4.2.2.20. Random Number Generator builtins

These functions implement random number generators from different

probability distributions.

test bernoulli(float: p)

Return a boolean sample from the Bernoulli distribution defined by probability \({\bf p}\)

function int: binomial(int: t, float: p)

Return a sample from the binomial distribution defined by sample number t and probability p

function float: cauchy(float: mean, float: scale)

Return a sample from the cauchy distribution defined by \({\bf mean}, {\bf scale}\)

function float: cauchy(int: mean, float: scale)

Return a sample from the cauchy distribution defined by \({\bf mean}, {\bf scale}\)

function float: chisquared(int: n)

Return a sample from the chi-squared distribution defined by the degree of freedom \({\bf n}\)

function float: chisquared(float: n)

Return a sample from the chi-squared distribution defined by the degree of freedom \({\bf n}\)

function int: discrete_distribution(array [int] of int: weights)

Return a sample from the discrete distribution defined by the array of weights \({\bf weights}\) that assigns a weight to each integer starting from zero

function float: exponential(int: lambda)

Return a sample from the exponential distribution defined by \({\bf lambda}\)

function float: exponential(float: lambda)

Return a sample from the exponential distribution defined by \({\bf lambda}\)

function float: fdistribution(float: d1, float: d2)

Return a sample from the Fisher-Snedecor F-distribution defined by the degrees of freedom \({\bf d1}, {\bf d2}\)

function float: fdistribution(int: d1, int: d2)

Return a sample from the Fisher-Snedecor F-distribution defined by the degrees of freedom \({\bf d1}, {\bf d2}\)

function float: gamma(float: alpha, float: beta)

Return a sample from the gamma distribution defined by \({\bf alpha}, {\bf beta}\)

function float: gamma(int: alpha, float: beta)

Return a sample from the gamma distribution defined by \({\bf alpha}, {\bf beta}\)

function float: lognormal(float: mean, float: std)

Return a sample from the lognormal distribution defined by \({\bf mean}, {\bf std}\)

function float: lognormal(int: mean, float: std)

Return a sample from the lognormal distribution defined by \({\bf mean}, {\bf std}\)

function float: normal(float: mean, float: std)

Return a sample from the normal distribution defined by \({\bf mean}, {\bf std}\)

function float: normal(int: mean, float: std)

Return a sample from the normal distribution defined by \({\bf mean}, {\bf std}\)

function int: poisson(float: mean)

Return a sample from the poisson distribution defined by mean

function int: poisson(int: mean)

Return a sample from the poisson distribution defined by an integer mean

function float: tdistribution(float: n)

Return a sample from the student’s t-distribution defined by the sample size \({\bf n}\)

function float: tdistribution(int: n)

Return a sample from the student’s t-distribution defined by the sample size \({\bf n}\)

function float: uniform(float: lowerbound, float: upperbound)

Return a sample from the uniform distribution defined by \({\bf lowerbound}, {\bf upperbound}\)

function int: uniform(int: lowerbound, int: upperbound)

Return a sample from the uniform distribution defined by \({\bf lowerbound}, {\bf upperbound}\)

function float: weibull(float: shape, float: scale)

Return a sample from the Weibull distribution defined by \({\bf shape}, {\bf scale}\)

function float: weibull(int: shape, float: scale)

Return a sample from the Weibull distribution defined by \({\bf shape}, {\bf scale}\)