This page lists the global constraints available in version 1.6 of the MiniZinc library.
alldifferent(array[int] of var int: x) alldifferent(array[int] of var set of int: x)
Constrains the array of objects x to be all different.
Also available by the name all_different.
alldifferent_except_0(array[int] of var int: x)
Constrains the elements of the array x to be all different except those elements that are assigned the value 0.
all_disjoint(array[int] of var set of int: x)
Ensures that every pair of sets in the array x is disjoint.
all_equal(array[int] of var int: x) all_equal(array[int] of var set of int: x)
Constrains the array of objects x to have the same value.
among(var int: n, array[int] of var int: x, set of int: v)
Requires exactly n variables in x to take one of the values in v.
at_least(int: n, array[int] of var int: x, int: v) at_least(int: n, array[int] of var set of int: x, set of int: v)
Requires at least n variables in x to take the value v.
Also available by the name atleast.
at_most(int: n, array[int] of var int: x, int: v) at_most(int: n, array[int] of var set of int: x, set of int: v)
Requires at most n variables in x to take the value v.
Also available by the name atmost.
at_most1(array[int] of var set of int: s)
Requires that each pair of sets in s overlap in at most one element.
Also available by the name atmost1.
bin_packing(int: c, array[int] of var int: bin, array[int] of int: w)
Requires that each item i be put into bin bin[i] such that the
sum of the weights of each item, w[i], in each bin does not exceed
the capacity c.
Aborts if an item has a negative weight or if the capacity is negative.
Aborts if the index sets of bin and w are not identical.
bin_packing_capa(array[int] of int: c, array[int] of var int: bin, array[int] of int:w)
Requires that each item i be put into bin bin[i] such that the
sum of the weights of each item, w[i], in each bin b does not
exceed the capacity c[b].
Aborts if an item has negative weight.
Aborts if the index sets of bin and w are not identical.
bin_backing_load(array[int] of var int: l, array[int] of var int: bin, array[int] of int: w)
Requires that each item i be put into bin bin[i] such that the
sum of the weights of each item, w[i], in each bin b is equal to
the load l[b].
Aborts if an item has negative weight.
Aborts if the index sets of bin and w are not identical.
circuit[array[int] of var int: x)
Constraints the elements of x to define a circuit where x[i] = j mean that j is the successor of i.
count_eq(array[int] of var int: x, var int: y, var int: c)
Constrains c to be the number of occurrences of y in x.
Also available by the name count.
count_geq(array[int] of var int: x, var int: y, var int: c)
Constrains c to greater than or equal to the number of occurrences of y in x.
count_gt(array[int] of var int: x, var int: y, var int: c)
Constrains c to strictly greater than the number of occurrences of y in x.
count_leq(array[int] of var int: x, var int: y, var int: c)
Constrains c to less than or equal to the number of occurrences of y in x.
count_lt(array[int] of var int: x, var int: y, var int: c)
Constrains c to strictly less than the number of occurrences of y in x.
count_neq(array[int] of var int: x, var int: y, var int: c)
Constrains c to not be the number of occurrences of y in x.
cumulative(array[int] of var int: s, array[int] of var int: d, array[int] of var int: r, var int: b)
Requires that a set of tasks given by start times s, durations d, and
resource requirements r, never require more than a global resource bound
b at any one time.
Aborts if s, d, and r do not have identical index sets.
Aborts if a duration or resource requirement is negative.
decreasing(array[int] of var bool: x) decreasing(array[int] of var float: x) decreasing(array[int] of var int: x) decreasing(array[int] of var set of int: x)
Requires that the array x is in (non-strictly) decreasing order.
diffn(array[int] of var int: x, array[int] of var int: y, array[int] of var int: dx, array[int] of var int: dy)
Constrains rectangles, given by their origins x,y and sizes dx,dy, to be non-overlapping.
disjoint(var set of int: s, var set of int: t)
Requires that sets s and t do not intersect.
distribute(array[int] of var int: card, array[int] of var int: value, array[int] of var int: base)
Requires that card[i] is the number of occurrences of value[i] in base.
In this implementation the values in value need not be distinct.
Aborts if card and value do not have identical index sets.
element(var int: i, array[int] of var bool: x, var bool: y) element(var int: i, array[int] of var float: x, var float: y) element(var int: i, array[int] of var int: x, var int: y) element(var int: i, array[int] of var set of int: x, var set of int: y)
The same as x[i] = y. That is, y is the ith element of the array x.
exactly(int: n, array[int] of var int: x, int: v) exactly(int: n, array[int] of var set of int: x, set of int: v)
Requires exactly n variables in x to take the value v.
global_cardinality(array[int] of var int: x, array[int] of int: cover, array[int] of var int: counts)
Requires that the number of occurrences of cover[i] in x is counts[i].
Aborts if cover and counts do not have identical index sets.
global_cardinality_closed(array[int] of var int: x, array[int] of int: cover, array[int] of var int: counts)
Requires that the number of occurrences of cover[i] in x is counts[i].
The elements of x must take their values from cover.
Aborts if cover and counts do not have identical index sets.
global_cardinality_low_up(array[int] of var int: x, array[int] of int: cover, array[int] of int: lb, array[int] of int: ub)
Requires that for all i, the value cover[i] appears at least lb[i] and at most ub[i] times in the array x.
global_cardinality_low_up_closed(array[int] of var int: x, array[int] of int: cover, array[int] of int: lb, array[int] of int: ub)
Requires that for all i, the value cover[i] appears at least
lb[i] and at most ub[i] times in the array x.
The elements of x must take their values from cover.
increasing(array[int] of var bool: x) increasing(array[int] of var float: x) increasing(array[int] of var int: x) increasing(array[int] of var set of int: x)
Requires that the array x is in (non-strictly) increasing order.
int_set_channel(array[int] of var int: x, array[int] of var set of int: y)
Requires that x[i] = j if and only if i ∈ y[j].
inverse(array[int] of var int: f, array[int] of var int: invf)
Constrains two arrays to represent inverse functions of each other. All the values in each array must be within the index set of the other array.
inverse_set(array[int] of var set of int: f, array[int] of var set of int: invf)
Constrains the two arrays f and invf so that a j ∈ f[i] if and only if i ∈ invf[j]. All the values in each array's sets must be within the index set of the other array.
lex_greater(array[int] of var bool: x, array[int] of var bool: y) lex_greater(array[int] of var float: x, array[int] of var float: y) lex_greater(array[int] of var int: x, array[int] of var int: y) lex_greater(array[int] of var set of int: x, array[int] of var set of int: y)
Requires that the array x is strictly lexicographically greater than array y.
Compares them from first to last element, regardless of indices.
lex_greatereq(array[int] of var bool: x, array[int] of var bool: y) lex_greatereq(array[int] of var float: x, array[int] of var float: y) lex_greatereq(array[int] of var int: x, array[int] of var int: y) lex_greatereq(array[int] of var set of int: x, array[int] of var set of int: y)
Requires that the array x is lexicographically greater than or equal to
array y.
Compares them from first to last element, regardless of indices.
lex_less(array[int] of var bool: x, array[int] of var bool: y) lex_less(array[int] of var float: x, array[int] of var float: y) lex_less(array[int] of var int: x, array[int] of var int: y) lex_less(array[int] of var set of int: x, array[int] of var set of int: y)
Requires that the array x is strictly lexicographically less than array y.
Compares them from first to last element, regardless of indices.
lex_lesseq(array[int] of var bool: x, array[int] of var bool: y) lex_lesseq(array[int] of var float: x, array[int] of var float: y) lex_lesseq(array[int] of var int: x, array[int] of var int: y) lex_lesseq(array[int] of var set of int: x, array[int] of var set of int: y)
Requires that the array x is lexicographically less than or equal to
array y.
Compares them from first to last element, regardless of indices.
lex2(array[int, int] of var int: x)
Require adjacent rows and adjacent columns in the the array x to be lexicographically ordered. Adjacent rows and adjacent columns may be equal.
link_set_to_booleans(var set of int: s, array[int] of var bool: b)
The array of booleans b is the characteristic representation of the set s.
Aborts if the index set of b is not a superset of the possible values of s.
maximum(var int: m, array[int] of var int: x) maximum(var float: m, array[int] of var float: x)
Constrains m to be the maximum of the values in x. (The array x must have at least one element.)
member(array[int] of var bool: x, var bool: y) member(array[int] of var float: x, var float: y) member(array[int] of var int: x, var int: y) member(array[int] of var set of int: x, var set of int: y) member(var set of int: x, var int: y)
Requires that y occurs in the array or set x.
minimum(var float: m, array[int] of var float: x) minimum(var int: m, array[int] of var int: x)
Constrains m to be the minimum of the values in x. (The array x must have at least one element.)
nvalue(var int: n, array[int] of var int: x)
Requires that the number of distinct values in x is n.
partition_set(array[int] of var set of int: s, set of int: universe)
Partitions universe into disjoint sets.
range(array[int] of var int: x, var set of int: s, var set of int: t)
Requires that the image of function x (represented as an array) on set
of values s is t.
Aborts if ub(s) is not a subset of the index set of x.
regular(array[int] of var int: x, int: Q, int: S, array[int,int] of int: d, int: q0, set of int: F)
The sequence of values in array x (which must all be in the range 1..S)
is accepted by the DFA of Q states with input 1..S and transition
function d (which maps ⟨1..Q, 1..S⟩ to 0..Q)
and initial state q0
(which must be in 1..Q) and accepting states F (which all must be in
1..Q). State 0 is reserved to be an always failing state.
Aborts if Q < 1.
Aborts if S < 1.
Aborts if the transition function d is not in [1..Q, 1..s].
Aborts if the start state, q0, is not in 1..Q.
Aborts if F is not a subset of 1..Q.
roots(array[int] of var int: x, var set of int: s, var set of int: t)
Requires that x[i] ∈ t for all i ∈ s.
Aborts if ub(s) is not a subset of the index set of x.
sliding_sum(int: low, int: up, int: seq, array[int] of var int: vs)
Requires that in each subsequence vs[i], ..., vs[i + seq - 1] the sum of the values belongs to the interval [low, up].
sort(array[int] of var int: x, array[int] of var int: y)
Requires that the multiset of values in x is the same as the
multiset of values in y but y is in sorted order.
Aborts if the cardinality of the index sets of x and y
is not equal.
strict_lex2(array[int, int] of var int: x)
Require adjacent rows and adjacent columns in the the array x to be lexicographically ordered. Adjacent rows and adjacent columns cannot be equal.
subcircuit(array[int] of var int: x)
Constrains the elements of x to define a subcircuit where x[i] = j means that j is the successor of i and x[i] = i means that i is not in the circuit.
sum_pred(var int: i, array[int] of set of int: sets, array[int] of int: c, var int: s)
Requires that the sum of c[i1]...c[iN] equals s, where i1..iN are the
elements of the ith set in sets.
This constraint is usually named sum, but using that would conflict with the MiniZinc built-in
function of the same name.
table(array[int] of var bool: x, array[int, int] of bool: t) table(array[int] of var int: x, array[int, int] of int: t)
Represents the constraint x ∈ t where we
consider each row in t to be a tuple and t as a set of tuples.
Aborts if the second dimension of t does not equal the number of variables in x.
The default decomposition of this constraint cannot be flattened if it occurs in
a reified context.
value_precede(int: s, int: t, array[int] of var int: x) value_precede(int: s, int: t, array[int] of var set of int: x)
Requires that s precede t in the array x.
For integer variables this constraint requires that if an element of x
is equal to t, then another element of x with a lower index
is equal to s.
For set variables this constraint requires that if an element of x
contains t but not s, then another element of x with
lower index contains s but not t.
value_precede_chain(array[int] of int: c, array[int] of var int: x) value_precede_chain(array[int] of int: c, array[int] of var set of int: x)
Requires that the value_precede constraint is true for every pair of adjacent integers in c in the array x.