pub enum PbConstraint {
Ub(PbUbConstr),
Lb(PbLbConstr),
Eq(PbEqConstr),
}
Expand description
Type representing a pseudo-boolean constraint. When literals are added to a constraint, the constraint is transformed so that all coefficients are positive.
Variants§
Ub(PbUbConstr)
An upper bound pseudo-boolean constraint
Lb(PbLbConstr)
A lower bound pseudo-boolean constraint
Eq(PbEqConstr)
An equality pseudo-boolean constraint
Implementations§
Source§impl PbConstraint
impl PbConstraint
Sourcepub fn new_ub<LI: IWLitIter>(lits: LI, b: isize) -> Self
pub fn new_ub<LI: IWLitIter>(lits: LI, b: isize) -> Self
Constructs a new upper bound pseudo-boolean constraint (weighted sum of lits <= b
)
Sourcepub fn new_ub_unsigned<LI: WLitIter>(lits: LI, b: isize) -> Self
pub fn new_ub_unsigned<LI: WLitIter>(lits: LI, b: isize) -> Self
Constructs a new upper bound pseudo-boolean constraint (weighted sum of lits <= b
)
Sourcepub fn new_lb<LI: IWLitIter>(lits: LI, b: isize) -> Self
pub fn new_lb<LI: IWLitIter>(lits: LI, b: isize) -> Self
Constructs a new lower bound pseudo-boolean constraint (weighted sum of lits >= b
)
Sourcepub fn new_lb_unsigned<LI: WLitIter>(lits: LI, b: isize) -> Self
pub fn new_lb_unsigned<LI: WLitIter>(lits: LI, b: isize) -> Self
Constructs a new lower bound pseudo-boolean constraint (weighted sum of lits >= b
)
Sourcepub fn new_eq<LI: IWLitIter>(lits: LI, b: isize) -> Self
pub fn new_eq<LI: IWLitIter>(lits: LI, b: isize) -> Self
Constructs a new equality pseudo-boolean constraint (weighted sum of lits = b
)
Sourcepub fn new_eq_unsigned<LI: WLitIter>(lits: LI, b: isize) -> Self
pub fn new_eq_unsigned<LI: WLitIter>(lits: LI, b: isize) -> Self
Constructs a new equality pseudo-boolean constraint (weighted sum of lits = b
)
Sourcepub fn weight_sum(&self) -> usize
pub fn weight_sum(&self) -> usize
Gets the sum of weights of 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 sorts the literal and merges duplicates. Comparing two normalized constraints checks their logical equivalence.
Sourcepub fn into_card_constr(self) -> Result<CardConstraint, PbToCardError>
pub fn into_card_constr(self) -> Result<CardConstraint, PbToCardError>
Converts the pseudo-boolean constraint into a cardinality constraint, only if the constraint is already a cardinality
§Errors
If the constraint is not a cardinality constraint, including when it is a tautology or
unsat, returns PbToCardError
Sourcepub fn extend_to_card_constr(self) -> CardConstraint
pub fn extend_to_card_constr(self) -> CardConstraint
Extends the constraint into a cardinality constraint by repeating literals as often as their coefficient requires
§Panics
If the constraint is UNSAT or a tautology
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 into_lits(self) -> impl WLitIter
pub fn into_lits(self) -> impl WLitIter
Gets the (positively) weighted literals that are in the constraint
Sourcepub fn iter(&self) -> Iter<'_, (Lit, usize)>
pub fn iter(&self) -> Iter<'_, (Lit, usize)>
Gets an iterator over the literals in the constraint
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, (Lit, usize)>
pub fn iter_mut(&mut self) -> IterMut<'_, (Lit, usize)>
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 PB constraint is satisfied by the given assignment
Trait Implementations§
Source§impl Clone for PbConstraint
impl Clone for PbConstraint
Source§fn clone(&self) -> PbConstraint
fn clone(&self) -> PbConstraint
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 PbConstraint
Available on crate feature proof-logging
only.
impl ConstraintLike<Var> for PbConstraint
proof-logging
only.Source§impl Debug for PbConstraint
impl Debug for PbConstraint
Source§impl<'de> Deserialize<'de> for PbConstraint
impl<'de> Deserialize<'de> for PbConstraint
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 PbConstraint
impl Display for PbConstraint
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 PbConstraint
impl From<Clause> for PbConstraint
Source§impl<'slf> IntoIterator for &'slf PbConstraint
impl<'slf> IntoIterator for &'slf PbConstraint
Source§impl<'slf> IntoIterator for &'slf mut PbConstraint
impl<'slf> IntoIterator for &'slf mut PbConstraint
Source§impl PartialEq for PbConstraint
impl PartialEq for PbConstraint
Source§impl Serialize for PbConstraint
impl Serialize for PbConstraint
impl Eq for PbConstraint
impl StructuralPartialEq for PbConstraint
Auto Trait Implementations§
impl Freeze for PbConstraint
impl RefUnwindSafe for PbConstraint
impl Send for PbConstraint
impl Sync for PbConstraint
impl Unpin for PbConstraint
impl UnwindSafe for PbConstraint
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