python-sat 1.9.dev6__tar.gz → 1.9.dev8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of python-sat might be problematic. Click here for more details.
- {python_sat-1.9.dev6/python_sat.egg-info → python_sat-1.9.dev8}/PKG-INFO +1 -1
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/examples/rc2.py +6 -4
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/formula/pf_parse.cc +32 -14
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/formula/pf_scan.hh +26 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/formula/pf_weight.cc +3 -2
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/formula/pyformula.hh +1 -1
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/pysat/__init__.py +1 -1
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/pysat/formula.py +204 -106
- {python_sat-1.9.dev6 → python_sat-1.9.dev8/python_sat.egg-info}/PKG-INFO +1 -1
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/tests/test_clausification.py +4 -4
- python_sat-1.9.dev8/tests/test_formula_parsing.py +143 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/tests/test_formula_unique.py +32 -0
- python_sat-1.9.dev6/tests/test_formula_parsing.py +0 -70
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/LICENSE.txt +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/MANIFEST.in +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/README.rst +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/allies/__init__.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/allies/approxmc.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/allies/unigen.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/cardenc/bitwise.hh +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/cardenc/card.hh +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/cardenc/clset.hh +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/cardenc/common.hh +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/cardenc/itot.hh +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/cardenc/ladder.hh +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/cardenc/mto.hh +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/cardenc/pairwise.hh +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/cardenc/ptypes.hh +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/cardenc/pycard.cc +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/cardenc/seqcounter.hh +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/cardenc/sortcard.hh +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/cardenc/utils.hh +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/examples/__init__.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/examples/bbscan.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/examples/bica.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/examples/fm.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/examples/genhard.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/examples/hitman.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/examples/lbx.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/examples/lsu.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/examples/mcsls.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/examples/models.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/examples/musx.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/examples/optux.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/examples/primer.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/examples/usage.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/formula/pf_plus.cc +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/formula/pf_plus.hh +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/formula/pf_py.hh +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/formula/pf_weight.hh +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/formula/pyformula.cc +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/pysat/_fileio.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/pysat/_utils.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/pysat/card.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/pysat/engines.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/pysat/integer.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/pysat/pb.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/pysat/process.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/pysat/solvers.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/python_sat.egg-info/SOURCES.txt +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/python_sat.egg-info/dependency_links.txt +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/python_sat.egg-info/requires.txt +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/python_sat.egg-info/top_level.txt +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/requirements.txt +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/setup.cfg +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/setup.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/cadical103.tar.gz +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/cadical153.tar.gz +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/cadical195.tar.gz +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/cadical300.tar.gz +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/glucose30.tar.gz +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/glucose41.tar.gz +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/glucose421.tar.gz +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/lingeling.tar.gz +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/maplechrono.zip +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/maplecm.zip +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/maplesat.zip +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/mergesat3.tar.gz +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/minicard.tar.gz +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/minisat22.tar.gz +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/minisatgh.zip +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/patches/cadical103.patch +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/patches/cadical153.patch +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/patches/cadical195.patch +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/patches/cadical300.patch +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/patches/glucose30.patch +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/patches/glucose41.patch +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/patches/glucose421.patch +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/patches/gluecard30.patch +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/patches/gluecard41.patch +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/patches/kissat404.patch +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/patches/lingeling.patch +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/patches/maplechrono.patch +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/patches/maplecm.patch +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/patches/maplesat.patch +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/patches/mergesat3.patch +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/patches/minicard.patch +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/patches/minisat22.patch +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/patches/minisatep.patch +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/patches/minisatgh.patch +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/prepare.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/solvers/pysolvers.cc +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/tests/test_accum_stats.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/tests/test_atmost.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/tests/test_atmost1.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/tests/test_atmostk.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/tests/test_boolengine.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/tests/test_cnf.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/tests/test_empty_extclause.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/tests/test_encode_pb_conditional.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/tests/test_equals1.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/tests/test_idpool.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/tests/test_integer.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/tests/test_oom.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/tests/test_process.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/tests/test_propagate.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/tests/test_unique_model.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/tests/test_unique_mus.py +0 -0
- {python_sat-1.9.dev6 → python_sat-1.9.dev8}/tests/test_warmstart.py +0 -0
|
@@ -134,7 +134,6 @@ from __future__ import print_function
|
|
|
134
134
|
import bisect
|
|
135
135
|
import collections
|
|
136
136
|
import getopt
|
|
137
|
-
import itertools
|
|
138
137
|
from math import copysign
|
|
139
138
|
import os
|
|
140
139
|
from pysat.formula import CNFPlus, WCNFPlus, IDPool
|
|
@@ -740,9 +739,12 @@ class RC2(object):
|
|
|
740
739
|
self.minw = min(map(lambda l: self.wght[l], self.core))
|
|
741
740
|
|
|
742
741
|
# dividing the core into two parts
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
742
|
+
self.core_sels, self.core_sums = [], []
|
|
743
|
+
for l in self.core:
|
|
744
|
+
if l in self.sels_set:
|
|
745
|
+
self.core_sels.append(l)
|
|
746
|
+
else:
|
|
747
|
+
self.core_sums.append(l)
|
|
746
748
|
|
|
747
749
|
def process_core(self):
|
|
748
750
|
"""
|
|
@@ -47,10 +47,14 @@ PyObject *parse_cnf_impl(PyObject *txt_obj, PyObject *comment_lead)
|
|
|
47
47
|
continue;
|
|
48
48
|
|
|
49
49
|
if (comment_mask[(unsigned char)beg[0]]) {
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
if (line_has_kind(beg, lend, "cnf"))
|
|
51
|
+
continue;
|
|
52
|
+
if (line_has_p(beg, lend)) {
|
|
53
|
+
PyErr_SetString(PyExc_ValueError, "invalid CNF preamble");
|
|
54
|
+
goto fail;
|
|
53
55
|
}
|
|
56
|
+
if (!append_comment(comments, beg, lend))
|
|
57
|
+
goto fail;
|
|
54
58
|
continue;
|
|
55
59
|
}
|
|
56
60
|
|
|
@@ -143,13 +147,17 @@ PyObject *parse_wcnf_impl(PyObject *txt_obj, PyObject *comment_lead)
|
|
|
143
147
|
continue;
|
|
144
148
|
|
|
145
149
|
if (comment_mask[(unsigned char)beg[0]]) {
|
|
146
|
-
if (
|
|
147
|
-
if (!
|
|
150
|
+
if (line_has_kind(beg, lend, "wcnf")) {
|
|
151
|
+
if (!parse_weight_preamble(beg, lend,
|
|
152
|
+
"invalid WCNF preamble", &topw))
|
|
148
153
|
goto fail;
|
|
149
154
|
}
|
|
155
|
+
else if (line_has_p(beg, lend)) {
|
|
156
|
+
PyErr_SetString(PyExc_ValueError, "invalid WCNF preamble");
|
|
157
|
+
goto fail;
|
|
158
|
+
}
|
|
150
159
|
else {
|
|
151
|
-
if (!
|
|
152
|
-
"invalid WCNF preamble", &topw))
|
|
160
|
+
if (!append_comment(comments, beg, lend))
|
|
153
161
|
goto fail;
|
|
154
162
|
}
|
|
155
163
|
continue;
|
|
@@ -249,10 +257,15 @@ PyObject *parse_cnfplus_impl(PyObject *txt_obj, PyObject *comment_lead)
|
|
|
249
257
|
continue;
|
|
250
258
|
|
|
251
259
|
if (comment_mask[(unsigned char)beg[0]]) {
|
|
252
|
-
if (
|
|
253
|
-
|
|
254
|
-
|
|
260
|
+
if (line_has_kind(beg, lend, "cnf", "cnf+"))
|
|
261
|
+
continue;
|
|
262
|
+
if (line_has_p(beg, lend)) {
|
|
263
|
+
PyErr_SetString(PyExc_ValueError, "invalid CNF/CNF+ preamble");
|
|
264
|
+
goto fail;
|
|
255
265
|
}
|
|
266
|
+
|
|
267
|
+
if (!append_comment(comments, beg, lend))
|
|
268
|
+
goto fail;
|
|
256
269
|
continue;
|
|
257
270
|
}
|
|
258
271
|
|
|
@@ -366,13 +379,18 @@ PyObject *parse_wcnfplus_impl(PyObject *txt_obj, PyObject *comment_lead)
|
|
|
366
379
|
continue;
|
|
367
380
|
|
|
368
381
|
if (comment_mask[(unsigned char)beg[0]]) {
|
|
369
|
-
if (
|
|
370
|
-
if (!
|
|
382
|
+
if (line_has_kind(beg, lend, "wcnf", "wcnf+")) {
|
|
383
|
+
if (!parse_weight_preamble(beg, lend,
|
|
384
|
+
"invalid WCNF/WCNF+ preamble", &topw))
|
|
371
385
|
goto fail;
|
|
372
386
|
}
|
|
387
|
+
else if (line_has_p(beg, lend)) {
|
|
388
|
+
PyErr_SetString(PyExc_ValueError,
|
|
389
|
+
"invalid WCNF/WCNF+ preamble");
|
|
390
|
+
goto fail;
|
|
391
|
+
}
|
|
373
392
|
else {
|
|
374
|
-
if (!
|
|
375
|
-
"invalid WCNF+ preamble", &topw))
|
|
393
|
+
if (!append_comment(comments, beg, lend))
|
|
376
394
|
goto fail;
|
|
377
395
|
}
|
|
378
396
|
continue;
|
|
@@ -83,6 +83,32 @@ static inline bool read_span(const char * &p, const char *end,
|
|
|
83
83
|
return true;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
// check whether a line starts with the exact DIMACS preamble marker
|
|
87
|
+
//=============================================================================
|
|
88
|
+
static inline bool line_has_p(const char *beg, const char *end)
|
|
89
|
+
{
|
|
90
|
+
const char *p = beg;
|
|
91
|
+
const char *tbeg, *tend;
|
|
92
|
+
|
|
93
|
+
return read_span(p, end, tbeg, tend) && span_eq(tbeg, tend, "p");
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// check whether a line has an exact DIMACS preamble kind token
|
|
97
|
+
//=============================================================================
|
|
98
|
+
static inline bool line_has_kind(const char *beg, const char *end,
|
|
99
|
+
const char *kind1, const char *kind2 = NULL)
|
|
100
|
+
{
|
|
101
|
+
const char *p = beg;
|
|
102
|
+
const char *tbeg, *tend;
|
|
103
|
+
|
|
104
|
+
if (!read_span(p, end, tbeg, tend) || !span_eq(tbeg, tend, "p") ||
|
|
105
|
+
!read_span(p, end, tbeg, tend))
|
|
106
|
+
return false;
|
|
107
|
+
|
|
108
|
+
return span_eq(tbeg, tend, kind1) ||
|
|
109
|
+
(kind2 != NULL && span_eq(tbeg, tend, kind2));
|
|
110
|
+
}
|
|
111
|
+
|
|
86
112
|
// check whether a span has the syntax of a signed integer
|
|
87
113
|
//=============================================================================
|
|
88
114
|
static inline bool span_is_integer_like(const char *beg, const char *end)
|
|
@@ -13,13 +13,14 @@
|
|
|
13
13
|
// parse only the weighted preamble fields relevant to the native parser
|
|
14
14
|
//=============================================================================
|
|
15
15
|
bool parse_weight_preamble(const char *beg, const char *end,
|
|
16
|
-
const char *
|
|
16
|
+
const char *errmsg, PyObject **topw)
|
|
17
17
|
{
|
|
18
18
|
const char *p = beg;
|
|
19
19
|
const char *tbeg, *tend;
|
|
20
20
|
|
|
21
21
|
if (!read_span(p, end, tbeg, tend) || !span_eq(tbeg, tend, "p") ||
|
|
22
|
-
!read_span(p, end, tbeg, tend) ||
|
|
22
|
+
!read_span(p, end, tbeg, tend) ||
|
|
23
|
+
!(span_eq(tbeg, tend, "wcnf") || span_eq(tbeg, tend, "wcnf+")) ||
|
|
23
24
|
!read_span(p, end, tbeg, tend) ||
|
|
24
25
|
!read_span(p, end, tbeg, tend)) {
|
|
25
26
|
PyErr_SetString(PyExc_ValueError, errmsg);
|
|
@@ -76,7 +76,7 @@ typedef struct {
|
|
|
76
76
|
vector<long long> wght;
|
|
77
77
|
} plus_body;
|
|
78
78
|
|
|
79
|
-
bool parse_weight_preamble(const char *beg, const char *end,
|
|
79
|
+
bool parse_weight_preamble(const char *beg, const char *end,
|
|
80
80
|
const char *errmsg, PyObject **topw);
|
|
81
81
|
|
|
82
82
|
bool parse_clause_body(const char *p, const char *end,
|