python-sat 1.9.dev20__cp315-cp315t-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.
- pycard.cp315t-win_amd64.pyd +0 -0
- pyformula.cp315t-win_amd64.pyd +0 -0
- pysat/__init__.py +36 -0
- pysat/_fileio.py +224 -0
- pysat/_utils.py +58 -0
- pysat/allies/__init__.py +0 -0
- pysat/allies/approxmc.py +385 -0
- pysat/allies/unigen.py +435 -0
- pysat/card.py +1024 -0
- pysat/engines.py +1328 -0
- pysat/examples/__init__.py +0 -0
- pysat/examples/bbscan.py +663 -0
- pysat/examples/bica.py +701 -0
- pysat/examples/fm.py +527 -0
- pysat/examples/genhard.py +516 -0
- pysat/examples/hitman.py +648 -0
- pysat/examples/lbx.py +638 -0
- pysat/examples/lsu.py +496 -0
- pysat/examples/mcsls.py +610 -0
- pysat/examples/models.py +189 -0
- pysat/examples/musx.py +344 -0
- pysat/examples/optux.py +750 -0
- pysat/examples/primer.py +620 -0
- pysat/examples/rc2.py +2043 -0
- pysat/examples/usage.py +63 -0
- pysat/formula.py +5899 -0
- pysat/integer.py +2768 -0
- pysat/pb.py +454 -0
- pysat/process.py +363 -0
- pysat/solvers.py +10223 -0
- pysolvers.cp315t-win_amd64.pyd +0 -0
- python_sat-1.9.dev20.data/platlib/msvcp140-a4c2229bdc2a2a630acdc095b4d86008.dll +0 -0
- python_sat-1.9.dev20.data/scripts/approxmc.py +385 -0
- python_sat-1.9.dev20.data/scripts/bbscan.py +663 -0
- python_sat-1.9.dev20.data/scripts/bica.py +701 -0
- python_sat-1.9.dev20.data/scripts/fm.py +527 -0
- python_sat-1.9.dev20.data/scripts/genhard.py +516 -0
- python_sat-1.9.dev20.data/scripts/lbx.py +638 -0
- python_sat-1.9.dev20.data/scripts/lsu.py +496 -0
- python_sat-1.9.dev20.data/scripts/mcsls.py +610 -0
- python_sat-1.9.dev20.data/scripts/models.py +189 -0
- python_sat-1.9.dev20.data/scripts/musx.py +344 -0
- python_sat-1.9.dev20.data/scripts/optux.py +750 -0
- python_sat-1.9.dev20.data/scripts/primer.py +620 -0
- python_sat-1.9.dev20.data/scripts/rc2.py +2043 -0
- python_sat-1.9.dev20.data/scripts/unigen.py +435 -0
- python_sat-1.9.dev20.dist-info/DELVEWHEEL +2 -0
- python_sat-1.9.dev20.dist-info/METADATA +47 -0
- python_sat-1.9.dev20.dist-info/RECORD +52 -0
- python_sat-1.9.dev20.dist-info/WHEEL +5 -0
- python_sat-1.9.dev20.dist-info/licenses/LICENSE.txt +21 -0
- python_sat-1.9.dev20.dist-info/top_level.txt +4 -0
|
Binary file
|
|
Binary file
|
pysat/__init__.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
#-*- coding:utf-8 -*-
|
|
3
|
+
##
|
|
4
|
+
## __init__.py
|
|
5
|
+
##
|
|
6
|
+
## Created on: Mar 4, 2017
|
|
7
|
+
## Author: Alexey S. Ignatiev
|
|
8
|
+
## E-mail: aignatiev@ciencias.ulisboa.pt
|
|
9
|
+
##
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# start delvewheel patch
|
|
13
|
+
def _delvewheel_patch_1_13_2():
|
|
14
|
+
import os
|
|
15
|
+
if os.path.isdir(libs_dir := os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, '.'))):
|
|
16
|
+
os.add_dll_directory(libs_dir)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
_delvewheel_patch_1_13_2()
|
|
20
|
+
del _delvewheel_patch_1_13_2
|
|
21
|
+
# end delvewheel patch
|
|
22
|
+
|
|
23
|
+
# current version
|
|
24
|
+
#==============================================================================
|
|
25
|
+
VERSION = (1, 9, 'dev', 20)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# PEP440 Format
|
|
29
|
+
#==============================================================================
|
|
30
|
+
__version__ = '%d.%d.%s%d' % VERSION if len(VERSION) == 4 else \
|
|
31
|
+
'%d.%d.%d' % VERSION
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
# all submodules
|
|
35
|
+
#==============================================================================
|
|
36
|
+
__all__ = ['card', 'engines', 'formula', 'integer', 'pb', 'process', 'solvers']
|
pysat/_fileio.py
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
#-*- coding:utf-8 -*-
|
|
3
|
+
##
|
|
4
|
+
## _fileio.py
|
|
5
|
+
##
|
|
6
|
+
## Created on: Aug 18, 2018
|
|
7
|
+
## Author: Alexey S. Ignatiev
|
|
8
|
+
## E-mail: aignatiev@ciencias.ulisboa.pt
|
|
9
|
+
##
|
|
10
|
+
|
|
11
|
+
"""
|
|
12
|
+
===============
|
|
13
|
+
List of classes
|
|
14
|
+
===============
|
|
15
|
+
|
|
16
|
+
.. autosummary::
|
|
17
|
+
:nosignatures:
|
|
18
|
+
|
|
19
|
+
FileObject
|
|
20
|
+
|
|
21
|
+
==================
|
|
22
|
+
Module description
|
|
23
|
+
==================
|
|
24
|
+
|
|
25
|
+
This simple module provides a basic interface to input/output operations
|
|
26
|
+
on files. Its key design feature is the ability to work with both
|
|
27
|
+
uncompressed and compressed files through a unified interface, thus,
|
|
28
|
+
making it easier for a user to deal with various types of compressed
|
|
29
|
+
files. The compression types supported include gzip, bzip2, lzma (xz), and
|
|
30
|
+
zstandard (zstd).
|
|
31
|
+
|
|
32
|
+
The module is supposed to be mainly used by :mod:`pysat.formula`.
|
|
33
|
+
|
|
34
|
+
A simple usage example is the following:
|
|
35
|
+
|
|
36
|
+
.. code-block:: python
|
|
37
|
+
|
|
38
|
+
>>> from pysat._fileio import FileObject
|
|
39
|
+
>>>
|
|
40
|
+
>>> with FileObject(name='formula.cnf', mode='r') as fp1:
|
|
41
|
+
... contents1 = fp1.readlines()
|
|
42
|
+
>>>
|
|
43
|
+
>>> with FileObject(name='filename.txt.gz', compression='use_ext') as fp2:
|
|
44
|
+
... contents2 = fp2.readlines()
|
|
45
|
+
>>>
|
|
46
|
+
>>> with FileObject(name='f.txt.bz2', mode='w', compression='bzip2') as fp3:
|
|
47
|
+
... fp3.write('hello, world!\n')
|
|
48
|
+
|
|
49
|
+
==============
|
|
50
|
+
Module details
|
|
51
|
+
==============
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
#
|
|
55
|
+
#==============================================================================
|
|
56
|
+
import bz2
|
|
57
|
+
import codecs
|
|
58
|
+
import gzip
|
|
59
|
+
import os
|
|
60
|
+
|
|
61
|
+
lzma_present = True
|
|
62
|
+
try: # for Python3
|
|
63
|
+
import lzma
|
|
64
|
+
except ImportError:
|
|
65
|
+
try: # for Python2 + backports.lzma installed
|
|
66
|
+
from backports import lzma
|
|
67
|
+
except ImportError: # for Python2 without lzma
|
|
68
|
+
lzma_present = False
|
|
69
|
+
|
|
70
|
+
zstd_present = True
|
|
71
|
+
try:
|
|
72
|
+
from compression import zstd
|
|
73
|
+
except ImportError: # zstandard is introduced in Python 3.14
|
|
74
|
+
zstd_present = False
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
#
|
|
78
|
+
#==============================================================================
|
|
79
|
+
def read_all_text(fp):
|
|
80
|
+
"""
|
|
81
|
+
Read the entire contents of a file-like object and normalize the
|
|
82
|
+
result to text.
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
data = fp.read()
|
|
86
|
+
|
|
87
|
+
if isinstance(data, bytes):
|
|
88
|
+
return data.decode('utf-8')
|
|
89
|
+
|
|
90
|
+
return data
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
#
|
|
94
|
+
#==============================================================================
|
|
95
|
+
class FileObject(object):
|
|
96
|
+
"""
|
|
97
|
+
Auxiliary class for convenient and uniform file manipulation, e.g. to
|
|
98
|
+
open files creating standard file pointers and closing them. The class
|
|
99
|
+
is used when opening DIMACS files for reading and writing. Supports
|
|
100
|
+
both uncompressed and compressed files. Compression algorithms
|
|
101
|
+
supported are ``gzip``, ``bzip2``, ``lzma``, and ``zstd``. Algorithm
|
|
102
|
+
``lzma`` can be used in Python 3 by default and also in Python 2 if
|
|
103
|
+
the ``backports.lzma`` package is installed. Algorithm ``zstandard``
|
|
104
|
+
can be used in Python 3.14 and later.
|
|
105
|
+
|
|
106
|
+
Note that the class opens a file in text mode.
|
|
107
|
+
|
|
108
|
+
:param name: a file name to open
|
|
109
|
+
:param mode: opening mode
|
|
110
|
+
:param compression: compression type
|
|
111
|
+
|
|
112
|
+
:type name: str
|
|
113
|
+
:type mode: str
|
|
114
|
+
:type compression: str
|
|
115
|
+
|
|
116
|
+
Compression type can be ``None``, ``'gzip'``, ``'bzip2'``, ``'lzma'``,
|
|
117
|
+
``'zstd'``, as well as ``'use_ext'``. If ``'use_ext'`` is specified,
|
|
118
|
+
compression algorithm is defined by the extension of the given file
|
|
119
|
+
name.
|
|
120
|
+
"""
|
|
121
|
+
|
|
122
|
+
def __init__(self, name, mode='r', compression=None):
|
|
123
|
+
"""
|
|
124
|
+
Constructor.
|
|
125
|
+
"""
|
|
126
|
+
|
|
127
|
+
self.fp = None # file pointer to give access to
|
|
128
|
+
self.ctype = None # compression type
|
|
129
|
+
|
|
130
|
+
# in some cases an additional file pointer is needed
|
|
131
|
+
self.fp_extra = None
|
|
132
|
+
|
|
133
|
+
self.open(name, mode=mode, compression=compression)
|
|
134
|
+
|
|
135
|
+
def open(self, name, mode='r', compression=None):
|
|
136
|
+
"""
|
|
137
|
+
Open a file pointer. Note that a file is *always* opened in
|
|
138
|
+
text mode. The method inherits its input parameters from the
|
|
139
|
+
constructor of :class:`FileObject`.
|
|
140
|
+
"""
|
|
141
|
+
|
|
142
|
+
if compression == 'use_ext':
|
|
143
|
+
self.get_compression_type(name)
|
|
144
|
+
else:
|
|
145
|
+
self.ctype = compression
|
|
146
|
+
|
|
147
|
+
if not self.ctype:
|
|
148
|
+
self.fp = open(name, mode)
|
|
149
|
+
elif self.ctype == 'gzip':
|
|
150
|
+
self.fp = gzip.open(name, mode + 't')
|
|
151
|
+
elif self.ctype == 'bzip2':
|
|
152
|
+
try:
|
|
153
|
+
# Python 3 supports opening bzip2 files in text mode
|
|
154
|
+
# therefore, we prefer to open them this way
|
|
155
|
+
self.fp = bz2.open(name, mode + 't')
|
|
156
|
+
except:
|
|
157
|
+
# BZ2File opens a file in binary mode
|
|
158
|
+
# thus, we have to use codecs.getreader()
|
|
159
|
+
# to be able to use it in text mode
|
|
160
|
+
self.fp_extra = bz2.BZ2File(name, mode)
|
|
161
|
+
|
|
162
|
+
if mode == 'r':
|
|
163
|
+
self.fp = codecs.getreader('ascii')(self.fp_extra)
|
|
164
|
+
else: # mode == 'w'
|
|
165
|
+
self.fp = codecs.getwriter('ascii')(self.fp_extra)
|
|
166
|
+
elif self.ctype == 'lzma':
|
|
167
|
+
# LZMA is available in Python 2 only if backports.lzma is installed
|
|
168
|
+
# Python 3 supports it by default
|
|
169
|
+
assert lzma_present, 'LZMA compression is unavailable.'
|
|
170
|
+
self.fp = lzma.open(name, mode=mode + 't')
|
|
171
|
+
else: # self.ctype == 'zstd'
|
|
172
|
+
# Zstandard is available only in Python 3.14 and later
|
|
173
|
+
assert zstd_present, 'Zstandard compression is unavailable.'
|
|
174
|
+
self.fp = zstd.open(name, mode=mode + 't')
|
|
175
|
+
|
|
176
|
+
def close(self):
|
|
177
|
+
"""
|
|
178
|
+
Close a file pointer.
|
|
179
|
+
"""
|
|
180
|
+
|
|
181
|
+
if self.fp:
|
|
182
|
+
self.fp.close()
|
|
183
|
+
self.fp = None
|
|
184
|
+
|
|
185
|
+
if self.fp_extra:
|
|
186
|
+
self.fp_extra.close()
|
|
187
|
+
self.fp_extra = None
|
|
188
|
+
|
|
189
|
+
self.ctype = None
|
|
190
|
+
|
|
191
|
+
def get_compression_type(self, file_name):
|
|
192
|
+
"""
|
|
193
|
+
Determine compression type for a given file using its extension.
|
|
194
|
+
|
|
195
|
+
:param file_name: a given file name
|
|
196
|
+
:type file_name: str
|
|
197
|
+
"""
|
|
198
|
+
|
|
199
|
+
ext = os.path.splitext(file_name)[1]
|
|
200
|
+
|
|
201
|
+
if ext == '.gz':
|
|
202
|
+
self.ctype = 'gzip'
|
|
203
|
+
elif ext == '.bz2':
|
|
204
|
+
self.ctype = 'bzip2'
|
|
205
|
+
elif ext in ('.xz', '.lzma'):
|
|
206
|
+
self.ctype = 'lzma'
|
|
207
|
+
elif ext == '.zst':
|
|
208
|
+
self.ctype = 'zstd'
|
|
209
|
+
else:
|
|
210
|
+
self.ctype = None
|
|
211
|
+
|
|
212
|
+
def __enter__(self):
|
|
213
|
+
"""
|
|
214
|
+
'with' constructor.
|
|
215
|
+
"""
|
|
216
|
+
|
|
217
|
+
return self
|
|
218
|
+
|
|
219
|
+
def __exit__(self, exc_type, exc_value, traceback):
|
|
220
|
+
"""
|
|
221
|
+
'with' destructor.
|
|
222
|
+
"""
|
|
223
|
+
|
|
224
|
+
self.close()
|
pysat/_utils.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
#-*- coding:utf-8 -*-
|
|
3
|
+
##
|
|
4
|
+
## _utils.py
|
|
5
|
+
##
|
|
6
|
+
## Created on: Nov 27, 2019
|
|
7
|
+
## Author: Alexey S. Ignatiev
|
|
8
|
+
## E-mail: aignatiev@ciencias.ulisboa.pt
|
|
9
|
+
##
|
|
10
|
+
|
|
11
|
+
"""
|
|
12
|
+
===============
|
|
13
|
+
List of classes
|
|
14
|
+
===============
|
|
15
|
+
|
|
16
|
+
.. autosummary::
|
|
17
|
+
:nosignatures:
|
|
18
|
+
|
|
19
|
+
MainThread
|
|
20
|
+
|
|
21
|
+
==================
|
|
22
|
+
Module description
|
|
23
|
+
==================
|
|
24
|
+
|
|
25
|
+
This simple module is supposed to implement auxiliary classes and routines
|
|
26
|
+
that are used by the other (main) modules of PySAT.
|
|
27
|
+
|
|
28
|
+
==============
|
|
29
|
+
Module details
|
|
30
|
+
==============
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
#
|
|
34
|
+
#==============================================================================
|
|
35
|
+
import threading
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
#
|
|
39
|
+
#==============================================================================
|
|
40
|
+
class MainThread(object):
|
|
41
|
+
"""
|
|
42
|
+
A dummy class for checking whether the current thread is the main one.
|
|
43
|
+
This is currently necessary for proper signal handling when making
|
|
44
|
+
oracle calls and creating cardinality encodings.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
@staticmethod
|
|
48
|
+
def check():
|
|
49
|
+
"""
|
|
50
|
+
The actual checker.
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
try: # for Python > 3.4
|
|
54
|
+
res = threading.current_thread() is threading.main_thread()
|
|
55
|
+
except AttributeError:
|
|
56
|
+
res = isinstance(threading.current_thread(), threading._MainThread)
|
|
57
|
+
|
|
58
|
+
return res
|
pysat/allies/__init__.py
ADDED
|
File without changes
|