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.
Files changed (125) hide show
  1. {python_sat-1.9.dev14/python_sat.egg-info → python_sat-1.9.dev16}/PKG-INFO +1 -1
  2. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/hitman.py +2 -7
  3. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/lsu.py +1 -1
  4. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/rc2.py +25 -17
  5. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/pysat/__init__.py +1 -1
  6. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/pysat/solvers.py +1004 -58
  7. {python_sat-1.9.dev14 → python_sat-1.9.dev16/python_sat.egg-info}/PKG-INFO +1 -1
  8. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/python_sat.egg-info/SOURCES.txt +6 -0
  9. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/setup.py +4 -1
  10. python_sat-1.9.dev16/solvers/ergo.tar.gz +0 -0
  11. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/cadical153.patch +3 -3
  12. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/cadical195.patch +3 -3
  13. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/cadical300.patch +3 -3
  14. python_sat-1.9.dev16/solvers/patches/ergo.patch +646 -0
  15. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/prepare.py +17 -2
  16. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/pysolvers.cc +1609 -183
  17. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_accum_stats.py +5 -0
  18. python_sat-1.9.dev16/tests/test_boolengine.py +97 -0
  19. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_cnf.py +5 -0
  20. python_sat-1.9.dev16/tests/test_empty_clause.py +32 -0
  21. python_sat-1.9.dev16/tests/test_hitman.py +31 -0
  22. python_sat-1.9.dev16/tests/test_lsu.py +15 -0
  23. python_sat-1.9.dev16/tests/test_proof.py +40 -0
  24. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_propagate.py +50 -4
  25. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_unique_model.py +5 -0
  26. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_warmstart.py +2 -1
  27. python_sat-1.9.dev14/tests/test_boolengine.py +0 -34
  28. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/LICENSE.txt +0 -0
  29. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/MANIFEST.in +0 -0
  30. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/README.rst +0 -0
  31. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/allies/__init__.py +0 -0
  32. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/allies/approxmc.py +0 -0
  33. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/allies/unigen.py +0 -0
  34. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/bitwise.hh +0 -0
  35. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/card.hh +0 -0
  36. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/clset.hh +0 -0
  37. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/common.hh +0 -0
  38. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/itot.hh +0 -0
  39. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/ladder.hh +0 -0
  40. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/mto.hh +0 -0
  41. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/pairwise.hh +0 -0
  42. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/ptypes.hh +0 -0
  43. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/pycard.cc +0 -0
  44. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/seqcounter.hh +0 -0
  45. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/sortcard.hh +0 -0
  46. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/cardenc/utils.hh +0 -0
  47. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/__init__.py +0 -0
  48. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/bbscan.py +0 -0
  49. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/bica.py +0 -0
  50. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/fm.py +0 -0
  51. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/genhard.py +0 -0
  52. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/lbx.py +0 -0
  53. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/mcsls.py +0 -0
  54. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/models.py +0 -0
  55. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/musx.py +0 -0
  56. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/optux.py +0 -0
  57. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/primer.py +0 -0
  58. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/examples/usage.py +0 -0
  59. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/formula/pf_parse.cc +0 -0
  60. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/formula/pf_plus.cc +0 -0
  61. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/formula/pf_plus.hh +0 -0
  62. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/formula/pf_py.hh +0 -0
  63. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/formula/pf_scan.hh +0 -0
  64. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/formula/pf_weight.cc +0 -0
  65. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/formula/pf_weight.hh +0 -0
  66. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/formula/pyformula.cc +0 -0
  67. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/formula/pyformula.hh +0 -0
  68. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/pysat/_fileio.py +0 -0
  69. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/pysat/_utils.py +0 -0
  70. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/pysat/card.py +0 -0
  71. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/pysat/engines.py +0 -0
  72. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/pysat/formula.py +0 -0
  73. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/pysat/integer.py +0 -0
  74. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/pysat/pb.py +0 -0
  75. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/pysat/process.py +0 -0
  76. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/python_sat.egg-info/dependency_links.txt +0 -0
  77. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/python_sat.egg-info/requires.txt +0 -0
  78. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/python_sat.egg-info/top_level.txt +0 -0
  79. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/requirements.txt +0 -0
  80. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/setup.cfg +0 -0
  81. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/cadical103.tar.gz +0 -0
  82. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/cadical153.tar.gz +0 -0
  83. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/cadical195.tar.gz +0 -0
  84. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/cadical300.tar.gz +0 -0
  85. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/glucose30.tar.gz +0 -0
  86. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/glucose41.tar.gz +0 -0
  87. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/glucose421.tar.gz +0 -0
  88. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/lingeling.tar.gz +0 -0
  89. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/maplechrono.zip +0 -0
  90. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/maplecm.zip +0 -0
  91. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/maplesat.zip +0 -0
  92. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/mergesat3.tar.gz +0 -0
  93. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/minicard.tar.gz +0 -0
  94. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/minisat22.tar.gz +0 -0
  95. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/minisatgh.zip +0 -0
  96. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/cadical103.patch +0 -0
  97. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/glucose30.patch +0 -0
  98. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/glucose41.patch +0 -0
  99. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/glucose421.patch +0 -0
  100. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/gluecard30.patch +0 -0
  101. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/gluecard41.patch +0 -0
  102. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/kissat404.patch +0 -0
  103. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/lingeling.patch +0 -0
  104. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/maplechrono.patch +0 -0
  105. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/maplecm.patch +0 -0
  106. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/maplesat.patch +0 -0
  107. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/mergesat3.patch +0 -0
  108. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/minicard.patch +0 -0
  109. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/minisat22.patch +0 -0
  110. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/minisatep.patch +0 -0
  111. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/solvers/patches/minisatgh.patch +0 -0
  112. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_atmost.py +0 -0
  113. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_atmost1.py +0 -0
  114. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_atmostk.py +0 -0
  115. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_clausification.py +0 -0
  116. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_empty_extclause.py +0 -0
  117. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_encode_pb_conditional.py +0 -0
  118. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_equals1.py +0 -0
  119. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_formula_parsing.py +0 -0
  120. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_formula_unique.py +0 -0
  121. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_idpool.py +0 -0
  122. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_integer.py +0 -0
  123. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_oom.py +0 -0
  124. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_process.py +0 -0
  125. {python_sat-1.9.dev14 → python_sat-1.9.dev16}/tests/test_unique_mus.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-sat
3
- Version: 1.9.dev14
3
+ Version: 1.9.dev16
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
@@ -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 = filter(lambda vid: abs(vid) not in self.oracle.vmap.e2i, clause)
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 = filter(lambda vid: abs(vid) not in self.oracle.vmap.e2i, clause[0])
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 not weight:
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 selv not in self.wght:
468
- # record selector and its weight
469
- self.sels.append(selv)
470
- self.wght[selv] = weight
471
- self.smap[selv] = len(self.sels) - 1
472
- else:
473
- # selector is not new; increment its weight
474
- self.wght[selv] += weight
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
- self.sall.append(selv)
477
- self.sels_set.add(selv)
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.sels + self.sums,
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
- if not t.rhs[b]:
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]
@@ -10,7 +10,7 @@
10
10
 
11
11
  # current version
12
12
  #==============================================================================
13
- VERSION = (1, 9, 'dev', 14)
13
+ VERSION = (1, 9, 'dev', 16)
14
14
 
15
15
 
16
16
  # PEP440 Format