1#ifndef ADIAR_INTERNAL_DD_H
2#define ADIAR_INTERNAL_DD_H
6#include <adiar/exec_policy.h>
8#include <adiar/internal/cut.h>
9#include <adiar/internal/data_types/arc.h>
10#include <adiar/internal/data_types/node.h>
11#include <adiar/internal/io/arc_file.h>
12#include <adiar/internal/io/node_file.h>
14namespace adiar::internal
28 using no_file = std::monostate;
91 std::variant<no_file, shared_node_file_type, shared_arc_file_type>
_union;
144 template <
typename file_t>
148 return std::holds_alternative<file_t>(
_union);
156 template <
typename file_t>
160 return std::get<file_t>(
_union);
202 return af->max_1level_cut + (
ct.includes(
false) ?
af->number_of_terminals[
false] : 0
u)
203 + (
ct.includes(
true) ?
af->number_of_terminals[
true] : 0
u);
221 (3 *
af->max_1level_cut) / 2 + (
ct.includes(
false) ?
af->number_of_terminals[
false] : 0
u)
222 + (
ct.includes(
true) ?
af->number_of_terminals[
true] : 0
u),
224 (
af->size() / 2u) + 1);
253 return af->number_of_terminals[
false] +
af->number_of_terminals[
true];
257 return nf->number_of_terminals[
false] + nf->number_of_terminals[
true];
409 return this->_file.get();
438 max_1level_cut(
const cut ct)
const
440 return this->_file->max_1level_cut[negate_cut_type(
ct)];
450 max_2level_cut(
const cut ct)
const
452 return this->_file->max_2level_cut[negate_cut_type(
ct)];
463 return this->_file->size();
472 return this->_file->width;
481 return this->_file->number_of_terminals[this->_negate ^
value];
499 negate_cut_type(
const cut ct)
const
501 if (!this->_negate) {
return ct; }
504 case cut::Internal_False:
return cut::Internal_True;
505 case cut::Internal_True:
return cut::Internal_False;
517 , _negate(
dd._negate)
522 template <
typename DD,
typename __DD>
536 using __dd_type = __DD;
541 using node_type =
typename dd_type::node_type;
546 using pointer_type =
typename dd_type::pointer_type;
551 using uid_type =
typename dd_type::uid_type;
556 using children_type =
typename node_type::children_type;
561 using label_type =
typename dd_type::label_type;
566 using signed_label_type =
typename dd_type::label_type;
571 static constexpr label_type max_label = dd_type::max_label;
576 using id_type =
typename dd_type::id_type;
581 static constexpr id_type max_id = dd_type::max_id;
586 using terminal_type =
typename dd_type::terminal_type;
591 using shared_node_file_type =
typename __dd_type::shared_node_file_type;
596 using shared_arc_file_type =
typename __dd_type::shared_arc_file_type;
606 static inline pointer_type
607 reduction_rule(
const node_type& n);
615 static inline children_type
616 reduction_rule_inv(
const pointer_type& child);
Settings to dictate the execution of Adiar's algorithms.
Definition exec_policy.h:35
exec_policy _policy
Copy of the execution policy given to the top-down algorithm.
Definition dd.h:106
shared_levelized_file< arc_type > shared_arc_file_type
Type of the file object arc-based representation of a diagram.
Definition dd.h:85
shared_levelized_file< node_type > shared_node_file_type
Type of the file object node-based representation of a diagram.
Definition dd.h:55
node_type::signed_label_type signed_label_type
Type for difference between variable labels.
Definition dd.h:75
__dd()=default
Default construction to nothing.
arc arc_type
Type of nodes of this diagram.
Definition dd.h:80
__dd(const shared_arc_file_type &f, const exec_policy &ep)
Conversion for algorithms returning to-be reduced arcs.
Definition dd.h:126
std::variant< no_file, shared_node_file_type, shared_arc_file_type > _union
Union of levelized node or arc files to reflect the possible return types of a function and a 'no_fil...
Definition dd.h:91
node_type::uid_type uid_type
Type of unique identifiers (pointers without metadata) of this diagram.
Definition dd.h:65
bool has() const
Whether the union currently holds a certain file type.
Definition dd.h:146
__dd(const shared_node_file_type &f)
Conversion for algorithms returning already-reduced nodes.
Definition dd.h:119
cut::size_type max_2level_cut(const cut ct) const
Obtain the 2-level cut of the desired type, i.e. of the sub-graph including the desired type of arcs.
Definition dd.h:216
size_t number_of_terminals() const
Number of terminals.
Definition dd.h:249
bool _negate
Propagation of the dd.negate flag.
Definition dd.h:96
node node_type
Type of nodes of this diagram.
Definition dd.h:50
node_type::pointer_type pointer_type
Type of pointers of this diagram.
Definition dd.h:60
size_t size() const
Number of nodes.
Definition dd.h:181
const file_t & get() const
Get the content of a certain type.
Definition dd.h:158
cut::size_type max_1level_cut(const cut ct) const
Obtain the 1-level cut of the desired type, i.e. of the sub-graph including the desired type of arcs.
Definition dd.h:198
bool empty() const
Whether it currently holds no content.
Definition dd.h:169
node_type::label_type label_type
Type of this node's variable label.
Definition dd.h:70
signed_label_type _shift
Propagation of the dd.negate flag.
Definition dd.h:101
size_t number_of_terminals(const bool value) const
Number of terminals of a certain value.
Definition dd.h:234
Container for the files that represent a Decision Diagram.
Definition dd.h:270
static constexpr id_type max_id
The maximal possible value for this nodes level identifier.
Definition dd.h:312
levelized_file< node_type > node_file_type
File type for the file object representing the diagram.
Definition dd.h:322
bool _negate
Whether to negate the leaves when reading nodes from the file.
Definition dd.h:353
bool is_negated() const
Read-only access to the negation flag.
Definition dd.h:416
signed_label_type _shift
Number of levels to shift by.
Definition dd.h:358
node_type::uid_type uid_type
Type of unique identifiers (pointers without metadata) of this diagram.
Definition dd.h:287
const shared_node_file_type file_ptr() const
Read-only access to the raw files and meta information.
Definition dd.h:397
dd(const shared_node_file_type &f, bool negate=false, signed_label_type shift=0)
Constructor to wrap the node-based result of an algorithm.
Definition dd.h:366
shared_file_ptr< node_file_type > shared_node_file_type
File type for the shared file object representing the diagram.
Definition dd.h:327
static constexpr label_type max_label
The maximal possible value for a unique identifier's label.
Definition dd.h:302
node_type::signed_label_type signed_label_type
Type for difference between variable labels.
Definition dd.h:297
node_type::label_type label_type
Type of this node's variable label.
Definition dd.h:292
node_type::pointer_type pointer_type
Type of pointers of this diagram.
Definition dd.h:282
void deref()
Release the claim on the underlying file, thereby decreasing its reference counter....
Definition dd.h:343
signed_label_type shift() const
Read-only access to the number of levels to shift.
Definition dd.h:425
dd(dd &&dd)=default
Move construction, taking over ownership of the files underneath.
shared_node_file_type _file
The file describing the actual DAG of the decision diagram.
Definition dd.h:335
size_t number_of_terminals(const bool value) const
Number of terminals of a certain value.
Definition dd.h:479
const node_file_type * operator->() const
Read-only access to the members of the raw files and meta information, i.e. this is similar to writin...
Definition dd.h:407
typename node_type::terminal_type terminal_type
Type of a terminal value.
Definition dd.h:317
node_type::id_type id_type
Type of this node's level identifier.
Definition dd.h:307
size_t size() const
The number of elements in the node file.
Definition dd.h:461
dd(const dd &dd)=default
Copy construction, incrementing the reference count on the file underneath.
size_t width() const
The number of nodes on the widest level.
Definition dd.h:470
node node_type
Type of nodes of this diagram.
Definition dd.h:277
size_t number_of_terminals() const
Number of terminals.
Definition dd.h:488
consumer< ValueType > make_consumer(OutputIt &&iter)
Wrap an iterator into a consumer function.
Definition functional.h:71