MiniZinc Documentation - Standard Library

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

Functions and Predicates
function float: bool2float(bool: b) =
if b then 1.0 else 0.0 endif
(standard decomposition from builtins.mzn:1046)

Return Boolean b coerced to a float

function array [$T] of float: bool2float(array [$T] of bool: x) =
let {array [int] of bool: xx = array1d(x), } in (arrayXd(x, [ bool2float(xx[i]) | i in index_set(xx) ]))
(standard decomposition from builtins.mzn:1048)

Return array of Booleans x coerced to an array of floats

function array [$T] of var float: bool2float(array [$T] of var bool: x) =
let {array [int] of var bool: xx = array1d(x), } in (arrayXd(x, [ bool2float(xx[i]) | i in index_set(xx) ]))
(standard decomposition from builtins.mzn:1053)

Return array of Booleans x coerced to an array of floats

function var float: bool2float(var bool: b) =
int2float(bool2int(b))
(standard decomposition from builtins.mzn:1062)

Return Boolean b coerced to a float

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 [$$E] of var int: bool2int(array [$$E] 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) =
let {array [int] of bool: xx = array1d(x), } in (arrayXd(x, [ bool2int(xx[i]) | i in index_set(xx) ]))
(standard decomposition from builtins.mzn:1077)

Return array of Booleans x coerced to an array of integers

function array [$T] of set of int: bool2int(array [$T] of set of bool: x) =
let {array [int] of set of bool: xx = array1d(x), } in (arrayXd(x, [ bool2int(xx[i]) | i in index_set(xx) ]))
(standard decomposition from builtins.mzn:1083)

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

function array [$T] of var int: bool2int(array [$T] of var bool: x) =
let {array [int] of var bool: xx = array1d(x), } in (arrayXd(x, [ bool2int(xx[i]) | i in index_set(xx) ]))
(standard decomposition from builtins.mzn:1089)

Return array of Booleans x coerced to an array of integers

function array [$T] of var opt int: bool2int(array [$T] of var opt bool: x) =
let {array [int] of var opt bool: xx = array1d(x), } in (arrayXd(x, [ bool2int(xx[i]) | i in index_set(xx) ]))
(standard decomposition from builtins.mzn:1095)

Return array of Booleans x coerced to an array of integers

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) =
let { var int2float(lb(x))..int2float(ub(x)): y, constraint int2float(x, y), } in (y)
(standard decomposition from builtins.mzn:1066)

Return integer x coerced to a float

function array [$T] of float: int2float(array [$T] of int: x) =
let {array [int] of int: xx = array1d(x), } in (arrayXd(x, [ int2float(xx[i]) | i in index_set(xx) ]))
(standard decomposition from builtins.mzn:1101)

Return array of integers x coerced to an array of floats

function array [$T] of var float: int2float(array [$T] of var int: x) =
let {array [int] of var int: xx = array1d(x), } in (arrayXd(x, [ int2float(xx[i]) | i in index_set(xx) ]))
(standard decomposition from builtins.mzn:1107)

Return array of integers x coerced to an array of floats

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