Enum PbConstraint

Source
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

Source

pub fn new_unit(lit: Lit) -> Self

Constructs a new unit constraint enforcing a literal

Source

pub fn new_ub<LI: IWLitIter>(lits: LI, b: isize) -> Self

Constructs a new upper bound pseudo-boolean constraint (weighted sum of lits <= b)

Source

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)

Source

pub fn new_lb<LI: IWLitIter>(lits: LI, b: isize) -> Self

Constructs a new lower bound pseudo-boolean constraint (weighted sum of lits >= b)

Source

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)

Source

pub fn new_eq<LI: IWLitIter>(lits: LI, b: isize) -> Self

Constructs a new equality pseudo-boolean constraint (weighted sum of lits = b)

Source

pub fn new_eq_unsigned<LI: WLitIter>(lits: LI, b: isize) -> Self

Constructs a new equality pseudo-boolean constraint (weighted sum of lits = b)

Source

pub fn weight_sum(&self) -> usize

Gets the sum of weights of the constraint

Source

pub fn set_bound(&mut self, bound: isize)

Sets the bound of the constraint

Source

pub fn add<LI: IWLitIter>(&mut self, lits: LI)

Adds literals to the cardinality constraint

Source

pub fn bound(&self) -> isize

Gets the bound of the constraint

Source

pub fn len(&self) -> usize

Gets the number of literals in the constraint

Source

pub fn is_empty(&self) -> bool

Checks whether the constraint is empty

Source

pub fn n_lits(&self) -> usize

Gets the number of literals in the constraint

Source

pub fn is_tautology(&self) -> bool

Checks if the constraint is always satisfied

Source

pub fn is_unsat(&self) -> bool

Checks if the constraint is unsatisfiable

Source

pub fn is_positive_assignment(&self) -> bool

Checks if the constraint assigns all literals to true

Source

pub fn is_negative_assignment(&self) -> bool

Checks if the constraint assigns all literals to false

Source

pub fn is_card(&self) -> bool

Checks if the constraint is a cardinality constraint

Source

pub fn is_clause(&self) -> bool

Checks if the constraint is a clause

Source

pub fn normalize(self) -> Self

Normalizes the constraint. This sorts the literal and merges duplicates. Comparing two normalized constraints checks their logical equivalence.

Source

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

Source

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

Source

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

Source

pub fn into_lits(self) -> impl WLitIter

Gets the (positively) weighted literals that are in the constraint

Source

pub fn iter(&self) -> Iter<'_, (Lit, usize)>

Gets an iterator over the literals in the constraint

Source

pub fn iter_mut(&mut self) -> IterMut<'_, (Lit, usize)>

Gets a mutable iterator over the literals in the constraint

Source

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

Source§

fn clone(&self) -> PbConstraint

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ConstraintLike<Var> for PbConstraint

Available on crate feature proof-logging only.
Source§

fn rhs(&self) -> isize

Gets the operator and right hand side of the constraint
Source§

fn sum_iter(&self) -> impl Iterator<Item = (isize, Axiom<Var>)>

Gets an iterator over the coefficient literal pairs in the constraint
Source§

impl Debug for PbConstraint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for PbConstraint

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for PbConstraint

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<CardConstraint> for PbConstraint

Source§

fn from(value: CardConstraint) -> Self

Converts to this type from the input type.
Source§

impl From<Clause> for PbConstraint

Source§

fn from(value: Clause) -> Self

Converts to this type from the input type.
Source§

impl<'slf> IntoIterator for &'slf PbConstraint

Source§

type Item = &'slf (Lit, usize)

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'slf, (Lit, usize)>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'slf> IntoIterator for &'slf mut PbConstraint

Source§

type Item = &'slf mut (Lit, usize)

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'slf, (Lit, usize)>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for PbConstraint

Source§

fn eq(&self, other: &PbConstraint) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for PbConstraint

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Eq for PbConstraint

Source§

impl StructuralPartialEq for PbConstraint

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,