MiniZinc Documentation - Standard Library

Functions and Predicates
predicate '<'(var opt int: x, var opt int: y) =
absent(x) \/ absent(y) \/ deopt(x) < deopt(y)
(standard decomposition from stdlib.mzn:351)

Usage: x

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.

test '<'(opt int: x, opt int: y) =
absent(x) \/ absent(y) \/ deopt(x) < deopt(y)
(standard decomposition from stdlib.mzn:364)

Usage: x

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.

predicate '<='(var opt int: x, var opt int: y) =
absent(x) \/ absent(y) \/ deopt(x)<=deopt(y)
(standard decomposition from stdlib.mzn:354)

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.

test '<='(opt int: x, opt int: y) =
absent(x) \/ absent(y) \/ deopt(x)<=deopt(y)
(standard decomposition from stdlib.mzn:367)

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.

predicate '>'(var opt int: x, var opt int: y) =
absent(x) \/ absent(y) \/ deopt(x) > deopt(y)
(standard decomposition from stdlib.mzn:345)

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.

test '>'(opt int: x, opt int: y) =
absent(x) \/ absent(y) \/ deopt(x) > deopt(y)
(standard decomposition from stdlib.mzn:358)

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.

predicate '>='(var opt int: x, var opt int: y) =
absent(x) \/ absent(y) \/ deopt(x)>=deopt(y)
(standard decomposition from stdlib.mzn:348)

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.

test '>='(opt int: x, opt int: y) =
absent(x) \/ absent(y) \/ deopt(x)>=deopt(y)
(standard decomposition from stdlib.mzn:361)

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.

function var opt int: bool2int(var opt bool: x) =
let { var opt 0..1: xi, constraint absent(xi)==absent(x), constraint deopt(xi)==bool2int(deopt(x)), } in (xi)
(standard decomposition from stdlib.mzn:426)

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

function var opt int: element(var opt int: idx, array [int] of var int: x) =
if absent(idx) then <> else element(deopt(idx), x) endif
(standard decomposition from stdlib.mzn:454)

Return absent if idx is absent, otherwise return x[idx]

function var opt int: element(var opt int: idx1, var opt int: idx2, array [int,int] of var int: x) =
if absent(idx1) \/ absent(idx2) then <> else element(deopt(idx1), deopt(idx2), x) endif
(standard decomposition from stdlib.mzn:458)

Return absent if idx1 or idx2 is absent, otherwise return x[idx1, idx2]

function var opt int: element(var int: idx, array [int] of var opt int: x) =
let { var opt int: r, constraint occurs(r)==element(idx, array1d(index_set(x), [ occurs(x[i]) | i in index_set(x) ])), constraint deopt(r)==element(idx, array1d(index_set(x), [ deopt(x [i]) | i in index_set(x) ])), } in (r)
(standard decomposition from stdlib.mzn:462)

Return x[idx]

function var opt int: element(var int: idx1, var int: idx2, array [int,int] of var opt int: x) =
let { var opt int: r, constraint occurs(r)==element(idx1, idx2, array2d(index_set_1of2(x), index_set_2of2(x), [ occurs(x[i, j]) | i in index_set_1of2(x), j in index_set_2of2(x) ])), constraint deopt(r)==element(idx1, idx2, array2d(index_set_1of2(x), index_set_2of2(x), [ deopt(x[i, j]) | i in index_set_1of2(x), j in index_set_2of2(x) ])), } in (r)
(standard decomposition from stdlib.mzn:470)

Return x[idx1, idx2]

function var opt int: element(var opt int: idx, array [int] of var opt int: x) =
if absent(idx) then <> else element(deopt(idx), x) endif
(standard decomposition from stdlib.mzn:480)

Return absent if idx is absent, otherwise return x[idx]

function var opt int: element(var opt int: idx1, var opt int: idx2, array [int,int] of var opt int: x) =
if absent(idx1) \/ absent(idx2) then <> else element(deopt(idx1), deopt(idx2), x) endif
(standard decomposition from stdlib.mzn:484)

Return absent if idx1 or idx2 is absent, otherwise return x[idx1, idx2]

predicate int_eq(var opt int: x, var opt int: y) =
absent(x) /\ absent(y) \/ occurs(x) /\ occurs(y) /\ deopt(x)==deopt(y) :: maybe_partial
(standard decomposition from stdlib.mzn:435)

True iff both x and y are absent or both are present and have the same value.

predicate int_ne(var opt int: x, var opt int: y) =
absent(x)!=absent(y) \/ occurs(x) /\ occurs(y) /\ deopt(x)!=deopt(y) :: maybe_partial
(standard decomposition from stdlib.mzn:441)

True iff only one of x and y is absent or both are present and have different values.

function var opt int: max(array [int] of var opt int: x) =
let { var opt lb_array(x)..ub_array(x): m, int: xmin = lb_array(x), constraint occurs(m) <-> exists ( i in index_set(x) ) ( occurs(x[i]) ), constraint occurs(m) -> deopt(m)==max ( xi in x ) ( if occurs(xi) then deopt(xi) else xmin endif ), } in ( m)
(standard decomposition from stdlib.mzn:382)

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

function var opt int: min(array [int] of var opt int: x) =
let { var opt lb_array(x)..ub_array(x): m, int: xmax = ub_array(x), constraint occurs(m) <-> exists ( i in index_set(x) ) ( occurs(x[i]) ), constraint occurs(m) -> deopt(m)==min ( xi in x ) ( if occurs(xi) then deopt(xi) else xmax endif ), } in ( m)
(standard decomposition from stdlib.mzn:371)

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

predicate occurs(var opt int: x) =
let { var bool: b = occurs_internal(x), var int: dx = deopt_internal(x), constraint x==reverse_map(b, dx) :: is_reverse_map, } in (b)
(standard decomposition from stdlib.mzn:316)

True iff x is not absent

function var int: product(array [int] of var opt int: x) =
sum ( i in index_set(x) ) ( let {var int: dx = deopt(x[i]), } in (if occurs(x[i]) then dx else 1 endif) )
(standard decomposition from stdlib.mzn:450)

Return product of non-absent elements of x.

function var int: sum(array [int] of var opt int: x) =
sum ( i in index_set(x) ) ( let {var int: dx = deopt(x[i]), } in (if occurs(x[i]) then dx else 0 endif) )
(standard decomposition from stdlib.mzn:446)

Return sum of non-absent elements of x.

function var opt int: ~*(var opt int: x, var opt int: y) =
if absent(x) \/ absent(y) then <> else deopt(x)*deopt(y) endif
(standard decomposition from stdlib.mzn:415)

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

function var opt int: ~+(var opt int: x, var opt int: y) =
let { int: l = if lb(x)==-infinity \/ lb(y)==-infinity then -infinity else lb(x)+lb(y) endif, int: u = if ub(x)==infinity \/ ub(y)==infinity then infinity else ub(x)+ub(y) endif, var opt l..u: result, constraint absent(x) \/ absent(y) -> result==<>, constraint absent(x) \/ absent(y) \/ result==deopt(x)+deopt(y), } in ( result)
(standard decomposition from stdlib.mzn:393)

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

function var opt int: ~-(var opt int: x, var opt int: y) =
let { int: l = if lb(x)==-infinity \/ ub(y)==infinity then -infinity else lb(x)-ub(y) endif, int: u = if ub(x)==infinity \/ lb(y)==-infinity then infinity else ub(x)-lb(y) endif, var opt l..u: result, constraint absent(x) \/ absent(y) -> result==<>, constraint absent(x) \/ absent(y) \/ result==deopt(x)-deopt(y), } in ( result)
(standard decomposition from stdlib.mzn:404)

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

predicate ~=(var opt int: x, var opt int: y) =
absent(x) \/ absent(y) \/ deopt(x)==deopt(y)
(standard decomposition from stdlib.mzn:421)

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