Skip to main content

Constraint

Struct Constraint 

Source
pub struct Constraint<'model> { /* private fields */ }
Expand description

A constraint attached to a Model.

Constraints can be posted, reified, or combined to express relations between variables in the model.

Implementations§

Source§

impl<'model> Constraint<'model>

Source

pub fn post(&self) -> Result<(), SolverError>

Source

pub fn reify(&self) -> BoolVar<'model>

Reifies the constraint, i.e., returns a BoolVar whose instantiation in a solution corresponds to the satisfaction state of the constraint in this solution.

§Returns

A BoolVar that encodes the satisfaction state of the constraint.

§Panics

Panics if the backend fails to reify the constraint and returns a null handle.

Source

pub fn reify_with(&self, boolvar: &BoolVar<'model>)

Reifies the constraint with a given BoolVar whose instantiation in a solution corresponds to the satisfaction state of the constraint in this solution.

§Arguments
  • boolvar - The BoolVar to reify with.
Source

pub fn implies(&self, boolvar: &BoolVar<'model>)

Encapsulates this constraint in an implication relationship. The truth value of this constraint implies the truth value of the BoolVar.

§Arguments
  • boolvar - The BoolVar that is implied by this constraint.
Source

pub fn implied_by(&self, boolvar: &BoolVar<'model>)

Encapsulates this constraint in an implication relationship. Represents half-reification of the constraint. If the BoolVar is true, then the constraint must be satisfied.

§Arguments
  • boolvar - The BoolVar that implies this constraint.
Source

pub fn is_satisfied(&self) -> ESat

Check whether the constraint is satisfied.

Returns ESat::True if the constraint is satisfied, ESat::False if it is not, or ESat::Undefined if it is not yet possible to determine whether the constraint is satisfied or not.

§Note

This method can be useful to verify whether a constraint is satisfied (or not) regardless of the variables’ instantiation.

§Returns

The satisfaction state of the constraint.

Source

pub fn status(&self) -> ConstraintStatus

Source

pub fn if_then_else( &self, then_constraint: &Constraint<'model>, else_constraint: &Constraint<'model>, )

Posts a constraint ensuring that if self constraint is satisfied , then then_constraint must be satisfied as well. Otherwise, else_constraint must be satisfied.

Source

pub fn if_then(&self, then_constraint: &Constraint<'model>)

Creates an if-then constraint: self constraint -> then_constraint.

Source

pub fn if_only_if(&self, constraint: &Constraint<'model>)

Posts an equivalence constraint stating that: self constraint is satisfied (or true) <=> constraint is satisfied.

Auto Trait Implementations§

§

impl<'model> Freeze for Constraint<'model>

§

impl<'model> RefUnwindSafe for Constraint<'model>

§

impl<'model> !Send for Constraint<'model>

§

impl<'model> !Sync for Constraint<'model>

§

impl<'model> Unpin for Constraint<'model>

§

impl<'model> UnsafeUnpin for Constraint<'model>

§

impl<'model> UnwindSafe for Constraint<'model>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.