python-sat 0.1.8.dev10__cp310-cp310-win_amd64.whl → 1.8.dev26__cp310-cp310-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.
Potentially problematic release.
This version of python-sat might be problematic. Click here for more details.
- pycard.cp310-win_amd64.pyd +0 -0
- pysat/__init__.py +4 -4
- pysat/_fileio.py +30 -14
- pysat/allies/approxmc.py +22 -22
- pysat/allies/unigen.py +435 -0
- pysat/card.py +13 -12
- pysat/engines.py +1302 -0
- pysat/examples/bbscan.py +663 -0
- pysat/examples/bica.py +691 -0
- pysat/examples/fm.py +12 -8
- pysat/examples/genhard.py +24 -23
- pysat/examples/hitman.py +53 -37
- pysat/examples/lbx.py +56 -15
- pysat/examples/lsu.py +28 -14
- pysat/examples/mcsls.py +53 -15
- pysat/examples/models.py +6 -4
- pysat/examples/musx.py +15 -7
- pysat/examples/optux.py +71 -32
- pysat/examples/primer.py +620 -0
- pysat/examples/rc2.py +268 -69
- pysat/formula.py +3241 -229
- pysat/pb.py +85 -37
- pysat/process.py +16 -2
- pysat/solvers.py +2119 -724
- pysolvers.cp310-win_amd64.pyd +0 -0
- {python_sat-0.1.8.dev10.data → python_sat-1.8.dev26.data}/scripts/approxmc.py +22 -22
- python_sat-1.8.dev26.data/scripts/bbscan.py +663 -0
- python_sat-1.8.dev26.data/scripts/bica.py +691 -0
- {python_sat-0.1.8.dev10.data → python_sat-1.8.dev26.data}/scripts/fm.py +12 -8
- {python_sat-0.1.8.dev10.data → python_sat-1.8.dev26.data}/scripts/genhard.py +24 -23
- {python_sat-0.1.8.dev10.data → python_sat-1.8.dev26.data}/scripts/lbx.py +56 -15
- {python_sat-0.1.8.dev10.data → python_sat-1.8.dev26.data}/scripts/lsu.py +28 -14
- {python_sat-0.1.8.dev10.data → python_sat-1.8.dev26.data}/scripts/mcsls.py +53 -15
- {python_sat-0.1.8.dev10.data → python_sat-1.8.dev26.data}/scripts/models.py +6 -4
- {python_sat-0.1.8.dev10.data → python_sat-1.8.dev26.data}/scripts/musx.py +15 -7
- {python_sat-0.1.8.dev10.data → python_sat-1.8.dev26.data}/scripts/optux.py +71 -32
- python_sat-1.8.dev26.data/scripts/primer.py +620 -0
- {python_sat-0.1.8.dev10.data → python_sat-1.8.dev26.data}/scripts/rc2.py +268 -69
- python_sat-1.8.dev26.data/scripts/unigen.py +435 -0
- {python_sat-0.1.8.dev10.dist-info → python_sat-1.8.dev26.dist-info}/METADATA +19 -5
- python_sat-1.8.dev26.dist-info/RECORD +48 -0
- {python_sat-0.1.8.dev10.dist-info → python_sat-1.8.dev26.dist-info}/WHEEL +1 -1
- python_sat-0.1.8.dev10.dist-info/RECORD +0 -39
- {python_sat-0.1.8.dev10.dist-info → python_sat-1.8.dev26.dist-info/licenses}/LICENSE.txt +0 -0
- {python_sat-0.1.8.dev10.dist-info → python_sat-1.8.dev26.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
#!python
|
|
2
|
+
#-*- coding:utf-8 -*-
|
|
3
|
+
##
|
|
4
|
+
## unigen.py
|
|
5
|
+
##
|
|
6
|
+
## Created on: Oct 16, 2023
|
|
7
|
+
## Author: Alexey Ignatiev
|
|
8
|
+
## E-mail: alexey.ignatiev@monash.edu
|
|
9
|
+
##
|
|
10
|
+
|
|
11
|
+
"""
|
|
12
|
+
===============
|
|
13
|
+
List of classes
|
|
14
|
+
===============
|
|
15
|
+
|
|
16
|
+
.. autosummary::
|
|
17
|
+
:nosignatures:
|
|
18
|
+
|
|
19
|
+
Sampler
|
|
20
|
+
|
|
21
|
+
==================
|
|
22
|
+
Module description
|
|
23
|
+
==================
|
|
24
|
+
|
|
25
|
+
This module provides interface to `UniGen3
|
|
26
|
+
<https://github.com/meelgroup/unigen/>`_, a state-of-the-art
|
|
27
|
+
almost-uniform sampler utilising an improved version of CryptoMiniSat to
|
|
28
|
+
handle problems of size and complexity that were not possible before. .
|
|
29
|
+
The original work on UniGen3 has been published in [1]_, [2]_, and [3]_.
|
|
30
|
+
|
|
31
|
+
.. [1] Supratik Chakraborty, Kuldeep S. Meel, Moshe Y. Vardi. *Balancing
|
|
32
|
+
Scalability and Uniformity in SAT Witness Generator*. DAC 2014.
|
|
33
|
+
pp. 60:1-60:6
|
|
34
|
+
|
|
35
|
+
.. [2] Supratik Chakraborty, Daniel J. Fremont, Kuldeep S. Meel, Sanjit A.
|
|
36
|
+
Seshia, Moshe Y. Vardi. *On Parallel Scalable Uniform SAT Witness
|
|
37
|
+
Generation*. TACAS 2015. pp. 304-319
|
|
38
|
+
|
|
39
|
+
.. [3] Mate Soos, Stephan Gocht, Kuldeep S. Meel. *Tinted, Detached, and
|
|
40
|
+
Lazy CNF-XOR Solving and Its Applications to Counting and Sampling*.
|
|
41
|
+
CAV 2020. pp. 463-484
|
|
42
|
+
|
|
43
|
+
Note that to be functional, the module requires package ``pyunigen`` to be
|
|
44
|
+
installed:
|
|
45
|
+
|
|
46
|
+
::
|
|
47
|
+
|
|
48
|
+
$ pip install pyunigen
|
|
49
|
+
|
|
50
|
+
The interface gives access to :class:`Sampler`, which expects a formula in
|
|
51
|
+
:class:`.CNF` as input. Given a few additional (optional) arguments,
|
|
52
|
+
including a random seed, *tolerance factor* :math:`\\varepsilon`,
|
|
53
|
+
*confidence* :math:`\\delta` (to be used by ApproxMC), and *uniformity
|
|
54
|
+
parameter* :math:`\\kappa`, the class can be used to get apply
|
|
55
|
+
almost-uniform sampling and to obtain a requested number of samples as a
|
|
56
|
+
result, subject to the given tolerance factor and confidence parameter.
|
|
57
|
+
|
|
58
|
+
Namely, given a CNF formula :math:`\\mathcal{F}` with the set of
|
|
59
|
+
satisfying assignments (or models) denoted by :math:`sol(\\mathcal{F})`
|
|
60
|
+
and parameter :math:`\\varepsilon\\in(0,1]`, a uniform sampler outputs a
|
|
61
|
+
model :math:`y\\in sol(\\mathcal{F})` such that
|
|
62
|
+
:math:`\\textrm{Pr}\\left[y \\textrm{ is
|
|
63
|
+
output}\\right]=\\frac{1}{|sol(\\mathcal{F})|}`. Almost-uniform sampling
|
|
64
|
+
relaxes the uniformity guarantee and ensures that
|
|
65
|
+
:math:`\\frac{1}{(1+\\varepsilon)|sol(\\mathcal{F})|} \\leq
|
|
66
|
+
\\textrm{Pr}\\left[y \\textrm{ is output}\\right] \\leq
|
|
67
|
+
\\frac{1+\\varepsilon}{|sol(\\mathcal{F})|}`.
|
|
68
|
+
|
|
69
|
+
The implementation can be used as an executable (the list of available
|
|
70
|
+
command-line options can be shown using ``unigen.py -h``) in the
|
|
71
|
+
following way:
|
|
72
|
+
|
|
73
|
+
::
|
|
74
|
+
|
|
75
|
+
$ xzcat formula.cnf.xz
|
|
76
|
+
p cnf 6 2
|
|
77
|
+
1 5 0
|
|
78
|
+
1 6 0
|
|
79
|
+
|
|
80
|
+
$ unigen.py -n 4 formula.cnf.xz
|
|
81
|
+
v +1 -2 +3 -4 -5 -6 0
|
|
82
|
+
v +1 +2 +3 -4 +5 +6 0
|
|
83
|
+
v +1 -2 -3 -4 +5 -6 0
|
|
84
|
+
v -1 -2 -3 -4 +5 +6 0
|
|
85
|
+
|
|
86
|
+
Alternatively, the algorithm can be accessed and invoked through the
|
|
87
|
+
standard ``import`` interface of Python, e.g.
|
|
88
|
+
|
|
89
|
+
.. code-block:: python
|
|
90
|
+
|
|
91
|
+
>>> from pysat.allies.unigen import Sampler
|
|
92
|
+
>>> from pysat.formula import CNF
|
|
93
|
+
>>>
|
|
94
|
+
>>> cnf = CNF(from_file='formula.cnf.xz')
|
|
95
|
+
>>>
|
|
96
|
+
>>> with Sampler(cnf) as sampler:
|
|
97
|
+
... print(sampler.sample(nof_samples=4, sample_over=[1, 2, 3])
|
|
98
|
+
[[1, 2, 3, 4, 5], [1, -2, -3, -4, -5], [1, -2, -3, -4, 5], [1, 2, -3, 4, 5]]
|
|
99
|
+
|
|
100
|
+
As can be seen in the above example, sampling can be done over a
|
|
101
|
+
user-defined set of variables (rather than the complete set of variables).
|
|
102
|
+
|
|
103
|
+
==============
|
|
104
|
+
Module details
|
|
105
|
+
==============
|
|
106
|
+
"""
|
|
107
|
+
|
|
108
|
+
#
|
|
109
|
+
#==============================================================================
|
|
110
|
+
from __future__ import print_function
|
|
111
|
+
import getopt
|
|
112
|
+
import os
|
|
113
|
+
from pysat.formula import CNF
|
|
114
|
+
import re
|
|
115
|
+
import sys
|
|
116
|
+
|
|
117
|
+
# we need pyunigen to be installed:
|
|
118
|
+
pyunigen_present = True
|
|
119
|
+
try:
|
|
120
|
+
import pyunigen
|
|
121
|
+
except ImportError:
|
|
122
|
+
pyunigen_present = False
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
#
|
|
126
|
+
#==============================================================================
|
|
127
|
+
class Sampler(object):
|
|
128
|
+
"""
|
|
129
|
+
A wrapper for UniGen3, a state-of-the-art almost-uniform sampler.
|
|
130
|
+
Given a formula in :class:`.CNF`, this class can be used to apply
|
|
131
|
+
almost-uniform sampling of the formula's models, subject to a few
|
|
132
|
+
input parameters.
|
|
133
|
+
|
|
134
|
+
The class initialiser receives a number of input arguments. The
|
|
135
|
+
``formula`` argument can be left unspecified at this stage. In this
|
|
136
|
+
case, a user is expected to add all the relevant clauses using
|
|
137
|
+
:meth:`add_clause`.
|
|
138
|
+
|
|
139
|
+
Additional parameters a user may want to specify include integer
|
|
140
|
+
``seed`` (used by ApproxMC), tolerance factor ``epsilon`` (used in the
|
|
141
|
+
probabilistic guarantees of almost-uniformity), confidence parameter
|
|
142
|
+
``delta`` (used by ApproxMC), and uniformity parameter ``kappa`` (see
|
|
143
|
+
[2]_).
|
|
144
|
+
|
|
145
|
+
:param formula: CNF formula
|
|
146
|
+
:param seed: seed value
|
|
147
|
+
:param epsilon: tolerance factor
|
|
148
|
+
:param delta: confidence parameter (used by ApproxMC)
|
|
149
|
+
:param kappa: uniformity parameter
|
|
150
|
+
:param verbose: verbosity level
|
|
151
|
+
|
|
152
|
+
:type formula: :class:`.CNF`
|
|
153
|
+
:type seed: int
|
|
154
|
+
:type epsilon: float
|
|
155
|
+
:type delta: float
|
|
156
|
+
:type kappa: float
|
|
157
|
+
:type verbose: int
|
|
158
|
+
|
|
159
|
+
.. code-block:: python
|
|
160
|
+
|
|
161
|
+
>>> from pysat.allies.unigen import Sampler
|
|
162
|
+
>>> from pysat.formula import CNF
|
|
163
|
+
>>>
|
|
164
|
+
>>> cnf = CNF(from_file='some-formula.cnf')
|
|
165
|
+
>>> with Sampler(formula=cnf, epsilon=0.1, delta=0.9) as sampler:
|
|
166
|
+
... for model in sampler.sample(nof_samples=100):
|
|
167
|
+
... print(model) # printing 100 result samples
|
|
168
|
+
"""
|
|
169
|
+
|
|
170
|
+
def __init__(self, formula=None, seed=1, epsilon=0.8, delta=0.2,
|
|
171
|
+
kappa=0.638, verbose=0):
|
|
172
|
+
"""
|
|
173
|
+
Constructor.
|
|
174
|
+
"""
|
|
175
|
+
|
|
176
|
+
assert pyunigen_present, 'Package \'pyunigen\' is unavailable. Check your installation.'
|
|
177
|
+
|
|
178
|
+
# there are no initial values
|
|
179
|
+
self.cellc, self.hashc, self.samples = None, None, []
|
|
180
|
+
|
|
181
|
+
# creating the Sampler object
|
|
182
|
+
self.sampler = pyunigen.Sampler(verbosity=verbose, seed=seed,
|
|
183
|
+
delta=delta, epsilon=epsilon,
|
|
184
|
+
kappa=kappa)
|
|
185
|
+
|
|
186
|
+
# adding clauses to the sampler
|
|
187
|
+
if formula:
|
|
188
|
+
for clause in formula:
|
|
189
|
+
self.add_clause(clause)
|
|
190
|
+
|
|
191
|
+
def __del__(self):
|
|
192
|
+
"""
|
|
193
|
+
Destructor.
|
|
194
|
+
"""
|
|
195
|
+
|
|
196
|
+
self.delete()
|
|
197
|
+
|
|
198
|
+
def __enter__(self):
|
|
199
|
+
"""
|
|
200
|
+
'with' constructor.
|
|
201
|
+
"""
|
|
202
|
+
|
|
203
|
+
return self
|
|
204
|
+
|
|
205
|
+
def __exit__(self, exc_type, exc_value, traceback):
|
|
206
|
+
"""
|
|
207
|
+
'with' destructor.
|
|
208
|
+
"""
|
|
209
|
+
|
|
210
|
+
self.delete()
|
|
211
|
+
|
|
212
|
+
def add_clause(self, clause):
|
|
213
|
+
"""
|
|
214
|
+
The method for adding a clause to the problem formula. Although
|
|
215
|
+
the input formula can be specified as an argument of the
|
|
216
|
+
constructor of :class:`Sampler`, adding clauses may also be
|
|
217
|
+
helpful afterwards, *on the fly*.
|
|
218
|
+
|
|
219
|
+
The clause to add can be any iterable over integer literals.
|
|
220
|
+
|
|
221
|
+
:param clause: a clause to add
|
|
222
|
+
:type clause: iterable(int)
|
|
223
|
+
|
|
224
|
+
.. code-block:: python
|
|
225
|
+
|
|
226
|
+
>>> from pysat.allies.unigen import Sampler
|
|
227
|
+
>>>
|
|
228
|
+
>>> with Sampler() as sampler:
|
|
229
|
+
... sampler.add_clause(range(1, 4))
|
|
230
|
+
... sampler.add_clause([3, 4])
|
|
231
|
+
...
|
|
232
|
+
... print(sampler.sample(nof_samples=4))
|
|
233
|
+
[[1, 2, -3, 4], [-1, 2, -3, 4], [1, 2, 3, -4], [-1, 2, 3, 4]]
|
|
234
|
+
"""
|
|
235
|
+
|
|
236
|
+
self.sampler.add_clause(clause)
|
|
237
|
+
|
|
238
|
+
def sample(self, nof_samples, sample_over=None, counts=None):
|
|
239
|
+
"""
|
|
240
|
+
Given the formula provided by the user either in the constructor
|
|
241
|
+
of :class:`Sampler` or through a series of calls to
|
|
242
|
+
:meth:`add_clause`, this method runs the UniGen3 sampler with the
|
|
243
|
+
specified values of tolerance :math:`\\varepsilon`, confidence
|
|
244
|
+
:math:`\\delta` parameters, and uniformity parameter :math:`kappa`
|
|
245
|
+
as well as the random ``seed`` value, and outputs a requested
|
|
246
|
+
number of samples.
|
|
247
|
+
|
|
248
|
+
A user may specify an argument ``sample_over``, which is a list of
|
|
249
|
+
integers specifying the variables with respect to which sampling
|
|
250
|
+
should be performed. If ``sample_over`` is left as ``None``,
|
|
251
|
+
almost-uniform sampling is done wrt. all the variables of the
|
|
252
|
+
input formula.
|
|
253
|
+
|
|
254
|
+
Finally, argument ``counts`` can be specified as a pair of integer
|
|
255
|
+
values: *cell count* and *hash count* (in this order) used during
|
|
256
|
+
sampling. If left undefined (``None``), the values are determined
|
|
257
|
+
by ApproxMC.
|
|
258
|
+
|
|
259
|
+
:param nof_samples: number of samples to output
|
|
260
|
+
:param sample_over: variables to sample over
|
|
261
|
+
:param counts: cell count and hash count values
|
|
262
|
+
|
|
263
|
+
:type nof_samples: int
|
|
264
|
+
:type sample_over: list(int)
|
|
265
|
+
:type counts: [int, int]
|
|
266
|
+
|
|
267
|
+
:return: a list of samples
|
|
268
|
+
|
|
269
|
+
.. code-block:: python
|
|
270
|
+
|
|
271
|
+
>>> from pysat.allies.unigen import Sampler
|
|
272
|
+
>>> from pysat.card import CardEnc, EncType
|
|
273
|
+
>>>
|
|
274
|
+
>>> # cardinality constraint with auxiliary variables
|
|
275
|
+
>>> # there are exactly 6 models for the constraint
|
|
276
|
+
>>> # over the 6 original variables
|
|
277
|
+
>>> cnf = CardEnc.equals(lits=range(1, 5), bound=2, encoding=EncType.totalizer)
|
|
278
|
+
>>>
|
|
279
|
+
>>> with Sampler(formula=cnf, epsilon=0.05, delta=0.95) as sampler:
|
|
280
|
+
... for model in sampler.sample(nof_samples=3):
|
|
281
|
+
... print(model)
|
|
282
|
+
[1, -2, 3, -4, 5, 6, -7, -8, 9, -10, 11, -12, 13, 14, -15, 16, 17, -18, 19, -20]
|
|
283
|
+
[1, -2, -3, 4, 5, 6, -7, -8, 9, -10, 11, -12, 13, 14, -15, 16, 17, -18, 19, -20]
|
|
284
|
+
[1, 2, -3, -4, 5, 6, -7, 8, -9, -10, 11, 12, 13, 14, -15, 16, 17, 18, -19, -20]
|
|
285
|
+
>>>
|
|
286
|
+
>>> # now, sampling over the original variables
|
|
287
|
+
>>> with Sampler(formula=cnf, epsilon=0.05, delta=0.95) as sampler:
|
|
288
|
+
... for model in sampler.sample(nof_samples=3, sample_over=range(1, 5)):
|
|
289
|
+
... print(model)
|
|
290
|
+
[1, 2, -3, -4]
|
|
291
|
+
[1, -2, 3, -4]
|
|
292
|
+
[-1, 2, 3, -4]
|
|
293
|
+
"""
|
|
294
|
+
|
|
295
|
+
# we cannot pass None as arguments, hence these if-elif branches
|
|
296
|
+
if sample_over is None and counts is None:
|
|
297
|
+
self.cellc, self.hashc, self.samples = self.sampler.sample(num=nof_samples)
|
|
298
|
+
elif counts is None:
|
|
299
|
+
self.cellc, self.hashc, self.samples = self.sampler.sample(num=nof_samples,
|
|
300
|
+
sampling_set=sample_over)
|
|
301
|
+
elif sample_over is None:
|
|
302
|
+
self.cellc, self.hashc, self.samples = self.sampler.sample(num=nof_samples,
|
|
303
|
+
cell_hash_count=tuple(counts))
|
|
304
|
+
else:
|
|
305
|
+
self.cellc, self.hashc, self.samples = self.sampler.sample(num=nof_samples,
|
|
306
|
+
sampling_set=sample_over,
|
|
307
|
+
cell_hash_count=tuple(counts))
|
|
308
|
+
|
|
309
|
+
return self.samples
|
|
310
|
+
|
|
311
|
+
def delete(self):
|
|
312
|
+
"""
|
|
313
|
+
Explicit destructor of the internal Sampler oracle.
|
|
314
|
+
Delete the actual sampler object and sets it to ``None``.
|
|
315
|
+
"""
|
|
316
|
+
|
|
317
|
+
if self.sampler:
|
|
318
|
+
del self.sampler
|
|
319
|
+
self.sampler = None
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
#
|
|
323
|
+
#==============================================================================
|
|
324
|
+
def parse_options():
|
|
325
|
+
"""
|
|
326
|
+
Parses command-line option
|
|
327
|
+
"""
|
|
328
|
+
|
|
329
|
+
try:
|
|
330
|
+
opts, args = getopt.getopt(sys.argv[1:], 'c:d:e:hk:n:S:s:v:',
|
|
331
|
+
['counts=', 'delta=', 'epsilon=', 'help', 'kappa=',
|
|
332
|
+
'nof-samples=' 'sample-over=', 'seed=', 'verbose='])
|
|
333
|
+
except getopt.GetoptError as err:
|
|
334
|
+
sys.stderr.write(str(err).capitalize())
|
|
335
|
+
usage()
|
|
336
|
+
sys.exit(1)
|
|
337
|
+
|
|
338
|
+
counts = None
|
|
339
|
+
delta = 0.2
|
|
340
|
+
epsilon = 0.8
|
|
341
|
+
kappa = 0.638
|
|
342
|
+
nof_samples = 4
|
|
343
|
+
sample_over = None
|
|
344
|
+
seed = 1
|
|
345
|
+
verbose = 0
|
|
346
|
+
|
|
347
|
+
for opt, arg in opts:
|
|
348
|
+
if opt in ('-c', '--counts'):
|
|
349
|
+
counts = tuple([int(v) for v in str(arg).split(',')])
|
|
350
|
+
elif opt in ('-d', '--delta'):
|
|
351
|
+
delta = float(arg)
|
|
352
|
+
elif opt in ('-e', '--epsilon'):
|
|
353
|
+
epsilon = float(arg)
|
|
354
|
+
elif opt in ('-h', '--help'):
|
|
355
|
+
usage()
|
|
356
|
+
sys.exit(0)
|
|
357
|
+
elif opt in ('-k', '--kappa'):
|
|
358
|
+
kappa = float(arg)
|
|
359
|
+
elif opt in ('-n', '--nof-samples'):
|
|
360
|
+
nof_samples = int(arg)
|
|
361
|
+
elif opt in ('-S', '--sample-over'):
|
|
362
|
+
# parsing the list of variables
|
|
363
|
+
sample_over, values = [], str(arg).split(',')
|
|
364
|
+
|
|
365
|
+
# checking if there are intervals
|
|
366
|
+
for value in values:
|
|
367
|
+
if value.isnumeric():
|
|
368
|
+
sample_over.append(int(value))
|
|
369
|
+
elif '-' in value:
|
|
370
|
+
lb, ub = value.split('-')
|
|
371
|
+
assert int(lb) < int(ub)
|
|
372
|
+
sample_over.extend(list(range(int(lb), int(ub) + 1)))
|
|
373
|
+
|
|
374
|
+
# removing duplicates, if any
|
|
375
|
+
sample_over = sorted(set(sample_over))
|
|
376
|
+
elif opt in ('-s', '--seed'):
|
|
377
|
+
seed = int(arg)
|
|
378
|
+
elif opt in ('-v', '--verbose'):
|
|
379
|
+
verbose = int(arg)
|
|
380
|
+
else:
|
|
381
|
+
assert False, 'Unhandled option: {0} {1}'.format(opt, arg)
|
|
382
|
+
|
|
383
|
+
return nof_samples, counts, delta, epsilon, kappa, sample_over, seed, \
|
|
384
|
+
verbose, args
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
#
|
|
388
|
+
#==============================================================================
|
|
389
|
+
def usage():
|
|
390
|
+
"""
|
|
391
|
+
Prints usage message.
|
|
392
|
+
"""
|
|
393
|
+
|
|
394
|
+
print('Usage:', os.path.basename(sys.argv[0]), '[options] dimacs-file')
|
|
395
|
+
print('Options:')
|
|
396
|
+
print(' -c, --counts=<float> A comma-separated pair of integer values representing cell count and hash count parameters (if any)')
|
|
397
|
+
print(' Note: if omitted, there values are computed by ApproxMC')
|
|
398
|
+
print(' Default: none')
|
|
399
|
+
print(' -d, --delta=<float> Confidence parameter as per PAC guarantees')
|
|
400
|
+
print(' Available values: [0, 1) (default = 0.2)')
|
|
401
|
+
print(' -e, --epsilon=<float> Tolerance factor as per PAC guarantees')
|
|
402
|
+
print(' Available values: (0 .. 1], all (default = 0.8)')
|
|
403
|
+
print(' -k, --kappa=<float> Uniformity parameter')
|
|
404
|
+
print(' Available values: (0 .. 1], all (default = 0.638)')
|
|
405
|
+
print(' -n, --nof-samples=<int> Number of required samples')
|
|
406
|
+
print(' Available values: [1 .. INT_MAX] (default = 4)')
|
|
407
|
+
print(' -S, --sample-over=<list> If provided, solutions are almost uniformly sampled over this set of variables')
|
|
408
|
+
print(' Available values: comma-separated-list, none (default = none)')
|
|
409
|
+
print(' -s, --seed=<int> Random seed')
|
|
410
|
+
print(' Available values: [0 .. INT_MAX] (default = 1)')
|
|
411
|
+
print(' -v, --verbose=<int> Verbosity level')
|
|
412
|
+
print(' Available values: [0 .. 15] (default = 0)')
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
#
|
|
416
|
+
#==============================================================================
|
|
417
|
+
if __name__ == '__main__':
|
|
418
|
+
nof_samples, counts, delta, epsilon, kappa, sample_over, seed, verbose, \
|
|
419
|
+
files = parse_options()
|
|
420
|
+
|
|
421
|
+
# parsing the input formula
|
|
422
|
+
if files and re.search(r'\.cnf(\.(gz|bz2|lzma|xz))?$', files[0]):
|
|
423
|
+
formula = CNF(from_file=files[0])
|
|
424
|
+
|
|
425
|
+
# creating the sampler object
|
|
426
|
+
with Sampler(formula, seed=seed, epsilon=epsilon, delta=delta,
|
|
427
|
+
kappa=kappa, verbose=verbose) as sampler:
|
|
428
|
+
|
|
429
|
+
# almost uniform sampling
|
|
430
|
+
samples = sampler.sample(nof_samples, sample_over=sample_over,
|
|
431
|
+
counts=counts)
|
|
432
|
+
|
|
433
|
+
# printing the result
|
|
434
|
+
for sample in samples:
|
|
435
|
+
print('v {0} 0'.format(' '.join(['{0}{1}'.format('+' if v > 0 else '', v) for v in sample])))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: python-sat
|
|
3
|
-
Version:
|
|
3
|
+
Version: 1.8.dev26
|
|
4
4
|
Summary: A Python library for prototyping with SAT oracles
|
|
5
5
|
Home-page: https://github.com/pysathq/pysat
|
|
6
6
|
Author: Alexey Ignatiev, Joao Marques-Silva, Antonio Morgado
|
|
@@ -10,11 +10,25 @@ Description-Content-Type: text/x-rst; charset=UTF-8
|
|
|
10
10
|
License-File: LICENSE.txt
|
|
11
11
|
Requires-Dist: six
|
|
12
12
|
Provides-Extra: aiger
|
|
13
|
-
Requires-Dist: py-aiger-cnf
|
|
13
|
+
Requires-Dist: py-aiger-cnf>=2.0.0; extra == "aiger"
|
|
14
14
|
Provides-Extra: approxmc
|
|
15
|
-
Requires-Dist: pyapproxmc
|
|
15
|
+
Requires-Dist: pyapproxmc>=4.1.8; extra == "approxmc"
|
|
16
|
+
Provides-Extra: cryptosat
|
|
17
|
+
Requires-Dist: pycryptosat>=5.11.18; extra == "cryptosat"
|
|
16
18
|
Provides-Extra: pblib
|
|
17
|
-
Requires-Dist: pypblib
|
|
19
|
+
Requires-Dist: pypblib>=0.0.3; extra == "pblib"
|
|
20
|
+
Provides-Extra: unigen
|
|
21
|
+
Requires-Dist: pyunigen>=4.1.20; extra == "unigen"
|
|
22
|
+
Dynamic: author
|
|
23
|
+
Dynamic: author-email
|
|
24
|
+
Dynamic: description
|
|
25
|
+
Dynamic: description-content-type
|
|
26
|
+
Dynamic: home-page
|
|
27
|
+
Dynamic: license
|
|
28
|
+
Dynamic: license-file
|
|
29
|
+
Dynamic: provides-extra
|
|
30
|
+
Dynamic: requires-dist
|
|
31
|
+
Dynamic: summary
|
|
18
32
|
|
|
19
33
|
|
|
20
34
|
A Python library providing a simple interface to a number of state-of-art
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
pycard.cp310-win_amd64.pyd,sha256=PZEY3pEG8cRJOICHRGnVnBuuGHCQw8Jk0ZVWqb2yEt0,69632
|
|
2
|
+
pysolvers.cp310-win_amd64.pyd,sha256=6CUZI6VkPKJDV8ME4fS-Fl7H0iewtX7BXNQuMQAKV7g,2231296
|
|
3
|
+
pysat/__init__.py,sha256=74wko0o87fd5_HGmwcm6rHGu-57Nvcfj0i3NLHMO0hs,670
|
|
4
|
+
pysat/_fileio.py,sha256=cmrqvhPXxC87lpvLlFDG7EWpusQOaqCGPMDfWhqT6dg,6373
|
|
5
|
+
pysat/_utils.py,sha256=4cv40p70FKvjCTKq8GqzS_jlxF74cp_lojTZSim_qJE,1340
|
|
6
|
+
pysat/card.py,sha256=Np6HK2LfD-7YuOP53jMAm6JIO1lPFu_jqJP18n03uvM,30066
|
|
7
|
+
pysat/engines.py,sha256=PzcZJ4zFXDHfcSSHF7iPadtrwSVEt4t9B_cO5epwTZk,45182
|
|
8
|
+
pysat/formula.py,sha256=X0gKU5x6cygMmv0pQzNL5_mbV6smD0jVr-vHZT2i87I,203894
|
|
9
|
+
pysat/pb.py,sha256=DMy8UfbbpfJo5cTZul9W1o_mlr-B0lCIEseZjrQYd8A,17816
|
|
10
|
+
pysat/process.py,sha256=8lNbpEKipFZjbQ9DCJPfdL8eZHx-ltNuu7h4geWWdJY,12739
|
|
11
|
+
pysat/solvers.py,sha256=00Y6yKNXvJOLA7l4aIDgueFbNM9lt3PkmT2OxB43aQ8,229975
|
|
12
|
+
pysat/allies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
+
pysat/allies/approxmc.py,sha256=LtUss6PiqmgvFwLTe4KUHmhavdzlotRii2UUOSb9gTU,13586
|
|
14
|
+
pysat/allies/unigen.py,sha256=qOGc_WwcIi-AgFSJDBhhY2n6Q6UeYVMpMPuem4-Vf6c,16718
|
|
15
|
+
pysat/examples/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
+
pysat/examples/bbscan.py,sha256=E4Y5j3Llr0-jIn-RDZIk-f02Sbujg4wX7uysoiFRnLg,22046
|
|
17
|
+
pysat/examples/bica.py,sha256=OGcGQGQnMepCCurwRbygokFgoDkI7eBhjmsYvr3FM1M,27098
|
|
18
|
+
pysat/examples/fm.py,sha256=e_s6wNBstEeoMw9zYyyDRgkE-Hqa902Iy_CxCS961CE,18136
|
|
19
|
+
pysat/examples/genhard.py,sha256=DFXtSVQ4qn78y0-ZMr2D6gBCLizZSzgkvcbDsjqjnKI,19017
|
|
20
|
+
pysat/examples/hitman.py,sha256=vHJEeSfoMQlDD3D3Poofaryv-k_dMH37XoqVXJUUuUg,26360
|
|
21
|
+
pysat/examples/lbx.py,sha256=InMjqY-9UvWKznIXOEwfBsM4spfkduDld6gUkr1jCqo,23249
|
|
22
|
+
pysat/examples/lsu.py,sha256=qyN2TvXG61EtMy-IrX5EYmLPM_iNOhtOkGTY5nHO_zo,16198
|
|
23
|
+
pysat/examples/mcsls.py,sha256=bP47P56OOP_uy0MuFA7TGxMdkAis7gX4E9AEEI0tSec,22093
|
|
24
|
+
pysat/examples/models.py,sha256=cdIR8iOrYu2ibqfcb_kEKXQMCfmFiz7cvZ3y1dur3Qw,5741
|
|
25
|
+
pysat/examples/musx.py,sha256=hswVGkjm95lhOyrtl1e4ouDyNSy-hWvQ05084Xnck9I,10946
|
|
26
|
+
pysat/examples/optux.py,sha256=8eYHO_uhL_4ugb-hRv2s6cnOwTurfqkpbdnK9T4iDtw,27697
|
|
27
|
+
pysat/examples/primer.py,sha256=0OeV9R6mWyIr2BKIitkrfgY3q2XE-sV1ZLSiybGRFXw,23375
|
|
28
|
+
pysat/examples/rc2.py,sha256=4GwefgJscHwxwP4W05WoemZdaZpcKk842OOlqdvXmXA,75771
|
|
29
|
+
pysat/examples/usage.py,sha256=x9luw6pyKAAndlxAeUWFhS4aLSVmD2t_j_5uA9YddHg,2183
|
|
30
|
+
python_sat-1.8.dev26.data/scripts/approxmc.py,sha256=h6aMnSpIaYXkTMq-tCSzNWwKb0AG-vTH4vuLWGn5Q4s,13958
|
|
31
|
+
python_sat-1.8.dev26.data/scripts/bbscan.py,sha256=xGxklG6Gc_UBaM8QvEJDOtQhEamxAncfsd65E-0JcAc,22696
|
|
32
|
+
python_sat-1.8.dev26.data/scripts/bica.py,sha256=q6fQGsFp1EaaYRZGBsDFOIJPVScr5k42XFskBzW69mA,27776
|
|
33
|
+
python_sat-1.8.dev26.data/scripts/fm.py,sha256=ek1QDsuxiq1zm1PBLbrSXXEE89RP9_DYwVNnyB3eO4s,18650
|
|
34
|
+
python_sat-1.8.dev26.data/scripts/genhard.py,sha256=YswufT272W4xTJrSBlOC2ucJx4RK4ntfRv73rASrx30,19520
|
|
35
|
+
python_sat-1.8.dev26.data/scripts/lbx.py,sha256=rCQ6zH_DXoVjBrzhZHSDJMfP92-hz2JVwh6e4m44AUc,23874
|
|
36
|
+
python_sat-1.8.dev26.data/scripts/lsu.py,sha256=cAATg2x0Cu1LC8KszMctHqywjq7pygkb9vWNBrbUEZs,16681
|
|
37
|
+
python_sat-1.8.dev26.data/scripts/mcsls.py,sha256=cTJQMIO-4iho412wG0JhvhqXWy81U0RQV8wwOgkri3Q,22690
|
|
38
|
+
python_sat-1.8.dev26.data/scripts/models.py,sha256=UmMmklExzyXAIhh-0i038nQb7hTK6CbdV1M6m2GxxSI,5917
|
|
39
|
+
python_sat-1.8.dev26.data/scripts/musx.py,sha256=LwK10YuQ8pIf1TJwp0HKp54O0hdk8zBy3TIfGsF1yW0,11277
|
|
40
|
+
python_sat-1.8.dev26.data/scripts/optux.py,sha256=t20YBZH4_axTkRMapq-DL-fq-9tBybPWo0pkhIyGhDw,28394
|
|
41
|
+
python_sat-1.8.dev26.data/scripts/primer.py,sha256=iE9Vy0XyeySIY-7-L_VMwRahsIVCEmm9k04OhLwDvuw,23982
|
|
42
|
+
python_sat-1.8.dev26.data/scripts/rc2.py,sha256=YfsIhw1tC-TPmXs5GAUe8lDFQi52NR9kSsapODqHxoQ,77757
|
|
43
|
+
python_sat-1.8.dev26.data/scripts/unigen.py,sha256=e-HC2UxWA8MTN90VslkHX1ZlTPjdhI4etzkn6G8YAX4,17140
|
|
44
|
+
python_sat-1.8.dev26.dist-info/licenses/LICENSE.txt,sha256=6QMvEzxqdPXEoiAZUBaZLeLF4hW2S81fjKz_THER0uQ,1109
|
|
45
|
+
python_sat-1.8.dev26.dist-info/METADATA,sha256=C5nlMYUOlUR6OoC8ZFxHu8AlH470iEpiOPIesVh3mCI,1784
|
|
46
|
+
python_sat-1.8.dev26.dist-info/WHEEL,sha256=KUuBC6lxAbHCKilKua8R9W_TM71_-9Sg5uEP3uDWcoU,101
|
|
47
|
+
python_sat-1.8.dev26.dist-info/top_level.txt,sha256=fgEEGhMLivlF1ExCX8Y3niWsr4pDPRb5HdaWjNtabFI,23
|
|
48
|
+
python_sat-1.8.dev26.dist-info/RECORD,,
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
pycard.cp310-win_amd64.pyd,sha256=1Uq0A8wMUhVLJ7io-lYEYq7qeQ3OslAJmQYpee07BBc,69632
|
|
2
|
-
pysolvers.cp310-win_amd64.pyd,sha256=oBjwOlbYaPys1Pw-Ve9hsh428OsSvgixEtoF-MlGBh8,1783808
|
|
3
|
-
pysat/__init__.py,sha256=m47DTD-HSOEtFRJtSqRXH0TMjiUV34_UvhOKpYqsMk8,654
|
|
4
|
-
pysat/_fileio.py,sha256=zS0aqB8sopegp1VmwuUd7JzdIGrZkNAl9RVLCgg-i-Q,5814
|
|
5
|
-
pysat/_utils.py,sha256=4cv40p70FKvjCTKq8GqzS_jlxF74cp_lojTZSim_qJE,1340
|
|
6
|
-
pysat/card.py,sha256=a7nHWolYTl2H16IQfw7th_nxAQEIdM02LM0Ps0YJJ3g,30043
|
|
7
|
-
pysat/formula.py,sha256=YOA_cf7ge7wvcB6bL0aXzp9wyPJYa6JvcuwGJ789ZIc,95959
|
|
8
|
-
pysat/pb.py,sha256=Zffa2HuA9dDZYuy4rBhcsLD7fvwlNjd0fWPbxCFmShY,15657
|
|
9
|
-
pysat/process.py,sha256=QNDiz5OFpZctMzs9SOj3hxb3tuWA6N3Z2jlCoQoVciU,11968
|
|
10
|
-
pysat/solvers.py,sha256=Ph8taALcEIBB8fQlVUOp8BSw18cGtPxqcpBam7cnXjY,185866
|
|
11
|
-
pysat/allies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
-
pysat/allies/approxmc.py,sha256=Th9iCz_F_OtIsyCvlG9PfL6Ak4RQU64tbUmRx3sFotw,13572
|
|
13
|
-
pysat/examples/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
pysat/examples/fm.py,sha256=9wj-3Gm73DB7KLrEuDLxXKqQMMQ58NhhuBCPRWrCoSQ,17968
|
|
15
|
-
pysat/examples/genhard.py,sha256=sRvnrHqkk2SPxispGJOEp4-TAzCJonYU9PzI0HfOc00,18986
|
|
16
|
-
pysat/examples/hitman.py,sha256=1e6Q7sErXycstbGKmQBuECp1pu_UCXHZGggvEQuygoA,25406
|
|
17
|
-
pysat/examples/lbx.py,sha256=VYQ33z1IoqBYI9KxrJCzDjWyq9-sAd38jBl9rEUUD9o,21295
|
|
18
|
-
pysat/examples/lsu.py,sha256=h0B6pxfPSrZov9nenNLn7zk2rdm5u1_Uq__X1MMfd08,15523
|
|
19
|
-
pysat/examples/mcsls.py,sha256=UNoC3PhlYh1SC_IbAqvEmTsZDIalIJFGCyRJHtXMGls,20320
|
|
20
|
-
pysat/examples/models.py,sha256=XYFTvJjMlVDzU0jqt2UeBk8I3n6ZIF4x8xoqA0zsW1M,5724
|
|
21
|
-
pysat/examples/musx.py,sha256=oV4foCXxpWOky8e5_erxF4uoEQUI15XYTG90B-Qnssw,10563
|
|
22
|
-
pysat/examples/optux.py,sha256=xljpa8Ztptzi5f_Zhavzzb-jpmE4uwAyJuzq2GcAYKc,25636
|
|
23
|
-
pysat/examples/rc2.py,sha256=epF0ZigObVWQbYXyEzgP3flq22cQPIdV0vsHCnRPlGE,67270
|
|
24
|
-
pysat/examples/usage.py,sha256=x9luw6pyKAAndlxAeUWFhS4aLSVmD2t_j_5uA9YddHg,2183
|
|
25
|
-
python_sat-0.1.8.dev10.data/scripts/approxmc.py,sha256=b4TTg5NCAsZLuMlkw5DP4INuH9NcZ32gJTfxiXutTLA,13944
|
|
26
|
-
python_sat-0.1.8.dev10.data/scripts/fm.py,sha256=a94HXJAZWeir-BxwTgvcFCbxdDs94qQWxyA46AkSLOM,18478
|
|
27
|
-
python_sat-0.1.8.dev10.data/scripts/genhard.py,sha256=YF6FmBwVu6R8swSVBKoGrBQxQZI3WViFzG0O1LvIyVU,19488
|
|
28
|
-
python_sat-0.1.8.dev10.data/scripts/lbx.py,sha256=Ln7riOrlTrWpFeMZfc6ErrQqCAxOBT0S6MwC8_hxwjs,21879
|
|
29
|
-
python_sat-0.1.8.dev10.data/scripts/lsu.py,sha256=NE_1WxFNypXbmJv_g6LykwROhfutatuDMgq50hbUYy0,15992
|
|
30
|
-
python_sat-0.1.8.dev10.data/scripts/mcsls.py,sha256=tZG35WkeBgseY4GwcDjmQFXs_0rf50Nb7arQpphYVsQ,20879
|
|
31
|
-
python_sat-0.1.8.dev10.data/scripts/models.py,sha256=pRTaSLEcN1RTBXH_Lsi8L6h_lCwcofDiI_agyo7UCa0,5898
|
|
32
|
-
python_sat-0.1.8.dev10.data/scripts/musx.py,sha256=gNzKlF7p7cMu_TCY4veTOZagaoU-Jg9WAyce-7kl4PQ,10886
|
|
33
|
-
python_sat-0.1.8.dev10.data/scripts/optux.py,sha256=Y_pblJ62Jr2ZDliwPIzfA-WPM6avjjHiUO1EwGW40Us,26294
|
|
34
|
-
python_sat-0.1.8.dev10.data/scripts/rc2.py,sha256=-k4PrWxmOXi97fIh5mCjJsdtvmggGQwT0TnoDAqqBAI,69057
|
|
35
|
-
python_sat-0.1.8.dev10.dist-info/LICENSE.txt,sha256=6QMvEzxqdPXEoiAZUBaZLeLF4hW2S81fjKz_THER0uQ,1109
|
|
36
|
-
python_sat-0.1.8.dev10.dist-info/METADATA,sha256=uaP9HEuvfdQ9K_ch95WukaEyDGnmNk0XFIm6W2T59Aw,1405
|
|
37
|
-
python_sat-0.1.8.dev10.dist-info/WHEEL,sha256=yrvteVAZzxQvtDnzdCRh4dP01sPIxYhLXIXplC7o50E,102
|
|
38
|
-
python_sat-0.1.8.dev10.dist-info/top_level.txt,sha256=fgEEGhMLivlF1ExCX8Y3niWsr4pDPRb5HdaWjNtabFI,23
|
|
39
|
-
python_sat-0.1.8.dev10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|