Adiar 2.1.0
An External Memory Decision Diagram Library
Loading...
Searching...
No Matches
zdd.h
1#ifndef ADIAR_ZDD_H
2#define ADIAR_ZDD_H
3
14
15#include <iostream>
16#include <string>
17
18#include <adiar/bdd/bdd.h>
19#include <adiar/bool_op.h>
20#include <adiar/exec_policy.h>
21#include <adiar/functional.h>
22#include <adiar/zdd/zdd.h>
23
24namespace adiar
25{
30
38
47 zdd
49
53 zdd
55
59 zdd
61
80 zdd
82
101 template <typename ForwardIt>
102 zdd
107
116 zdd
118
137 zdd
139
158 template <typename ForwardIt>
159 zdd
164
173 zdd
175
189 zdd
191
205 template <typename ForwardIt>
206 zdd
211
224 zdd
226
240 template <typename ForwardIt>
241 zdd
246
259 zdd
261
275 zdd
277
291 template <typename ForwardIt>
292 zdd
297
310 zdd
312
326 template <typename ForwardIt>
327 zdd
332
342 zdd
344
357 template <typename ForwardIt>
358 inline zdd
363
369 zdd
371
381 zdd
383
396 template <typename ForwardIt>
397 inline zdd
402
411 zdd
413
416
421
438 __zdd
439 zdd_binop(const zdd& A, const zdd& B, const predicate<bool, bool>& op);
440
444 __zdd
445 zdd_binop(const exec_policy& ep, const zdd& A, const zdd& B, const predicate<bool, bool>& op);
446
452 __zdd
453 zdd_union(const zdd& A, const zdd& B);
454
458 __zdd
459 zdd_union(const exec_policy& ep, const zdd& A, const zdd& B);
460
464 __zdd
465 operator|(const zdd& lhs, const zdd& rhs);
466
468 __zdd
469 operator|(__zdd&&, __zdd&&);
470 __zdd
471 operator|(const zdd&, __zdd&&);
472 __zdd
473 operator|(__zdd&&, const zdd&);
475
479 zdd
480 operator+(const zdd& A);
481
483 __zdd
484 operator+(__zdd&& A);
486
487 __zdd
488 operator+(const zdd& lhs, const zdd& rhs);
489
491 __zdd
492 operator+(__zdd&&, __zdd&&);
493 __zdd
494 operator+(const zdd&, __zdd&&);
495 __zdd
496 operator+(__zdd&&, const zdd&);
498
504 __zdd
505 zdd_intsec(const zdd& A, const zdd& B);
506
510 __zdd
511 zdd_intsec(const exec_policy& ep, const zdd& A, const zdd& B);
512
516 __zdd
517 operator&(const zdd& lhs, const zdd& rhs);
518
520 __zdd
521 operator&(__zdd&&, __zdd&&);
522 __zdd
523 operator&(const zdd&, __zdd&&);
524 __zdd
525 operator&(__zdd&&, const zdd&);
527
531 __zdd
532 operator*(const zdd& lhs, const zdd& rhs);
533
535 __zdd
536 operator*(__zdd&&, __zdd&&);
537 __zdd
538 operator*(const zdd&, __zdd&&);
539 __zdd
540 operator*(__zdd&&, const zdd&);
542
548 __zdd
549 zdd_diff(const zdd& A, const zdd& B);
550
554 __zdd
555 zdd_diff(const exec_policy& ep, const zdd& A, const zdd& B);
556
563 __zdd
564 operator-(const zdd& A);
565
567 __zdd
568 operator-(__zdd&& A);
570
574 __zdd
575 operator-(const zdd& lhs, const zdd& rhs);
576
578 __zdd
579 operator-(__zdd&&, __zdd&&);
580 __zdd
581 operator-(const zdd&, __zdd&&);
582 __zdd
583 operator-(__zdd&&, const zdd&);
585
598 __zdd
600
604 __zdd
606
622 template <typename ForwardIt>
623 __zdd
628
632 template <typename ForwardIt>
633 __zdd
635 {
637 }
638
650 __zdd
652
656 __zdd
658
674 template <typename ForwardIt>
675 __zdd
680
684 template <typename ForwardIt>
685 __zdd
690
704 __zdd
706
710 __zdd
712
716 __zdd
717 operator~(const zdd& A);
718
720 __zdd
721 operator~(__zdd&& A);
723
739 __zdd
741
745 __zdd
747
767 template <typename ForwardIt>
768 __zdd
773
777 template <typename ForwardIt>
778 __zdd
780 {
782 }
783
795 __zdd
797
801 __zdd
803
816 __zdd
817 zdd_offset(const zdd& A);
818
822 __zdd
823 zdd_offset(const exec_policy& ep, const zdd& A);
824
837 __zdd
839
843 __zdd
845
861 template <typename ForwardIt>
862 __zdd
867
871 template <typename ForwardIt>
872 __zdd
874 {
876 }
877
889 __zdd
891
895 __zdd
897
910 __zdd
911 zdd_onset(const zdd& A);
912
916 __zdd
917 zdd_onset(const exec_policy& ep, const zdd& A);
918
931 __zdd
933
937 __zdd
939
955 template <typename ForwardIt>
956 __zdd
958 {
960 }
961
965 template <typename ForwardIt>
966 __zdd
968 {
969 return zdd_onset(ep, A, make_generator(begin, end));
970 }
971
986 __zdd
988
990
999 __zdd
1001
1009 __zdd
1011
1013
1018 __zdd
1020
1022
1031 __zdd
1033
1041 __zdd
1043
1045
1061 __zdd
1063
1065
1074 __zdd
1076
1084 __zdd
1086
1088
1093 __zdd
1095
1097
1106 __zdd
1108
1116 __zdd
1118
1120
1139 template <typename ForwardIt>
1140 __zdd
1142 {
1144 }
1145
1147
1156 template <typename ForwardIt>
1157 __zdd
1159 {
1160 return zdd_project(std::move(A), make_generator(begin, end));
1161 }
1162
1170 template <typename ForwardIt>
1171 __zdd
1173 {
1174 return zdd_project(std::move(A), make_generator(begin, end));
1175 }
1176
1178
1183 template <typename ForwardIt>
1184 __zdd
1186 {
1187 return zdd_project(ep, A, make_generator(begin, end));
1188 }
1189
1191
1200 template <typename ForwardIt>
1201 __zdd
1202 zdd_project(const exec_policy& ep, zdd&& A, ForwardIt begin, ForwardIt end)
1203 {
1204 return zdd_project(ep, std::move(A), make_generator(begin, end));
1205 }
1206
1214 template <typename ForwardIt>
1215 __zdd
1216 zdd_project(const exec_policy& ep, __zdd&& A, ForwardIt begin, ForwardIt end)
1217 {
1218 return zdd_project(ep, std::move(A), make_generator(begin, end));
1219 }
1220
1222
1225
1230
1236 bool
1238
1242 bool
1244
1248 bool
1250
1254 bool
1256
1260 bool
1262
1266 bool
1268
1272 bool
1274
1278 bool
1279 zdd_equal(const zdd& A, const zdd& B);
1280
1284 bool
1285 zdd_equal(const exec_policy& ep, const zdd& A, const zdd& B);
1286
1290 bool
1291 operator==(const zdd& lhs, const zdd& rhs);
1292
1294 bool
1295 operator==(__zdd&&, __zdd&&);
1296 bool
1297 operator==(const zdd&, __zdd&&);
1298 bool
1299 operator==(__zdd&&, const zdd&);
1301
1305 bool
1306 zdd_unequal(const zdd& A, const zdd& B);
1307
1311 bool
1312 zdd_unequal(const exec_policy& ep, const zdd& A, const zdd& B);
1313
1317 bool
1318 operator!=(const zdd& lhs, const zdd& rhs);
1319
1321 bool
1322 operator!=(__zdd&&, __zdd&&);
1323 bool
1324 operator!=(const zdd&, __zdd&&);
1325 bool
1326 operator!=(__zdd&&, const zdd&);
1328
1332 bool
1333 zdd_subseteq(const zdd& A, const zdd& B);
1334
1338 bool
1339 zdd_subseteq(const exec_policy& ep, const zdd& A, const zdd& B);
1340
1344 bool
1345 operator<=(const zdd& lhs, const zdd& rhs);
1346
1348 bool
1349 operator<=(__zdd&&, __zdd&&);
1350 bool
1351 operator<=(const zdd&, __zdd&&);
1352 bool
1353 operator<=(__zdd&&, const zdd&);
1355
1359 bool
1360 operator>=(const zdd& lhs, const zdd& rhs);
1361
1363 bool
1364 operator>=(__zdd&&, __zdd&&);
1365 bool
1366 operator>=(const zdd&, __zdd&&);
1367 bool
1368 operator>=(__zdd&&, const zdd&);
1370
1374 bool
1375 zdd_subset(const zdd& A, const zdd& B);
1376
1380 bool
1381 zdd_subset(const exec_policy& ep, const zdd& A, const zdd& B);
1382
1386 bool
1387 operator<(const zdd& lhs, const zdd& rhs);
1388
1390 bool
1391 operator<(__zdd&&, __zdd&&);
1392 bool
1393 operator<(const zdd&, __zdd&&);
1394 bool
1395 operator<(__zdd&&, const zdd&);
1397
1401 bool
1402 operator>(const zdd& lhs, const zdd& rhs);
1403
1405 bool
1406 operator>(__zdd&&, __zdd&&);
1407 bool
1408 operator>(const zdd&, __zdd&&);
1409 bool
1410 operator>(__zdd&&, const zdd&);
1412
1416 bool
1417 zdd_disjoint(const zdd& A, const zdd& B);
1418
1422 bool
1423 zdd_disjoint(const exec_policy& ep, const zdd& A, const zdd& B);
1424
1427
1432
1436 size_t
1438
1445
1449 uint64_t
1450 zdd_size(const zdd& A);
1451
1455 uint64_t
1456 zdd_size(const exec_policy& ep, const zdd& A);
1457
1460
1465
1475 void
1477
1490 template <typename OutputIt,
1491 typename = enable_if<!is_convertible<OutputIt, consumer<zdd::label_type>>>>
1492 OutputIt
1494 {
1496 return iter;
1497 }
1498
1506
1514
1522
1535 bool
1537
1553 template <typename ForwardIt>
1554 bool
1559
1570 zdd
1572
1585 void
1587
1599 template <typename OutputIt,
1600 typename = enable_if<!is_convertible<OutputIt, consumer<zdd::label_type>>>>
1601 OutputIt
1603 {
1605 return iter;
1606 }
1607
1618 zdd
1620
1633 void
1635
1647 template <typename OutputIt,
1648 typename = enable_if<!is_convertible<OutputIt, consumer<zdd::label_type>>>>
1649 OutputIt
1651 {
1653 return iter;
1654 }
1655
1658
1663
1677 __zdd
1679
1684 __zdd
1686
1703 template <typename ForwardIt>
1704 __zdd
1706 {
1707 return zdd_from(f, make_generator(begin, end));
1708 }
1709
1714 template <typename ForwardIt>
1715 __zdd
1717 {
1718 return zdd_from(ep, f, make_generator(begin, end));
1719 }
1720
1733 __zdd
1734 zdd_from(const bdd& f);
1735
1740 __zdd
1741 zdd_from(const exec_policy& ep, const bdd& f);
1742
1745
1750
1754 void
1755 zdd_printdot(const zdd& A, std::ostream& out = std::cout, bool include_id = false);
1756
1760 void
1761 zdd_printdot(const zdd& A, const std::string& file_name, bool include_id = false);
1762
1765
1768}
1769
1770#endif // ADIAR_ZDD_H
A (possibly unreduced) Zero-suppressed Decision Diagram.
Definition zdd.h:24
A reduced Binary Decision Diagram.
Definition bdd.h:53
Settings to dictate the execution of Adiar's algorithms.
Definition exec_policy.h:35
node_type::label_type label_type
Type of this node's variable label.
Definition dd.h:282
Reduced Ordered Zero-suppressed Decision Diagram.
Definition zdd.h:62
__bdd operator|(const bdd &lhs, const bdd &rhs)
__zdd zdd_change(const zdd &A, const generator< zdd::label_type > &vars)
The symmetric difference between each set in the family and the given set of variables.
zdd zdd_null()
The family only with the empty set, i.e. { Ø } .
zdd zdd_top()
Top of the powerset lattice.
zdd zdd_ithvar(zdd::label_type var, const generator< zdd::label_type > &dom)
The set of bitvectors over a given domain where var is set to true.
zdd zdd_point(const generator< zdd::label_type > &vars)
The family { { 1, 2, ..., k } } with a single bit-vector.
bool zdd_disjoint(const zdd &A, const zdd &B)
Whether the two families are disjoint.
__zdd zdd_binop(const zdd &A, const zdd &B, const predicate< bool, bool > &op)
Apply a binary operator between the sets of two families.
void zdd_printdot(const zdd &A, std::ostream &out=std::cout, bool include_id=false)
Output a DOT drawing of a ZDD to the given output stream.
zdd zdd_powerset(const generator< zdd::label_type > &vars)
The powerset of all given variables.
__zdd zdd_onset(const zdd &A, zdd::label_type var)
Subset that do include the given element.
bdd operator+(const bdd &f)
__zdd zdd_expand(const zdd &A, const generator< zdd::label_type > &vars)
Expands the domain of the given ZDD to also include the given set of labels.
bool zdd_isempty(const zdd &A)
Whether it is the empty family, i.e. Ø .
bool zdd_subseteq(const zdd &A, const zdd &B)
Whether one family is a subset or equal to the other.
__bdd operator&(const bdd &lhs, const bdd &rhs)
zdd zdd_nithvar(zdd::label_type var, const generator< zdd::label_type > &dom)
The set of bitvectors over a given domain where var is set to false.
zdd zdd_vars(const generator< zdd::label_type > &vars)
The family { { 1, 2, ..., k } }.
bool zdd_isfalse(const zdd &A)
Whether this ZDD represents false terminal.
uint64_t zdd_size(const zdd &A)
The number of sets in the family of sets.
bool zdd_equal(const zdd &A, const zdd &B)
Whether they represent the same family.
bool operator>(const zdd &lhs, const zdd &rhs)
zdd zdd_singletons(const generator< zdd::label_type > &vars)
The family { {1}, {2}, ..., {k} }.
__bdd operator*(const bdd &lhs, const bdd &rhs)
__zdd zdd_offset(const zdd &A, zdd::label_type var)
Subset that do not include the given element.
size_t zdd_nodecount(const zdd &A)
The number of (internal) nodes used to represent the family of sets.
bool zdd_isnull(const zdd &A)
Whether it is the null family, i.e. { Ø } .
bool operator<=(const zdd &lhs, const zdd &rhs)
bool zdd_istrue(const zdd &A)
Whether this BDD represents true terminal.
bool operator>=(const zdd &lhs, const zdd &rhs)
__zdd zdd_union(const zdd &A, const zdd &B)
The union of two families of sets.
__zdd zdd_complement(const zdd &A, const generator< zdd::label_type > &dom)
Complement of A within the given domain.
bool zdd_subset(const zdd &A, const zdd &B)
Whether one family is a strict subset of the other.
bool operator!=(const bdd &f, const bdd &g)
bool zdd_isterminal(const zdd &A)
Whether this ZDD represents a terminal.
zdd zdd_bot()
Bottom of the powerset lattice.
bool operator<(const zdd &lhs, const zdd &rhs)
bdd operator~(const bdd &f)
zdd zdd_singleton(zdd::label_type var)
The family { {i} } .
bool zdd_ispoint(const zdd &A)
Whether it contains a single bit-vector a, i.e. A = { a }.
__zdd zdd_project(const zdd &A, const predicate< zdd::label_type > &dom)
Project family of sets onto a domain, i.e. remove from every set all variables not within the domain.
zdd zdd_empty()
The empty family, i.e. Ø .
__zdd zdd_intsec(const zdd &A, const zdd &B)
The intersection of two families of sets.
bool operator==(const bdd &f, const bdd &g)
bool zdd_unequal(const zdd &A, const zdd &B)
Whether they represent two different families.
zdd zdd_terminal(bool value)
The ZDD of only a single terminal.
__zdd zdd_from(const bdd &f, const generator< zdd::label_type > &dom)
Obtains the ZDD that represents the same function/set as the given BDD within the given domain.
bool zdd_iscanonical(const zdd &A)
Check whether a given ZDD is canonical.
zdd::label_type zdd_varcount(const zdd &A)
The number of variables that exist in the family of sets, i.e. the number of levels present in the ZD...
bdd operator-(const bdd &f)
__zdd zdd_diff(const zdd &A, const zdd &B)
The set difference of two families of sets.
function< optional< RetType >()> generator
Generator function that produces a new value of RetType for each call.
Definition functional.h:170
function< void(Arg)> consumer
Consumer function of value of type Arg.
Definition functional.h:64
generator< typename std::remove_reference_t< ForwardIt >::value_type > make_generator(ForwardIt &&begin, ForwardIt &&end)
Wrap a begin and end iterator pair into a generator function.
Definition functional.h:177
function< bool(Args...)> predicate
Predicate function given value(s) of type(s) Args.
Definition functional.h:51
consumer< ValueType > make_consumer(OutputIt &&iter)
Wrap an iterator into a consumer function.
Definition functional.h:71
zdd::label_type zdd_minvar(const zdd &A)
Get the minimal occurring variable in the family.
zdd::label_type zdd_topvar(const zdd &f)
Get the root's variable label.
zdd::label_type zdd_maxvar(const zdd &A)
Get the maximal occurring variable in the family.
bool zdd_contains(const zdd &A, const generator< zdd::label_type > &a)
Whether the family includes the given set of labels.
zdd zdd_minelem(const zdd &A)
Retrieves the lexicographically smallest set a in A.
zdd zdd_maxelem(const zdd &A)
Retrieves the lexicographically largest set a in A.
void zdd_support(const zdd &A, const consumer< zdd::label_type > &cb)
Get (in ascending order) all of the variable labels that occur in the family.
Core types.
Definition adiar.h:40