Enum BddPtr

Source
pub enum BddPtr<'a> {
    Compl(&'a BddNode<'a>),
    Reg(&'a BddNode<'a>),
    PtrTrue,
    PtrFalse,
}
Expand description

Core BDD pointer datatype

Variants§

§

Compl(&'a BddNode<'a>)

§

Reg(&'a BddNode<'a>)

§

PtrTrue

§

PtrFalse

Implementations§

Source§

impl<'a> BddPtr<'a>

Source

pub fn var_safe(&self) -> Option<VarLabel>

Gets the varlabel of &self

Source

pub fn to_reg(&self) -> BddPtr<'_>

convert a BddPtr into a regular (non-complemented) pointer, but does not change the underlying node.

use rsdd::repr::{
    BddNode, BddPtr,
    VarLabel
};

assert_eq!(BddPtr::PtrTrue, BddPtr::PtrTrue.to_reg());
assert_eq!(BddPtr::PtrTrue, BddPtr::PtrFalse.to_reg());

// this node represents the positive literal 0
let node = BddNode::new(VarLabel::new(0), BddPtr::PtrFalse, BddPtr::PtrTrue);

assert_eq!(BddPtr::Reg(&node), BddPtr::Compl(&node).to_reg());
assert_eq!(BddPtr::Reg(&node), BddPtr::Reg(&node).to_reg());
Source

pub fn low(&self) -> BddPtr<'a>

use rsdd::repr::{
    BddNode, BddPtr,
    VarLabel
};

// this node represents the positive literal 0
let node = BddNode::new(VarLabel::new(0), BddPtr::PtrFalse, BddPtr::PtrTrue);

// for regular BDDs, this behaves "normally"
assert_eq!(BddPtr::Reg(&node).low(), BddPtr::PtrFalse);
// but, for complemented edges, it negates the low edge
assert_eq!(BddPtr::Compl(&node).low(), BddPtr::PtrTrue);
Source

pub fn low_raw(&self) -> BddPtr<'a>

use rsdd::repr::{
    BddNode, BddPtr,
    VarLabel
};

// this node represents the positive literal 0
let node = BddNode::new(VarLabel::new(0), BddPtr::PtrFalse, BddPtr::PtrTrue);

// for regular BDDs, this behaves "normally"
assert_eq!(BddPtr::Reg(&node).low_raw(), BddPtr::PtrFalse);
// but, for complemented edges, it does not negate the low edge
assert_eq!(BddPtr::Compl(&node).low_raw(), BddPtr::PtrFalse);
Source

pub fn high_raw(&self) -> BddPtr<'a>

use rsdd::repr::{
    BddNode, BddPtr,
    VarLabel
};

// this node represents the positive literal 0
let node = BddNode::new(VarLabel::new(0), BddPtr::PtrFalse, BddPtr::PtrTrue);

// for regular BDDs, this behaves "normally"
assert_eq!(BddPtr::Reg(&node).high_raw(), BddPtr::PtrTrue);
// but, for complemented edges, it does not negate the high edge
assert_eq!(BddPtr::Compl(&node).high_raw(), BddPtr::PtrTrue);
Source

pub fn high(&self) -> BddPtr<'a>

use rsdd::repr::{
    BddNode, BddPtr,
    VarLabel
};

// this node represents the positive literal 0
let node = BddNode::new(VarLabel::new(0), BddPtr::PtrFalse, BddPtr::PtrTrue);

// for regular BDDs, this behaves "normally"
assert_eq!(BddPtr::Reg(&node).high(), BddPtr::PtrTrue);
// but, for complemented edges, it negates the high edge
assert_eq!(BddPtr::Compl(&node).high(), BddPtr::PtrFalse);
Source

pub fn clear_scratch(&self)

Traverses the BDD and clears all scratch memory (sets it equal to 0)

Source

pub fn is_const(&self) -> bool

true if the BddPtr points to a constant (i.e., True or False)

use rsdd::repr::{
    BddNode, BddPtr,
    VarLabel
};

assert!(BddPtr::is_const(&BddPtr::PtrTrue));
assert!(BddPtr::is_const(&BddPtr::PtrFalse));

let node = BddNode::new(VarLabel::new(0), BddPtr::PtrFalse, BddPtr::PtrTrue);

assert!(!BddPtr::is_const(&BddPtr::Reg(&node)));
assert!(!BddPtr::is_const(&BddPtr::Compl(&node)));
Source

pub fn scratch<T: ?Sized + Clone + 'static>(&self) -> Option<T>

Gets the scratch value stored in &self

Panics if not node.

Source

pub fn set_scratch<T: 'static>(&self, v: T)

Set the scratch in this node to the value v.

Panics if not a node.

Invariant: values stored in set_scratch must not outlive the provided allocator alloc (i.e., calling scratch involves dereferencing a pointer stored in alloc)

Source

pub fn is_scratch_cleared(&self) -> bool

true if the scratch is current cleared

Source

pub fn to_string_debug(&self) -> String

Source

pub fn print_bdd_lbl(&self, map: &HashMap<VarLabel, VarLabel>) -> String

Print a debug form of the BDD with the label remapping given by map

Source

pub fn print_bdd(&self) -> String

Source

pub fn bdd_fold<T, F: Fn(VarLabel, T, T) -> T>( &self, f: &F, low_v: T, high_v: T, ) -> T
where T: 'static + Clone + Copy + Debug,

Source

pub fn marginal_map( &self, vars: &[VarLabel], num_vars: usize, wmc: &WmcParams<RealSemiring>, ) -> (f64, PartialModel)

Computes the marginal map over variables vars of ptr I.e., computes argmax_{v in vars} \sum_{v not in vars} w(ptr)

Source

pub fn meu( &self, decision_vars: &[VarLabel], num_vars: usize, wmc: &WmcParams<ExpectedUtility>, ) -> (ExpectedUtility, PartialModel)

maximum expected utility calc

Source

pub fn bb<T>( &self, join_vars: &[VarLabel], num_vars: usize, wmc: &WmcParams<T>, ) -> (T, PartialModel)
where T: 'static + BBSemiring,

branch and bound generic over T a BBAlgebra.

Source

pub fn cached_semantic_hash<const P: u128>( &self, order: &VarOrder, map: &WmcParams<FiniteField<P>>, ) -> FiniteField<P>

performs a semantic hash and caches the result on the node

Trait Implementations§

Source§

impl<'a> Clone for BddPtr<'a>

Source§

fn clone(&self) -> BddPtr<'a>

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<'a> DDNNFPtr<'a> for BddPtr<'a>

Source§

fn is_neg(&self) -> bool

True is this is a complemented edge pointer

Source§

fn true_ptr() -> BddPtr<'a>

Generate a pointer to the true constant
Source§

fn false_ptr() -> BddPtr<'a>

Generate a pointer to the false constant
Source§

fn is_true(&self) -> bool

True if self is a true constant, false otherwise
Source§

fn is_false(&self) -> bool

True if self is a false constant, false otherwise
Source§

fn fold<T, F: Fn(DDNNF<T>) -> T>(&self, f: F) -> T
where T: 'static + Clone + Copy + Debug,

performs a memoized bottom-up pass with aggregating function f calls
Source§

fn count_nodes(&self) -> usize

count the number of nodes in this representation
Source§

fn neg(&self) -> Self

Negate the pointer
Source§

fn unsmoothed_wmc<T>(&self, params: &WmcParams<T>) -> T
where T: 'static + Semiring + Add<Output = T> + Mul<Output = T>,

Unsmoothed weighted-model count
Source§

fn evaluate(&self, instantations: &[bool]) -> bool

Source§

fn semantic_hash<const P: u128>( &self, map: &WmcParams<FiniteField<P>>, ) -> FiniteField<P>

compute the semantic hash for this pointer
Source§

impl<'a> Debug for BddPtr<'a>

Source§

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

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

impl<'a> Hash for BddPtr<'a>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<'a> Ord for BddPtr<'a>

Source§

fn cmp(&self, other: &BddPtr<'a>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<'a> PartialEq for BddPtr<'a>

Source§

fn eq(&self, other: &Self) -> 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<'a> PartialOrd for BddPtr<'a>

Source§

fn partial_cmp(&self, other: &BddPtr<'a>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<'a> PartialVariableOrder for BddPtr<'a>

Source§

impl<'a> Copy for BddPtr<'a>

Source§

impl<'a> Eq for BddPtr<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for BddPtr<'a>

§

impl<'a> !RefUnwindSafe for BddPtr<'a>

§

impl<'a> !Send for BddPtr<'a>

§

impl<'a> !Sync for BddPtr<'a>

§

impl<'a> Unpin for BddPtr<'a>

§

impl<'a> !UnwindSafe for BddPtr<'a>

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<'a, T> BottomUpBuilder<'a, BddPtr<'a>> for T
where T: BddBuilder<'a>,

Source§

fn var(&'a self, label: VarLabel, polarity: bool) -> BddPtr<'a>

Get a pointer to the variable with label lbl and polarity polarity

Source§

fn and(&'a self, f: BddPtr<'a>, g: BddPtr<'a>) -> BddPtr<'a>

Produce a new BDD that is the result of conjoining f and g

let mut builder = RobddBuilder::<AllIteTable<BddPtr>>::new_with_linear_order(10);
let lbl_a = builder.new_label();
let a = builder.var(lbl_a, true);
let a_and_not_a = builder.and(a, a.neg());
assert!(a_and_not_a.is_false());
Source§

fn ite(&'a self, f: BddPtr<'a>, g: BddPtr<'a>, h: BddPtr<'a>) -> BddPtr<'a>

if f then g else h

Source§

fn iff(&'a self, f: BddPtr<'a>, g: BddPtr<'a>) -> BddPtr<'a>

Compute the Boolean function f iff g

Source§

fn exists(&'a self, bdd: BddPtr<'a>, lbl: VarLabel) -> BddPtr<'a>

Existentially quantifies out the variable lbl from f

Source§

fn condition( &'a self, bdd: BddPtr<'a>, lbl: VarLabel, value: bool, ) -> BddPtr<'a>

Compute the Boolean function f | var = value

Source§

fn compile_cnf(&'a self, cnf: &Cnf) -> BddPtr<'a>

Compile a BDD from a CNF

Source§

fn true_ptr(&self) -> BddPtr<'a>

Source§

fn false_ptr(&self) -> BddPtr<'a>

Source§

fn eq(&'a self, a: BddPtr<'a>, b: BddPtr<'a>) -> bool

Test for semantic equality (not pointer/structural equality)
Source§

fn negate(&'a self, f: BddPtr<'a>) -> BddPtr<'a>

Source§

fn xor(&'a self, f: BddPtr<'a>, g: BddPtr<'a>) -> BddPtr<'a>

logical exclusive-or
Source§

fn or(&'a self, a: Ptr, b: Ptr) -> Ptr

Compute the Boolean function f || g by default, or is defined using de morgan’s law as and
Source§

fn compose(&'a self, f: Ptr, lbl: VarLabel, g: Ptr) -> Ptr

compose g into f for variable v I.e., computes the logical function (exists v. (g <=> v) /\ f).
Source§

fn compile_logical_expr(&'a self, expr: &LogicalExpr) -> Ptr

directly compile a logical expression
Source§

fn compile_plan(&'a self, expr: &BottomUpPlan) -> Ptr

Compiles from a BottomUpPlan, which represents a deferred computation
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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> 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<'a, T> TopDownBuilder<'a, BddPtr<'a>> for T
where T: DecisionNNFBuilder<'a>,

Source§

fn var(&'a self, lbl: VarLabel, polarity: bool) -> BddPtr<'a>

Get a pointer to the variable with label lbl and polarity polarity

Source§

fn condition( &'a self, bdd: BddPtr<'a>, lbl: VarLabel, value: bool, ) -> BddPtr<'a>

Compute the Boolean function f | var = value

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.
§

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

§

fn vzip(self) -> V

Source§

impl<N> NodeTrait for N
where N: Copy + Ord + Hash,