PySDD 1.0.5__tar.gz → 1.0.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. pysdd-1.0.7/MANIFEST.in +5 -0
  2. {pysdd-1.0.5 → pysdd-1.0.7}/PKG-INFO +3 -2
  3. {pysdd-1.0.5 → pysdd-1.0.7}/PySDD.egg-info/PKG-INFO +3 -2
  4. {pysdd-1.0.5 → pysdd-1.0.7}/PySDD.egg-info/SOURCES.txt +16 -0
  5. {pysdd-1.0.5 → pysdd-1.0.7}/pyproject.toml +1 -1
  6. pysdd-1.0.7/pysdd/compiler_c.pxd +37 -0
  7. pysdd-1.0.7/pysdd/fnf_c.pxd +17 -0
  8. pysdd-1.0.7/pysdd/io_c.pxd +22 -0
  9. pysdd-1.0.7/pysdd/lib/libsdd-2.0/include/iterators.h +243 -0
  10. pysdd-1.0.7/pysdd/lib/libsdd-2.0/include/macros.h +273 -0
  11. pysdd-1.0.7/pysdd/lib/libsdd-2.0/include/parameters.h +71 -0
  12. pysdd-1.0.7/pysdd/lib/libsdd-2.0/include/sdd.h +823 -0
  13. pysdd-1.0.7/pysdd/lib/libsdd-2.0/include/stacks.h +86 -0
  14. pysdd-1.0.7/pysdd/lib/libsdd-2.0/src/vtree_operations/vtree_ops.h +48 -0
  15. pysdd-1.0.7/pysdd/lib/sdd-2.0/include/compiler.h +104 -0
  16. pysdd-1.0.7/pysdd/lib/sdd-2.0/include/fnf.h +13 -0
  17. pysdd-1.0.7/pysdd/lib/sdd-2.0/include/io.h +11 -0
  18. pysdd-1.0.7/pysdd/lib/sdd-2.0/include/sddapi.h +341 -0
  19. pysdd-1.0.7/pysdd/lib/sdd_extra/include/sddapi_extra.h +22 -0
  20. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/sdd.pyx +4 -1
  21. pysdd-1.0.7/pysdd/sddapi_c.pxd +241 -0
  22. {pysdd-1.0.5 → pysdd-1.0.7}/tests/test_minimize.py +16 -0
  23. {pysdd-1.0.5 → pysdd-1.0.7}/LICENSE +0 -0
  24. {pysdd-1.0.5 → pysdd-1.0.7}/PySDD.egg-info/dependency_links.txt +0 -0
  25. {pysdd-1.0.5 → pysdd-1.0.7}/PySDD.egg-info/entry_points.txt +0 -0
  26. {pysdd-1.0.5 → pysdd-1.0.7}/PySDD.egg-info/requires.txt +0 -0
  27. {pysdd-1.0.5 → pysdd-1.0.7}/PySDD.egg-info/top_level.txt +0 -0
  28. {pysdd-1.0.5 → pysdd-1.0.7}/README.rst +0 -0
  29. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/__init__.py +0 -0
  30. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/__main__.py +0 -0
  31. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/cli.py +0 -0
  32. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/iterator.py +0 -0
  33. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/basic/computed.c +0 -0
  34. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/basic/count_and_size.c +0 -0
  35. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/basic/gc.c +0 -0
  36. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/basic/hash.c +0 -0
  37. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/basic/memory.c +0 -0
  38. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/basic/multiply.c +0 -0
  39. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/basic/nodes.c +0 -0
  40. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/basic/partitions.c +0 -0
  41. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/basic/references.c +0 -0
  42. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/basic/replace.c +0 -0
  43. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/basic/shadows.c +0 -0
  44. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/basic/sort.c +0 -0
  45. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/manager/copy.c +0 -0
  46. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/manager/interface.c +0 -0
  47. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/manager/manager.c +0 -0
  48. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/manager/stats.c +0 -0
  49. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/manager/variables.c +0 -0
  50. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/sdds/apply.c +0 -0
  51. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/sdds/bits.c +0 -0
  52. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/sdds/cardinality.c +0 -0
  53. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/sdds/condition.c +0 -0
  54. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/sdds/copy.c +0 -0
  55. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/sdds/count.c +0 -0
  56. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/sdds/essential_vars.c +0 -0
  57. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/sdds/exists.c +0 -0
  58. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/sdds/exists_multiple.c +0 -0
  59. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/sdds/exists_multiple_static.c +0 -0
  60. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/sdds/forall.c +0 -0
  61. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/sdds/io.c +0 -0
  62. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/sdds/model_count.c +0 -0
  63. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/sdds/rename_vars.c +0 -0
  64. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/sdds/size.c +0 -0
  65. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/sdds/wmc.c +0 -0
  66. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/util.c +0 -0
  67. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/verify.c +0 -0
  68. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/version.c +0 -0
  69. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtree_fragments/construction.c +0 -0
  70. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtree_fragments/moves.c +0 -0
  71. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtree_fragments/operations.c +0 -0
  72. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtree_operations/cartesian_product.c +0 -0
  73. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtree_operations/dissect.c +0 -0
  74. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtree_operations/limits.c +0 -0
  75. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtree_operations/op_left_rotate.c +0 -0
  76. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtree_operations/op_right_rotate.c +0 -0
  77. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtree_operations/op_swap.c +0 -0
  78. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtree_operations/rollback.c +0 -0
  79. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtree_operations/split.c +0 -0
  80. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtree_search/auto.c +0 -0
  81. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtree_search/search.c +0 -0
  82. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtree_search/state.c +0 -0
  83. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtrees/compare.c +0 -0
  84. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtrees/edit.c +0 -0
  85. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtrees/io.c +0 -0
  86. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtrees/maps.c +0 -0
  87. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtrees/moves.c +0 -0
  88. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtrees/static.c +0 -0
  89. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/libsdd-2.0/src/vtrees/vtree.c +0 -0
  90. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/sdd-2.0/src/fnf/compiler.c +0 -0
  91. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/sdd-2.0/src/fnf/fnf.c +0 -0
  92. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/sdd-2.0/src/fnf/io.c +0 -0
  93. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/lib/sdd-2.0/src/fnf/utils.c +0 -0
  94. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/util.py +0 -0
  95. {pysdd-1.0.5 → pysdd-1.0.7}/pysdd/wmcstochastic.py +0 -0
  96. {pysdd-1.0.5 → pysdd-1.0.7}/setup.cfg +0 -0
  97. {pysdd-1.0.5 → pysdd-1.0.7}/tests/test_iterator.py +0 -0
  98. {pysdd-1.0.5 → pysdd-1.0.7}/tests/test_nnf.py +0 -0
  99. {pysdd-1.0.5 → pysdd-1.0.7}/tests/test_psdd.py +0 -0
  100. {pysdd-1.0.5 → pysdd-1.0.7}/tests/test_util.py +0 -0
  101. {pysdd-1.0.5 → pysdd-1.0.7}/tests/test_vtree.py +0 -0
  102. {pysdd-1.0.5 → pysdd-1.0.7}/tests/test_wmcstochastic.py +0 -0
@@ -0,0 +1,5 @@
1
+ # The sdist must hold what the build needs: setuptools adds the .pyx and .c
2
+ # sources listed in pyproject.toml, but not the .pxd files sdd.pyx cimports
3
+ # or the C headers in the include dirs.
4
+ include pysdd/*.pxd
5
+ recursive-include pysdd/lib *.h
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: PySDD
3
- Version: 1.0.5
3
+ Version: 1.0.7
4
4
  Summary: Sentential Decision Diagrams
5
5
  Author: Arthur Choi
6
6
  Author-email: Wannes Meert <wannes.meert@cs.kuleuven.be>, Robin Manhaeve <robin.manhaeve@kuleuven.be>
@@ -33,6 +33,7 @@ Provides-Extra: tests
33
33
  Requires-Dist: pytest; extra == "tests"
34
34
  Provides-Extra: notebooks
35
35
  Requires-Dist: numpy; extra == "notebooks"
36
+ Dynamic: license-file
36
37
 
37
38
  =====
38
39
  PySDD
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: PySDD
3
- Version: 1.0.5
3
+ Version: 1.0.7
4
4
  Summary: Sentential Decision Diagrams
5
5
  Author: Arthur Choi
6
6
  Author-email: Wannes Meert <wannes.meert@cs.kuleuven.be>, Robin Manhaeve <robin.manhaeve@kuleuven.be>
@@ -33,6 +33,7 @@ Provides-Extra: tests
33
33
  Requires-Dist: pytest; extra == "tests"
34
34
  Provides-Extra: notebooks
35
35
  Requires-Dist: numpy; extra == "notebooks"
36
+ Dynamic: license-file
36
37
 
37
38
  =====
38
39
  PySDD
@@ -1,4 +1,5 @@
1
1
  LICENSE
2
+ MANIFEST.in
2
3
  README.rst
3
4
  pyproject.toml
4
5
  PySDD.egg-info/PKG-INFO
@@ -10,10 +11,19 @@ PySDD.egg-info/top_level.txt
10
11
  pysdd/__init__.py
11
12
  pysdd/__main__.py
12
13
  pysdd/cli.py
14
+ pysdd/compiler_c.pxd
15
+ pysdd/fnf_c.pxd
16
+ pysdd/io_c.pxd
13
17
  pysdd/iterator.py
14
18
  pysdd/sdd.pyx
19
+ pysdd/sddapi_c.pxd
15
20
  pysdd/util.py
16
21
  pysdd/wmcstochastic.py
22
+ pysdd/lib/libsdd-2.0/include/iterators.h
23
+ pysdd/lib/libsdd-2.0/include/macros.h
24
+ pysdd/lib/libsdd-2.0/include/parameters.h
25
+ pysdd/lib/libsdd-2.0/include/sdd.h
26
+ pysdd/lib/libsdd-2.0/include/stacks.h
17
27
  pysdd/lib/libsdd-2.0/src/util.c
18
28
  pysdd/lib/libsdd-2.0/src/verify.c
19
29
  pysdd/lib/libsdd-2.0/src/version.c
@@ -61,6 +71,7 @@ pysdd/lib/libsdd-2.0/src/vtree_operations/op_right_rotate.c
61
71
  pysdd/lib/libsdd-2.0/src/vtree_operations/op_swap.c
62
72
  pysdd/lib/libsdd-2.0/src/vtree_operations/rollback.c
63
73
  pysdd/lib/libsdd-2.0/src/vtree_operations/split.c
74
+ pysdd/lib/libsdd-2.0/src/vtree_operations/vtree_ops.h
64
75
  pysdd/lib/libsdd-2.0/src/vtree_search/auto.c
65
76
  pysdd/lib/libsdd-2.0/src/vtree_search/search.c
66
77
  pysdd/lib/libsdd-2.0/src/vtree_search/state.c
@@ -71,10 +82,15 @@ pysdd/lib/libsdd-2.0/src/vtrees/maps.c
71
82
  pysdd/lib/libsdd-2.0/src/vtrees/moves.c
72
83
  pysdd/lib/libsdd-2.0/src/vtrees/static.c
73
84
  pysdd/lib/libsdd-2.0/src/vtrees/vtree.c
85
+ pysdd/lib/sdd-2.0/include/compiler.h
86
+ pysdd/lib/sdd-2.0/include/fnf.h
87
+ pysdd/lib/sdd-2.0/include/io.h
88
+ pysdd/lib/sdd-2.0/include/sddapi.h
74
89
  pysdd/lib/sdd-2.0/src/fnf/compiler.c
75
90
  pysdd/lib/sdd-2.0/src/fnf/fnf.c
76
91
  pysdd/lib/sdd-2.0/src/fnf/io.c
77
92
  pysdd/lib/sdd-2.0/src/fnf/utils.c
93
+ pysdd/lib/sdd_extra/include/sddapi_extra.h
78
94
  tests/test_iterator.py
79
95
  tests/test_minimize.py
80
96
  tests/test_nnf.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "PySDD"
7
- version = "1.0.5"
7
+ version = "1.0.7"
8
8
  description = "Sentential Decision Diagrams"
9
9
  authors = [
10
10
  { name = "Wannes Meert", email = "wannes.meert@cs.kuleuven.be" },
@@ -0,0 +1,37 @@
1
+ """
2
+ compiler_c - SDD
3
+
4
+ __author__ = "Wannes Meert, Arthur Choi"
5
+ __license__ = "APL"
6
+
7
+ """
8
+
9
+ from . cimport sddapi_c
10
+
11
+ cdef extern from "compiler.h":
12
+ ctypedef struct SddCompilerOptions:
13
+ # input files
14
+ char* cnf_filename # input cnf filename
15
+ char* dnf_filename # input dnf filename
16
+ char* vtree_filename # input vtree filename
17
+ char* sdd_filename # input sdd filename (.sdd, plain text)
18
+ # output files
19
+ char* output_vtree_filename # output vtree filename (.vtree, plain text)
20
+ char* output_vtree_dot_filename # output vtree filename (.dot)
21
+ char* output_sdd_filename # output sdd filename (.sdd, plain text)
22
+ char* output_sdd_dot_filename # output sdd filename (.dot)
23
+ # flags
24
+ int minimize_cardinality # construct sdd that has only minimum cardinality models
25
+ # initial vtree
26
+ char* initial_vtree_type # initial vtree for manager
27
+ # compilation controls
28
+ int vtree_search_mode # vtree search mode
29
+ int post_search # post-compilation search
30
+ int verbose # print manager
31
+ ctypedef struct Fnf:
32
+ long long var_count;
33
+ sddapi_c.SddSize litset_count;
34
+ ctypedef Fnf Cnf;
35
+ ctypedef Fnf Dnf;
36
+
37
+ sddapi_c.SddNode* fnf_to_sdd(Fnf* fnf, sddapi_c.SddManager* manager);
@@ -0,0 +1,17 @@
1
+ # -*- coding: UTF-8 -*-
2
+ """
3
+ pysdd.fnf_c
4
+ ~~~~~~~~~~~
5
+
6
+ :author: Wannes Meert, Arthur Choi
7
+ :copyright: Copyright 2017-2018 KU Leuven and Regents of the University of California.
8
+ :license: Apache License, Version 2.0, see LICENSE for details.
9
+ """
10
+ from . cimport sddapi_c
11
+ from . cimport compiler_c
12
+
13
+ cdef extern from "fnf.h":
14
+ void free_fnf(compiler_c.Fnf* fnf)
15
+
16
+ # cdef extern from "fnf_wrapper.h":
17
+ # void free_fnf_wrapper(compiler_c.Fnf* fnf)
@@ -0,0 +1,22 @@
1
+ # -*- coding: UTF-8 -*-
2
+ """
3
+ pysdd.io_c
4
+ ~~~~~~~~~~
5
+
6
+ :author: Wannes Meert, Arthur Choi
7
+ :copyright: Copyright 2017-2018 KU Leuven and Regents of the University of California.
8
+ :license: Apache License, Version 2.0, see LICENSE for details.
9
+ """
10
+ from . cimport sddapi_c
11
+ from . cimport compiler_c
12
+
13
+ cdef extern from "io.h":
14
+ compiler_c.Fnf* read_fnf(const char* filename);
15
+ compiler_c.Cnf* read_cnf(const char* filename);
16
+ compiler_c.Dnf* read_dnf(const char* filename);
17
+
18
+
19
+ # cdef extern from "io_wrapper.h":
20
+ # compiler_c.Fnf* read_fnf_wrapper(const char* filename)
21
+ # compiler_c.Cnf* read_cnf_wrapper(const char* filename)
22
+ # compiler_c.Dnf* read_dnf_wrapper(const char* filename)
@@ -0,0 +1,243 @@
1
+ /****************************************************************************************
2
+ * The Sentential Decision Diagram Package
3
+ * sdd version 2.0, January 8, 2018
4
+ * http://reasoning.cs.ucla.edu/sdd
5
+ ****************************************************************************************/
6
+
7
+ #ifndef ITERATORS_H_
8
+ #define ITERATORS_H_
9
+
10
+ /****************************************************************************************
11
+ * iterator over ALL vtree nodes (linked using ->next, ->prev, ->first and ->last)
12
+ ****************************************************************************************/
13
+
14
+ //iterates over each node V in a vtree rooted at R, executing code B for each node
15
+ //
16
+ //V: vtree node
17
+ //R: vtree root
18
+ //B: code
19
+ #define FOR_each_vtree_node(V,R,B) {\
20
+ Vtree* V = (R)->first; /* head of linked list */\
21
+ Vtree* _out = (R)->last->next; /* node following last node of vtree (can be NULL) */\
22
+ while(V!=_out) {\
23
+ assert(V);\
24
+ B; /* execute code */\
25
+ V = V->next; /* next node of vtree */\
26
+ }\
27
+ }
28
+
29
+ /****************************************************************************************
30
+ * iterator over INTERNAL vtree nodes (linked using ->next, ->prev, ->first and ->last)
31
+ *
32
+ * the nodes of a vtree linked list alternate between leaf and internal nodes, with
33
+ * the first and last nodes being leaves
34
+ ****************************************************************************************/
35
+
36
+ //iterates over each internal node V in a vtree rooted at R, executing code B for each node
37
+ //
38
+ //V: vtree node
39
+ //R: vtree root
40
+ //B: code
41
+ #define FOR_each_internal_vtree_node(V,R,B) {\
42
+ Vtree* V = (R)->first; /* first leaf node of vtree */\
43
+ Vtree* _last_leaf = (R)->last; /* last leaf node of vtree */\
44
+ while(V!=_last_leaf) {\
45
+ V = V->next; /* V is internal */\
46
+ assert(INTERNAL(V));\
47
+ B; /* execute code */\
48
+ V = V->next; /* V is leaf */\
49
+ assert(LEAF(V));\
50
+ }\
51
+ }
52
+
53
+ /****************************************************************************************
54
+ * iterator over LEAF vtree nodes (linked using ->next, ->prev, ->first and ->last)
55
+ *
56
+ * the nodes of a vtree linked list alternate between leaf and internal nodes, with
57
+ * the first and last nodes being leaves
58
+ ****************************************************************************************/
59
+
60
+ //iterates over each leaf node V in a vtree rooted at R, executing code B for each node
61
+ //
62
+ //V: vtree node
63
+ //R: vtree root
64
+ //B: code
65
+ #define FOR_each_leaf_vtree_node(V,R,B) {\
66
+ Vtree* V = (R)->first; /* first leaf node of vtree */\
67
+ Vtree* _last_leaf = (R)->last; /* last leaf node of vtree */\
68
+ while(V!=_last_leaf) {\
69
+ assert(LEAF(V));\
70
+ B; /* execute code */\
71
+ V = V->next->next; /* V is leaf */\
72
+ }\
73
+ assert(LEAF(V));\
74
+ B; /* execute code on last leaf */\
75
+ }
76
+
77
+ /****************************************************************************************
78
+ * iterator over ANCESTOR vtree nodes (visiting children before parents)
79
+ ****************************************************************************************/
80
+
81
+ //iterates over each ancestor V in a vtree rooted at R, executing code B for each node
82
+ //
83
+ //V: vtree node
84
+ //R: vtree root
85
+ //B: code
86
+ #define FOR_each_ancestral_vtree_node(V,R,B) {\
87
+ Vtree* V = (R)->parent;\
88
+ while(V) {\
89
+ B; /* execute code */\
90
+ V = V->parent;\
91
+ }\
92
+ }
93
+
94
+
95
+ /****************************************************************************************
96
+ * iterator over nodes normalized for a vtree
97
+ * (linked using the ->vtree_next and ->vtree_prev fields)
98
+ ****************************************************************************************/
99
+
100
+ //iterate over the sdd nodes normalized for vtree node V, executing code B for each node
101
+ //this iterator allows freeing sdd nodes or changing their ->vtree_next and ->vtree_prev
102
+ //fields in code B
103
+ //
104
+ //N: node
105
+ //V: vtree
106
+ //B: code
107
+ #define FOR_each_sdd_node_normalized_for(N,V,B) {\
108
+ SddNode* N = (V)->nodes; /* head of linked list */\
109
+ while(N) {\
110
+ /* save N->vtree_next in case N is freed or N->vtree_next is changed in code B */\
111
+ SddNode* _next = N->vtree_next;\
112
+ /* execute code */\
113
+ B;\
114
+ /* advance to next node */\
115
+ N = _next;\
116
+ }\
117
+ }
118
+
119
+ /****************************************************************************************
120
+ * iterator over sdd nodes normalized for nodes in vtree
121
+ ****************************************************************************************/
122
+
123
+ //N: node
124
+ //V: vtree
125
+ //B: code
126
+ #define FOR_each_decomposition_in(N,V,B) FOR_each_internal_vtree_node(v,V,FOR_each_sdd_node_normalized_for(N,v,B))
127
+ #define FOR_each_decomposition_above(N,V,B) FOR_each_ancestral_vtree_node(v,V,FOR_each_sdd_node_normalized_for(N,v,B))
128
+ #define FOR_each_literal_in(N,V,B) FOR_each_leaf_vtree_node(v,V,FOR_each_sdd_node_normalized_for(N,v,B))
129
+
130
+ /****************************************************************************************
131
+ * iterator for sdd nodes (linked using the ->next field)
132
+ ****************************************************************************************/
133
+
134
+ //this iterator allows freeing nodes or changing their ->next field in code B
135
+ //
136
+ //N: node
137
+ //L: head of linked list (node)
138
+ //B: code
139
+ #define FOR_each_linked_node(N,L,B) {\
140
+ SddNode* N = L; /* head of linked list */\
141
+ while(N) {\
142
+ /* save N->next in case N is freed or N->next is changed in code B */\
143
+ SddNode* _next = N->next;\
144
+ /* execute code */\
145
+ B;\
146
+ /* advance to next node */\
147
+ N = _next;\
148
+ }\
149
+ }
150
+
151
+ /****************************************************************************************
152
+ * iterator for unique nodes
153
+ ****************************************************************************************/
154
+
155
+ //iterates over unique nodes of manager, executing a bit of code for each node
156
+ //this iterator allows freeing nodes or changing their ->next field in code B
157
+ //
158
+ //N: node
159
+ //M: manager
160
+ //B: code to be executed for each node (references the variable E)
161
+ #define FOR_each_unique_node(N,M,B) {\
162
+ SddHash* H = M->unique_nodes;\
163
+ if(H->count) {\
164
+ SddSize _size = H->size;\
165
+ SddNode** _clists = H->clists;\
166
+ while(_size--) {\
167
+ SddNode* N = *_clists++;\
168
+ while(N) {\
169
+ /* save next in case N is freed or N->next is changed in code B */\
170
+ SddNode* _next = N->next;\
171
+ /* execute code */\
172
+ B;\
173
+ /* advance to next entry in hash table */\
174
+ N = _next;\
175
+ }\
176
+ }\
177
+ }\
178
+ }
179
+
180
+ /****************************************************************************************
181
+ * macros for iterating over primes, subs and elements of an sdd node
182
+ ****************************************************************************************/
183
+
184
+ //iterate over elements, executing code B for each element
185
+ //
186
+ //P: prime
187
+ //S: sub
188
+ //C: element count
189
+ //ES: elements array
190
+ //B: code
191
+ #define FOR_each_prime_sub_of_elements(P,S,C,ES,B) {\
192
+ for(SddElement* _e=ES; _e<(ES)+(C); _e++) {\
193
+ SddNode* P = _e->prime;\
194
+ SddNode* S = _e->sub;\
195
+ /* execute code */\
196
+ B;\
197
+ }\
198
+ }
199
+
200
+ //iterate over primes and subs P/S of sdd node N, executing code B for each P/S pair
201
+ //
202
+ //P: prime
203
+ //S: sub
204
+ //N: sdd node
205
+ //B: code
206
+ #define FOR_each_prime_sub_of_node(P,S,N,B) {\
207
+ assert(IS_DECOMPOSITION(N));\
208
+ FOR_each_prime_sub_of_elements(P,S,(N)->size,ELEMENTS_OF(N),B)\
209
+ }
210
+
211
+ //iterate over primes P of sdd node N, executing code B for each prime
212
+ //
213
+ //P: prime
214
+ //N: sdd node
215
+ //B: code
216
+ #define FOR_each_prime_of_node(P,N,B) {\
217
+ assert(IS_DECOMPOSITION(N));\
218
+ for(SddElement* _e=ELEMENTS_OF(N); _e<ELEMENTS_OF(N)+(N)->size; _e++) {\
219
+ SddNode* P = _e->prime;\
220
+ /* execute code */\
221
+ B;\
222
+ }\
223
+ }
224
+
225
+ //iterate over subs S of sdd node N, executing code B for each sub
226
+ //
227
+ //S: sub
228
+ //N: sdd node
229
+ //B: code
230
+ #define FOR_each_sub_of_node(S,N,B) {\
231
+ assert(IS_DECOMPOSITION(N));\
232
+ for(SddElement* _e=ELEMENTS_OF(N); _e<ELEMENTS_OF(N)+(N)->size; _e++) {\
233
+ SddNode* S = _e->sub;\
234
+ /* execute code */\
235
+ B;\
236
+ }\
237
+ }
238
+
239
+ #endif // ITERATORS_H_
240
+
241
+ /****************************************************************************************
242
+ * end
243
+ ****************************************************************************************/