python-sat 1.9.dev14__tar.gz → 1.9.dev16__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.
- {python_sat-1.9.dev14/python_sat.egg-info → python_sat-1.9.dev16}/PKG-INFO +1 -1
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/hitman.py +2 -7
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/lsu.py +1 -1
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/rc2.py +25 -17
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/pysat/__init__.py +1 -1
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/pysat/solvers.py +1004 -58
- {python_sat-1.9.dev14 → python_sat-1.9.dev16/python_sat.egg-info}/PKG-INFO +1 -1
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/python_sat.egg-info/SOURCES.txt +6 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/setup.py +4 -1
- python_sat-1.9.dev16/solvers/ergo.tar.gz +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/cadical153.patch +3 -3
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/cadical195.patch +3 -3
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/cadical300.patch +3 -3
- python_sat-1.9.dev16/solvers/patches/ergo.patch +646 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/prepare.py +17 -2
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/pysolvers.cc +1609 -183
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_accum_stats.py +5 -0
- python_sat-1.9.dev16/tests/test_boolengine.py +97 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_cnf.py +5 -0
- python_sat-1.9.dev16/tests/test_empty_clause.py +32 -0
- python_sat-1.9.dev16/tests/test_hitman.py +31 -0
- python_sat-1.9.dev16/tests/test_lsu.py +15 -0
- python_sat-1.9.dev16/tests/test_proof.py +40 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_propagate.py +50 -4
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_unique_model.py +5 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_warmstart.py +2 -1
- python_sat-1.9.dev14/tests/test_boolengine.py +0 -34
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/LICENSE.txt +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/MANIFEST.in +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/README.rst +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/allies/__init__.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/allies/approxmc.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/allies/unigen.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/bitwise.hh +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/card.hh +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/clset.hh +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/common.hh +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/itot.hh +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/ladder.hh +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/mto.hh +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/pairwise.hh +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/ptypes.hh +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/pycard.cc +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/seqcounter.hh +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/sortcard.hh +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/utils.hh +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/__init__.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/bbscan.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/bica.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/fm.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/genhard.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/lbx.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/mcsls.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/models.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/musx.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/optux.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/primer.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/usage.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/formula/pf_parse.cc +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/formula/pf_plus.cc +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/formula/pf_plus.hh +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/formula/pf_py.hh +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/formula/pf_scan.hh +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/formula/pf_weight.cc +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/formula/pf_weight.hh +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/formula/pyformula.cc +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/formula/pyformula.hh +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/pysat/_fileio.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/pysat/_utils.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/pysat/card.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/pysat/engines.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/pysat/formula.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/pysat/integer.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/pysat/pb.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/pysat/process.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/python_sat.egg-info/dependency_links.txt +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/python_sat.egg-info/requires.txt +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/python_sat.egg-info/top_level.txt +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/requirements.txt +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/setup.cfg +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/cadical103.tar.gz +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/cadical153.tar.gz +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/cadical195.tar.gz +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/cadical300.tar.gz +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/glucose30.tar.gz +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/glucose41.tar.gz +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/glucose421.tar.gz +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/lingeling.tar.gz +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/maplechrono.zip +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/maplecm.zip +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/maplesat.zip +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/mergesat3.tar.gz +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/minicard.tar.gz +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/minisat22.tar.gz +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/minisatgh.zip +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/cadical103.patch +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/glucose30.patch +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/glucose41.patch +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/glucose421.patch +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/gluecard30.patch +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/gluecard41.patch +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/kissat404.patch +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/lingeling.patch +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/maplechrono.patch +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/maplecm.patch +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/maplesat.patch +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/mergesat3.patch +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/minicard.patch +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/minisat22.patch +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/minisatep.patch +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/minisatgh.patch +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_atmost.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_atmost1.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_atmostk.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_clausification.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_empty_extclause.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_encode_pb_conditional.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_equals1.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_formula_parsing.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_formula_unique.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_idpool.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_integer.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_oom.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_process.py +0 -0
- {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_unique_mus.py +0 -0
|
@@ -476,24 +476,19 @@ class Hitman(object):
|
|
|
476
476
|
|
|
477
477
|
if no_obj is False:
|
|
478
478
|
# a soft clause should be added for each new object
|
|
479
|
-
new_obj =
|
|
479
|
+
new_obj = sorted(set(abs(vid) for vid in clause if abs(vid) not in self.oracle.vmap.e2i))
|
|
480
480
|
else:
|
|
481
481
|
# this is a native AtMostK constraint
|
|
482
482
|
clause = [list(map(lambda a: self.idpool.id(a.obj) * (2 * a.sign - 1), clause[0])), clause[1]]
|
|
483
483
|
|
|
484
484
|
if no_obj is False:
|
|
485
485
|
# a soft clause should be added for each new object
|
|
486
|
-
new_obj =
|
|
487
|
-
|
|
488
|
-
# there may be duplicate literals if the constraint is weighted
|
|
489
|
-
new_obj = list(set(new_obj))
|
|
486
|
+
new_obj = sorted(set(abs(vid) for vid in clause[0] if abs(vid) not in self.oracle.vmap.e2i))
|
|
490
487
|
|
|
491
488
|
# adding the hard clause
|
|
492
489
|
self.oracle.add_clause(clause)
|
|
493
490
|
|
|
494
491
|
if no_obj is False:
|
|
495
|
-
# some of the literals may also have the opposite polarity
|
|
496
|
-
new_obj = [l if l in self.idpool.obj2id else -l for l in new_obj]
|
|
497
492
|
|
|
498
493
|
if self.htype != 'sat':
|
|
499
494
|
# new soft clauses
|
|
@@ -235,7 +235,7 @@ class LSU:
|
|
|
235
235
|
self._assert_lt(self.cost)
|
|
236
236
|
|
|
237
237
|
if is_sat:
|
|
238
|
-
self.model = filter(lambda l: abs(l) <= self.formula.nv, self.model)
|
|
238
|
+
self.model = list(filter(lambda l: abs(l) <= self.formula.nv, self.model))
|
|
239
239
|
if self.verbose:
|
|
240
240
|
if self.found_optimum():
|
|
241
241
|
print('s OPTIMUM FOUND')
|
|
@@ -237,6 +237,7 @@ class RC2(object):
|
|
|
237
237
|
self.bnds = {} # a mapping from sum assumptions to totalizer bounds
|
|
238
238
|
self.tobj = {} # a mapping from sum assumptions to totalizer objects
|
|
239
239
|
self.swgt = {} # a mapping from sum assumptions to their core weights
|
|
240
|
+
self.filt = [] # contextual assumptions (useless in RC2)
|
|
240
241
|
self.cost = 0
|
|
241
242
|
|
|
242
243
|
# mappings between internal and external variables
|
|
@@ -440,7 +441,7 @@ class RC2(object):
|
|
|
440
441
|
# introduce new variables if necessary
|
|
441
442
|
cl = list(map(lambda l: self._map_extlit(l), clause if not len(clause) == 2 or not type(clause[0]) in (list, tuple, set) else clause[0]))
|
|
442
443
|
|
|
443
|
-
if
|
|
444
|
+
if weight is None:
|
|
444
445
|
if not len(clause) == 2 or not type(clause[0]) in (list, tuple, set):
|
|
445
446
|
# the clause is hard, and so we simply add it to the SAT oracle
|
|
446
447
|
self.oracle.add_clause(cl)
|
|
@@ -464,17 +465,18 @@ class RC2(object):
|
|
|
464
465
|
cl.append(-selv)
|
|
465
466
|
self.oracle.add_clause(cl)
|
|
466
467
|
|
|
467
|
-
if
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
468
|
+
if weight:
|
|
469
|
+
if selv not in self.wght:
|
|
470
|
+
# record selector and its weight
|
|
471
|
+
self.sels.append(selv)
|
|
472
|
+
self.wght[selv] = weight
|
|
473
|
+
self.smap[selv] = len(self.sels) - 1
|
|
474
|
+
else:
|
|
475
|
+
# selector is not new; increment its weight
|
|
476
|
+
self.wght[selv] += weight
|
|
475
477
|
|
|
476
|
-
|
|
477
|
-
|
|
478
|
+
self.sall.append(selv)
|
|
479
|
+
self.sels_set.add(selv)
|
|
478
480
|
|
|
479
481
|
return selv
|
|
480
482
|
|
|
@@ -658,6 +660,13 @@ class RC2(object):
|
|
|
658
660
|
else:
|
|
659
661
|
done = True
|
|
660
662
|
|
|
663
|
+
def active_assumps(self):
|
|
664
|
+
"""
|
|
665
|
+
Get the assumptions for the main core-guided loop.
|
|
666
|
+
"""
|
|
667
|
+
|
|
668
|
+
return self.sels + self.sums
|
|
669
|
+
|
|
661
670
|
def compute_(self):
|
|
662
671
|
"""
|
|
663
672
|
Main core-guided loop, which iteratively calls a SAT
|
|
@@ -679,7 +688,7 @@ class RC2(object):
|
|
|
679
688
|
self.interrupted = False
|
|
680
689
|
|
|
681
690
|
# main solving loop
|
|
682
|
-
while not self._call_oracle(assumptions=self.
|
|
691
|
+
while not self._call_oracle(assumptions=self.active_assumps(),
|
|
683
692
|
expect_interrupt=self.expect_interrupt):
|
|
684
693
|
|
|
685
694
|
# even if the call has been interrupted, we
|
|
@@ -1055,7 +1064,7 @@ class RC2(object):
|
|
|
1055
1064
|
"""
|
|
1056
1065
|
|
|
1057
1066
|
# the first case is simpler
|
|
1058
|
-
if self._call_oracle(assumptions=[-tobj.rhs[1]]):
|
|
1067
|
+
if self._call_oracle(assumptions=self.filt + [-tobj.rhs[1]]):
|
|
1059
1068
|
return 1
|
|
1060
1069
|
else:
|
|
1061
1070
|
self.cost += self.minw
|
|
@@ -1068,7 +1077,7 @@ class RC2(object):
|
|
|
1068
1077
|
# increasing the bound
|
|
1069
1078
|
self.update_sum(-tobj.rhs[i - 1])
|
|
1070
1079
|
|
|
1071
|
-
if self._call_oracle(assumptions=[-tobj.rhs[i]]):
|
|
1080
|
+
if self._call_oracle(assumptions=self.filt + [-tobj.rhs[i]]):
|
|
1072
1081
|
# the bound should be equal to i
|
|
1073
1082
|
return i
|
|
1074
1083
|
|
|
@@ -1244,10 +1253,9 @@ class RC2(object):
|
|
|
1244
1253
|
# right-hand side is always equal to the number of input literals
|
|
1245
1254
|
rhs = len(t.lits)
|
|
1246
1255
|
|
|
1247
|
-
if b < rhs:
|
|
1256
|
+
if b < rhs and not t.rhs[b]:
|
|
1248
1257
|
# creating an additional bound
|
|
1249
|
-
|
|
1250
|
-
t.rhs[b] = self.pool.id()
|
|
1258
|
+
t.rhs[b] = self.pool.id()
|
|
1251
1259
|
|
|
1252
1260
|
# a new at-most-b constraint
|
|
1253
1261
|
amb = [[-t.rhs[b]] * (rhs - b) + t.lits, rhs]
|