#[non_exhaustive]pub enum Constraint {
Show 79 variants
Difference(TwoVars, Var),
Div(TwoVars, Var),
DivUndefZero(TwoVars, Var),
Modulo(TwoVars, Var),
ModuloUndefZero(TwoVars, Var),
Pow(TwoVars, Var),
Product(TwoVars, Var),
WeightedSumGeq(Vec<Constant>, Vec<Var>, Var),
WeightedSumLeq(Vec<Constant>, Vec<Var>, Var),
CheckAssign(Box<Constraint>),
CheckGsa(Box<Constraint>),
ForwardChecking(Box<Constraint>),
Reify(Box<Constraint>, Var),
ReifyImply(Box<Constraint>, Var),
ReifyImplyQuick(Box<Constraint>, Var),
WatchedAnd(Vec<Constraint>),
WatchedOr(Vec<Constraint>),
GacAllDiff(Vec<Var>),
AllDiff(Vec<Var>),
AllDiffMatrix(Vec<Var>, Constant),
WatchSumGeq(Vec<Var>, Constant),
WatchSumLeq(Vec<Var>, Constant),
OccurrenceGeq(Vec<Var>, Constant, Constant),
OccurrenceLeq(Vec<Var>, Constant, Constant),
Occurrence(Vec<Var>, Constant, Var),
LitSumGeq(Vec<Var>, Vec<Constant>, Constant),
Gcc(Vec<Var>, Vec<Constant>, Vec<Var>),
GccWeak(Vec<Var>, Vec<Constant>, Vec<Var>),
LexLeqRv(Vec<Var>, Vec<Var>),
LexLeq(Vec<Var>, Vec<Var>),
LexLess(Vec<Var>, Vec<Var>),
LexLeqQuick(Vec<Var>, Vec<Var>),
LexLessQuick(Vec<Var>, Vec<Var>),
WatchVecNeq(Vec<Var>, Vec<Var>),
WatchVecExistsLess(Vec<Var>, Vec<Var>),
Hamming(Vec<Var>, Vec<Var>, Constant),
NotHamming(Vec<Var>, Vec<Var>, Constant),
FrameUpdate(Vec<Var>, Vec<Var>, Vec<Var>, Vec<Var>, Constant),
NegativeTable(Vec<Var>, Vec<Tuple>),
Table(Vec<Var>, Vec<Tuple>),
GacSchema(Vec<Var>, Vec<Tuple>),
LightTable(Vec<Var>, Vec<Tuple>),
Mddc(Vec<Var>, Vec<Tuple>),
NegativeMddc(Vec<Var>, Vec<Tuple>),
Str2Plus(Vec<Var>, Var),
ShortStr2(Vec<Var>, Vec<ShortTuple>),
HaggisGac(Vec<Var>, Vec<ShortTuple>),
HaggisGacStable(Vec<Var>, Vec<ShortTuple>),
ShortCTupleStr2(Vec<Var>, Vec<ShortTuple>),
Max(Vec<Var>, Var),
Min(Vec<Var>, Var),
NvalueGeq(Vec<Var>, Var),
NvalueLeq(Vec<Var>, Var),
SumLeq(Vec<Var>, Var),
SumGeq(Vec<Var>, Var),
Element(Vec<Var>, Var, Var),
ElementOne(Vec<Var>, Var, Var),
ElementUndefZero(Vec<Var>, Var, Var),
WatchElement(Vec<Var>, Var, Var),
WatchElementOne(Vec<Var>, Var, Var),
WatchElementOneUndefZero(Vec<Var>, Var, Var),
WatchElementUndefZero(Vec<Var>, Var, Var),
WLiteral(Var, Constant),
WNotLiteral(Var, Constant),
WInIntervalSet(Var, Vec<Constant>),
WInRange(Var, Vec<Constant>),
WInset(Var, Vec<Constant>),
WNotInRange(Var, Vec<Constant>),
WNotInset(Var, Vec<Constant>),
Abs(Var, Var),
DisEq(Var, Var),
Eq(Var, Var),
MinusEq(Var, Var),
GacEq(Var, Var),
WatchLess(Var, Var),
WatchNeq(Var, Var),
Ineq(Var, Var, Constant),
False,
True,
}Expand description
All supported Minion constraints.
Each variant corresponds to a Minion input-language constraint (see the Minion constraint reference). Variants are named to match their Minion input names as closely as Rust’s naming conventions permit.
§Argument conventions
Vec<Var>is a list of variables.Varalone is a single variable (orVar::ConstantAsVarfor a constant in variable position).Vec<Constant>is a list of integer constants (e.g. weights, values).Constantalone is a single integer constant.(Var, Var)in theTwoVarsposition means two variables.Vec<Tuple>is a list of tuples (aTupleis aVec<Constant>).Box<Constraint>means the variant wraps another constraint (reification, nested boolean operators, etc.).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Difference(TwoVars, Var)
difference(x, y, z) — z = |x - y|. Bounds consistency.
Div(TwoVars, Var)
div(x, y, z) — z = floor(x / y). False when y = 0.
DivUndefZero(TwoVars, Var)
div_undefzero(x, y, z) — like Div, but true (not false) when y = 0.
Modulo(TwoVars, Var)
modulo(x, y, z) — z = x % y. False when y = 0.
ModuloUndefZero(TwoVars, Var)
modulo_undefzero(x, y, z) — like Modulo, but true when y = 0.
Pow(TwoVars, Var)
pow(x, y, z) — z = x^y. False when y < 0 (with exceptions for ±1).
Product(TwoVars, Var)
product(x, y, z) — z = x * y.
WeightedSumGeq(Vec<Constant>, Vec<Var>, Var)
weightedsumgeq(weights, vars, total) — dot product ≥ total.
WeightedSumLeq(Vec<Constant>, Vec<Var>, Var)
weightedsumleq(weights, vars, total) — dot product ≤ total.
CheckAssign(Box<Constraint>)
check[assign](c) — internal: checks c after each assignment.
CheckGsa(Box<Constraint>)
check[gsa](c) — internal: checks c via GSA (generalised-scope-all).
ForwardChecking(Box<Constraint>)
forwardchecking(c) — internal: run c in forward-checking mode.
Reify(Box<Constraint>, Var)
reify(c, r) — r = 1 iff c is satisfied. r must be 0/1.
ReifyImply(Box<Constraint>, Var)
reifyimply(c, r) — if r = 1 then c must hold.
ReifyImplyQuick(Box<Constraint>, Var)
reifyimply-quick(c, r) — like ReifyImply but only checks c when r is assigned.
WatchedAnd(Vec<Constraint>)
watched-and({c1, ..., cn}) — all ci must be true.
WatchedOr(Vec<Constraint>)
watched-or({c1, ..., cn}) — at least one ci must be true.
GacAllDiff(Vec<Var>)
gacalldiff(vars) — all variables in vars take distinct values. GAC.
AllDiff(Vec<Var>)
alldiff(vars) — like GacAllDiff but weaker (clique of ≠ constraints).
AllDiffMatrix(Vec<Var>, Constant)
alldiffmatrix(matrix, dim) — Latin-square condition on a dim×dim matrix.
WatchSumGeq(Vec<Var>, Constant)
watchsumgeq(vars, c) — sum of 0/1 vars ≥ c. Fast for small c.
WatchSumLeq(Vec<Var>, Constant)
watchsumleq(vars, c) — sum of 0/1 vars ≤ c. Fast for c close to len.
OccurrenceGeq(Vec<Var>, Constant, Constant)
occurrencegeq(vars, val, count) — val occurs ≥ count times. Constants only.
OccurrenceLeq(Vec<Var>, Constant, Constant)
occurrenceleq(vars, val, count) — val occurs ≤ count times. Constants only.
Occurrence(Vec<Var>, Constant, Var)
occurrence(vars, val, count) — val occurs exactly count times.
LitSumGeq(Vec<Var>, Vec<Constant>, Constant)
litsumgeq(vars, literals, c) — at least c positions where vars[i] == literals[i].
Gcc(Vec<Var>, Vec<Constant>, Vec<Var>)
gcc(vars, values, caps) — each value in values appears exactly caps[i] times. Strong propagation.
GccWeak(Vec<Var>, Vec<Constant>, Vec<Var>)
gccweak(vars, values, caps) — like Gcc but weaker, faster propagation on caps.
LexLeqRv(Vec<Var>, Vec<Var>)
lexleq[rv](a, b) — a ≤ b lexicographically. GAC, handles repeated variables.
LexLeq(Vec<Var>, Vec<Var>)
lexleq(a, b) — a ≤ b lexicographically. GAC, assumes no repeated variables.
LexLess(Vec<Var>, Vec<Var>)
lexless(a, b) — a < b lexicographically. GAC, assumes no repeated variables.
LexLeqQuick(Vec<Var>, Vec<Var>)
lexleq[quick](a, b) — a ≤ b lexicographically. Fast but weaker propagation.
LexLessQuick(Vec<Var>, Vec<Var>)
lexless[quick](a, b) — a < b lexicographically. Fast but weaker propagation.
WatchVecNeq(Vec<Var>, Vec<Var>)
watchvecneq(a, b) — vectors a and b differ in at least one position.
WatchVecExistsLess(Vec<Var>, Vec<Var>)
watchvecexists_less(a, b) — there exists i such that a[i] < b[i].
Hamming(Vec<Var>, Vec<Var>, Constant)
hamming(a, b, c) — Hamming distance between a and b ≥ c.
NotHamming(Vec<Var>, Vec<Var>, Constant)
not-hamming(a, b, c) — Hamming distance between a and b < c.
FrameUpdate(Vec<Var>, Vec<Var>, Vec<Var>, Vec<Var>, Constant)
frameupdate(...) — internal frame-update constraint.
NegativeTable(Vec<Var>, Vec<Tuple>)
negativetable(vars, tuples) — disallows the given tuples. GAC.
Table(Vec<Var>, Vec<Tuple>)
table(vars, tuples) — allows only the given tuples. GAC.
GacSchema(Vec<Var>, Vec<Tuple>)
gacschema(vars, tuples) — like Table with an alternative GAC algorithm.
LightTable(Vec<Var>, Vec<Tuple>)
lighttable(vars, tuples) — stateless variant of Table, faster for small constraints.
Mddc(Vec<Var>, Vec<Tuple>)
mddc(vars, tuples) — MDDC propagator (multi-valued decision diagram). GAC.
NegativeMddc(Vec<Var>, Vec<Tuple>)
negativemddc(vars, tuples) — negative MDDC. GAC on disallowed tuples.
Str2Plus(Vec<Var>, Var)
str2plus(vars, table_ref) — STR2+ algorithm. The second argument is a
Var::NameRef referencing a named tuple table registered with
Model::add_tuple_table.
ShortStr2(Vec<Var>, Vec<ShortTuple>)
shortstr2(vars, short_tuples) — STR2+ over a short-tuple list.
Each short tuple is a partial assignment; an assignment satisfies
the constraint iff some short tuple’s literals match. GAC.
Indexes within one short tuple must be distinct.
HaggisGac(Vec<Var>, Vec<ShortTuple>)
haggisgac(vars, short_tuples) — HaggisGAC over short tuples.
Same semantics as ShortStr2; different propagator. Discrete vars only.
HaggisGacStable(Vec<Var>, Vec<ShortTuple>)
haggisgac-stable(vars, short_tuples) — backtrack-stable HaggisGAC.
Same semantics as HaggisGac. Discrete vars only.
ShortCTupleStr2(Vec<Var>, Vec<ShortTuple>)
shortctuplestr2(vars, short_tuples) — STR2+ over short cTuples.
Like ShortStr2 but allows multiple (idx, val) literals for the
same idx within one short tuple (OR semantics for that variable).
Discrete vars only.
Max(Vec<Var>, Var)
max(vars, x) — x equals the maximum value in vars.
Min(Vec<Var>, Var)
min(vars, x) — x equals the minimum value in vars.
NvalueGeq(Vec<Var>, Var)
nvaluegeq(vars, x) — at least x distinct values appear in vars.
NvalueLeq(Vec<Var>, Var)
nvalueleq(vars, x) — at most x distinct values appear in vars.
SumLeq(Vec<Var>, Var)
sumleq(vars, x) — sum of vars ≤ x.
SumGeq(Vec<Var>, Var)
sumgeq(vars, x) — sum of vars ≥ x.
Element(Vec<Var>, Var, Var)
element(vec, i, e) — vec[i] = e. 0-indexed. Not confluent.
ElementOne(Vec<Var>, Var, Var)
element_one(vec, i, e) — like Element, 1-indexed.
ElementUndefZero(Vec<Var>, Var, Var)
element_undefzero(vec, i, e) — like Element, but true with e=0 when i is out of bounds.
WatchElement(Vec<Var>, Var, Var)
watchelement(vec, i, e) — like Element but watched and GAC.
WatchElementOne(Vec<Var>, Var, Var)
watchelement_one(vec, i, e) — like WatchElement, 1-indexed.
WatchElementOneUndefZero(Vec<Var>, Var, Var)
watchelement_one_undefzero(vec, i, e) — like WatchElementOne with undefzero semantics.
WatchElementUndefZero(Vec<Var>, Var, Var)
watchelement_undefzero(vec, i, e) — like WatchElement with undefzero semantics.
WLiteral(Var, Constant)
w-literal(x, a) — x = a.
WNotLiteral(Var, Constant)
w-notliteral(x, a) — x ≠ a.
WInIntervalSet(Var, Vec<Constant>)
w-inintervalset(x, [a1,a2, b1,b2, ...]) — x is in one of the intervals.
WInRange(Var, Vec<Constant>)
w-inrange(x, [a, b]) — a ≤ x ≤ b.
WInset(Var, Vec<Constant>)
w-inset(x, vals) — x is in the set vals.
WNotInRange(Var, Vec<Constant>)
w-notinrange(x, [a, b]) — x < a or x > b.
WNotInset(Var, Vec<Constant>)
w-notinset(x, vals) — x is not in the set vals.
Abs(Var, Var)
abs(x, y) — x = |y|.
DisEq(Var, Var)
diseq(x, y) — x ≠ y. Arc consistency.
Eq(Var, Var)
eq(x, y) — x = y. Bounds consistency.
MinusEq(Var, Var)
minuseq(x, y) — x = -y. Bounds consistency.
GacEq(Var, Var)
gaceq(x, y) — x = y. GAC.
WatchLess(Var, Var)
watchless(x, y) — x < y. Watched.
WatchNeq(Var, Var)
watchneq(x, y) — x ≠ y. Watched (may be faster when one var is assigned early).
Ineq(Var, Var, Constant)
ineq(x, y, k) — x ≤ y + k. k must be a constant.
False
false — always false. Makes a model unsatisfiable.
True
true — always true.
Trait Implementations§
Source§impl Clone for Constraint
impl Clone for Constraint
Source§fn clone(&self) -> Constraint
fn clone(&self) -> Constraint
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Constraint
impl Debug for Constraint
Source§impl Display for Constraint
impl Display for Constraint
impl Eq for Constraint
Source§impl PartialEq for Constraint
impl PartialEq for Constraint
impl StructuralPartialEq for Constraint
Auto Trait Implementations§
impl Freeze for Constraint
impl RefUnwindSafe for Constraint
impl Send for Constraint
impl Sync for Constraint
impl Unpin for Constraint
impl UnsafeUnpin for Constraint
impl UnwindSafe for Constraint
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 104 bytes
Size for each variant:
Difference: 80 bytesDiv: 80 bytesDivUndefZero: 80 bytesModulo: 80 bytesModuloUndefZero: 80 bytesPow: 80 bytesProduct: 80 bytesWeightedSumGeq: 80 bytesWeightedSumLeq: 80 bytesCheckAssign: 16 bytesCheckGsa: 16 bytesForwardChecking: 16 bytesReify: 40 bytesReifyImply: 40 bytesReifyImplyQuick: 40 bytesWatchedAnd: 32 bytesWatchedOr: 32 bytesGacAllDiff: 32 bytesAllDiff: 32 bytesAllDiffMatrix: 40 bytesWatchSumGeq: 40 bytesWatchSumLeq: 40 bytesOccurrenceGeq: 48 bytesOccurrenceLeq: 48 bytesOccurrence: 64 bytesLitSumGeq: 64 bytesGcc: 80 bytesGccWeak: 80 bytesLexLeqRv: 56 bytesLexLeq: 56 bytesLexLess: 56 bytesLexLeqQuick: 56 bytesLexLessQuick: 56 bytesWatchVecNeq: 56 bytesWatchVecExistsLess: 56 bytesHamming: 64 bytesNotHamming: 64 bytesFrameUpdate: 104 bytesNegativeTable: 56 bytesTable: 56 bytesGacSchema: 56 bytesLightTable: 56 bytesMddc: 56 bytesNegativeMddc: 56 bytesStr2Plus: 56 bytesShortStr2: 56 bytesHaggisGac: 56 bytesHaggisGacStable: 56 bytesShortCTupleStr2: 56 bytesMax: 56 bytesMin: 56 bytesNvalueGeq: 56 bytesNvalueLeq: 56 bytesSumLeq: 56 bytesSumGeq: 56 bytesElement: 80 bytesElementOne: 80 bytesElementUndefZero: 80 bytesWatchElement: 80 bytesWatchElementOne: 80 bytesWatchElementOneUndefZero: 80 bytesWatchElementUndefZero: 80 bytesWLiteral: 40 bytesWNotLiteral: 40 bytesWInIntervalSet: 56 bytesWInRange: 56 bytesWInset: 56 bytesWNotInRange: 56 bytesWNotInset: 56 bytesAbs: 56 bytesDisEq: 56 bytesEq: 56 bytesMinusEq: 56 bytesGacEq: 56 bytesWatchLess: 56 bytesWatchNeq: 56 bytesIneq: 64 bytesFalse: 0 bytesTrue: 0 bytes