TeDDy 4.1.0
Decision diagram library.
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
teddy::diagram_manager< Data, Degree, Domain > Class Template Reference

Base class for all diagram managers that generically implements all of the algorithms. More...

#include <diagram_manager.hpp>

Inheritance diagram for teddy::diagram_manager< Data, Degree, Domain >:
teddy::reliability_manager< degrees::fixed< 2 >, domains::fixed< 2 > > teddy::reliability_manager< degrees::fixed< M >, domains::mixed > teddy::reliability_manager< degrees::mixed, domains::mixed > teddy::reliability_manager< degrees::fixed< M >, domains::fixed< M > > teddy::bss_manager teddy::ifmss_manager< M > teddy::imss_manager teddy::mss_manager< M >

Public Types

using diagram_t = diagram< Data, Degree >
 Alias for the diagram type used in the functions of this manager.
 

Public Member Functions

auto constant (int32 val) -> diagram_t
 Creates diagram representing constant function.
 
auto variable (int32 index) -> diagram_t
 Creates diagram representing function of single variable.
 
template<class Foo = void>
requires (is_bdd<Degree>)
auto variable_not (int32 index) -> utils::second_t< Foo, diagram_t >
 Creates BDD representing function of complemented variable.
 
auto operator() (int32 index) -> diagram_t
 Creates diagram representing function of single variable.
 
template<std::convertible_to< int32 > T>
auto variables (std::initializer_list< T > indices) -> std::vector< diagram_t >
 Creates vector of diagrams representing single variables.
 
template<std::input_iterator I, std::sentinel_for< I > S>
auto variables (I first, S last) -> std::vector< diagram_t >
 Creates vector of diagrams representing functions of single variables.
 
template<std::ranges::input_range Is>
auto variables (Is const &indices) -> std::vector< diagram_t >
 Creates vector of diagrams representing single variables.
 
template<std::input_iterator I, std::sentinel_for< I > S>
auto from_vector (I first, S last) -> diagram_t
 Creates diagram from a truth vector of a function.
 
template<std::ranges::input_range R>
auto from_vector (R &&vector) -> diagram_t
 Creates diagram from a truth vector of a function.
 
auto to_vector (diagram_t const &diagram) const -> std::vector< int32 >
 Creates truth vector from the diagram.
 
template<std::output_iterator< teddy::int32 > O>
auto to_vector_g (diagram_t const &diagram, O out) const -> void
 Creates truth vector from the diagram.
 
template<class Foo = void>
requires (is_bdd<Degree>)
auto from_pla (pla_file const &file, fold_type foldType=fold_type::Tree) -> utils::second_t< Foo, std::vector< diagram_t > >
 Creates BDDs defined by PLA file.
 
template<expression_node Node>
auto from_expression_tree (Node const &root) -> diagram_t
 Creates diagram from an expression tree (AST).
 
template<teddy_bin_op Op>
auto apply (diagram_t const &lhs, diagram_t const &rhs) -> diagram_t
 Merges two diagrams using given binary operation.
 
template<teddy_bin_op Op, class... Diagram>
auto apply_n (Diagram const &... diagrams) -> diagram_t
 TODO.
 
template<teddy_bin_op Op, std::ranges::input_range R>
auto left_fold (R const &diagrams) -> diagram_t
 Merges diagams in the range using the apply function and binary operation.
 
template<teddy_bin_op Op, std::input_iterator I, std::sentinel_for< I > S>
auto left_fold (I first, S last) -> diagram_t
 Merges diagams in the range using the apply function and binary operation.
 
template<teddy_bin_op Op, std::ranges::random_access_range R>
auto tree_fold (R &diagrams) -> diagram_t
 Merges diagams in the range using the apply function and binary operation.
 
template<teddy_bin_op Op, std::random_access_iterator I, std::sentinel_for< I > S>
auto tree_fold (I first, S last) -> diagram_t
 Merges diagams in the range using the apply function and binary operation.
 
template<in_var_values Vars>
auto evaluate (diagram_t const &diagram, Vars const &values) const -> int32
 Evaluates value of the function represented by the diagram.
 
auto satisfy_count (int32 value, diagram_t const &diagram) -> int64
 Calculates number of variable assignments for which the functions evaluates to certain value.
 
template<out_var_values Vars>
auto satisfy_one (int32 value, diagram_t const &diagram) -> std::optional< Vars >
 Finds variable assignment for which diagram evaluates to value.
 
template<out_var_values Vars>
auto satisfy_all (int32 value, diagram_t const &diagram) const -> std::vector< Vars >
 Enumerates all elements of the satisfying set.
 
template<out_var_values Vars, std::output_iterator< Vars > O>
auto satisfy_all_g (int32 value, diagram_t const &diagram, O out) const -> void
 Enumerates all elements of the satisfying set.
 
auto get_cofactor (diagram_t const &diagram, int32 varIndex, int32 varValue) -> diagram_t
 Calculates cofactor of the functions.
 
auto get_cofactor (diagram_t const &diagram, std::vector< var_cofactor > const &vars) -> diagram_t
 
template<int_to_int F>
auto transform (diagram_t const &diagram, F transformer) -> diagram_t
 Transforms values of the function.
 
template<class Foo = void>
requires (is_bdd<Degree>)
auto negate (diagram_t const &diagram) -> utils::second_t< Foo, diagram_t >
 Negates Boolean function.
 
auto get_dependency_set (diagram_t const &diagram) const -> std::vector< int32 >
 Enumerates indices of variables that the function depends on.
 
template<std::output_iterator< int32 > O>
auto get_dependency_set_g (diagram_t const &diagram, O out) const -> void
 Enumerates indices of variables that the function depends on.
 
auto reduce (diagram_t const &diagram) -> diagram_t
 Reduces diagrams to its canonical form.
 
auto get_node_count () const -> int64
 Returns number of nodes that are currently used by the manager.
 
auto get_node_count (diagram_t const &diagram) const -> int64
 Returns number of nodes in the diagram including terminal nodes.
 
auto to_dot_graph (std::ostream &out) const -> void
 Prints dot representation of the graph.
 
auto to_dot_graph (std::ostream &out, diagram_t const &diagram) const -> void
 Prints dot representation of the diagram.
 
auto force_gc () -> void
 Runs garbage collection.
 
auto force_reorder () -> void
 Runs variable reordering heuristic.
 
auto clear_cache () -> void
 Clears apply cache.
 
auto get_var_count () const -> int32
 Returns number of variables for this manager set in the constructor.
 
auto get_order () const -> std::vector< int32 > const &
 Returns current order of variables.
 
auto get_domains () const -> std::vector< int32 >
 Return domains of variables.
 
auto set_cache_ratio (double ratio) -> void
 Sets the relative cache size w.r.t the number of nodes.
 
auto set_gc_ratio (double ratio) -> void
 Sets ratio used to determine new node pool allocation.
 
auto set_auto_reorder (bool doReorder) -> void
 Enables or disables automatic variable reordering.
 
 diagram_manager (diagram_manager &&) noexcept=default
 
auto operator= (diagram_manager &&) noexcept -> diagram_manager &=default
 
 diagram_manager (diagram_manager const &)=delete
 
auto operator= (diagram_manager const &) -> diagram_manager &=delete
 
template<out_var_values Vars, std::output_iterator< Vars > OutputIt>
auto satisfy_all_g (int32 const value, diagram_t const &diagram, OutputIt out) const -> void
 

Protected Types

using node_t = typename diagram< Data, Degree >::node_t
 
using son_container = typename node_t::son_container
 

Protected Member Functions

 diagram_manager (int32 varCount, int64 nodePoolSize, int64 extraNodePoolSize, std::vector< int32 > order)
 Initializes diagram manager.
 
 diagram_manager (int32 varCount, int64 nodePoolSize, int64 extraNodePoolSize, domains::mixed domain, std::vector< int32 > order)
 Initializes diagram manager.
 

Protected Attributes

node_manager< Data, Degree, Domain > nodes_
 

Detailed Description

template<class Data, class Degree, class Domain>
class teddy::diagram_manager< Data, Degree, Domain >

Base class for all diagram managers that generically implements all of the algorithms.

Constructor & Destructor Documentation

◆ diagram_manager() [1/2]

template<class Data , class Degree , class Domain >
requires (domains::is_fixed<Domain>::value)
teddy::diagram_manager< Data, Degree, Domain >::diagram_manager ( int32  varCount,
int64  nodePoolSize,
int64  extraNodePoolSize,
std::vector< int32 >  order 
)
protected

Initializes diagram manager.

This overload is for managers that have fixed domains (known at copile time).

Parameters
varCountNumber of variables.
nodePoolSizeNumber of nodes that is pre-allocated.
extraNodePoolSizeSize of the additional node pools.
orderOrder of variables.

◆ diagram_manager() [2/2]

template<class Data , class Degree , class Domain >
requires (domains::is_mixed<Domain>::value)
teddy::diagram_manager< Data, Degree, Domain >::diagram_manager ( int32  varCount,
int64  nodePoolSize,
int64  extraNodePoolSize,
domains::mixed  domain,
std::vector< int32 >  order 
)
protected

Initializes diagram manager.

This overload is for managers that have mixed domains specified by the ds paramter.

Parameters
varCountNumber of variables.
nodePoolSizeNumber of nodes that is pre-allocated.
extraNodePoolSizeSize of the additional node pools.
dsDomains of varibales.
orderOrder of variables.

Member Function Documentation

◆ constant()

template<class Data , class Degree , class Domain >
auto teddy::diagram_manager< Data, Degree, Domain >::constant ( int32  val) -> diagram_t

Creates diagram representing constant function.

Parameters
valValue of the constant function
Returns
Diagram representing constant function

◆ variable()

template<class Data , class Degree , class Domain >
auto teddy::diagram_manager< Data, Degree, Domain >::variable ( int32  index) -> diagram_t

Creates diagram representing function of single variable.

Parameters
indexIndex of the variable
Returns
Diagram of a function of single variable

◆ variable_not()

template<class Data , class Degree , class Domain >
requires (is_bdd<Degree>)
template<class Foo >
requires (is_bdd<Degree>)
auto teddy::diagram_manager< Data, Degree, Domain >::variable_not ( int32  index) -> utils::second_t<Foo, diagram_t>

Creates BDD representing function of complemented variable.

Parameters
indexIndex of the variable
Returns
Diagram of a function of single variable

◆ operator()()

template<class Data , class Degree , class Domain >
auto teddy::diagram_manager< Data, Degree, Domain >::operator() ( int32  index) -> diagram_t

Creates diagram representing function of single variable.

Parameters
iIndex of the variable
Returns
Diagram of a function of single variable

◆ variables() [1/3]

template<class Data , class Degree , class Domain >
template<std::convertible_to< int32 > T>
auto teddy::diagram_manager< Data, Degree, Domain >::variables ( std::initializer_list< T >  indices) -> std::vector<diagram_t>

Creates vector of diagrams representing single variables.

Template Parameters
Tintegral type convertible to unsgined int
Parameters
indicesinitializer list of indices
Returns
Vector of diagrams

◆ variables() [2/3]

template<class Data , class Degree , class Domain >
template<std::input_iterator I, std::sentinel_for< I > S>
auto teddy::diagram_manager< Data, Degree, Domain >::variables ( first,
last 
) -> std::vector<diagram_t>

Creates vector of diagrams representing functions of single variables.

Template Parameters
Iiterator type for the input range.
Ssentinel type for I . (end iterator)
Parameters
firstiterator to the first element of range of indices represented by integral type convertible to unsgined int.
lastsentinel for first (end iterator).
Returns
Vector of diagrams.

◆ variables() [3/3]

template<class Data , class Degree , class Domain >
template<std::ranges::input_range Is>
auto teddy::diagram_manager< Data, Degree, Domain >::variables ( Is const &  indices) -> std::vector<diagram_t>

Creates vector of diagrams representing single variables.

Template Parameters
Isrange of integral indices
Parameters
indicesrange of Ts (e.g. std::vector<int>)
Returns
Vector of diagrams

◆ from_vector() [1/2]

template<class Data , class Degree , class Domain >
template<std::input_iterator I, std::sentinel_for< I > S>
auto teddy::diagram_manager< Data, Degree, Domain >::from_vector ( first,
last 
) -> diagram_t

Creates diagram from a truth vector of a function.

Example for the function f(x) = max(x0, x1, x2):

// Truth table:
+----+----+----+----+---+----+-----+----+---+
| x1 | x2 | x3 | f | _ | x1 | x2 | x3 | f |
+----+----+----+----+---+----+-----+----+---+
| 0 | 0 | 0 | 0 | | 1 | 0 | 0 | 1 |
| 0 | 0 | 1 | 1 | | 1 | 0 | 1 | 1 |
| 0 | 0 | 2 | 2 | | 1 | 0 | 2 | 2 |
| 0 | 1 | 0 | 1 | | 1 | 1 | 0 | 1 |
| 0 | 1 | 1 | 1 | | 1 | 1 | 1 | 1 |
| 0 | 1 | 2 | 2 | | 1 | 1 | 2 | 2 |
+----+----+----+----+---+----+-----+----+---+
// Truth vector:
[0 1 2 1 1 2 1 1 2 1 1 2]
// Teddy code:
teddy::ifmdd_manager<3> manager(3, 100, {2, 2, 3});
std::vector<int> vec {0, 1, 2, 1, 1, 2, 1, 1, 2, 1, 1, 2};
diagram_t f = manager.from_vector(vec);
diagram< Data, Degree > diagram_t
Alias for the diagram type used in the functions of this manager.
Definition diagram_manager.hpp:97
Diagram manager (integer) Multi-valued Decision Diagrams (iMDDs)
Definition core.hpp:149
Template Parameters
IIterator type for the input range.
SSentinel type for I (end iterator)
Parameters
firstiterator to the first element of the truth vector
lastsentinel for first (end iterator)
Returns
Diagram representing function given by the truth vector

◆ from_vector() [2/2]

template<class Data , class Degree , class Domain >
template<std::ranges::input_range R>
auto teddy::diagram_manager< Data, Degree, Domain >::from_vector ( R &&  vector) -> diagram_t

Creates diagram from a truth vector of a function.

See the other overload for details.

Template Parameters
RType of the range that contains the truth vector
Parameters
vectorRange representing the truth vector Elements of the range must be convertible to int
Returns
Diagram representing function given by the truth vector

◆ to_vector()

template<class Data , class Degree , class Domain >
auto teddy::diagram_manager< Data, Degree, Domain >::to_vector ( diagram_t const &  diagram) const -> std::vector<int32>

Creates truth vector from the diagram.

Significance of variables is the same as in the from_vector function i.e., variable on the last level of the diagram is least significant. The following assertion holds:

assert(manager.from_vector(manager.to_vector(d)))
Parameters
diagramDiagram
Returns
Vector of ints representing the truth vector

◆ to_vector_g()

template<class Data , class Degree , class Domain >
template<std::output_iterator< teddy::int32 > O>
auto teddy::diagram_manager< Data, Degree, Domain >::to_vector_g ( diagram_t const &  diagram,
out 
) const -> void

Creates truth vector from the diagram.

Template Parameters
OOutput iterator type
Parameters
diagramDiagram
outOutput iterator that is used to output the truth vector

◆ from_pla()

template<class Data , class Degree , class Domain >
requires (is_bdd<Degree>)
template<class Foo >
requires (is_bdd<Degree>)
auto teddy::diagram_manager< Data, Degree, Domain >::from_pla ( pla_file const &  file,
fold_type  foldType = fold_type::Tree 
) -> utils::second_t<Foo, std::vector<diagram_t>>

Creates BDDs defined by PLA file.

Template Parameters
FooDummy template to enable SFINE.
Parameters
filePLA file loaded in the instance of pla_file class.
foldTypefold type used in diagram creation.
Returns
Vector of diagrams.

◆ from_expression_tree()

template<class Data , class Degree , class Domain >
template<expression_node Node>
auto teddy::diagram_manager< Data, Degree, Domain >::from_expression_tree ( Node const &  root) -> diagram_t

Creates diagram from an expression tree (AST).

Template Parameters
NodeNode type of the tree. Must provide API given by the concept. Required API might change in the future.
Parameters
rootRoot of the expression tree.
Returns
Diagram representing function defined by the expression.

◆ apply()

template<class Data , class Degree , class Domain >
template<teddy_bin_op Op>
auto teddy::diagram_manager< Data, Degree, Domain >::apply ( diagram_t const &  lhs,
diagram_t const &  rhs 
) -> diagram_t

Merges two diagrams using given binary operation.

Binary operations are defined in the namespace teddy::ops . All availabe operations are listed in the following table:

+-------------------+---------------------------------------+
| Binary operation | Description |
+-------------------+---------------------------------------+
| AND | Logical and. ^ $ |
| OR | Logical or. ^ $ |
| XOR | Logical xor. ^ $ |
| NAND | Logical nand. ^ $ |
| NOR | Logical nor. ^ $ |
| XNOR | Logical xnor. ^ $ |
| IMPLIES | Logical implication. ^ $ |
| EQUAL_TO | Equal to relation. ^ |
| NOT_EQUAL_TO | Not equal to relation. ^ |
| LESS | Less than relation. ^ |
| LESS_EQUAL | Less than or equal relation. ^ |
| GREATER | Greater than relation. ^ |
| GREATER_EQUAL | Greater than or equal relation. ^ |
| MIN | Minimum of two values. |
| MAX | Maximum of two values. |
| PLUS<M> | Modular addition: (a + b) mod M. |
| MULTIPLIES<M> | Modular multiplication: (a * b) mod M.|
+-------------------+---------------------------------------+
^ 0 is false and 1 is true
$ assumes that arguments are 0 or 1
// Examples:
manager.apply<teddy::ops::AND>(bdd1, bdd2);
manager.apply<teddy::ops::PLUS<4>>(mdd1, mdd2);
auto apply(diagram_t const &lhs, diagram_t const &rhs) -> diagram_t
Merges two diagrams using given binary operation.
Definition diagram_manager.hpp:1190
Contains definitions of all binary operations for apply function.
Definition operators.hpp:255
Template Parameters
OpBinary operation
Parameters
lhsfirst diagram
rhssecond diagram
Returns
Diagram representing merger of lhs and rhs

◆ left_fold() [1/2]

template<class Data , class Degree , class Domain >
template<teddy_bin_op Op, std::ranges::input_range R>
auto teddy::diagram_manager< Data, Degree, Domain >::left_fold ( R const &  diagrams) -> diagram_t

Merges diagams in the range using the apply function and binary operation.

Uses left fold order of evaluation (sequentially from the left).

// Example:
std::vector<diagram_t> vs = manager.variables({0, 1, 2});
diagram_t product = manager.left_fold<teddy::ops>(vs);
Template Parameters
OpBinary operation
RRange containing diagrams (e.g. std::vector<diagram_t>)
Parameters
diagramsInput range of diagrams to be merged
Returns
Diagram representing merger of all diagrams from the range

◆ left_fold() [2/2]

template<class Data , class Degree , class Domain >
template<teddy_bin_op Op, std::input_iterator I, std::sentinel_for< I > S>
auto teddy::diagram_manager< Data, Degree, Domain >::left_fold ( first,
last 
) -> diagram_t

Merges diagams in the range using the apply function and binary operation.

Uses left fold order of evaluation (sequentially from the left).

// Example:
std::vector<diagram_t> vs = manager.variables({0, 1, 2});
diagram_t product = manager.left_fold<teddy::ops>(
vs.begin(), vs.end());
Template Parameters
OpBinary operation
IRange iterator type
SSentinel type for I (end iterator)
Parameters
firstInput iterator to the first diagram
lastSentinel for first (end iterator)
Returns
Diagram representing merger of all diagrams from the range

◆ tree_fold() [1/2]

template<class Data , class Degree , class Domain >
template<teddy_bin_op Op, std::ranges::random_access_range R>
auto teddy::diagram_manager< Data, Degree, Domain >::tree_fold ( R &  diagrams) -> diagram_t

Merges diagams in the range using the apply function and binary operation.

Uses tree fold order of evaluation ((d1 op d2) op (d3 op d4) ...) . Tree fold uses the input range range to store some intermediate results. range is left in valid but unspecified state.

// Example:
std::vector<diagram_t> vs = manager.variables({0, 1, 2});
diagram_t product = manager.tree_fold<teddy::ops>(vs);
Template Parameters
OpBinary operation
RRange containing diagrams (e.g. std::vector<diagram_t>)
Parameters
diagramsRandom access range of diagrams to be merged (e.g. std::vector)
Returns
Diagram representing merger of all diagrams from the range

◆ tree_fold() [2/2]

template<class Data , class Degree , class Domain >
template<teddy_bin_op Op, std::random_access_iterator I, std::sentinel_for< I > S>
auto teddy::diagram_manager< Data, Degree, Domain >::tree_fold ( first,
last 
) -> diagram_t

Merges diagams in the range using the apply function and binary operation.

Uses tree fold order of evaluation ((d1 op d2) op (d3 op d4) ...) . Tree fold uses the input range range to store some intermediate results. range is left in valid but unspecified state.

// Example:
std::vector<diagram_t> vs = manager.variables({0, 1, 2});
diagram_t product = manager.tree_fold<teddy::ops>(
vs.begin(), vs.end());
Template Parameters
OpBinary operation
IRange iterator type
SSentinel type for I (end iterator)
Parameters
firstRandom access iterator to the first diagram
lastSentinel for first (end iterator)
Returns
Diagram representing merger of all diagrams from the range

◆ evaluate()

template<class Data , class Degree , class Domain >
template<in_var_values Vars>
auto teddy::diagram_manager< Data, Degree, Domain >::evaluate ( diagram_t const &  diagram,
Vars const &  values 
) const -> int32

Evaluates value of the function represented by the diagram.

Complexity is O(n) where n is the number of variables.

Template Parameters
VarsContainer type that defines operator[] and returns value convertible to int
Parameters
diagramDiagram
valuesContainer holding values of variables
Returns
Value of the function represented by d for variable values given in vs

◆ satisfy_count()

template<class Data , class Degree , class Domain >
auto teddy::diagram_manager< Data, Degree, Domain >::satisfy_count ( int32  value,
diagram_t const &  diagram 
) -> int64

Calculates number of variable assignments for which the functions evaluates to certain value.

Complexity is O(|d|) where |d| is the number of nodes.

Parameters
valueValue of the function
diagramDiagram representing the function
Returns
Number of different variable assignments for which the the function represented by d evaluates to val

◆ satisfy_one()

template<class Data , class Degree , class Domain >
template<out_var_values Vars>
auto teddy::diagram_manager< Data, Degree, Domain >::satisfy_one ( int32  value,
diagram_t const &  diagram 
) -> std::optional<Vars>

Finds variable assignment for which diagram evaluates to value.

Complexity is O(|n|) where |n| is the number of nodes.

Parameters
valueValue of the function
diagramDiagram representing the function
Returns
Optinal containing variable assignment or std::nullopt if there is no such an assignment

◆ satisfy_all()

template<class Data , class Degree , class Domain >
template<out_var_values Vars>
auto teddy::diagram_manager< Data, Degree, Domain >::satisfy_all ( int32  value,
diagram_t const &  diagram 
) const -> std::vector<Vars>

Enumerates all elements of the satisfying set.

Enumerates all elements of the satisfying set of the function i.e. variable assignments for which the function evaluates to certain value.

Complexity is O(n*|Sf|) where |Sf| is the size of the satisfying set and n is the number of variables. Please note that this is quite high for bigger functions and the computation will probably not finish in reasonable time.

Template Parameters
VarsContainer type that defines operator[] and allows assigning integers, std::vector is also allowed
Parameters
valueValue of the function
diagramDiagram representing the function
Returns
Vector of Vars

◆ satisfy_all_g()

template<class Data , class Degree , class Domain >
template<out_var_values Vars, std::output_iterator< Vars > O>
auto teddy::diagram_manager< Data, Degree, Domain >::satisfy_all_g ( int32  value,
diagram_t const &  diagram,
out 
) const -> void

Enumerates all elements of the satisfying set.

Enumerates all elements of the satisfying set of the function i.e. variable assignments for which the function evaluates to certain value.

Complexity is O(n*|Sf|) where |Sf| is the size of the satisfying set and n is the number of variables. Please note that this is quite high for bigger functions and the computation will probably not finish in reasonable time.

Template Parameters
VarsContainer type that defines operator[] and allows assigning integers. std::vector is also allowed.
OOutput iterator type.
Parameters
valueValue of the function
diagramDiagram representing the function
outOutput iterator that is used to output instances of Vars .

◆ get_cofactor()

template<class Data , class Degree , class Domain >
auto teddy::diagram_manager< Data, Degree, Domain >::get_cofactor ( diagram_t const &  diagram,
int32  varIndex,
int32  varValue 
) -> diagram_t

Calculates cofactor of the functions.

Calculates cofactor of the function i.e. fixes value of the i th variable to the value val .

Parameters
diagramDiagram representing the function
varIndexIndex of the variable to be fixed
varValueValue to which the i th varibale should be fixed
Returns
Diagram representing cofactor of the function

◆ transform()

template<class Data , class Degree , class Domain >
template<int_to_int F>
auto teddy::diagram_manager< Data, Degree, Domain >::transform ( diagram_t const &  diagram,
transformer 
) -> diagram_t

Transforms values of the function.

// Example of the call with 4-valued MDD.
manager.transform(diagram, [](int v)
{
return 3 - v;
});
Cheap wrapper for the internal diagram node type.
Definition diagram.hpp:20
Template Parameters
FType of the transformation function
Parameters
diagramDiagram representing the function
transformerTransformation function that is applied to values of the function.
Returns
Diagram representing transformed function

◆ negate()

template<class Data , class Degree , class Domain >
requires (is_bdd<Degree>)
template<class Foo >
requires (is_bdd<Degree>)
auto teddy::diagram_manager< Data, Degree, Domain >::negate ( diagram_t const &  diagram) -> utils::second_t<Foo, diagram_t>

Negates Boolean function.

Parameters
diagramDiagram representing the function
transformerTransformation function that is applied to values of the function.
Returns
Diagram representing transformed function

◆ get_dependency_set()

template<class Data , class Degree , class Domain >
auto teddy::diagram_manager< Data, Degree, Domain >::get_dependency_set ( diagram_t const &  diagram) const -> std::vector<int32>

Enumerates indices of variables that the function depends on.

Parameters
diagramDiagram representing the function
Returns
Vector of indices

◆ get_dependency_set_g()

template<class Data , class Degree , class Domain >
template<std::output_iterator< int32 > O>
auto teddy::diagram_manager< Data, Degree, Domain >::get_dependency_set_g ( diagram_t const &  diagram,
out 
) const -> void

Enumerates indices of variables that the function depends on.

Template Parameters
OOutput iterator type.
Parameters
diagramDiagram representing the function.
outOutput iterator that is used to output indices.

◆ reduce()

template<class Data , class Degree , class Domain >
auto teddy::diagram_manager< Data, Degree, Domain >::reduce ( diagram_t const &  diagram) -> diagram_t

Reduces diagrams to its canonical form.

You probably won't need to call this.

Parameters
diagramDiagram
Returns
Diagram in a reduced canonical form

◆ get_node_count() [1/2]

template<class Data , class Degree , class Domain >
auto teddy::diagram_manager< Data, Degree, Domain >::get_node_count

Returns number of nodes that are currently used by the manager.

This function returns number of nodes that are currently stored in the unique tables. Total number of allocated nodes might and probably will be higher. See implementation details on github for details.

Returns
Number of nodes

◆ get_node_count() [2/2]

template<class Data , class Degree , class Domain >
auto teddy::diagram_manager< Data, Degree, Domain >::get_node_count ( diagram_t const &  diagram) const -> int64

Returns number of nodes in the diagram including terminal nodes.

Parameters
diagramDiagram
Returns
Number of node

◆ to_dot_graph() [1/2]

template<class Data , class Degree , class Domain >
auto teddy::diagram_manager< Data, Degree, Domain >::to_dot_graph ( std::ostream &  out) const -> void

Prints dot representation of the graph.

Prints dot representation of the entire multi rooted graph to the output stream.

Parameters
outOutput stream (e.g. std::cout or std::ofstream )

◆ to_dot_graph() [2/2]

template<class Data , class Degree , class Domain >
auto teddy::diagram_manager< Data, Degree, Domain >::to_dot_graph ( std::ostream &  out,
diagram_t const &  diagram 
) const -> void

Prints dot representation of the diagram.

Prints dot representation of the diagram to the output stream.

Parameters
outOutput stream (e.g. std::cout or std::ofstream )
diagramDiagram

◆ force_gc()

template<class Data , class Degree , class Domain >
auto teddy::diagram_manager< Data, Degree, Domain >::force_gc

Runs garbage collection.

Forces the garbage collection to run which removes nodes that are not referenced from the unique tables. These nodes, however, are not deallocated. See implementation details on github for details. GC is run automatically so you probably won't need to run this function yourself.

◆ get_var_count()

template<class Data , class Degree , class Domain >
auto teddy::diagram_manager< Data, Degree, Domain >::get_var_count

Returns number of variables for this manager set in the constructor.

Returns
Number of variables.

◆ get_order()

template<class Data , class Degree , class Domain >
auto teddy::diagram_manager< Data, Degree, Domain >::get_order

Returns current order of variables.

If no sifting was performed in between call to the constructor and call to this function then the order is the same as specified in the constructor.

Returns
Vector of indices. Index at l-th position is the index of variable at l-th level of the diagram.

◆ get_domains()

template<class Data , class Degree , class Domain >
auto teddy::diagram_manager< Data, Degree, Domain >::get_domains

Return domains of variables.

In case of bdd_manager and mdd_manager domains of each variable is the same i.e. 2 or P. In case of imdd_manager and ifmdd_manager the domains are the same as set in the constructor.

Returns
Vector of domains.

◆ set_cache_ratio()

template<class Data , class Degree , class Domain >
auto teddy::diagram_manager< Data, Degree, Domain >::set_cache_ratio ( double  ratio) -> void

Sets the relative cache size w.r.t the number of nodes.

Size of the cache is calculated as:

ratio * uniqueNodeCount
Parameters
ratioNumber from the interval (0,oo)

◆ set_gc_ratio()

template<class Data , class Degree , class Domain >
auto teddy::diagram_manager< Data, Degree, Domain >::set_gc_ratio ( double  ratio) -> void

Sets ratio used to determine new node pool allocation.

New pool is allocated if:

garbageCollectedNodes < ratio * initNodeCount
Parameters
ratioNumber from the interval [0,1]

◆ set_auto_reorder()

template<class Data , class Degree , class Domain >
auto teddy::diagram_manager< Data, Degree, Domain >::set_auto_reorder ( bool  doReorder) -> void

Enables or disables automatic variable reordering.

Note that when automatic reordering is enabled the manager can't guarantee that all diagrams will remain canonical. To ensure that a diagram d is canonical (e.g. to compare two functions), you need to call reduce on them.

Parameters
doReorderSpecifies whether to disable (false) or enable (true) automatic reordering

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