This page lists the global constraints available in version 1.2 of the MiniZinc library.
all_different(array[int] of var int: x) all_different(array[int] of var set of int: x)
Constrains the array of objects x to be all different.
Also available by the name alldifferent.
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.
count(array[int] of var int: x, var int: y, var int: c)
Constrains c to 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 int: x, array[int] of var int: y) lex_greater(array[int] of var float: x, array[int] of var float: 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 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 int: x, array[int] of var int: y) lex_less(array[int] of var float: x, array[int] of var float: 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 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.
precedence(array[int] of var int: x)
Ensures that the first occurrence of i is before that of j for i < j and that the first value used is the value 1.
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.
sequence(array[int] of var int: x, int: k, int: lb, int: ub)
Requires that in each subsequence x[i], ..., x[i + k - 1] the sum of the
values is between lb and ub.
NOTE: this constraint is deprecated; use sliding_sum instead.
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.
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.