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;
101 std::variant<no_file, shared_node_file_type, shared_arc_file_type>
_union;
154 template <
typename file_t>
158 return std::holds_alternative<file_t>(
_union);
166 template <
typename file_t>
170 return std::get<file_t>(
_union);
212 return af->max_1level_cut + (
ct.includes(
false) ?
af->number_of_terminals[
false] : 0
u)
213 + (
ct.includes(
true) ?
af->number_of_terminals[
true] : 0
u);
231 (3 *
af->max_1level_cut) / 2 + (
ct.includes(
false) ?
af->number_of_terminals[
false] : 0
u)
232 + (
ct.includes(
true) ?
af->number_of_terminals[
true] : 0
u),
234 (
af->size() / 2u) + 1);
263 return af->number_of_terminals[
false] +
af->number_of_terminals[
true];
267 return nf->number_of_terminals[
false] + nf->number_of_terminals[
true];
429 return this->_file.get();
458 max_1level_cut(
const cut ct)
const
460 return this->_file->max_1level_cut[negate_cut_type(
ct)];
470 max_2level_cut(
const cut ct)
const
472 return this->_file->max_2level_cut[negate_cut_type(
ct)];
483 return this->_file->size();
492 return this->_file->width;
501 return this->_file->number_of_terminals[this->_negate ^
value];
519 negate_cut_type(
const cut ct)
const
521 if (!this->_negate) {
return ct; }
524 case cut::Internal_False:
return cut::Internal_True;
525 case cut::Internal_True:
return cut::Internal_False;
532 : _union(
dd.file_ptr())
533 , _negate(
dd.is_negated())
538 template <
typename DD,
typename __DD>
552 using __dd_type = __DD;
557 using node_type =
typename dd_type::node_type;
562 using pointer_type =
typename dd_type::pointer_type;
567 using uid_type =
typename dd_type::uid_type;
572 using children_type =
typename node_type::children_type;
577 using level_type =
typename dd_type::level_type;
582 using signed_level_type =
typename dd_type::signed_level_type;
587 using label_type =
typename dd_type::label_type;
592 using signed_label_type =
typename dd_type::signed_label_type;
597 static constexpr label_type max_label = dd_type::max_label;
602 using id_type =
typename dd_type::id_type;
607 static constexpr id_type max_id = dd_type::max_id;
612 using terminal_type =
typename dd_type::terminal_type;
617 using shared_node_file_type =
typename __dd_type::shared_node_file_type;
622 using shared_arc_file_type =
typename __dd_type::shared_arc_file_type;
632 static inline pointer_type
633 reduction_rule(
const node_type& n);
641 static inline children_type
642 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:116
shared_levelized_file< arc_type > shared_arc_file_type
Type of the file object arc-based representation of a diagram.
Definition dd.h:95
shared_levelized_file< node_type > shared_node_file_type
Type of the file object node-based representation of a diagram.
Definition dd.h:55
signed_level_type signed_label_type
Type for difference between variable labels.
Definition dd.h:85
__dd()=default
Default construction to nothing.
arc arc_type
Type of nodes of this diagram.
Definition dd.h:90
__dd(const shared_arc_file_type &f, const exec_policy &ep)
Conversion for algorithms returning to-be reduced arcs.
Definition dd.h:136
node_type::signed_level_type signed_level_type
Type for difference between node levels.
Definition dd.h:75
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:101
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:156
level_type label_type
Type of variable labels.
Definition dd.h:80
__dd(const shared_node_file_type &f)
Conversion for algorithms returning already-reduced nodes.
Definition dd.h:129
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:226
size_t number_of_terminals() const
Number of terminals.
Definition dd.h:259
bool _negate
Propagation of the dd.negate flag.
Definition dd.h:106
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:191
node_type::level_type level_type
Type of the level of nodes.
Definition dd.h:70
const file_t & get() const
Get the content of a certain type.
Definition dd.h:168
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:208
bool empty() const
Whether it currently holds no content.
Definition dd.h:179
signed_label_type _shift
Propagation of the dd.shift value.
Definition dd.h:111
size_t number_of_terminals(const bool value) const
Number of terminals of a certain value.
Definition dd.h:244
Container for the files that represent a Decision Diagram.
Definition dd.h:280
static constexpr id_type max_id
The maximal possible value for this nodes level identifier.
Definition dd.h:332
levelized_file< node_type > node_file_type
File type for the file object representing the diagram.
Definition dd.h:342
level_type label_type
Type of variable labels.
Definition dd.h:312
signed_level_type signed_label_type
Type for difference between variable labels.
Definition dd.h:317
bool _negate
Whether to negate the leaves when reading nodes from the file.
Definition dd.h:373
bool is_negated() const
Read-only access to the negation flag.
Definition dd.h:436
signed_label_type _shift
Number of levels to shift by.
Definition dd.h:378
node_type::uid_type uid_type
Type of unique identifiers (pointers without metadata) of this diagram.
Definition dd.h:297
const shared_node_file_type file_ptr() const
Read-only access to the raw files and meta information.
Definition dd.h:417
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:386
shared_file_ptr< node_file_type > shared_node_file_type
File type for the shared file object representing the diagram.
Definition dd.h:347
static constexpr label_type max_label
The maximal possible value for a unique identifier's label.
Definition dd.h:322
node_type::level_type level_type
Type of the level of nodes.
Definition dd.h:302
node_type::pointer_type pointer_type
Type of pointers of this diagram.
Definition dd.h:292
void deref()
Release the claim on the underlying file, thereby decreasing its reference counter....
Definition dd.h:363
signed_label_type shift() const
Read-only access to the number of levels to shift.
Definition dd.h:445
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:355
size_t number_of_terminals(const bool value) const
Number of terminals of a certain value.
Definition dd.h:499
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:427
typename node_type::terminal_type terminal_type
Type of a terminal value.
Definition dd.h:337
node_type::signed_level_type signed_level_type
Type for difference between node levels.
Definition dd.h:307
node_type::id_type id_type
Type of this node's level identifier.
Definition dd.h:327
size_t size() const
The number of elements in the node file.
Definition dd.h:481
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:490
node node_type
Type of nodes of this diagram.
Definition dd.h:287
size_t number_of_terminals() const
Number of terminals.
Definition dd.h:508
consumer< ValueType > make_consumer(OutputIt &&iter)
Wrap an iterator into a consumer function.
Definition functional.h:71