PySDD 0.2.12__cp313-cp313-win_amd64.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.
- PySDD-0.2.12.dist-info/LICENSE +13 -0
- PySDD-0.2.12.dist-info/METADATA +225 -0
- PySDD-0.2.12.dist-info/RECORD +97 -0
- PySDD-0.2.12.dist-info/WHEEL +5 -0
- PySDD-0.2.12.dist-info/entry_points.txt +2 -0
- PySDD-0.2.12.dist-info/top_level.txt +1 -0
- pysdd/__init__.py +1 -0
- pysdd/__main__.py +19 -0
- pysdd/cli.py +261 -0
- pysdd/compiler_c.pxd +37 -0
- pysdd/fnf_c.pxd +17 -0
- pysdd/io_c.pxd +22 -0
- pysdd/iterator.py +223 -0
- pysdd/lib/libsdd-2.0/build/sdd.lib +0 -0
- pysdd/lib/libsdd-2.0/include/iterators.h +243 -0
- pysdd/lib/libsdd-2.0/include/macros.h +272 -0
- pysdd/lib/libsdd-2.0/include/parameters.h +71 -0
- pysdd/lib/libsdd-2.0/include/sdd.h +822 -0
- pysdd/lib/libsdd-2.0/include/stacks.h +86 -0
- pysdd/lib/libsdd-2.0/sddapi.h +247 -0
- pysdd/lib/libsdd-2.0/src/basic/computed.c +91 -0
- pysdd/lib/libsdd-2.0/src/basic/count_and_size.c +173 -0
- pysdd/lib/libsdd-2.0/src/basic/gc.c +104 -0
- pysdd/lib/libsdd-2.0/src/basic/hash.c +220 -0
- pysdd/lib/libsdd-2.0/src/basic/memory.c +179 -0
- pysdd/lib/libsdd-2.0/src/basic/multiply.c +209 -0
- pysdd/lib/libsdd-2.0/src/basic/nodes.c +174 -0
- pysdd/lib/libsdd-2.0/src/basic/partitions.c +351 -0
- pysdd/lib/libsdd-2.0/src/basic/references.c +79 -0
- pysdd/lib/libsdd-2.0/src/basic/replace.c +91 -0
- pysdd/lib/libsdd-2.0/src/basic/shadows.c +384 -0
- pysdd/lib/libsdd-2.0/src/basic/sort.c +148 -0
- pysdd/lib/libsdd-2.0/src/fnf/io.c +125 -0
- pysdd/lib/libsdd-2.0/src/manager/copy.c +84 -0
- pysdd/lib/libsdd-2.0/src/manager/interface.c +410 -0
- pysdd/lib/libsdd-2.0/src/manager/manager.c +308 -0
- pysdd/lib/libsdd-2.0/src/manager/stats.c +121 -0
- pysdd/lib/libsdd-2.0/src/manager/variables.c +267 -0
- pysdd/lib/libsdd-2.0/src/sdds/apply.c +396 -0
- pysdd/lib/libsdd-2.0/src/sdds/bits.c +156 -0
- pysdd/lib/libsdd-2.0/src/sdds/cardinality.c +313 -0
- pysdd/lib/libsdd-2.0/src/sdds/condition.c +107 -0
- pysdd/lib/libsdd-2.0/src/sdds/copy.c +117 -0
- pysdd/lib/libsdd-2.0/src/sdds/count.c +78 -0
- pysdd/lib/libsdd-2.0/src/sdds/essential_vars.c +128 -0
- pysdd/lib/libsdd-2.0/src/sdds/exists.c +29 -0
- pysdd/lib/libsdd-2.0/src/sdds/exists_multiple.c +310 -0
- pysdd/lib/libsdd-2.0/src/sdds/exists_multiple_static.c +165 -0
- pysdd/lib/libsdd-2.0/src/sdds/forall.c +28 -0
- pysdd/lib/libsdd-2.0/src/sdds/io.c +447 -0
- pysdd/lib/libsdd-2.0/src/sdds/model_count.c +146 -0
- pysdd/lib/libsdd-2.0/src/sdds/rename_vars.c +113 -0
- pysdd/lib/libsdd-2.0/src/sdds/size.c +65 -0
- pysdd/lib/libsdd-2.0/src/sdds/wmc.c +412 -0
- pysdd/lib/libsdd-2.0/src/util.c +254 -0
- pysdd/lib/libsdd-2.0/src/verify.c +236 -0
- pysdd/lib/libsdd-2.0/src/version.c +14 -0
- pysdd/lib/libsdd-2.0/src/vtree_fragments/construction.c +329 -0
- pysdd/lib/libsdd-2.0/src/vtree_fragments/moves.c +100 -0
- pysdd/lib/libsdd-2.0/src/vtree_fragments/operations.c +302 -0
- pysdd/lib/libsdd-2.0/src/vtree_operations/cartesian_product.c +166 -0
- pysdd/lib/libsdd-2.0/src/vtree_operations/dissect.c +78 -0
- pysdd/lib/libsdd-2.0/src/vtree_operations/limits.c +237 -0
- pysdd/lib/libsdd-2.0/src/vtree_operations/op_left_rotate.c +143 -0
- pysdd/lib/libsdd-2.0/src/vtree_operations/op_right_rotate.c +150 -0
- pysdd/lib/libsdd-2.0/src/vtree_operations/op_swap.c +112 -0
- pysdd/lib/libsdd-2.0/src/vtree_operations/rollback.c +68 -0
- pysdd/lib/libsdd-2.0/src/vtree_operations/split.c +180 -0
- pysdd/lib/libsdd-2.0/src/vtree_operations/vtree_ops.h +48 -0
- pysdd/lib/libsdd-2.0/src/vtree_search/auto.c +186 -0
- pysdd/lib/libsdd-2.0/src/vtree_search/search.c +332 -0
- pysdd/lib/libsdd-2.0/src/vtree_search/state.c +127 -0
- pysdd/lib/libsdd-2.0/src/vtrees/compare.c +137 -0
- pysdd/lib/libsdd-2.0/src/vtrees/edit.c +199 -0
- pysdd/lib/libsdd-2.0/src/vtrees/io.c +207 -0
- pysdd/lib/libsdd-2.0/src/vtrees/maps.c +42 -0
- pysdd/lib/libsdd-2.0/src/vtrees/moves.c +156 -0
- pysdd/lib/libsdd-2.0/src/vtrees/static.c +269 -0
- pysdd/lib/libsdd-2.0/src/vtrees/vtree.c +197 -0
- pysdd/lib/sdd-2.0/include/compiler.h +103 -0
- pysdd/lib/sdd-2.0/include/fnf.h +13 -0
- pysdd/lib/sdd-2.0/include/io.h +11 -0
- pysdd/lib/sdd-2.0/include/sddapi.h +340 -0
- pysdd/lib/sdd-2.0/lib/sdd.lib +0 -0
- pysdd/lib/sdd-2.0/src/fnf/compiler.c +119 -0
- pysdd/lib/sdd-2.0/src/fnf/fnf.c +56 -0
- pysdd/lib/sdd-2.0/src/fnf/io.c +200 -0
- pysdd/lib/sdd-2.0/src/fnf/utils.c +71 -0
- pysdd/lib/sdd-2.0/src/getopt.c +146 -0
- pysdd/lib/sdd-2.0/src/main.c +159 -0
- pysdd/lib/sdd_extra/include/sddapi_extra.h +22 -0
- pysdd/sdd.c +84299 -0
- pysdd/sdd.cp313-win_amd64.pyd +0 -0
- pysdd/sdd.pyx +1804 -0
- pysdd/sddapi_c.pxd +240 -0
- pysdd/util.py +450 -0
- 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,225 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: PySDD
|
|
3
|
+
Version: 0.2.12
|
|
4
|
+
Summary: Sentential Decision Diagrams
|
|
5
|
+
Home-page: https://github.com/wannesm/PySDD
|
|
6
|
+
Author: Wannes Meert, Arthur Choi
|
|
7
|
+
Author-email: wannes.meert@cs.kuleuven.be
|
|
8
|
+
License: Apache 2.0
|
|
9
|
+
Project-URL: PySDD documentation, https://pysdd.readthedocs.io/en/latest/
|
|
10
|
+
Project-URL: PySDD source, https://github.com/wannesm/PySDD
|
|
11
|
+
Keywords: sdd,knowledge compilation
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Requires-Python: >=3.6
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: cython>=3.0.0
|
|
19
|
+
Provides-Extra: all
|
|
20
|
+
Requires-Dist: cysignals; extra == "all"
|
|
21
|
+
Requires-Dist: numpy; extra == "all"
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest; extra == "dev"
|
|
24
|
+
Requires-Dist: cython>=3.0.0; extra == "dev"
|
|
25
|
+
|
|
26
|
+
=====
|
|
27
|
+
PySDD
|
|
28
|
+
=====
|
|
29
|
+
|
|
30
|
+
Python wrapper package to interactively use `Sententical Decision Diagrams (SDD) <http://reasoning.cs.ucla.edu/sdd/>`_.
|
|
31
|
+
|
|
32
|
+
Full documentation available on http://pysdd.readthedocs.io.
|
|
33
|
+
|
|
34
|
+
------------
|
|
35
|
+
Dependencies
|
|
36
|
+
------------
|
|
37
|
+
|
|
38
|
+
* Python >=3.6
|
|
39
|
+
* Cython
|
|
40
|
+
|
|
41
|
+
Optional:
|
|
42
|
+
|
|
43
|
+
* cysignals
|
|
44
|
+
* numpy
|
|
45
|
+
|
|
46
|
+
Make sure to have the correct development tools installed:
|
|
47
|
+
|
|
48
|
+
* C compiler (see `Installing Cython <https://cython.readthedocs.io/en/latest/src/quickstart/install.html>`_)
|
|
49
|
+
* The Python development version that includes Python header files and static library (e.g. libpython3-dev, python-dev, ...)
|
|
50
|
+
|
|
51
|
+
------------
|
|
52
|
+
Installation
|
|
53
|
+
------------
|
|
54
|
+
|
|
55
|
+
.. code-block:: shell
|
|
56
|
+
|
|
57
|
+
$ pip install PySDD
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
--------------
|
|
61
|
+
Python package
|
|
62
|
+
--------------
|
|
63
|
+
|
|
64
|
+
The wrapper can be used as a Python package and allows for interactive use.
|
|
65
|
+
|
|
66
|
+
The following example builds an SDD for the formula ``a∧b ∨ b∧c ∨ c∧d``.
|
|
67
|
+
|
|
68
|
+
.. code-block:: python
|
|
69
|
+
|
|
70
|
+
from pysdd.sdd import SddManager, Vtree, WmcManager
|
|
71
|
+
vtree = Vtree(var_count=4, var_order=[2,1,4,3], vtree_type="balanced")
|
|
72
|
+
sdd = SddManager.from_vtree(vtree)
|
|
73
|
+
a, b, c, d = sdd.vars
|
|
74
|
+
|
|
75
|
+
# Build SDD for formula
|
|
76
|
+
formula = (a & b) | (b & c) | (c & d)
|
|
77
|
+
|
|
78
|
+
# Model Counting
|
|
79
|
+
wmc = formula.wmc(log_mode=False)
|
|
80
|
+
print(f"Model Count: {wmc.propagate()}")
|
|
81
|
+
wmc.set_literal_weight(a, 0.5)
|
|
82
|
+
print(f"Weighted Model Count: {wmc.propagate()}")
|
|
83
|
+
|
|
84
|
+
# Visualize SDD and Vtree
|
|
85
|
+
with open("output/sdd.dot", "w") as out:
|
|
86
|
+
print(formula.dot(), file=out)
|
|
87
|
+
with open("output/vtree.dot", "w") as out:
|
|
88
|
+
print(vtree.dot(), file=out)
|
|
89
|
+
|
|
90
|
+
The SDD and Vtree are visualized using Graphviz DOT:
|
|
91
|
+
|
|
92
|
+
.. image:: https://people.cs.kuleuven.be/wannes.meert/pysdd/sdd.png
|
|
93
|
+
.. image:: https://people.cs.kuleuven.be/wannes.meert/pysdd/vtree.png
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
More examples are available in the ``examples`` directory.
|
|
98
|
+
An interactive Jupyter notebook is available in
|
|
99
|
+
`notebooks/examples.ipynb <notebooks/examples.ipynb>`_
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
----------------------
|
|
103
|
+
Command Line Interface
|
|
104
|
+
----------------------
|
|
105
|
+
|
|
106
|
+
A Python CLI application is installed if you use pip, ``pysdd``. Or it can be used
|
|
107
|
+
directly from the source directory where it is called ``pysdd-cli.py``.
|
|
108
|
+
This script mimicks the original sdd binary and adds additional features (e.g. weighted model counting)
|
|
109
|
+
|
|
110
|
+
.. code-block:: shell
|
|
111
|
+
|
|
112
|
+
$ pysdd -h
|
|
113
|
+
$ ./pysdd-cli.py -h
|
|
114
|
+
usage: pysdd-cli.py [-h] [-c FILE | -d FILE | -s FILE] [-v FILE] [-W FILE]
|
|
115
|
+
[-V FILE] [-R FILE] [-S FILE] [-m] [-t TYPE] [-r K] [-q]
|
|
116
|
+
[-p] [--log_mode]
|
|
117
|
+
|
|
118
|
+
Sentential Decision Diagram, Compiler
|
|
119
|
+
|
|
120
|
+
optional arguments:
|
|
121
|
+
-h, --help show this help message and exit
|
|
122
|
+
-c FILE set input CNF file
|
|
123
|
+
-d FILE set input DNF file
|
|
124
|
+
-s FILE set input SDD file
|
|
125
|
+
-v FILE set input VTREE file
|
|
126
|
+
-W FILE set output VTREE file
|
|
127
|
+
-V FILE set output VTREE (dot) file
|
|
128
|
+
-R FILE set output SDD file
|
|
129
|
+
-S FILE set output SDD (dot) file
|
|
130
|
+
-m minimize the cardinality of compiled sdd
|
|
131
|
+
-t TYPE set initial vtree type (left/right/vertical/balanced/random)
|
|
132
|
+
-r K if K>0: invoke vtree search every K clauses. If K=0: disable
|
|
133
|
+
vtree search. By default (no -r option), dynamic vtree search is
|
|
134
|
+
enabled
|
|
135
|
+
-q perform post-compilation vtree search
|
|
136
|
+
-p verbose output
|
|
137
|
+
--log_mode weights in log
|
|
138
|
+
|
|
139
|
+
Weighted Model Counting is performed if the NNF file containts a line
|
|
140
|
+
formatted as follows: "c weights PW_1 NW_1 ... PW_n NW_n".
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
-----------------
|
|
144
|
+
Memory management
|
|
145
|
+
-----------------
|
|
146
|
+
|
|
147
|
+
Python's memory management is not used for the internal datastructures.
|
|
148
|
+
Use the SDD library's garbage collection commands (e.g. ref, deref) to
|
|
149
|
+
perform memory management.
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
-----------------------
|
|
153
|
+
Compilation from source
|
|
154
|
+
-----------------------
|
|
155
|
+
|
|
156
|
+
.. code-block:: shell
|
|
157
|
+
|
|
158
|
+
$ pip install git+https://github.com/wannesm/PySDD.git#egg=PySDD
|
|
159
|
+
|
|
160
|
+
The repository should contain all the required files and libraries (unless
|
|
161
|
+
you use Windows). If you want to compile from source, note that some c-source
|
|
162
|
+
files from the SDD package have been updated to work with this wrapper and are
|
|
163
|
+
included in this repository. Do not overwrite these new files with the original
|
|
164
|
+
files.
|
|
165
|
+
|
|
166
|
+
* Download the SDD package from http://reasoning.cs.ucla.edu/sdd/.
|
|
167
|
+
* Install the SDD package in the PySDD package in directories
|
|
168
|
+
``pysdd/lib/sdd-2.0`` and ``pysdd/lib/sddlib-2.0`` without overwriting
|
|
169
|
+
the already available files.
|
|
170
|
+
* Run ``python3 setup.py build_ext --inplace`` or ``make build`` to compile the
|
|
171
|
+
library in the current directory. If you want to install the library such
|
|
172
|
+
that the library is available for your local installation or in your virtual
|
|
173
|
+
environment, use ``python3 setup.py install``.
|
|
174
|
+
|
|
175
|
+
For some Linux platforms, it might be necessary to recompile the libsdd-2.0 code with
|
|
176
|
+
the gcc option ``-fPIC`` and replace the ``pysdd/lib/sdd-2.0/lib/Linux/libsdd.a``
|
|
177
|
+
library with your newly compiled version.
|
|
178
|
+
|
|
179
|
+
The Windows platform is not supported. There is some initial support but we cannot
|
|
180
|
+
offer guarantees or detailed instructions (but are happy to accept pull requests).
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
----------
|
|
184
|
+
References
|
|
185
|
+
----------
|
|
186
|
+
|
|
187
|
+
This package is inspired by the SDD wrapper used in the probabilistic
|
|
188
|
+
programming language `ProbLog <https://dtai.cs.kuleuven.be/problog/>`_.
|
|
189
|
+
|
|
190
|
+
References:
|
|
191
|
+
|
|
192
|
+
* Wannes Meert, PySDD,
|
|
193
|
+
in `Recent Trends in Knowledge Compilation
|
|
194
|
+
<http://drops.dagstuhl.de/opus/volltexte/2018/8589/pdf/dagrep_v007_i009_p062_17381.pdf>`_,
|
|
195
|
+
Report from Dagstuhl Seminar 17381, Sep 2017.
|
|
196
|
+
Eds. A. Darwiche, P. Marquis, D. Suciu, S. Szeider.
|
|
197
|
+
|
|
198
|
+
Other languages:
|
|
199
|
+
|
|
200
|
+
* C: http://reasoning.cs.ucla.edu/sdd/
|
|
201
|
+
* Java: https://github.com/jessa/JSDD
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
-------
|
|
205
|
+
Contact
|
|
206
|
+
-------
|
|
207
|
+
|
|
208
|
+
* Wannes Meert, KU Leuven, https://people.cs.kuleuven.be/wannes.meert
|
|
209
|
+
* Arthur Choi, UCLA, http://web.cs.ucla.edu/~aychoi/
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
-------
|
|
213
|
+
License
|
|
214
|
+
-------
|
|
215
|
+
|
|
216
|
+
Python SDD wrapper:
|
|
217
|
+
|
|
218
|
+
Copyright 2017-2018, KU Leuven and Regents of the University of California.
|
|
219
|
+
Licensed under the Apache License, Version 2.0.
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
SDD package:
|
|
223
|
+
|
|
224
|
+
Copyright 2013-2018, Regents of the University of California
|
|
225
|
+
Licensed under the Apache License, Version 2.0.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
pysdd/__init__.py,sha256=Hke1EXjPf-qvTjrD5jnwxpRx7X-EgMa3MqddqlIq68Y,24
|
|
2
|
+
pysdd/__main__.py,sha256=g_Uyk_9SiKfE3Yr3WwX3N8KBF22Y4wbAFLimnw72Pw8,401
|
|
3
|
+
pysdd/cli.py,sha256=LvTkQ_X2wvJnmvjwWJzUjfZksEhrweP6a0f8Bm7vM1U,9900
|
|
4
|
+
pysdd/compiler_c.pxd,sha256=CDjYQnNZMY-9zOVQs1-TWr4qBx5Gc0E4Uil5Q984k48,1435
|
|
5
|
+
pysdd/fnf_c.pxd,sha256=xF2YefPTb-ClJ678i7d9nGyRHq2n6_93Ln242_cc87Q,462
|
|
6
|
+
pysdd/io_c.pxd,sha256=q9kYCbqFCVIAzBTYKsSAQmIN1dwvQSNE9E5Dl9rNRr0,715
|
|
7
|
+
pysdd/iterator.py,sha256=quW7gqgBKjH9O-wUDjnVbEiR8ZplynUEeEraxOPgyrA,10077
|
|
8
|
+
pysdd/sdd.c,sha256=PtXYX8VgmzGjizNtUp2iUek115St_HSVKWdPEHCkORs,3587321
|
|
9
|
+
pysdd/sdd.cp313-win_amd64.pyd,sha256=JpLX1aSldJSLVwxEdyY1SBtYYojEsM3k6hfa936HdWY,699904
|
|
10
|
+
pysdd/sdd.pyx,sha256=FO6P95EgwDrWf_Zkw6749Iof4lLKPqHtJXCch2a5Iis,76570
|
|
11
|
+
pysdd/sddapi_c.pxd,sha256=1EGJFTpabA-U03byy38cTqM49275bDK5KzQx54viGOE,11594
|
|
12
|
+
pysdd/util.py,sha256=0URem_Bu37eTuXKpkDDvoBWJR1YNxSh_ld4mzAe0D4I,16298
|
|
13
|
+
pysdd/wmcstochastic.py,sha256=OqXfp5jHqI1WCJtqIoJUyr9hkOsMTsdVo2oFGIF7iQI,7587
|
|
14
|
+
pysdd/lib/libsdd-2.0/sddapi.h,sha256=h2-loR3NrAGsFKIIvxqG1Dh3tnB1i1bwcJvvgyjejJY,11724
|
|
15
|
+
pysdd/lib/libsdd-2.0/build/sdd.lib,sha256=63-du4AmtJmhF5vW8hYxHXkTVYhSLVSMTgy0T7hfMW4,789558
|
|
16
|
+
pysdd/lib/libsdd-2.0/include/iterators.h,sha256=yjwnUs_JbVzRdbfmQuKFOUMfUl1MfmR922HoRjxUIgU,8259
|
|
17
|
+
pysdd/lib/libsdd-2.0/include/macros.h,sha256=l0lAyIkrDcE6spI4b-ChebBxceWTZQDWvoagmCxhhLM,10392
|
|
18
|
+
pysdd/lib/libsdd-2.0/include/parameters.h,sha256=XotF9_GxEK1Nk2Gd4awPdLrfnEbFG45gJlOYeYGjSd0,3011
|
|
19
|
+
pysdd/lib/libsdd-2.0/include/sdd.h,sha256=0luBM7mekJ6ncyLmST3ri2gVq0Rggh2VjhJua8Dlxmc,30549
|
|
20
|
+
pysdd/lib/libsdd-2.0/include/stacks.h,sha256=vmZT9p5A03cxN0QLouFkLE4qN-3wCM5U0CvwEkK7lGg,3424
|
|
21
|
+
pysdd/lib/libsdd-2.0/src/util.c,sha256=h3TWigokJsMLQ3D0dK-1NzWFVEs5o2MjK_1om_wNjKU,7397
|
|
22
|
+
pysdd/lib/libsdd-2.0/src/verify.c,sha256=UKNhs9LPKZdXCqaTBaieXQeT9AQ6k4z5lSQOsCZcXzo,7781
|
|
23
|
+
pysdd/lib/libsdd-2.0/src/version.c,sha256=pget9bX6l8GknHoAmu2Ed8o-yGFI_XGrSSdzH0xUBV8,624
|
|
24
|
+
pysdd/lib/libsdd-2.0/src/basic/computed.c,sha256=7Hwh6VzEqFq7-N4glU78zungQz9ZBqFLc_XsuxMfiF0,3952
|
|
25
|
+
pysdd/lib/libsdd-2.0/src/basic/count_and_size.c,sha256=0BUuDyMlG-QmfIItPuGW6xWp9QV1O7nCfnVzEuLMkBU,6328
|
|
26
|
+
pysdd/lib/libsdd-2.0/src/basic/gc.c,sha256=IVF5h4dM7E9ZBF71FSAF5SGyuUT0u1VRxor2Y1DX0b0,3928
|
|
27
|
+
pysdd/lib/libsdd-2.0/src/basic/hash.c,sha256=rs6iFEtpnP-jSPGkryT9DkQ8oaVsoZmD1RhuZnhYZew,7484
|
|
28
|
+
pysdd/lib/libsdd-2.0/src/basic/memory.c,sha256=VtvlUx7uL-Zvkj69CrwfTB1J27Sw3MAZVwO2mupxw8o,7771
|
|
29
|
+
pysdd/lib/libsdd-2.0/src/basic/multiply.c,sha256=KMNiyksxviE5F1OK-FfRUmUjVymsQqTIl5koBLpBasE,8573
|
|
30
|
+
pysdd/lib/libsdd-2.0/src/basic/nodes.c,sha256=ZO2oaqJ6g4SsD0DhJQhV8PwWZlPi7UhaiOXyOVXOWFI,6716
|
|
31
|
+
pysdd/lib/libsdd-2.0/src/basic/partitions.c,sha256=yaAr_2-2_KoXlv4ffBkeHXt5-yYVfTYIr1kcOwNQRhg,16029
|
|
32
|
+
pysdd/lib/libsdd-2.0/src/basic/references.c,sha256=2CDMKvIaW5vEoOomZdJCgHV5t3x3c5-NWft2vXllXf4,2762
|
|
33
|
+
pysdd/lib/libsdd-2.0/src/basic/replace.c,sha256=zuHqPOU0RKKxeeTM_FDjNYOAlD8D6jH2iwsUXfzGUv0,3747
|
|
34
|
+
pysdd/lib/libsdd-2.0/src/basic/shadows.c,sha256=XFMz3HfoIdi5Lv-DDXCytixbqEucm_VpVH4CE3j7-U8,14647
|
|
35
|
+
pysdd/lib/libsdd-2.0/src/basic/sort.c,sha256=joYBKXWF7jc8hXeZdOwIvpUBwjJWn6VBFYroG-PCpTY,6018
|
|
36
|
+
pysdd/lib/libsdd-2.0/src/fnf/io.c,sha256=ki1FzHiauxM6YAKAv0NRiqzNrlyiGhENCPrvP1cwjo4,4118
|
|
37
|
+
pysdd/lib/libsdd-2.0/src/manager/copy.c,sha256=4YEsRh9AT220eg6ZwbdUqbb3gTTUu9SJSGDKvRBgM94,3485
|
|
38
|
+
pysdd/lib/libsdd-2.0/src/manager/interface.c,sha256=-A8RsQtCDDbuQPXHUtN-XpAymQwXsromXv_Fs7alNzI,13854
|
|
39
|
+
pysdd/lib/libsdd-2.0/src/manager/manager.c,sha256=ZUqWi5JZCsBUwJCiiVwRG5_OvOZQR-dZ-R9weAXDWzU,11724
|
|
40
|
+
pysdd/lib/libsdd-2.0/src/manager/stats.c,sha256=EkLq8EKLsDkQmtIR26-Cn_vxY8Psuu4Bg-X-MH5fpnY,10233
|
|
41
|
+
pysdd/lib/libsdd-2.0/src/manager/variables.c,sha256=T5aF_6qEpD4yvILeJaBgxpVduICtpMTVq1P-dm5UkCM,10559
|
|
42
|
+
pysdd/lib/libsdd-2.0/src/sdds/apply.c,sha256=ArxmD2vftO3wDv-3LNtHvJRVw_l530rQ14NBb8UsQ5c,15824
|
|
43
|
+
pysdd/lib/libsdd-2.0/src/sdds/bits.c,sha256=vaJ4Q7u8uuya_fCKvdFTfJDYdO6_taRlnSpnfG-_xSY,5232
|
|
44
|
+
pysdd/lib/libsdd-2.0/src/sdds/cardinality.c,sha256=gwDn81Q32X2DhHlblTr69V9lzUWt6ZWU24TM9Jk44ls,12073
|
|
45
|
+
pysdd/lib/libsdd-2.0/src/sdds/condition.c,sha256=YVBbyEzeJ4DaLIypCyVihRXJAgUxZbJnnpVlFAQg9-g,4283
|
|
46
|
+
pysdd/lib/libsdd-2.0/src/sdds/copy.c,sha256=O60kThQ6ldQD81dBl22gScx6dgaISTAyoDOFN0Z2PEE,4520
|
|
47
|
+
pysdd/lib/libsdd-2.0/src/sdds/count.c,sha256=_Bs3Bnj-lzfwDxqARrJNtGRRszyBdOW2hZhPZQlHlrs,2635
|
|
48
|
+
pysdd/lib/libsdd-2.0/src/sdds/essential_vars.c,sha256=oTtwmF8_03A1LxJosH9vQ7QFYraf09nLAQhI84ygQGY,4130
|
|
49
|
+
pysdd/lib/libsdd-2.0/src/sdds/exists.c,sha256=mXXjdEszfPmvv2rIDHOc7PPPsUltF4oeya6vMi4ajxM,1179
|
|
50
|
+
pysdd/lib/libsdd-2.0/src/sdds/exists_multiple.c,sha256=9UTfnnWO_ZnDItUogsGsOf7GAczF75cI3jUMYpKh6os,11544
|
|
51
|
+
pysdd/lib/libsdd-2.0/src/sdds/exists_multiple_static.c,sha256=z9QlFWSbjHPsPQ7wvFR2_JBgBn4q9CN9s3P_S5AT2aE,5732
|
|
52
|
+
pysdd/lib/libsdd-2.0/src/sdds/forall.c,sha256=N2GKKW4ZjeaoXDfdaEENYePG-RBu_3drZJKghNZhwrk,1190
|
|
53
|
+
pysdd/lib/libsdd-2.0/src/sdds/io.c,sha256=MlM8QJ4lTK0yPdQngloZSyVIep3dteSWWtqVYs0gVc4,14394
|
|
54
|
+
pysdd/lib/libsdd-2.0/src/sdds/model_count.c,sha256=6bBRXIDe_LHXzq69C0e0-HxaUWag9aiApBuT8l3-WdU,5237
|
|
55
|
+
pysdd/lib/libsdd-2.0/src/sdds/rename_vars.c,sha256=a2_YxDXATF-Qaull553iR-Sh0B4SVKwTP6a8nLj0enM,4246
|
|
56
|
+
pysdd/lib/libsdd-2.0/src/sdds/size.c,sha256=svxja-Opxoav0ap42aZzMd-QOXdSdMhDzztHSbJC8e8,2071
|
|
57
|
+
pysdd/lib/libsdd-2.0/src/sdds/wmc.c,sha256=03b_OyRcpRfPs6J16ZaISfqEfKmvfeMnp_fS1vlDe8A,16817
|
|
58
|
+
pysdd/lib/libsdd-2.0/src/vtree_fragments/construction.c,sha256=XjLT3IV6HjOG0R5UEpRUoZuNUfxfVmqbxh_ib6hDmNQ,14133
|
|
59
|
+
pysdd/lib/libsdd-2.0/src/vtree_fragments/moves.c,sha256=ORHXUQussnhdUeOUPdeMPCuS_VOJfsjf3qRaN6xyvWQ,3459
|
|
60
|
+
pysdd/lib/libsdd-2.0/src/vtree_fragments/operations.c,sha256=xYZiizYnmU_C9VPudeNDQt_2Ib2JKvJI798FUGOvYOo,11936
|
|
61
|
+
pysdd/lib/libsdd-2.0/src/vtree_operations/cartesian_product.c,sha256=3g7HDZx-QJnRgHlCqgVp-HeushIifW7KlYVcah4TMEA,7304
|
|
62
|
+
pysdd/lib/libsdd-2.0/src/vtree_operations/dissect.c,sha256=2hR5QlsssXaRx5gmunbXkZpEtNIuunohmuOaSwlqxwk,2629
|
|
63
|
+
pysdd/lib/libsdd-2.0/src/vtree_operations/limits.c,sha256=Rsf6-u5VrjfLHAck163ByjiDZRTHhljQ5rvaYghOQyY,10447
|
|
64
|
+
pysdd/lib/libsdd-2.0/src/vtree_operations/op_left_rotate.c,sha256=l0jK4mYJJkXt4vNHGw8cyHGQdYvrhpSzL-R_Crh78Uw,6166
|
|
65
|
+
pysdd/lib/libsdd-2.0/src/vtree_operations/op_right_rotate.c,sha256=uJL3s8kGd8_rhGajzZHaLMkahCW1acTIMP-lAAN4IBE,6316
|
|
66
|
+
pysdd/lib/libsdd-2.0/src/vtree_operations/op_swap.c,sha256=CVDhtpE9J7cBN41hOl-MOY6qVG2yZvR6qFSmzfgHNfk,4617
|
|
67
|
+
pysdd/lib/libsdd-2.0/src/vtree_operations/rollback.c,sha256=fyTJr7K1jw5FStSO-WoxzkchOLELyHF65DCD0TmOSEo,3033
|
|
68
|
+
pysdd/lib/libsdd-2.0/src/vtree_operations/split.c,sha256=LPckVF3NRj_rOFngArkxTzfs9viFQ4SB9-43dgXCikE,6984
|
|
69
|
+
pysdd/lib/libsdd-2.0/src/vtree_operations/vtree_ops.h,sha256=Gdb3MNZE_9XZy3WTPI4r_zjvK3KtNmV7KH8pVt2MUd0,2575
|
|
70
|
+
pysdd/lib/libsdd-2.0/src/vtree_search/auto.c,sha256=ucSPpabDFPNnT3Vcdw_fB7Hb5IC6_Yj_ElQqlO7y1YU,7327
|
|
71
|
+
pysdd/lib/libsdd-2.0/src/vtree_search/search.c,sha256=n7slHEoujTfMBfNFADWIYV8z6F1sh3qJQT9RALBeDWM,13262
|
|
72
|
+
pysdd/lib/libsdd-2.0/src/vtree_search/state.c,sha256=rhN8Bw9JY8NuOLXRixZQGYHyd1U4RHF_wXhOzTgPGzQ,5724
|
|
73
|
+
pysdd/lib/libsdd-2.0/src/vtrees/compare.c,sha256=N_jGis9QLSlg8uXXbAA2Ry0CjmgXVwxFwjCUeovpK1w,4676
|
|
74
|
+
pysdd/lib/libsdd-2.0/src/vtrees/edit.c,sha256=of5tDC5Mw_dGtC0BEujJrAADO8V39QW-Pl6VRqijQH4,7451
|
|
75
|
+
pysdd/lib/libsdd-2.0/src/vtrees/io.c,sha256=2LPz18ODwJYyRVVIjusEM3rPY6i7ry8LFETkZW9-a2I,7225
|
|
76
|
+
pysdd/lib/libsdd-2.0/src/vtrees/maps.c,sha256=RRJjyVty9e8ycbb6yGT7I71yOcxHYxtMP6J9Ly40HXc,1431
|
|
77
|
+
pysdd/lib/libsdd-2.0/src/vtrees/moves.c,sha256=de0FKIuoAu-wYPd4qLiSPvb0CW6_dM2eYv1QTse2r7k,5095
|
|
78
|
+
pysdd/lib/libsdd-2.0/src/vtrees/static.c,sha256=9ugPi0AA4NfJ6XAgv7eKWkE4sHDD0Hy2bApzC4yDsPs,10989
|
|
79
|
+
pysdd/lib/libsdd-2.0/src/vtrees/vtree.c,sha256=7PrO2MvPp9iEab0SSkmVSnyYv4pAy0zSFFoqBpyUlUY,6573
|
|
80
|
+
pysdd/lib/sdd-2.0/include/compiler.h,sha256=2LBG7xzYVguXfSkdn6ocOwa7NuPNedXAJsE5E2GCIIU,4134
|
|
81
|
+
pysdd/lib/sdd-2.0/include/fnf.h,sha256=-EOHhmi0EtJedXAQYcEy-eh7KQq297f9842qJ8CJU0A,267
|
|
82
|
+
pysdd/lib/sdd-2.0/include/io.h,sha256=NuPVsCQnN6aISS7lrWmf9cf6llOpJEiUiAkVVuuVFgA,183
|
|
83
|
+
pysdd/lib/sdd-2.0/include/sddapi.h,sha256=rVkf-NJre06iFtt2cfwP_IsdxF62CSlcsU31ifNf4t4,15944
|
|
84
|
+
pysdd/lib/sdd-2.0/lib/sdd.lib,sha256=63-du4AmtJmhF5vW8hYxHXkTVYhSLVSMTgy0T7hfMW4,789558
|
|
85
|
+
pysdd/lib/sdd-2.0/src/getopt.c,sha256=yj53BKvV1uS6b-d1VFvd0Q6pjSCMRNeww6hIaAkV8Xc,4738
|
|
86
|
+
pysdd/lib/sdd-2.0/src/main.c,sha256=_et4NiLkQCjhmqNEbTXCQO71ECfm5QvgZd2aF0_Lom0,5169
|
|
87
|
+
pysdd/lib/sdd-2.0/src/fnf/compiler.c,sha256=kMT5KxoNsTfs4wer_Caadck4NYqL1XkKUmAeZ8A_J0E,4343
|
|
88
|
+
pysdd/lib/sdd-2.0/src/fnf/fnf.c,sha256=hHAHnCC3j5VE3DBvbMhL3-mwiXnwdkyrB5ncasPQw2c,1906
|
|
89
|
+
pysdd/lib/sdd-2.0/src/fnf/io.c,sha256=0sgHCS4fg5FLI6ztkM79Xtq8cNL_zLZRsWNQxLq2jqY,6269
|
|
90
|
+
pysdd/lib/sdd-2.0/src/fnf/utils.c,sha256=czS7hdG-4t6Qow-JQ41LlzeOaVTNxGgmHHxCoY0kgEI,2960
|
|
91
|
+
pysdd/lib/sdd_extra/include/sddapi_extra.h,sha256=A3ALoWr7H3tnmZLTZrlFwG0MufuDKO_6rm--o95L7yA,1060
|
|
92
|
+
PySDD-0.2.12.dist-info/LICENSE,sha256=6JN9Nwj-WgYn5VVLl1GND2dp2mJU2kE1pSNNhaUZEYA,607
|
|
93
|
+
PySDD-0.2.12.dist-info/METADATA,sha256=QYwiu7qXsvCi4pczUCwKNQAPAzGxAmxG5jNVAWNQWnY,7275
|
|
94
|
+
PySDD-0.2.12.dist-info/WHEEL,sha256=-v_yZ08fSknsoT62oIKG9wp1eCBV9_ao2rO4BeIReTY,101
|
|
95
|
+
PySDD-0.2.12.dist-info/entry_points.txt,sha256=wJDgU0k4O8ra-dgCPMcddMbtXFuC8jpvzLQLRyZP3UU,41
|
|
96
|
+
PySDD-0.2.12.dist-info/top_level.txt,sha256=_L11xkkgNpPVgmo8iYCg9PgIRe41nPLle1rjhIJgoNc,6
|
|
97
|
+
PySDD-0.2.12.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pysdd
|
pysdd/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.12"
|
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
|
pysdd/compiler_c.pxd
ADDED
|
@@ -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);
|