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
21
22#include <iostream>
23#include <string>
24
25#include <adiar/bdd/bdd.h>
26#include <adiar/bool_op.h>
27#include <adiar/exec_policy.h>
28#include <adiar/functional.h>
29#include <adiar/zdd/zdd.h>
30
31namespace adiar
32{
47
56 zdd
58
62 zdd
64
68 zdd
70
89 zdd
91
110 template <typename ForwardIt>
111 zdd
116
125 zdd
127
146 zdd
148
167 template <typename ForwardIt>
168 zdd
173
182 zdd
184
198 zdd
200
214 template <typename ForwardIt>
215 zdd
220
233 zdd
235
249 template <typename ForwardIt>
250 zdd
255
268 zdd
270
284 zdd
286
300 template <typename ForwardIt>
301 zdd
306
319 zdd
321
335 template <typename ForwardIt>
336 zdd
341
351 zdd
353
366 template <typename ForwardIt>
367 inline zdd
372
378 zdd
380
390 zdd
392
405 template <typename ForwardIt>
406 inline zdd
411
420 zdd
422
426
438
455 __zdd
456 zdd_binop(const zdd& A, const zdd& B, const predicate<bool, bool>& op);
457
462 __zdd
463 zdd_binop(const exec_policy& ep, const zdd& A, const zdd& B, const predicate<bool, bool>& op);
465
471 __zdd
472 zdd_union(const zdd& A, const zdd& B);
473
478 __zdd
479 zdd_union(const exec_policy& ep, const zdd& A, const zdd& B);
481
485 __zdd
486 operator|(const zdd& lhs, const zdd& rhs);
487
489 __zdd
490 operator|(__zdd&&, __zdd&&);
491 __zdd
492 operator|(const zdd&, __zdd&&);
493 __zdd
494 operator|(__zdd&&, const zdd&);
496
500 zdd
501 operator+(const zdd& A);
502
504 __zdd
505 operator+(__zdd&& A);
507
511 __zdd
512 operator+(const zdd& lhs, const zdd& rhs);
513
515 __zdd
516 operator+(__zdd&&, __zdd&&);
517 __zdd
518 operator+(const zdd&, __zdd&&);
519 __zdd
520 operator+(__zdd&&, const zdd&);
522
528 __zdd
529 zdd_intsec(const zdd& A, const zdd& B);
530
535 __zdd
536 zdd_intsec(const exec_policy& ep, const zdd& A, const zdd& B);
538
542 __zdd
543 operator&(const zdd& lhs, const zdd& rhs);
544
546 __zdd
547 operator&(__zdd&&, __zdd&&);
548 __zdd
549 operator&(const zdd&, __zdd&&);
550 __zdd
551 operator&(__zdd&&, const zdd&);
553
557 __zdd
558 operator*(const zdd& lhs, const zdd& rhs);
559
561 __zdd
562 operator*(__zdd&&, __zdd&&);
563 __zdd
564 operator*(const zdd&, __zdd&&);
565 __zdd
566 operator*(__zdd&&, const zdd&);
568
574 __zdd
575 zdd_diff(const zdd& A, const zdd& B);
576
581 __zdd
582 zdd_diff(const exec_policy& ep, const zdd& A, const zdd& B);
584
591 __zdd
592 operator-(const zdd& A);
593
595 __zdd
596 operator-(__zdd&& A);
598
602 __zdd
603 operator-(const zdd& lhs, const zdd& rhs);
604
606 __zdd
607 operator-(__zdd&&, __zdd&&);
608 __zdd
609 operator-(const zdd&, __zdd&&);
610 __zdd
611 operator-(__zdd&&, const zdd&);
613
626 __zdd
628
633 __zdd
635
637
653 template <typename ForwardIt>
654 __zdd
659
664 template <typename ForwardIt>
665 __zdd
666 zdd_change(const exec_policy& ep, const zdd& A, ForwardIt begin, ForwardIt end)
667 {
669 }
670
672
684 __zdd
686
691 __zdd
693
695
711 template <typename ForwardIt>
712 __zdd
717
722 template <typename ForwardIt>
723 __zdd
724 zdd_complement(const exec_policy& ep, const zdd& A, ForwardIt begin, ForwardIt end)
725 {
727 }
728
730
744 __zdd
746
751 __zdd
752 zdd_complement(const exec_policy& ep, const zdd& A);
754
758 __zdd
759 operator~(const zdd& A);
760
762 __zdd
763 operator~(__zdd&& A);
765
781 __zdd
783
788 __zdd
790
792
813 template <typename ForwardIt>
814 __zdd
819
824 template <typename ForwardIt>
825 __zdd
826 zdd_expand(const exec_policy& ep, const zdd& A, ForwardIt begin, ForwardIt end)
827 {
829 }
830
832
844 __zdd
846
851 __zdd
854
867 __zdd
868 zdd_offset(const zdd& A);
869
874 __zdd
875 zdd_offset(const exec_policy& ep, const zdd& A);
877
890 __zdd
892
897 __zdd
899
901
917 template <typename ForwardIt>
918 __zdd
923
928 template <typename ForwardIt>
929 __zdd
930 zdd_offset(const exec_policy& ep, const zdd& A, ForwardIt begin, ForwardIt end)
931 {
933 }
934
936
948 __zdd
950
955 __zdd
958
971 __zdd
972 zdd_onset(const zdd& A);
973
978 __zdd
979 zdd_onset(const exec_policy& ep, const zdd& A);
981
994 __zdd
996
1001 __zdd
1003
1005
1021 template <typename ForwardIt>
1022 __zdd
1024 {
1025 return zdd_onset(A, make_generator(begin, end));
1026 }
1027
1032 template <typename ForwardIt>
1033 __zdd
1034 zdd_onset(const exec_policy& ep, const zdd& A, ForwardIt begin, ForwardIt end)
1035 {
1036 return zdd_onset(ep, A, make_generator(begin, end));
1037 }
1038
1040
1055 __zdd
1057
1059
1068 __zdd
1070
1078 __zdd
1080
1085 __zdd
1087
1096 __zdd
1098
1106 __zdd
1108
1110
1126 __zdd
1128
1130
1139 __zdd
1141
1149 __zdd
1151
1156 __zdd
1158
1167 __zdd
1169
1177 __zdd
1179
1181
1200 template <typename ForwardIt>
1201 __zdd
1203 {
1205 }
1206
1208
1217 template <typename ForwardIt>
1218 __zdd
1220 {
1221 return zdd_project(std::move(A), make_generator(begin, end));
1222 }
1223
1231 template <typename ForwardIt>
1232 __zdd
1234 {
1235 return zdd_project(std::move(A), make_generator(begin, end));
1236 }
1237
1242 template <typename ForwardIt>
1243 __zdd
1244 zdd_project(const exec_policy& ep, const zdd& A, ForwardIt begin, ForwardIt end)
1245 {
1246 return zdd_project(ep, A, make_generator(begin, end));
1247 }
1248
1257 template <typename ForwardIt>
1258 __zdd
1259 zdd_project(const exec_policy& ep, zdd&& A, ForwardIt begin, ForwardIt end)
1260 {
1261 return zdd_project(ep, std::move(A), make_generator(begin, end));
1262 }
1263
1271 template <typename ForwardIt>
1272 __zdd
1273 zdd_project(const exec_policy& ep, __zdd&& A, ForwardIt begin, ForwardIt end)
1274 {
1275 return zdd_project(ep, std::move(A), make_generator(begin, end));
1276 }
1277
1279
1283
1295
1301 bool
1303
1307 bool
1309
1319 bool
1321
1331 bool
1333
1337 bool
1339
1343 bool
1345
1349 bool
1351
1355 bool
1356 zdd_equal(const zdd& A, const zdd& B);
1357
1362 bool
1363 zdd_equal(const exec_policy& ep, const zdd& A, const zdd& B);
1365
1369 bool
1370 operator==(const zdd& lhs, const zdd& rhs);
1371
1373 bool
1374 operator==(__zdd&&, __zdd&&);
1375 bool
1376 operator==(const zdd&, __zdd&&);
1377 bool
1378 operator==(__zdd&&, const zdd&);
1380
1384 bool
1385 zdd_unequal(const zdd& A, const zdd& B);
1386
1391 bool
1392 zdd_unequal(const exec_policy& ep, const zdd& A, const zdd& B);
1394
1398 bool
1399 operator!=(const zdd& lhs, const zdd& rhs);
1400
1402 bool
1403 operator!=(__zdd&&, __zdd&&);
1404 bool
1405 operator!=(const zdd&, __zdd&&);
1406 bool
1407 operator!=(__zdd&&, const zdd&);
1409
1413 bool
1414 zdd_subseteq(const zdd& A, const zdd& B);
1415
1420 bool
1421 zdd_subseteq(const exec_policy& ep, const zdd& A, const zdd& B);
1423
1427 bool
1428 operator<=(const zdd& lhs, const zdd& rhs);
1429
1431 bool
1432 operator<=(__zdd&&, __zdd&&);
1433 bool
1434 operator<=(const zdd&, __zdd&&);
1435 bool
1436 operator<=(__zdd&&, const zdd&);
1438
1442 bool
1443 operator>=(const zdd& lhs, const zdd& rhs);
1444
1446 bool
1447 operator>=(__zdd&&, __zdd&&);
1448 bool
1449 operator>=(const zdd&, __zdd&&);
1450 bool
1451 operator>=(__zdd&&, const zdd&);
1453
1457 bool
1458 zdd_subset(const zdd& A, const zdd& B);
1459
1464 bool
1465 zdd_subset(const exec_policy& ep, const zdd& A, const zdd& B);
1467
1471 bool
1472 operator<(const zdd& lhs, const zdd& rhs);
1473
1475 bool
1476 operator<(__zdd&&, __zdd&&);
1477 bool
1478 operator<(const zdd&, __zdd&&);
1479 bool
1480 operator<(__zdd&&, const zdd&);
1482
1486 bool
1487 operator>(const zdd& lhs, const zdd& rhs);
1488
1490 bool
1491 operator>(__zdd&&, __zdd&&);
1492 bool
1493 operator>(const zdd&, __zdd&&);
1494 bool
1495 operator>(__zdd&&, const zdd&);
1497
1501 bool
1502 zdd_disjoint(const zdd& A, const zdd& B);
1503
1508 bool
1509 zdd_disjoint(const exec_policy& ep, const zdd& A, const zdd& B);
1511
1515
1527
1531 size_t
1533
1540
1544 uint64_t
1545 zdd_size(const zdd& A);
1546
1551 uint64_t
1552 zdd_size(const exec_policy& ep, const zdd& A);
1554
1558
1570
1580 void
1582
1595 template <typename OutputIt,
1596 typename = enable_if<!is_convertible<OutputIt, consumer<zdd::label_type>>>>
1597 OutputIt
1599 {
1601 return iter;
1602 }
1603
1611
1619
1627
1640 bool
1642
1658 template <typename ForwardIt>
1659 bool
1664
1675 zdd
1677
1690 void
1692
1704 template <typename OutputIt,
1705 typename = enable_if<!is_convertible<OutputIt, consumer<zdd::label_type>>>>
1706 OutputIt
1708 {
1710 return iter;
1711 }
1712
1723 zdd
1725
1738 void
1740
1752 template <typename OutputIt,
1753 typename = enable_if<!is_convertible<OutputIt, consumer<zdd::label_type>>>>
1754 OutputIt
1756 {
1758 return iter;
1759 }
1760
1764
1776
1790 __zdd
1792
1798 __zdd
1799 zdd_from(const exec_policy& ep, const bdd& f, const generator<zdd::label_type>& dom);
1800
1802
1819 template <typename ForwardIt>
1820 __zdd
1822 {
1823 return zdd_from(f, make_generator(begin, end));
1824 }
1825
1831 template <typename ForwardIt>
1832 __zdd
1833 zdd_from(const exec_policy& ep, const bdd& f, ForwardIt begin, ForwardIt end)
1834 {
1835 return zdd_from(ep, f, make_generator(begin, end));
1836 }
1837
1839
1852 __zdd
1853 zdd_from(const bdd& f);
1854
1860 __zdd
1861 zdd_from(const exec_policy& ep, const bdd& f);
1863
1867
1879
1883 void
1884 zdd_printdot(const zdd& A, std::ostream& out = std::cout, bool include_id = false);
1885
1889 void
1890 zdd_printdot(const zdd& A, const std::string& file_name, bool include_id = false);
1891
1895}
1896
1897#endif // ADIAR_ZDD_H
A (possibly unreduced) Zero-suppressed Decision Diagram.
Definition zdd.h:24
A reduced Binary Decision Diagram.
Definition bdd.h:59
Settings to dictate the execution of Adiar's algorithms.
Definition exec_policy.h:35
level_type label_type
Type of variable labels.
Definition dd.h:312
Reduced Ordered Zero-suppressed Decision Diagram.
Definition zdd.h:68
__bdd operator|(const bdd &lhs, const bdd &rhs)
bdd operator+(const bdd &f)
__bdd operator&(const bdd &lhs, const bdd &rhs)
__bdd operator*(const bdd &lhs, const bdd &rhs)
bdd operator~(const bdd &f)
bdd operator-(const bdd &f)
bool operator!=(const bdd &f, const bdd &g)
bool operator==(const bdd &f, const bdd &g)
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 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_binop(const zdd &A, const zdd &B, const predicate< bool, bool > &op)
Apply a binary operator between the sets of two families.
__zdd zdd_onset(const zdd &A, zdd::label_type var)
Subset that do include the given element.
__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.
__zdd zdd_offset(const zdd &A, zdd::label_type var)
Subset that do not include the given element.
__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.
__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_intsec(const zdd &A, const zdd &B)
The intersection of two families of sets.
__zdd zdd_diff(const zdd &A, const zdd &B)
The set difference of two families of sets.
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.
zdd zdd_powerset(const generator< zdd::label_type > &vars)
The powerset of all given variables.
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 } }.
zdd zdd_singletons(const generator< zdd::label_type > &vars)
The family { {1}, {2}, ..., {k} }.
zdd zdd_bot()
Bottom of the powerset lattice.
zdd zdd_singleton(zdd::label_type var)
The family { {i} } .
zdd zdd_empty()
The empty family, i.e. Ø .
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.
uint64_t zdd_size(const zdd &A)
The number of sets in the family of sets.
size_t zdd_nodecount(const zdd &A)
The number of (internal) nodes used to represent the family of sets.
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...
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::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.
bool zdd_disjoint(const zdd &A, const zdd &B)
Whether the two families are disjoint.
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.
bool zdd_isfalse(const zdd &A)
Whether this ZDD is the false terminal.
bool zdd_equal(const zdd &A, const zdd &B)
Whether they represent the same family.
bool operator>(const zdd &lhs, const zdd &rhs)
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 ZDD is the true terminal.
bool operator>=(const zdd &lhs, const zdd &rhs)
bool zdd_subset(const zdd &A, const zdd &B)
Whether one family is a strict subset of the other.
bool zdd_isterminal(const zdd &A)
Whether this ZDD represents a terminal.
bool operator<(const zdd &lhs, const zdd &rhs)
bool zdd_ispoint(const zdd &A)
Whether it contains a single bit-vector a, i.e. A = { a }.
bool zdd_unequal(const zdd &A, const zdd &B)
Whether they represent two different families.
bool zdd_iscanonical(const zdd &A)
Check whether a given ZDD is canonical.
Core types.
Definition adiar.h:40