Skip to main content

Constraint

Enum Constraint 

Source
#[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.
  • Var alone is a single variable (or Var::ConstantAsVar for a constant in variable position).
  • Vec<Constant> is a list of integer constants (e.g. weights, values).
  • Constant alone is a single integer constant.
  • (Var, Var) in the TwoVars position means two variables.
  • Vec<Tuple> is a list of tuples (a Tuple is a Vec<Constant>).
  • Box<Constraint> means the variant wraps another constraint (reification, nested boolean operators, etc.).

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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 varsc. Fast for small c.

§

WatchSumLeq(Vec<Var>, Constant)

watchsumleq(vars, c) — sum of 0/1 varsc. 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 bc.

§

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 varsx.

§

SumGeq(Vec<Var>, Var)

sumgeq(vars, x) — sum of varsx.

§

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

Source§

fn clone(&self) -> Constraint

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Constraint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Constraint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Constraint

Source§

impl PartialEq for Constraint

Source§

fn eq(&self, other: &Constraint) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Constraint

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

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 bytes
  • Div: 80 bytes
  • DivUndefZero: 80 bytes
  • Modulo: 80 bytes
  • ModuloUndefZero: 80 bytes
  • Pow: 80 bytes
  • Product: 80 bytes
  • WeightedSumGeq: 80 bytes
  • WeightedSumLeq: 80 bytes
  • CheckAssign: 16 bytes
  • CheckGsa: 16 bytes
  • ForwardChecking: 16 bytes
  • Reify: 40 bytes
  • ReifyImply: 40 bytes
  • ReifyImplyQuick: 40 bytes
  • WatchedAnd: 32 bytes
  • WatchedOr: 32 bytes
  • GacAllDiff: 32 bytes
  • AllDiff: 32 bytes
  • AllDiffMatrix: 40 bytes
  • WatchSumGeq: 40 bytes
  • WatchSumLeq: 40 bytes
  • OccurrenceGeq: 48 bytes
  • OccurrenceLeq: 48 bytes
  • Occurrence: 64 bytes
  • LitSumGeq: 64 bytes
  • Gcc: 80 bytes
  • GccWeak: 80 bytes
  • LexLeqRv: 56 bytes
  • LexLeq: 56 bytes
  • LexLess: 56 bytes
  • LexLeqQuick: 56 bytes
  • LexLessQuick: 56 bytes
  • WatchVecNeq: 56 bytes
  • WatchVecExistsLess: 56 bytes
  • Hamming: 64 bytes
  • NotHamming: 64 bytes
  • FrameUpdate: 104 bytes
  • NegativeTable: 56 bytes
  • Table: 56 bytes
  • GacSchema: 56 bytes
  • LightTable: 56 bytes
  • Mddc: 56 bytes
  • NegativeMddc: 56 bytes
  • Str2Plus: 56 bytes
  • ShortStr2: 56 bytes
  • HaggisGac: 56 bytes
  • HaggisGacStable: 56 bytes
  • ShortCTupleStr2: 56 bytes
  • Max: 56 bytes
  • Min: 56 bytes
  • NvalueGeq: 56 bytes
  • NvalueLeq: 56 bytes
  • SumLeq: 56 bytes
  • SumGeq: 56 bytes
  • Element: 80 bytes
  • ElementOne: 80 bytes
  • ElementUndefZero: 80 bytes
  • WatchElement: 80 bytes
  • WatchElementOne: 80 bytes
  • WatchElementOneUndefZero: 80 bytes
  • WatchElementUndefZero: 80 bytes
  • WLiteral: 40 bytes
  • WNotLiteral: 40 bytes
  • WInIntervalSet: 56 bytes
  • WInRange: 56 bytes
  • WInset: 56 bytes
  • WNotInRange: 56 bytes
  • WNotInset: 56 bytes
  • Abs: 56 bytes
  • DisEq: 56 bytes
  • Eq: 56 bytes
  • MinusEq: 56 bytes
  • GacEq: 56 bytes
  • WatchLess: 56 bytes
  • WatchNeq: 56 bytes
  • Ineq: 64 bytes
  • False: 0 bytes
  • True: 0 bytes