Adiar  2.1.0
An External Memory Decision Diagram Library
adiar::builder< Policy > Class Template Reference

A builder for decision diagrams. More...

#include <adiar/builder.h>

Public Member Functions

 builder () noexcept
 Constructor.
 
 ~builder () noexcept
 Destructor.
 
builder_ptr< Policy > add_node (typename Policy::label_type label, const builder_ptr< Policy > &low, const builder_ptr< Policy > &high)
 Add an internal node with a given label and its two children. More...
 
builder_ptr< Policy > add_node (const typename Policy::label_type label, const bool low, const builder_ptr< Policy > &high)
 Add an internal node with a given label and its two children. More...
 
builder_ptr< Policy > add_node (const typename Policy::label_type label, const builder_ptr< Policy > &low, const bool high)
 Add an internal node with a given label and its two children. More...
 
builder_ptr< Policy > add_node (const typename Policy::label_type label, const bool low, const bool high)
 Add an internal node with a given label and its two children. More...
 
builder_ptr< Policy > add_node (bool terminal_value)
 Add a terminal node with a given value. More...
 
Policy::dd_type build ()
 Builds the decision diagram with the added nodes. This also clears the builder. More...
 
void clear () noexcept
 Clear builder of all its current content, discarding all nodes and invalidating any pointers to them. More...
 

Detailed Description

template<typename Policy>
class adiar::builder< Policy >

A builder for decision diagrams.

Nodes should be added bottom-up. Each added node returns a builder_ptr so that it can be used as a child for other nodes.

Template Parameters
PolicyLogic related to the specific type of decision diagram to construct.

Member Function Documentation

◆ add_node() [1/5]

template<typename Policy >
builder_ptr<Policy> adiar::builder< Policy >::add_node ( bool  terminal_value)
inline

Add a terminal node with a given value.

Parameters
terminal_valueValue of the constant function to create.
Remarks
One may call this function at any time during the construction process since terminals are not part of the bottom-up requirement.

◆ add_node() [2/5]

template<typename Policy >
builder_ptr<Policy> adiar::builder< Policy >::add_node ( const typename Policy::label_type  label,
const bool  low,
const bool  high 
)
inline

Add an internal node with a given label and its two children.

Parameters
labelThe variable label for the node to create.
lowTerminal value for when when the variable with the given label evaluates to false.
highTerminal value for when the variable with the given label evaluates to true.
Returns
Pointer to the node for the desired function.
Exceptions
invalid_argumentIf label violates the bottom-up ordering (see add_node).

◆ add_node() [3/5]

template<typename Policy >
builder_ptr<Policy> adiar::builder< Policy >::add_node ( const typename Policy::label_type  label,
const bool  low,
const builder_ptr< Policy > &  high 
)
inline

Add an internal node with a given label and its two children.

Parameters
labelThe variable label for the node to create.
lowTerminal value for when the variable with the given label evaluates to false.
highPointer for when the variable with the given label evaluates to true.
Returns
Pointer to the (possibly new) node for the desired function.
Exceptions
invalid_argumentIf label and high are illegal (see add_node).

◆ add_node() [4/5]

template<typename Policy >
builder_ptr<Policy> adiar::builder< Policy >::add_node ( const typename Policy::label_type  label,
const builder_ptr< Policy > &  low,
const bool  high 
)
inline

Add an internal node with a given label and its two children.

Parameters
labelThe variable label for the node to create.
lowPointer for when when the variable with the given label evaluates to false.
highTerminal value for when the variable with the given label evaluates to true.
Returns
Pointer to the (possibly new) node for the desired function.
Exceptions
invalid_argumentIf label and low are illegal (see add_node).

◆ add_node() [5/5]

template<typename Policy >
builder_ptr<Policy> adiar::builder< Policy >::add_node ( typename Policy::label_type  label,
const builder_ptr< Policy > &  low,
const builder_ptr< Policy > &  high 
)
inline

Add an internal node with a given label and its two children.

Parameters
labelThe variable label for the node to create.
lowPointer for when the variable with the given label evaluates to false.
highPointer for when the variable with the given label evaluates to true.
Returns
Pointer to the (possibly new) node for the desired function.
Remarks
This will apply the first reduction rule associated with the specific type of decision diagram, e.g. not construct a "don’t care" node for bdd but instead just return its child. The builder cannot apply the second reduction rule, i.e. merging of duplicate nodes, so that is still left up to you to do.
Exceptions
invalid_argumentIf a node is malformed or not added in bottom-up order.
invalid_argumentIf pointers stem from another builder.

◆ build()

template<typename Policy >
Policy::dd_type adiar::builder< Policy >::build ( )
inline

Builds the decision diagram with the added nodes. This also clears the builder.

See also
clear
Exceptions
domain_errorIf add_node has not been called
domain_errorIf there are more than one root in the diagram.
Precondition
One has used add_node to create a non-empty and singly-rooted decision diagram.
Warning
After calling this function all previously created builder_ptr created by this object will be invalidated and cannot be used anymore.

◆ clear()

template<typename Policy >
void adiar::builder< Policy >::clear ( )
inlinenoexcept

Clear builder of all its current content, discarding all nodes and invalidating any pointers to them.

Warning
This will invalidate any pointers created up to this point. You will not be able to use them after this.

The documentation for this class was generated from the following file: