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>
impl<'model> Constraint<'model>
pub fn post(&self) -> Result<(), SolverError>
Sourcepub fn reify(&self) -> BoolVar<'model>
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.
Sourcepub fn reify_with(&self, boolvar: &BoolVar<'model>)
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.
Sourcepub fn implies(&self, boolvar: &BoolVar<'model>)
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.
Sourcepub fn implied_by(&self, boolvar: &BoolVar<'model>)
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.
Sourcepub fn is_satisfied(&self) -> ESat
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.
pub fn status(&self) -> ConstraintStatus
Sourcepub fn if_then_else(
&self,
then_constraint: &Constraint<'model>,
else_constraint: &Constraint<'model>,
)
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.
Sourcepub fn if_then(&self, then_constraint: &Constraint<'model>)
pub fn if_then(&self, then_constraint: &Constraint<'model>)
Creates an if-then constraint: self constraint -> then_constraint.
Sourcepub fn if_only_if(&self, constraint: &Constraint<'model>)
pub fn if_only_if(&self, constraint: &Constraint<'model>)
Posts an equivalence constraint stating that:
self constraint is satisfied (or true) <=> constraint is satisfied.