PySDD 1.0.0__cp310-cp310-win_arm64.whl

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 (75) hide show
  1. PySDD-1.0.0.dist-info/LICENSE +13 -0
  2. PySDD-1.0.0.dist-info/METADATA +214 -0
  3. PySDD-1.0.0.dist-info/RECORD +75 -0
  4. PySDD-1.0.0.dist-info/WHEEL +5 -0
  5. PySDD-1.0.0.dist-info/entry_points.txt +2 -0
  6. PySDD-1.0.0.dist-info/top_level.txt +1 -0
  7. pysdd/__init__.py +1 -0
  8. pysdd/__main__.py +19 -0
  9. pysdd/cli.py +261 -0
  10. pysdd/iterator.py +223 -0
  11. pysdd/lib/libsdd-2.0/src/basic/computed.c +91 -0
  12. pysdd/lib/libsdd-2.0/src/basic/count_and_size.c +173 -0
  13. pysdd/lib/libsdd-2.0/src/basic/gc.c +104 -0
  14. pysdd/lib/libsdd-2.0/src/basic/hash.c +221 -0
  15. pysdd/lib/libsdd-2.0/src/basic/memory.c +180 -0
  16. pysdd/lib/libsdd-2.0/src/basic/multiply.c +209 -0
  17. pysdd/lib/libsdd-2.0/src/basic/nodes.c +174 -0
  18. pysdd/lib/libsdd-2.0/src/basic/partitions.c +351 -0
  19. pysdd/lib/libsdd-2.0/src/basic/references.c +79 -0
  20. pysdd/lib/libsdd-2.0/src/basic/replace.c +91 -0
  21. pysdd/lib/libsdd-2.0/src/basic/shadows.c +384 -0
  22. pysdd/lib/libsdd-2.0/src/basic/sort.c +148 -0
  23. pysdd/lib/libsdd-2.0/src/manager/copy.c +84 -0
  24. pysdd/lib/libsdd-2.0/src/manager/interface.c +411 -0
  25. pysdd/lib/libsdd-2.0/src/manager/manager.c +308 -0
  26. pysdd/lib/libsdd-2.0/src/manager/stats.c +121 -0
  27. pysdd/lib/libsdd-2.0/src/manager/variables.c +267 -0
  28. pysdd/lib/libsdd-2.0/src/sdds/apply.c +396 -0
  29. pysdd/lib/libsdd-2.0/src/sdds/bits.c +156 -0
  30. pysdd/lib/libsdd-2.0/src/sdds/cardinality.c +313 -0
  31. pysdd/lib/libsdd-2.0/src/sdds/condition.c +107 -0
  32. pysdd/lib/libsdd-2.0/src/sdds/copy.c +117 -0
  33. pysdd/lib/libsdd-2.0/src/sdds/count.c +78 -0
  34. pysdd/lib/libsdd-2.0/src/sdds/essential_vars.c +128 -0
  35. pysdd/lib/libsdd-2.0/src/sdds/exists.c +29 -0
  36. pysdd/lib/libsdd-2.0/src/sdds/exists_multiple.c +311 -0
  37. pysdd/lib/libsdd-2.0/src/sdds/exists_multiple_static.c +165 -0
  38. pysdd/lib/libsdd-2.0/src/sdds/forall.c +28 -0
  39. pysdd/lib/libsdd-2.0/src/sdds/io.c +448 -0
  40. pysdd/lib/libsdd-2.0/src/sdds/model_count.c +146 -0
  41. pysdd/lib/libsdd-2.0/src/sdds/rename_vars.c +113 -0
  42. pysdd/lib/libsdd-2.0/src/sdds/size.c +65 -0
  43. pysdd/lib/libsdd-2.0/src/sdds/wmc.c +412 -0
  44. pysdd/lib/libsdd-2.0/src/util.c +255 -0
  45. pysdd/lib/libsdd-2.0/src/verify.c +236 -0
  46. pysdd/lib/libsdd-2.0/src/version.c +14 -0
  47. pysdd/lib/libsdd-2.0/src/vtree_fragments/construction.c +329 -0
  48. pysdd/lib/libsdd-2.0/src/vtree_fragments/moves.c +100 -0
  49. pysdd/lib/libsdd-2.0/src/vtree_fragments/operations.c +302 -0
  50. pysdd/lib/libsdd-2.0/src/vtree_operations/cartesian_product.c +166 -0
  51. pysdd/lib/libsdd-2.0/src/vtree_operations/dissect.c +78 -0
  52. pysdd/lib/libsdd-2.0/src/vtree_operations/limits.c +237 -0
  53. pysdd/lib/libsdd-2.0/src/vtree_operations/op_left_rotate.c +143 -0
  54. pysdd/lib/libsdd-2.0/src/vtree_operations/op_right_rotate.c +150 -0
  55. pysdd/lib/libsdd-2.0/src/vtree_operations/op_swap.c +112 -0
  56. pysdd/lib/libsdd-2.0/src/vtree_operations/rollback.c +68 -0
  57. pysdd/lib/libsdd-2.0/src/vtree_operations/split.c +180 -0
  58. pysdd/lib/libsdd-2.0/src/vtree_search/auto.c +186 -0
  59. pysdd/lib/libsdd-2.0/src/vtree_search/search.c +332 -0
  60. pysdd/lib/libsdd-2.0/src/vtree_search/state.c +127 -0
  61. pysdd/lib/libsdd-2.0/src/vtrees/compare.c +138 -0
  62. pysdd/lib/libsdd-2.0/src/vtrees/edit.c +199 -0
  63. pysdd/lib/libsdd-2.0/src/vtrees/io.c +207 -0
  64. pysdd/lib/libsdd-2.0/src/vtrees/maps.c +42 -0
  65. pysdd/lib/libsdd-2.0/src/vtrees/moves.c +156 -0
  66. pysdd/lib/libsdd-2.0/src/vtrees/static.c +270 -0
  67. pysdd/lib/libsdd-2.0/src/vtrees/vtree.c +197 -0
  68. pysdd/lib/sdd-2.0/src/fnf/compiler.c +120 -0
  69. pysdd/lib/sdd-2.0/src/fnf/fnf.c +57 -0
  70. pysdd/lib/sdd-2.0/src/fnf/io.c +201 -0
  71. pysdd/lib/sdd-2.0/src/fnf/utils.c +72 -0
  72. pysdd/sdd.cp310-win_arm64.pyd +0 -0
  73. pysdd/sdd.pyx +1804 -0
  74. pysdd/util.py +450 -0
  75. pysdd/wmcstochastic.py +188 -0
@@ -0,0 +1,13 @@
1
+ Copyright 2018, KU Leuven and Regents of the University of California
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,214 @@
1
+ Metadata-Version: 2.1
2
+ Name: PySDD
3
+ Version: 1.0.0
4
+ Summary: Sentential Decision Diagrams
5
+ Author: Arthur Choi
6
+ Author-email: Wannes Meert <wannes.meert@cs.kuleuven.be>
7
+ License: Copyright 2018, KU Leuven and Regents of the University of California
8
+
9
+ Licensed under the Apache License, Version 2.0 (the "License");
10
+ you may not use this file except in compliance with the License.
11
+ You may obtain a copy of the License at
12
+
13
+ http://www.apache.org/licenses/LICENSE-2.0
14
+
15
+ Unless required by applicable law or agreed to in writing, software
16
+ distributed under the License is distributed on an "AS IS" BASIS,
17
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ See the License for the specific language governing permissions and
19
+ limitations under the License.
20
+
21
+ Project-URL: Homepage, https://github.com/wannesm/PySDD
22
+ Project-URL: Documentation, https://pysdd.readthedocs.io/en/latest/
23
+ Keywords: sdd, knowledge compilation
24
+ Classifier: Intended Audience :: Developers
25
+ Classifier: License :: OSI Approved :: Apache Software License
26
+ Classifier: Programming Language :: Python :: 3
27
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
28
+ Requires-Python: >=3.8
29
+ Description-Content-Type: text/x-rst
30
+ License-File: LICENSE
31
+ Requires-Dist: cython
32
+ Requires-Dist: numpy
33
+ Provides-Extra: tests
34
+ Requires-Dist: pytest ; extra == 'tests'
35
+
36
+ =====
37
+ PySDD
38
+ =====
39
+
40
+ Python wrapper package to interactively use `Sentential Decision Diagrams (SDD) <http://reasoning.cs.ucla.edu/sdd/>`_.
41
+
42
+ Full documentation available on http://pysdd.readthedocs.io.
43
+
44
+ ------------
45
+ Installation
46
+ ------------
47
+
48
+ .. code-block:: shell
49
+
50
+ $ pip install PySDD
51
+
52
+
53
+ --------------
54
+ Python package
55
+ --------------
56
+
57
+ The wrapper can be used as a Python package and allows for interactive use.
58
+
59
+ The following example builds an SDD for the formula ``a∧b ∨ b∧c ∨ c∧d``.
60
+
61
+ .. code-block:: python
62
+
63
+ from pysdd.sdd import SddManager, Vtree, WmcManager
64
+ vtree = Vtree(var_count=4, var_order=[2,1,4,3], vtree_type="balanced")
65
+ sdd = SddManager.from_vtree(vtree)
66
+ a, b, c, d = sdd.vars
67
+
68
+ # Build SDD for formula
69
+ formula = (a & b) | (b & c) | (c & d)
70
+
71
+ # Model Counting
72
+ wmc = formula.wmc(log_mode=False)
73
+ print(f"Model Count: {wmc.propagate()}")
74
+ wmc.set_literal_weight(a, 0.5)
75
+ print(f"Weighted Model Count: {wmc.propagate()}")
76
+
77
+ # Visualize SDD and Vtree
78
+ with open("output/sdd.dot", "w") as out:
79
+ print(formula.dot(), file=out)
80
+ with open("output/vtree.dot", "w") as out:
81
+ print(vtree.dot(), file=out)
82
+
83
+ The SDD and Vtree are visualized using Graphviz DOT:
84
+
85
+ .. image:: https://people.cs.kuleuven.be/wannes.meert/pysdd/sdd.png
86
+ .. image:: https://people.cs.kuleuven.be/wannes.meert/pysdd/vtree.png
87
+
88
+
89
+
90
+ More examples are available in the ``examples`` directory.
91
+ An interactive Jupyter notebook is available in
92
+ `notebooks/examples.ipynb <notebooks/examples.ipynb>`_
93
+
94
+
95
+ ----------------------
96
+ Command Line Interface
97
+ ----------------------
98
+
99
+ A Python CLI application is installed if you use pip, ``pysdd``. Or it can be used
100
+ directly from the source directory where it is called ``pysdd-cli.py``.
101
+ This script mimicks the original sdd binary and adds additional features (e.g. weighted model counting)
102
+
103
+ .. code-block:: shell
104
+
105
+ $ pysdd -h
106
+ $ ./pysdd-cli.py -h
107
+ usage: pysdd-cli.py [-h] [-c FILE | -d FILE | -s FILE] [-v FILE] [-W FILE]
108
+ [-V FILE] [-R FILE] [-S FILE] [-m] [-t TYPE] [-r K] [-q]
109
+ [-p] [--log_mode]
110
+
111
+ Sentential Decision Diagram, Compiler
112
+
113
+ optional arguments:
114
+ -h, --help show this help message and exit
115
+ -c FILE set input CNF file
116
+ -d FILE set input DNF file
117
+ -s FILE set input SDD file
118
+ -v FILE set input VTREE file
119
+ -W FILE set output VTREE file
120
+ -V FILE set output VTREE (dot) file
121
+ -R FILE set output SDD file
122
+ -S FILE set output SDD (dot) file
123
+ -m minimize the cardinality of compiled sdd
124
+ -t TYPE set initial vtree type (left/right/vertical/balanced/random)
125
+ -r K if K>0: invoke vtree search every K clauses. If K=0: disable
126
+ vtree search. By default (no -r option), dynamic vtree search is
127
+ enabled
128
+ -q perform post-compilation vtree search
129
+ -p verbose output
130
+ --log_mode weights in log
131
+
132
+ Weighted Model Counting is performed if the NNF file containts a line
133
+ formatted as follows: "c weights PW_1 NW_1 ... PW_n NW_n".
134
+
135
+
136
+ -----------------
137
+ Memory management
138
+ -----------------
139
+
140
+ Python's memory management is not used for the internal datastructures.
141
+ Use the SDD library's garbage collection commands (e.g. ref, deref) to
142
+ perform memory management.
143
+
144
+
145
+ -----------------------
146
+ Compilation from source
147
+ -----------------------
148
+
149
+ To install from source, make sure to have the correct development tools installed:
150
+
151
+ * C compiler (see `Installing Cython <https://cython.readthedocs.io/en/latest/src/quickstart/install.html>`_)
152
+ * The Python development version that includes Python header files and static library (e.g. libpython3-dev, python-dev, ...)
153
+
154
+ The build process will download Cython and numpy in an isolated environment.
155
+
156
+ Then run:
157
+
158
+ .. code-block:: shell
159
+
160
+ $ pip install build
161
+ $ python -m build
162
+
163
+
164
+ To install the main branch:
165
+
166
+ .. code-block:: shell
167
+
168
+ $ pip install git+https://github.com/wannesm/PySDD.git#egg=PySDD
169
+
170
+
171
+
172
+ ----------
173
+ References
174
+ ----------
175
+
176
+ This package is inspired by the SDD wrapper used in the probabilistic
177
+ programming language `ProbLog <https://dtai.cs.kuleuven.be/problog/>`_.
178
+
179
+ References:
180
+
181
+ * Wannes Meert & Arthur Choi, PySDD,
182
+ in `Recent Trends in Knowledge Compilation
183
+ <http://drops.dagstuhl.de/opus/volltexte/2018/8589/pdf/dagrep_v007_i009_p062_17381.pdf>`_,
184
+ Report from Dagstuhl Seminar 17381, Sep 2017.
185
+ Eds. A. Darwiche, P. Marquis, D. Suciu, S. Szeider.
186
+
187
+ Other languages:
188
+
189
+ * C: http://reasoning.cs.ucla.edu/sdd/
190
+ * Java: https://github.com/jessa/JSDD
191
+
192
+
193
+ -------
194
+ Contact
195
+ -------
196
+
197
+ * Wannes Meert, KU Leuven, https://people.cs.kuleuven.be/wannes.meert
198
+ * Arthur Choi, UCLA, http://web.cs.ucla.edu/~aychoi/
199
+
200
+
201
+ -------
202
+ License
203
+ -------
204
+
205
+ Python SDD wrapper:
206
+
207
+ Copyright 2017-2024, KU Leuven and Regents of the University of California.
208
+ Licensed under the Apache License, Version 2.0.
209
+
210
+
211
+ SDD package:
212
+
213
+ Copyright 2013-2018, Regents of the University of California
214
+ Licensed under the Apache License, Version 2.0.
@@ -0,0 +1,75 @@
1
+ pysdd/__init__.py,sha256=ZhzQKWZ8RFrTIkj7z87B144DI95e8LMfA5w8NDWQDtg,23
2
+ pysdd/__main__.py,sha256=g_Uyk_9SiKfE3Yr3WwX3N8KBF22Y4wbAFLimnw72Pw8,401
3
+ pysdd/cli.py,sha256=LvTkQ_X2wvJnmvjwWJzUjfZksEhrweP6a0f8Bm7vM1U,9900
4
+ pysdd/iterator.py,sha256=quW7gqgBKjH9O-wUDjnVbEiR8ZplynUEeEraxOPgyrA,10077
5
+ pysdd/sdd.cp310-win_arm64.pyd,sha256=3IywpCCQ27pvWuUh5s9-3__H17Ia3o8QpmX7l96jbKs,613376
6
+ pysdd/sdd.pyx,sha256=FO6P95EgwDrWf_Zkw6749Iof4lLKPqHtJXCch2a5Iis,76570
7
+ pysdd/util.py,sha256=0URem_Bu37eTuXKpkDDvoBWJR1YNxSh_ld4mzAe0D4I,16298
8
+ pysdd/wmcstochastic.py,sha256=OqXfp5jHqI1WCJtqIoJUyr9hkOsMTsdVo2oFGIF7iQI,7587
9
+ pysdd/lib/libsdd-2.0/src/util.c,sha256=8kuAdW86mX-2k1SzWmxFLIeP1DZi5kNriYfXlaOqySA,7419
10
+ pysdd/lib/libsdd-2.0/src/verify.c,sha256=UKNhs9LPKZdXCqaTBaieXQeT9AQ6k4z5lSQOsCZcXzo,7781
11
+ pysdd/lib/libsdd-2.0/src/version.c,sha256=eJycIItgq_O6KwqraFO5s7qsgb2diSlYdGSdr5zLMSk,585
12
+ pysdd/lib/libsdd-2.0/src/basic/computed.c,sha256=7Hwh6VzEqFq7-N4glU78zungQz9ZBqFLc_XsuxMfiF0,3952
13
+ pysdd/lib/libsdd-2.0/src/basic/count_and_size.c,sha256=0BUuDyMlG-QmfIItPuGW6xWp9QV1O7nCfnVzEuLMkBU,6328
14
+ pysdd/lib/libsdd-2.0/src/basic/gc.c,sha256=IVF5h4dM7E9ZBF71FSAF5SGyuUT0u1VRxor2Y1DX0b0,3928
15
+ pysdd/lib/libsdd-2.0/src/basic/hash.c,sha256=HCrHK3MfBLYJ-Mvg6X7GGAc_g6UmhpBaT07-OUoZbkE,7506
16
+ pysdd/lib/libsdd-2.0/src/basic/memory.c,sha256=Xo1aYRdxWZwd8QPj8-hWL3DpgITuzxAVAB6EWG3ECGM,7793
17
+ pysdd/lib/libsdd-2.0/src/basic/multiply.c,sha256=KMNiyksxviE5F1OK-FfRUmUjVymsQqTIl5koBLpBasE,8573
18
+ pysdd/lib/libsdd-2.0/src/basic/nodes.c,sha256=ZO2oaqJ6g4SsD0DhJQhV8PwWZlPi7UhaiOXyOVXOWFI,6716
19
+ pysdd/lib/libsdd-2.0/src/basic/partitions.c,sha256=yaAr_2-2_KoXlv4ffBkeHXt5-yYVfTYIr1kcOwNQRhg,16029
20
+ pysdd/lib/libsdd-2.0/src/basic/references.c,sha256=2CDMKvIaW5vEoOomZdJCgHV5t3x3c5-NWft2vXllXf4,2762
21
+ pysdd/lib/libsdd-2.0/src/basic/replace.c,sha256=zuHqPOU0RKKxeeTM_FDjNYOAlD8D6jH2iwsUXfzGUv0,3747
22
+ pysdd/lib/libsdd-2.0/src/basic/shadows.c,sha256=XFMz3HfoIdi5Lv-DDXCytixbqEucm_VpVH4CE3j7-U8,14647
23
+ pysdd/lib/libsdd-2.0/src/basic/sort.c,sha256=joYBKXWF7jc8hXeZdOwIvpUBwjJWn6VBFYroG-PCpTY,6018
24
+ pysdd/lib/libsdd-2.0/src/manager/copy.c,sha256=4YEsRh9AT220eg6ZwbdUqbb3gTTUu9SJSGDKvRBgM94,3485
25
+ pysdd/lib/libsdd-2.0/src/manager/interface.c,sha256=BzAFZshyyIoGWghNDlcZAOxoikf-YzViTu3HNH4gvA0,13876
26
+ pysdd/lib/libsdd-2.0/src/manager/manager.c,sha256=ZUqWi5JZCsBUwJCiiVwRG5_OvOZQR-dZ-R9weAXDWzU,11724
27
+ pysdd/lib/libsdd-2.0/src/manager/stats.c,sha256=EkLq8EKLsDkQmtIR26-Cn_vxY8Psuu4Bg-X-MH5fpnY,10233
28
+ pysdd/lib/libsdd-2.0/src/manager/variables.c,sha256=T5aF_6qEpD4yvILeJaBgxpVduICtpMTVq1P-dm5UkCM,10559
29
+ pysdd/lib/libsdd-2.0/src/sdds/apply.c,sha256=ArxmD2vftO3wDv-3LNtHvJRVw_l530rQ14NBb8UsQ5c,15824
30
+ pysdd/lib/libsdd-2.0/src/sdds/bits.c,sha256=vaJ4Q7u8uuya_fCKvdFTfJDYdO6_taRlnSpnfG-_xSY,5232
31
+ pysdd/lib/libsdd-2.0/src/sdds/cardinality.c,sha256=gwDn81Q32X2DhHlblTr69V9lzUWt6ZWU24TM9Jk44ls,12073
32
+ pysdd/lib/libsdd-2.0/src/sdds/condition.c,sha256=YVBbyEzeJ4DaLIypCyVihRXJAgUxZbJnnpVlFAQg9-g,4283
33
+ pysdd/lib/libsdd-2.0/src/sdds/copy.c,sha256=O60kThQ6ldQD81dBl22gScx6dgaISTAyoDOFN0Z2PEE,4520
34
+ pysdd/lib/libsdd-2.0/src/sdds/count.c,sha256=_Bs3Bnj-lzfwDxqARrJNtGRRszyBdOW2hZhPZQlHlrs,2635
35
+ pysdd/lib/libsdd-2.0/src/sdds/essential_vars.c,sha256=oTtwmF8_03A1LxJosH9vQ7QFYraf09nLAQhI84ygQGY,4130
36
+ pysdd/lib/libsdd-2.0/src/sdds/exists.c,sha256=mXXjdEszfPmvv2rIDHOc7PPPsUltF4oeya6vMi4ajxM,1179
37
+ pysdd/lib/libsdd-2.0/src/sdds/exists_multiple.c,sha256=PSzgx9Q20d58Cw2Iz2JcVJIuXWkLr5pAaHXtz7E0-dY,11566
38
+ pysdd/lib/libsdd-2.0/src/sdds/exists_multiple_static.c,sha256=z9QlFWSbjHPsPQ7wvFR2_JBgBn4q9CN9s3P_S5AT2aE,5732
39
+ pysdd/lib/libsdd-2.0/src/sdds/forall.c,sha256=N2GKKW4ZjeaoXDfdaEENYePG-RBu_3drZJKghNZhwrk,1190
40
+ pysdd/lib/libsdd-2.0/src/sdds/io.c,sha256=qrpKZoclP01e4eQgpHT3Yw3dcTdGzegj_S4FvhzdJmE,14416
41
+ pysdd/lib/libsdd-2.0/src/sdds/model_count.c,sha256=6bBRXIDe_LHXzq69C0e0-HxaUWag9aiApBuT8l3-WdU,5237
42
+ pysdd/lib/libsdd-2.0/src/sdds/rename_vars.c,sha256=a2_YxDXATF-Qaull553iR-Sh0B4SVKwTP6a8nLj0enM,4246
43
+ pysdd/lib/libsdd-2.0/src/sdds/size.c,sha256=svxja-Opxoav0ap42aZzMd-QOXdSdMhDzztHSbJC8e8,2071
44
+ pysdd/lib/libsdd-2.0/src/sdds/wmc.c,sha256=03b_OyRcpRfPs6J16ZaISfqEfKmvfeMnp_fS1vlDe8A,16817
45
+ pysdd/lib/libsdd-2.0/src/vtree_fragments/construction.c,sha256=XjLT3IV6HjOG0R5UEpRUoZuNUfxfVmqbxh_ib6hDmNQ,14133
46
+ pysdd/lib/libsdd-2.0/src/vtree_fragments/moves.c,sha256=ORHXUQussnhdUeOUPdeMPCuS_VOJfsjf3qRaN6xyvWQ,3459
47
+ pysdd/lib/libsdd-2.0/src/vtree_fragments/operations.c,sha256=xYZiizYnmU_C9VPudeNDQt_2Ib2JKvJI798FUGOvYOo,11936
48
+ pysdd/lib/libsdd-2.0/src/vtree_operations/cartesian_product.c,sha256=3g7HDZx-QJnRgHlCqgVp-HeushIifW7KlYVcah4TMEA,7304
49
+ pysdd/lib/libsdd-2.0/src/vtree_operations/dissect.c,sha256=2hR5QlsssXaRx5gmunbXkZpEtNIuunohmuOaSwlqxwk,2629
50
+ pysdd/lib/libsdd-2.0/src/vtree_operations/limits.c,sha256=Rsf6-u5VrjfLHAck163ByjiDZRTHhljQ5rvaYghOQyY,10447
51
+ pysdd/lib/libsdd-2.0/src/vtree_operations/op_left_rotate.c,sha256=l0jK4mYJJkXt4vNHGw8cyHGQdYvrhpSzL-R_Crh78Uw,6166
52
+ pysdd/lib/libsdd-2.0/src/vtree_operations/op_right_rotate.c,sha256=uJL3s8kGd8_rhGajzZHaLMkahCW1acTIMP-lAAN4IBE,6316
53
+ pysdd/lib/libsdd-2.0/src/vtree_operations/op_swap.c,sha256=CVDhtpE9J7cBN41hOl-MOY6qVG2yZvR6qFSmzfgHNfk,4617
54
+ pysdd/lib/libsdd-2.0/src/vtree_operations/rollback.c,sha256=fyTJr7K1jw5FStSO-WoxzkchOLELyHF65DCD0TmOSEo,3033
55
+ pysdd/lib/libsdd-2.0/src/vtree_operations/split.c,sha256=LPckVF3NRj_rOFngArkxTzfs9viFQ4SB9-43dgXCikE,6984
56
+ pysdd/lib/libsdd-2.0/src/vtree_search/auto.c,sha256=ucSPpabDFPNnT3Vcdw_fB7Hb5IC6_Yj_ElQqlO7y1YU,7327
57
+ pysdd/lib/libsdd-2.0/src/vtree_search/search.c,sha256=n7slHEoujTfMBfNFADWIYV8z6F1sh3qJQT9RALBeDWM,13262
58
+ pysdd/lib/libsdd-2.0/src/vtree_search/state.c,sha256=rhN8Bw9JY8NuOLXRixZQGYHyd1U4RHF_wXhOzTgPGzQ,5724
59
+ pysdd/lib/libsdd-2.0/src/vtrees/compare.c,sha256=gs0OS0cqtNVNnwdvcpA3KEbDFLeOwdmEx1lPHWhTd30,4698
60
+ pysdd/lib/libsdd-2.0/src/vtrees/edit.c,sha256=of5tDC5Mw_dGtC0BEujJrAADO8V39QW-Pl6VRqijQH4,7451
61
+ pysdd/lib/libsdd-2.0/src/vtrees/io.c,sha256=2LPz18ODwJYyRVVIjusEM3rPY6i7ry8LFETkZW9-a2I,7225
62
+ pysdd/lib/libsdd-2.0/src/vtrees/maps.c,sha256=RRJjyVty9e8ycbb6yGT7I71yOcxHYxtMP6J9Ly40HXc,1431
63
+ pysdd/lib/libsdd-2.0/src/vtrees/moves.c,sha256=de0FKIuoAu-wYPd4qLiSPvb0CW6_dM2eYv1QTse2r7k,5095
64
+ pysdd/lib/libsdd-2.0/src/vtrees/static.c,sha256=9sbwezeCKws8ek8T9bbq5mnvmDfTeFQHt-e7y0rjUrw,11011
65
+ pysdd/lib/libsdd-2.0/src/vtrees/vtree.c,sha256=7PrO2MvPp9iEab0SSkmVSnyYv4pAy0zSFFoqBpyUlUY,6573
66
+ pysdd/lib/sdd-2.0/src/fnf/compiler.c,sha256=x7CeG3SLAjkrFFdUEgXhaJqWLWn1z77kRACk2hC9MPM,4365
67
+ pysdd/lib/sdd-2.0/src/fnf/fnf.c,sha256=0sGBx8G1awJTBCszw58vbSoj20rUO0E11N6EKVZqSa0,1928
68
+ pysdd/lib/sdd-2.0/src/fnf/io.c,sha256=qjR8OjVHS9oSYlwvQOu6b48vNNCpbTG3XD6xckmznws,6291
69
+ pysdd/lib/sdd-2.0/src/fnf/utils.c,sha256=jJkJ-dQtShsRpBgpV5tk7eLHP1NSZEsyRFtieEuglt8,2982
70
+ PySDD-1.0.0.dist-info/LICENSE,sha256=6JN9Nwj-WgYn5VVLl1GND2dp2mJU2kE1pSNNhaUZEYA,607
71
+ PySDD-1.0.0.dist-info/METADATA,sha256=1Tb32BjF8LWiBzzn9VzVZO18pDNZE-pP6cIg4wBMTMs,6724
72
+ PySDD-1.0.0.dist-info/WHEEL,sha256=bIftBojrTJYDxBm6tOg04Oqd6yev1FOJOVBYS8t7ujY,101
73
+ PySDD-1.0.0.dist-info/entry_points.txt,sha256=wJDgU0k4O8ra-dgCPMcddMbtXFuC8jpvzLQLRyZP3UU,41
74
+ PySDD-1.0.0.dist-info/top_level.txt,sha256=_L11xkkgNpPVgmo8iYCg9PgIRe41nPLle1rjhIJgoNc,6
75
+ PySDD-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.3.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp310-cp310-win_arm64
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ pysdd = pysdd.cli:main
@@ -0,0 +1 @@
1
+ pysdd
pysdd/__init__.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = "1.0.0"
pysdd/__main__.py ADDED
@@ -0,0 +1,19 @@
1
+ # -*- coding: UTF-8 -*-
2
+ """
3
+ pysdd.__main__
4
+ ~~~~~~~~~~~~~~
5
+
6
+ Command Line Interface.
7
+
8
+ Will be run when `python -m pysdd` is used.
9
+
10
+ :author: Wannes Meert, Arthur Choi
11
+ :copyright: Copyright 2017-2019 KU Leuven and Regents of the University of California.
12
+ :license: Apache License, Version 2.0, see LICENSE for details.
13
+
14
+ """
15
+ from .cli import main
16
+
17
+
18
+ if __name__ == "__main__":
19
+ main()
pysdd/cli.py ADDED
@@ -0,0 +1,261 @@
1
+ #!/usr/bin/env python3
2
+ # encoding: utf-8
3
+ """
4
+ pysdd-cli
5
+ ~~~~~~~~~
6
+
7
+ PySDD command line interface.
8
+
9
+ :author: Wannes Meert, Arthur Choi
10
+ :copyright: Copyright 2019 KU Leuven and Regents of the University of California.
11
+ :license: Apache License, Version 2.0, see LICENSE for details.
12
+ """
13
+ from pathlib import Path
14
+ import sys
15
+ import time
16
+ import argparse
17
+ import logging
18
+ from .sdd import SddManager, Vtree, Fnf, CompilerOptions
19
+
20
+
21
+ logger = logging.getLogger(__name__)
22
+
23
+
24
+ def main(argv=None):
25
+ options, args = getopt(argv)
26
+ fnf = None
27
+ weights = None
28
+
29
+ if options.cnf_filename is not None:
30
+ print("reading cnf...")
31
+ fnf = Fnf.from_cnf_file(bytes(options.cnf_filename))
32
+ weights = read_weights(options.cnf_filename)
33
+ elif options.dnf_filename is not None:
34
+ print("reading dnf...")
35
+ fnf = Fnf.from_dnf_file(bytes(options.dnf_filename))
36
+ weights = read_weights(options.dnf_filename)
37
+
38
+ if options.vtree_filename is not None:
39
+ print("reading initial vtree...")
40
+ vtree = Vtree.from_file(bytes(options.vtree_filename))
41
+ else:
42
+ if fnf is None:
43
+ raise argparse.ArgumentTypeError("CNF or DNF file required")
44
+ print(f"creating initial vtree {options.initial_vtree_type.decode()}")
45
+ vtree = Vtree(var_count=fnf.var_count, vtree_type=options.initial_vtree_type)
46
+
47
+ print("creating manager...")
48
+ manager = SddManager.from_vtree(vtree)
49
+ manager.set_options(options)
50
+
51
+ if options.sdd_filename is None:
52
+ print("compiling...")
53
+ c1 = time.time()
54
+ node = manager.fnf_to_sdd(fnf)
55
+ c2 = time.time()
56
+ secs = c2 - c1
57
+ print("")
58
+ print(f"compilation time : {secs:.3f} sec")
59
+ else:
60
+ print("reading sdd from file...")
61
+ c1 = time.time()
62
+ node = manager.read_sdd_file(options.sdd_filename)
63
+ c2 = time.time()
64
+ secs = c2 - c1
65
+ print(f"read time : {secs:.3f} sec")
66
+ weights = read_weights(options.sdd_filename)
67
+
68
+ wmc = create_wmc(node, weights, args)
69
+
70
+ print_node(node, wmc)
71
+ if options.verbose:
72
+ manager.print_stdout()
73
+
74
+ if options.minimize_cardinality:
75
+ print("\nminimizing cardinality...", end="")
76
+ c1 = time.time()
77
+ node = manager.global_minimize_cardinality(node)
78
+ c2 = time.time()
79
+ min_card = manager.minimum_cardinality(node)
80
+ print("")
81
+ wmc = create_wmc(node, weights, args)
82
+ print_node(node, wmc)
83
+ print(f" min cardinality : {min_card} {c2-c1:.3f} sec")
84
+
85
+ manager_vtree = manager.vtree()
86
+
87
+ if options.post_search:
88
+ node.ref()
89
+ print("dynamic vtree (post compilation)")
90
+ print(f" sdd initial size : {node.size()}")
91
+ c1 = time.time()
92
+ manager.minimize_limited()
93
+ c2 = time.time()
94
+ print(f" dynamic vtree time : {c2-c1:.3f} sec")
95
+ wmc = create_wmc(node, weights, args)
96
+ print_node(node, wmc)
97
+ node.deref()
98
+ if options.verbose:
99
+ manager.print_stdout()
100
+
101
+ if options.output_sdd_filename is not None:
102
+ print("saving compiled sdd ...", end="")
103
+ node.save(options.output_sdd_filename)
104
+ print("done")
105
+
106
+ if options.output_sdd_dot_filename is not None:
107
+ print("saving compiled sdd (dot) ...", end="")
108
+ node.save_as_dot(options.output_sdd_dot_filename)
109
+ print("done")
110
+
111
+ if options.output_vtree_filename is not None:
112
+ print("saving vtree ...", end="")
113
+ manager_vtree.save(options.output_vtree_filename)
114
+ print("done")
115
+
116
+ if options.output_vtree_dot_filename is not None:
117
+ print("saving vtree (dot) ...", end="")
118
+ manager_vtree.save_as_dot(options.output_vtree_dot_filename)
119
+ print("done")
120
+
121
+ print("done")
122
+
123
+
124
+ def create_wmc(node, weights, args):
125
+ if weights is None:
126
+ return None
127
+ wmc = node.wmc(log_mode=args.log_mode)
128
+ for i in range(len(weights)):
129
+ lit = (i // 2) + 1
130
+ if (i % 2) == 1:
131
+ lit = -lit
132
+ w = weights[i]
133
+ wmc.set_literal_weight(node.manager.literal(lit), w)
134
+ return wmc
135
+
136
+
137
+ def read_weights(nnf_path):
138
+ """
139
+ Format: c weights PW_1 NW_1 ... PW_n NW_n
140
+ :param nnf_path: Path to NNF file
141
+ :return: list of weights
142
+ """
143
+ weight_str = None
144
+ with open(nnf_path, "r") as ifile:
145
+ for line in ifile.readlines():
146
+ if "c weights " in line:
147
+ weight_str = line[10:].strip()
148
+ break
149
+ if weight_str is None:
150
+ return None
151
+ weight_strs = weight_str.split(" ")
152
+ weights = [float(w) for w in weight_strs]
153
+ return weights
154
+
155
+
156
+ def print_node(node, wmc=None):
157
+ print(f" sdd size : {node.size()}")
158
+ print(f" sdd node count : {node.count()}")
159
+ c1 = time.time()
160
+ mc = node.global_model_count()
161
+ c2 = time.time()
162
+ print(f" sdd model count : {mc} {c2-c1:.3f} sec")
163
+ if wmc is not None:
164
+ c1 = time.time()
165
+ mc = wmc.propagate()
166
+ c2 = time.time()
167
+ print(f" sdd weighted model count: {mc} {c2-c1:.3f} sec")
168
+
169
+
170
+ class CustomHelpFormatter(argparse.HelpFormatter):
171
+
172
+ def _format_text(self, text):
173
+ text = super()._format_text(text)
174
+ if "Copyright" in text:
175
+ a, b = text.split("Copyright")
176
+ text = a + "\n\n" + super()._format_text("Copyright" + b)
177
+ return text
178
+
179
+
180
+ def create_parser():
181
+ def bytes_path(p):
182
+ return bytes(Path(p))
183
+
184
+ def bytes_str(s):
185
+ return s.encode()
186
+
187
+ epilog = ("Weighted Model Counting is performed if the NNF file containts a line formatted as follows: "
188
+ "\"c weights PW_1 NW_1 ... PW_n NW_n\"."
189
+ "Copyright 2017-2019, Regents of the University of California and KU Leuven")
190
+ parser = argparse.ArgumentParser(description='Sentential Decision Diagram, Compiler',
191
+ epilog=epilog,
192
+ formatter_class=CustomHelpFormatter)
193
+ input_group = parser.add_mutually_exclusive_group()
194
+ input_group.add_argument('-c', metavar='FILE', type=bytes_path,
195
+ dest='cnf_filename', help='set input CNF file')
196
+ input_group.add_argument('-d', metavar='FILE', type=bytes_path,
197
+ dest='dnf_filename', help='set input DNF file')
198
+ input_group.add_argument('-s', metavar='FILE', type=bytes_path,
199
+ dest='sdd_filename', help='set input SDD file')
200
+ parser.add_argument('-v', metavar='FILE', type=bytes_path,
201
+ dest='vtree_filename', help='set input VTREE file')
202
+
203
+ parser.add_argument('-W', metavar='FILE', type=bytes_path,
204
+ dest='output_vtree_filename', help='set output VTREE file')
205
+ parser.add_argument('-V', metavar='FILE', type=bytes_path,
206
+ dest='output_vtree_dot_filename', help='set output VTREE (dot) file')
207
+ parser.add_argument('-R', metavar='FILE', type=bytes_path,
208
+ dest='output_sdd_filename', help='set output SDD file')
209
+ parser.add_argument('-S', metavar='FILE', type=bytes_path,
210
+ dest='output_sdd_dot_filename', help='set output SDD (dot) file')
211
+
212
+ parser.add_argument('-m', action='store_true',
213
+ dest='minimize_cardinality', help='minimize the cardinality of compiled sdd')
214
+
215
+ parser.add_argument('-t', metavar='TYPE', type=bytes_str, default='balanced',
216
+ choices=[b'left', b'right', b'vertical', b'balanced', b'random'],
217
+ dest='initial_vtree_type',
218
+ help='set initial vtree type (left/right/vertical/balanced/random)')
219
+
220
+ parser.add_argument('-r', metavar='K', type=int, default=-1,
221
+ dest='vtree_search_mode',
222
+ help='if K>0: invoke vtree search every K clauses. If K=0: disable vtree search. ' +
223
+ 'By default (no -r option), dynamic vtree search is enabled')
224
+
225
+ parser.add_argument('-q', action='store_true',
226
+ dest='post_search', help='perform post-compilation vtree search')
227
+
228
+ parser.add_argument('-p', action='store_true',
229
+ dest='verbose', help='verbose output')
230
+
231
+ parser.add_argument('--log_mode', action='store_true',
232
+ dest='log_mode', help='weights in log')
233
+
234
+ return parser
235
+
236
+
237
+ def getopt(argv=None):
238
+ parser = create_parser()
239
+ args = parser.parse_args(argv)
240
+
241
+ if args.verbose:
242
+ logger.setLevel(logging.INFO)
243
+ else:
244
+ logger.setLevel(logging.WARNING)
245
+ logger.addHandler(logging.StreamHandler(sys.stdout))
246
+
247
+ options = CompilerOptions(cnf_filename=args.cnf_filename,
248
+ dnf_filename=args.dnf_filename,
249
+ vtree_filename=args.vtree_filename,
250
+ sdd_filename=args.sdd_filename,
251
+ output_vtree_filename=args.output_vtree_filename,
252
+ output_vtree_dot_filename=args.output_vtree_dot_filename,
253
+ output_sdd_filename=args.output_sdd_filename,
254
+ output_sdd_dot_filename=args.output_sdd_dot_filename,
255
+ initial_vtree_type=args.initial_vtree_type,
256
+ minimize_cardinality=args.minimize_cardinality,
257
+ vtree_search_mode=args.vtree_search_mode,
258
+ post_search=args.post_search,
259
+ verbose=args.verbose)
260
+ # print(str(options))
261
+ return options, args