pub enum CardConstraint {
Ub(CardUbConstr),
Lb(CardLbConstr),
Eq(CardEqConstr),
}Expand description
Type representing a cardinality constraint.
Variants§
Ub(CardUbConstr)
An upper bound cardinality constraint
Lb(CardLbConstr)
A lower bound cardinality constraint
Eq(CardEqConstr)
An equality cardinality constraint
Implementations§
Source§impl CardConstraint
impl CardConstraint
Sourcepub fn new_ub<LI: LitIter>(lits: LI, b: usize) -> Self
pub fn new_ub<LI: LitIter>(lits: LI, b: usize) -> Self
Constructs a new upper bound cardinality constraint (sum of lits <= b)
Sourcepub fn new_lb<LI: LitIter>(lits: LI, b: usize) -> Self
pub fn new_lb<LI: LitIter>(lits: LI, b: usize) -> Self
Constructs a new lower bound cardinality constraint (sum of lits >= b)
Sourcepub fn new_eq<LI: LitIter>(lits: LI, b: usize) -> Self
pub fn new_eq<LI: LitIter>(lits: LI, b: usize) -> Self
Constructs a new equality cardinality constraint (sum of lits = b)
Sourcepub fn change_bound(&mut self, b: usize)
👎Deprecated since 0.7.0: change_bound has been renamed to set_bound
pub fn change_bound(&mut self, b: usize)
change_bound has been renamed to set_boundChanges the bound on the constraint
Sourcepub fn is_tautology(&self) -> bool
pub fn is_tautology(&self) -> bool
Checks if the constraint is always satisfied
Sourcepub fn is_positive_assignment(&self) -> bool
pub fn is_positive_assignment(&self) -> bool
Checks if the constraint assigns all literals to true
Sourcepub fn is_negative_assignment(&self) -> bool
pub fn is_negative_assignment(&self) -> bool
Checks if the constraint assigns all literals to false
Sourcepub fn normalize(self) -> Self
pub fn normalize(self) -> Self
Normalizes the constraint. This only consists of sorting the literals. Comparing two normalized constraints checks their logical equivalence.
Sourcepub fn into_clause(self) -> Result<Clause, RequiresClausal>
pub fn into_clause(self) -> Result<Clause, RequiresClausal>
Converts the constraint into a clause, if possible
§Errors
If the constraint is not a clause, returns RequiresClausal.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, Lit>
pub fn iter_mut(&mut self) -> IterMut<'_, Lit>
Gets a mutable iterator over the literals in the constraint
Sourcepub fn evaluate(&self, assign: &Assignment) -> TernaryVal
pub fn evaluate(&self, assign: &Assignment) -> TernaryVal
Checks whether the cardinality constraint is satisfied by the given assignment
Trait Implementations§
Source§impl Clone for CardConstraint
impl Clone for CardConstraint
Source§fn clone(&self) -> CardConstraint
fn clone(&self) -> CardConstraint
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl ConstraintLike<Var> for CardConstraint
Available on crate feature proof-logging only.
impl ConstraintLike<Var> for CardConstraint
proof-logging only.Source§impl Debug for CardConstraint
impl Debug for CardConstraint
Source§impl<'de> Deserialize<'de> for CardConstraint
impl<'de> Deserialize<'de> for CardConstraint
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for CardConstraint
impl Display for CardConstraint
Source§impl From<CardConstraint> for PbConstraint
impl From<CardConstraint> for PbConstraint
Source§fn from(value: CardConstraint) -> Self
fn from(value: CardConstraint) -> Self
Source§impl From<Clause> for CardConstraint
impl From<Clause> for CardConstraint
Source§impl Hash for CardConstraint
impl Hash for CardConstraint
Source§impl<'slf> IntoIterator for &'slf CardConstraint
impl<'slf> IntoIterator for &'slf CardConstraint
Source§impl<'slf> IntoIterator for &'slf mut CardConstraint
impl<'slf> IntoIterator for &'slf mut CardConstraint
Source§impl PartialEq for CardConstraint
impl PartialEq for CardConstraint
Source§impl Serialize for CardConstraint
impl Serialize for CardConstraint
impl Eq for CardConstraint
impl StructuralPartialEq for CardConstraint
Auto Trait Implementations§
impl Freeze for CardConstraint
impl RefUnwindSafe for CardConstraint
impl Send for CardConstraint
impl Sync for CardConstraint
impl Unpin for CardConstraint
impl UnwindSafe for CardConstraint
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,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more