4.2.4. Builtins

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

4.2.4.1. Comparison Builtins

These builtins implement comparison operations.

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

Usage: x != y

Return if x is not equal to y

predicate '!='(var $T: x, var $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

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

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

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

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

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.4.2. 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 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 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 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 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 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 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 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 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 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 $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 $$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(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 $$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 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 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 bool: x)

Return sum of elements in array x

More…

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

Return sum of elements in array 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

4.2.4.3. 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.4.4. 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.4.5. 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

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

Usage: x /\ y

Return truth value of x &and; y

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

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

Usage: x \/ y

Return truth value of x &or; y

test 'not'(bool: x)

Usage: not x

Return truth value of the negation of x

predicate 'not'(var bool: x)

Usage: not x

Return truth value of the negation of x

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 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]\)

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]\)

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.4.6. 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.4.7. 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.4.8. Array operations

These functions implement the basic operations on arrays.

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 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.4.9. 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.4.10. Coercions

These functions implement coercions, or channeling, between different types.

function float: bool2float(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 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 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 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 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 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.4.11. 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.4.12. Reflection operations

These functions return information about declared or inferred variable bounds and domains.

function set of int: dom(var 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_bounds_array(array [$T] of var 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_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

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.4.13. Assertions and debugging functions

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

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 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 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 $T: trace(string: msg, $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 .

test trace(string: msg)

Return true, and print message msg .

function $T: trace_stdout(string: msg, $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 .

test trace_stdout(string: msg)

Return true, and print message msg .

4.2.4.14. Functions for enums

function $$E: enum_next(set of $$E: e, $$E: x)

Return next greater enum value of x in enum e

function var $$E: enum_next(set of $$E: e, var $$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 var $$E: enum_prev(set of $$E: e, var $$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 var $$E: to_enum(set of $$E: X, var 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 var $$E: to_enum(set of $$E: X,
                                        array [$U] of var 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…

4.2.4.15. 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}\)

4.2.4.16. 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)

More…

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.4.17. Language information

These functions return information about the MiniZinc system.

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…