pub struct BddManager { /* private fields */ }Expand description
A Binary Decision Diagram manager. Maintains a unique table to ensure node sharing and canonical representation.
Implementations§
Source§impl BddManager
impl BddManager
Sourcepub fn constant_false(&self) -> NodeId
pub fn constant_false(&self) -> NodeId
Returns the FALSE constant.
Sourcepub fn constant_true(&self) -> NodeId
pub fn constant_true(&self) -> NodeId
Returns the TRUE constant.
Sourcepub fn not(&mut self, node: NodeId) -> NodeId
pub fn not(&mut self, node: NodeId) -> NodeId
Negates a BDD node.
Runs on an explicit work-stack with a computed table (not_cache),
rather than the tree recursion this replaces. Two defects are fixed:
- The recursion had no computed table, so every shared node was
re-expanded.
noton a 40-variable parity BDD — O(n) nodes, 2ⁿ tree unfoldings — never returned. - Recursion depth was the BDD height, i.e. the variable count, with
no guard. The return type is
NodeId, so a depth cap could only have produced a silently wrong diagram.
Sourcepub fn and(&mut self, left: NodeId, right: NodeId) -> NodeId
pub fn and(&mut self, left: NodeId, right: NodeId) -> NodeId
Computes the AND of two BDD nodes.
Sourcepub fn xor(&mut self, left: NodeId, right: NodeId) -> NodeId
pub fn xor(&mut self, left: NodeId, right: NodeId) -> NodeId
Computes the XOR of two BDD nodes.
Sourcepub fn implies(&mut self, left: NodeId, right: NodeId) -> NodeId
pub fn implies(&mut self, left: NodeId, right: NodeId) -> NodeId
Computes the implication: left => right (equivalent to !left | right)
Sourcepub fn iff(&mut self, left: NodeId, right: NodeId) -> NodeId
pub fn iff(&mut self, left: NodeId, right: NodeId) -> NodeId
Computes the equivalence: left <=> right
Sourcepub fn ite(
&mut self,
cond: NodeId,
then_node: NodeId,
else_node: NodeId,
) -> NodeId
pub fn ite( &mut self, cond: NodeId, then_node: NodeId, else_node: NodeId, ) -> NodeId
If-then-else operation: if cond then then_node else else_node.
Runs on an explicit work-stack with the standard ITE computed table
keyed on the (cond, then, else) triple. The recursion this replaces
had neither: with triple fan-out and no memo, shared cofactors of the
hash-consed diagram were re-expanded exponentially, and the depth was
the (unguarded) variable count. NodeId has no error channel, so a
depth cap could only have returned a silently wrong diagram.
Sourcepub fn eval(&self, node: NodeId, assignment: &FxHashMap<VarId, bool>) -> bool
pub fn eval(&self, node: NodeId, assignment: &FxHashMap<VarId, bool>) -> bool
Evaluates a BDD with a given variable assignment.
Sourcepub fn sat_count(&self, node: NodeId, num_vars: u32) -> u64
pub fn sat_count(&self, node: NodeId, num_vars: u32) -> u64
Counts the number of satisfying assignments for a BDD.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Returns the number of nodes in the manager.
Sourcepub fn clear_cache(&mut self)
pub fn clear_cache(&mut self)
Clears the operation caches (useful for memory management).
Trait Implementations§
Source§impl Clone for BddManager
impl Clone for BddManager
Source§fn clone(&self) -> BddManager
fn clone(&self) -> BddManager
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more