pub enum ConstraintEnum<D: Domain> {
NotEqual(NotEqual),
AllDifferent(AllDifferent),
AllDifferentExcept(AllDifferentExcept<D::Value>),
Lambda(LambdaConstraint<D>),
Soft(SoftLambdaConstraint<D>),
Custom(Box<dyn Constraint<D>>),
}Expand description
Enum-dispatched constraint storage. Avoids vtable indirection for built-in types.
Variants§
NotEqual(NotEqual)
AllDifferent(AllDifferent)
AllDifferentExcept(AllDifferentExcept<D::Value>)
Lambda(LambdaConstraint<D>)
Soft(SoftLambdaConstraint<D>)
Custom(Box<dyn Constraint<D>>)
Implementations§
Source§impl<D: Domain> ConstraintEnum<D>
impl<D: Domain> ConstraintEnum<D>
pub fn scope(&self) -> &[VarId] ⓘ
pub fn check(&self, assignment: &[Option<D::Value>]) -> bool
pub fn revise(&self, vars: &mut [Variable<D>], depth: usize) -> Revision
Sourcepub fn soft_penalty(&self, assignment: &[Option<D::Value>]) -> f64
pub fn soft_penalty(&self, assignment: &[Option<D::Value>]) -> f64
For soft constraints, compute the penalty if the underlying predicate is violated. Returns 0.0 for hard constraints or satisfied soft constraints.
Trait Implementations§
Auto Trait Implementations§
impl<D> Freeze for ConstraintEnum<D>
impl<D> !RefUnwindSafe for ConstraintEnum<D>
impl<D> !Send for ConstraintEnum<D>
impl<D> !Sync for ConstraintEnum<D>
impl<D> Unpin for ConstraintEnum<D>
impl<D> UnsafeUnpin for ConstraintEnum<D>
impl<D> !UnwindSafe for ConstraintEnum<D>
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
Mutably borrows from an owned value. Read more