pub enum BddPtr<'a> {
Compl(&'a BddNode<'a>),
Reg(&'a BddNode<'a>),
PtrTrue,
PtrFalse,
}
Expand description
Core BDD pointer datatype
Variants§
Implementations§
Source§impl<'a> BddPtr<'a>
impl<'a> BddPtr<'a>
Sourcepub fn to_reg(&self) -> BddPtr<'_>
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());
Sourcepub fn low(&self) -> BddPtr<'a>
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);
Sourcepub fn low_raw(&self) -> BddPtr<'a>
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);
Sourcepub fn high_raw(&self) -> BddPtr<'a>
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);
Sourcepub fn high(&self) -> BddPtr<'a>
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);
Sourcepub fn clear_scratch(&self)
pub fn clear_scratch(&self)
Traverses the BDD and clears all scratch memory (sets it equal to 0)
Sourcepub fn is_const(&self) -> bool
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)));
Sourcepub fn scratch<T: ?Sized + Clone + 'static>(&self) -> Option<T>
pub fn scratch<T: ?Sized + Clone + 'static>(&self) -> Option<T>
Gets the scratch value stored in &self
Panics if not node.
Sourcepub fn set_scratch<T: 'static>(&self, v: T)
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
)
Sourcepub fn is_scratch_cleared(&self) -> bool
pub fn is_scratch_cleared(&self) -> bool
true if the scratch is current cleared
pub fn to_string_debug(&self) -> String
Sourcepub fn print_bdd_lbl(&self, map: &HashMap<VarLabel, VarLabel>) -> String
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
pub fn print_bdd(&self) -> String
pub fn bdd_fold<T, F: Fn(VarLabel, T, T) -> T>( &self, f: &F, low_v: T, high_v: T, ) -> T
Sourcepub fn marginal_map(
&self,
vars: &[VarLabel],
num_vars: usize,
wmc: &WmcParams<RealSemiring>,
) -> (f64, PartialModel)
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)
Sourcepub fn meu(
&self,
decision_vars: &[VarLabel],
num_vars: usize,
wmc: &WmcParams<ExpectedUtility>,
) -> (ExpectedUtility, PartialModel)
pub fn meu( &self, decision_vars: &[VarLabel], num_vars: usize, wmc: &WmcParams<ExpectedUtility>, ) -> (ExpectedUtility, PartialModel)
maximum expected utility calc
Sourcepub fn bb<T>(
&self,
join_vars: &[VarLabel],
num_vars: usize,
wmc: &WmcParams<T>,
) -> (T, PartialModel)where
T: 'static + BBSemiring,
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.
Sourcepub fn cached_semantic_hash<const P: u128>(
&self,
order: &VarOrder,
map: &WmcParams<FiniteField<P>>,
) -> FiniteField<P>
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> DDNNFPtr<'a> for BddPtr<'a>
impl<'a> DDNNFPtr<'a> for BddPtr<'a>
Source§fn fold<T, F: Fn(DDNNF<T>) -> T>(&self, f: F) -> T
fn fold<T, F: Fn(DDNNF<T>) -> T>(&self, f: F) -> T
f
callsSource§fn count_nodes(&self) -> usize
fn count_nodes(&self) -> usize
Source§fn unsmoothed_wmc<T>(&self, params: &WmcParams<T>) -> T
fn unsmoothed_wmc<T>(&self, params: &WmcParams<T>) -> T
fn evaluate(&self, instantations: &[bool]) -> bool
Source§fn semantic_hash<const P: u128>(
&self,
map: &WmcParams<FiniteField<P>>,
) -> FiniteField<P>
fn semantic_hash<const P: u128>( &self, map: &WmcParams<FiniteField<P>>, ) -> FiniteField<P>
Source§impl<'a> Ord for BddPtr<'a>
impl<'a> Ord for BddPtr<'a>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<'a> PartialOrd for BddPtr<'a>
impl<'a> PartialOrd for BddPtr<'a>
impl<'a> Copy for BddPtr<'a>
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> 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<'a, T> BottomUpBuilder<'a, BddPtr<'a>> for Twhere
T: BddBuilder<'a>,
impl<'a, T> BottomUpBuilder<'a, BddPtr<'a>> for Twhere
T: BddBuilder<'a>,
Source§fn var(&'a self, label: VarLabel, polarity: bool) -> BddPtr<'a>
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>
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>
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>
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>
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>
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>
fn compile_cnf(&'a self, cnf: &Cnf) -> BddPtr<'a>
Compile a BDD from a CNF
fn true_ptr(&self) -> BddPtr<'a>
fn false_ptr(&self) -> BddPtr<'a>
Source§fn eq(&'a self, a: BddPtr<'a>, b: BddPtr<'a>) -> bool
fn eq(&'a self, a: BddPtr<'a>, b: BddPtr<'a>) -> bool
fn negate(&'a self, f: BddPtr<'a>) -> BddPtr<'a>
Source§fn or(&'a self, a: Ptr, b: Ptr) -> Ptr
fn or(&'a self, a: Ptr, b: Ptr) -> Ptr
f || g
by default, or is defined using de morgan’s law as andSource§fn compose(&'a self, f: Ptr, lbl: VarLabel, g: Ptr) -> Ptr
fn compose(&'a self, f: Ptr, lbl: VarLabel, g: Ptr) -> Ptr
Source§fn compile_logical_expr(&'a self, expr: &LogicalExpr) -> Ptr
fn compile_logical_expr(&'a self, expr: &LogicalExpr) -> Ptr
Source§fn compile_plan(&'a self, expr: &BottomUpPlan) -> Ptr
fn compile_plan(&'a self, expr: &BottomUpPlan) -> Ptr
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.