Struct obddimal::bdd_manager::DDManager
source · [−]pub struct DDManager {
pub nodes: HashMap<NodeID, DDNode>,
order: Vec<u32>,
var2nodes: Vec<HashSet<DDNode>>,
c_table: HashMap<(NodeID, NodeID, NodeID), NodeID>,
}
Expand description
Container combining the nodes list, unique tables, information about current variable ordering and computed table.
Fields
nodes: HashMap<NodeID, DDNode>
Node List
order: Vec<u32>
Variable ordering: order[v.0] is the depth of variable v in the tree
var2nodes: Vec<HashSet<DDNode>>
Unique Table for each variable. Note that the order (depth) in the BDD may be different than the order of this vec, and is only determined by order!
c_table: HashMap<(NodeID, NodeID, NodeID), NodeID>
Computed Table: maps (f,g,h) to ite(f,g,h)
Implementations
sourceimpl DDManager
impl DDManager
sourcefn var_at_level(&self, level: u32) -> Option<VarID>
fn var_at_level(&self, level: u32) -> Option<VarID>
Find the variable at specified level
sourcefn sift_single_var(
&mut self,
var: VarID,
max_increase: Option<u32>,
f: NodeID
) -> NodeID
fn sift_single_var(
&mut self,
var: VarID,
max_increase: Option<u32>,
f: NodeID
) -> NodeID
Swap layer containing specified variable first to the bottom of the BDD, then to the top,
and then to the position which resulted in smallest BDD size.
Optional parameter max_increase
stops swapping in either direction once the difference
between BDD size and current optimum exceeds threshold.
sourcepub fn sift_all_vars(
&mut self,
f: NodeID,
progressbar: bool,
max_increase: Option<u32>
) -> NodeID
pub fn sift_all_vars(
&mut self,
f: NodeID,
progressbar: bool,
max_increase: Option<u32>
) -> NodeID
Perform sifting for every layer containing at least one variable.
If progressbar
is true
, display a progress bar in the terminal
which shows the number of layers already processed.
See Self::sift_single_var() for max_increase
parameter.
sourceimpl DDManager
impl DDManager
sourcepub fn from_instance(
instance: &mut Instance,
order: Option<Vec<u32>>,
options: Options
) -> Result<(DDManager, NodeID), String>
pub fn from_instance(
instance: &mut Instance,
order: Option<Vec<u32>>,
options: Options
) -> Result<(DDManager, NodeID), String>
Builds a BDD from a CNF read from DIMACS.
instance
- Input CNForder
- Optional initial variable ordering, see crate::static_ordering for implementationsoptions
- DVO and progress bar settings
let mut instance = dimacs::parse_dimacs("examples/trivial.dimacs");
let order = Some(static_ordering::force(&instance));
let dvo = dvo_schedules::SiftingAtThreshold::new(5);
let (man, bdd) = DDManager::from_instance(
&mut instance,
order,
Options::default().with_progressbars().with_dvo(dvo.into()),
).unwrap();
sourceimpl DDManager
impl DDManager
sourcefn collect_nodes(&self, f: NodeID) -> HashSet<NodeID>
fn collect_nodes(&self, f: NodeID) -> HashSet<NodeID>
Collect all nodes that are part of the specified function
sourceimpl DDManager
impl DDManager
sourcepub(crate) fn reduce(&mut self, v: NodeID) -> NodeID
pub(crate) fn reduce(&mut self, v: NodeID) -> NodeID
Reduces the BDD. This changes Node IDs, the new Node ID of the function passed to the function is returned. All other known Node IDs are invalid after reduce. Note: Reduction does not imply removing nodes not part of the specified function. Other functions may be present in the tree (multiple root nodes, or root above function).
See also “Graph-Based Algorithms for Boolean Function Manipulation” by Bryant (10.1109/TC.1986.1676819)
sourceimpl DDManager
impl DDManager
sourcefn ensure_order(&mut self, target: VarID)
fn ensure_order(&mut self, target: VarID)
Ensure order vec is valid up to specified variable
sourcefn add_node(&mut self, node: DDNode) -> NodeID
fn add_node(&mut self, node: DDNode) -> NodeID
Insert Node. ID is assigned for nonterminal nodes (var != 0). This does not check the unique table, you should do so before using!
sourcefn node_get_or_create(&mut self, node: &DDNode) -> NodeID
fn node_get_or_create(&mut self, node: &DDNode) -> NodeID
Search for Node, create if it doesnt exist
fn zero(&self) -> NodeID
fn one(&self) -> NodeID
pub fn ith_var(&mut self, var: VarID) -> NodeID
pub fn nith_var(&mut self, var: VarID) -> NodeID
fn not(&mut self, f: NodeID) -> NodeID
pub fn and(&mut self, f: NodeID, g: NodeID) -> NodeID
pub fn or(&mut self, f: NodeID, g: NodeID) -> NodeID
fn xor(&mut self, f: NodeID, g: NodeID) -> NodeID
sourcefn min_by_order(&self, fvar: VarID, gvar: VarID, hvar: VarID) -> VarID
fn min_by_order(&self, fvar: VarID, gvar: VarID, hvar: VarID) -> VarID
Find top variable: Highest in tree according to order
fn ite(&mut self, f: NodeID, g: NodeID, h: NodeID) -> NodeID
fn verify(&self, f: NodeID, trues: &[u32]) -> bool
pub fn purge_retain(&mut self, f: NodeID)
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for DDManager
impl Send for DDManager
impl Sync for DDManager
impl Unpin for DDManager
impl UnwindSafe for DDManager
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more