python-sat 1.9.dev18__cp313-cp313-win_amd64.whl → 1.9.dev19__cp313-cp313-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.

Files changed (24) hide show
  1. pycard.cp313-win_amd64.pyd +0 -0
  2. pyformula.cp313-win_amd64.pyd +0 -0
  3. pysat/__init__.py +1 -1
  4. pysat/card.py +243 -3
  5. pysolvers.cp313-win_amd64.pyd +0 -0
  6. {python_sat-1.9.dev18.dist-info → python_sat-1.9.dev19.dist-info}/METADATA +1 -1
  7. {python_sat-1.9.dev18.dist-info → python_sat-1.9.dev19.dist-info}/RECORD +24 -24
  8. {python_sat-1.9.dev18.data → python_sat-1.9.dev19.data}/scripts/approxmc.py +0 -0
  9. {python_sat-1.9.dev18.data → python_sat-1.9.dev19.data}/scripts/bbscan.py +0 -0
  10. {python_sat-1.9.dev18.data → python_sat-1.9.dev19.data}/scripts/bica.py +0 -0
  11. {python_sat-1.9.dev18.data → python_sat-1.9.dev19.data}/scripts/fm.py +0 -0
  12. {python_sat-1.9.dev18.data → python_sat-1.9.dev19.data}/scripts/genhard.py +0 -0
  13. {python_sat-1.9.dev18.data → python_sat-1.9.dev19.data}/scripts/lbx.py +0 -0
  14. {python_sat-1.9.dev18.data → python_sat-1.9.dev19.data}/scripts/lsu.py +0 -0
  15. {python_sat-1.9.dev18.data → python_sat-1.9.dev19.data}/scripts/mcsls.py +0 -0
  16. {python_sat-1.9.dev18.data → python_sat-1.9.dev19.data}/scripts/models.py +0 -0
  17. {python_sat-1.9.dev18.data → python_sat-1.9.dev19.data}/scripts/musx.py +0 -0
  18. {python_sat-1.9.dev18.data → python_sat-1.9.dev19.data}/scripts/optux.py +0 -0
  19. {python_sat-1.9.dev18.data → python_sat-1.9.dev19.data}/scripts/primer.py +0 -0
  20. {python_sat-1.9.dev18.data → python_sat-1.9.dev19.data}/scripts/rc2.py +0 -0
  21. {python_sat-1.9.dev18.data → python_sat-1.9.dev19.data}/scripts/unigen.py +0 -0
  22. {python_sat-1.9.dev18.dist-info → python_sat-1.9.dev19.dist-info}/WHEEL +0 -0
  23. {python_sat-1.9.dev18.dist-info → python_sat-1.9.dev19.dist-info}/licenses/LICENSE.txt +0 -0
  24. {python_sat-1.9.dev18.dist-info → python_sat-1.9.dev19.dist-info}/top_level.txt +0 -0
Binary file
Binary file
pysat/__init__.py CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  # current version
12
12
  #==============================================================================
13
- VERSION = (1, 9, 'dev', 18)
13
+ VERSION = (1, 9, 'dev', 19)
14
14
 
15
15
 
16
16
  # PEP440 Format
pysat/card.py CHANGED
@@ -19,6 +19,7 @@
19
19
  EncType
20
20
  CardEnc
21
21
  ITotalizer
22
+ ISeqCounter
22
23
 
23
24
  ==================
24
25
  Module description
@@ -79,9 +80,10 @@
79
80
  Additionally, to the standard cardinality encodings that are basically
80
81
  "static" CNF formulas, the module is designed to able to construct
81
82
  *incremental* cardinality encodings, i.e. those that can be incrementally
82
- extended at a later stage. At this point only the *iterative totalizer*
83
- [11]_ encoding is supported. Iterative totalizer can be accessed with the
84
- use of the :class:`.ITotalizer` class.
83
+ extended at a later stage. The *iterative totalizer* [11]_ is available
84
+ through :class:`.ITotalizer`. An iterative sequential counter is available
85
+ through :class:`.ISeqCounter`; it supports increasing the bound and
86
+ obtaining constraint literals for prefixes of the input.
85
87
 
86
88
  .. [11] Ruben Martins, Saurabh Joshi, Vasco M. Manquinho, Inês Lynce.
87
89
  *Incremental Cardinality Constraints for MaxSAT*. CP 2014. pp. 531-548
@@ -782,3 +784,241 @@ class ITotalizer(object):
782
784
 
783
785
  # memory deallocation should not be done for the merged tree
784
786
  another._merged = True
787
+
788
+
789
+ # Incremental sequential counter taken almost verbatim from jesselooney/pysat,
790
+ # commit 8d3449e8d1845cc9e0f682a45beb888bbac8be0c
791
+ #==============================================================================
792
+ class ISeqCounter(object):
793
+ """
794
+ This class implements an iterative sequential-counter encoding. Like
795
+ :class:`ITotalizer`, this class is not abstract and its objects once
796
+ created can be reused several times: the bound can be increased, and
797
+ the internal state can be read out as standalone constraint literals
798
+ via :meth:`get_constraint`. The interface intentionally mirrors
799
+ :class:`ITotalizer`'s.
800
+
801
+ The constructor of the class object takes 3 default arguments.
802
+
803
+ :param lits: a list of literals to sum.
804
+ :param ubound: the largest potential bound to use.
805
+ :param top_id: top variable identifier used so far.
806
+
807
+ :type lits: iterable(int)
808
+ :type ubound: int
809
+ :type top_id: integer or None
810
+
811
+ The encoding of the current counter can be accessed with the use of
812
+ :class:`.CNF` variable stored as ``self.cnf``. Potential bounds **are
813
+ not** imposed by default but can be added as unit clauses in the final
814
+ CNF formula. The bounds are stored in the list of Boolean variables as
815
+ ``self.rhs``. A concrete bound :math:`k` can be enforced by
816
+ considering a unit clause ``-self.rhs[k]``. **Note** that
817
+ ``-self.rhs[0]`` enforces all literals of the sum to be *false*.
818
+
819
+ An :class:`ISeqCounter` object should be deleted if it is not needed
820
+ anymore.
821
+
822
+ Possible usage of the class is shown below:
823
+
824
+ .. code-block:: python
825
+
826
+ >>> from pysat.card import ISeqCounter
827
+ >>> t = ISeqCounter(lits=[1, 2, 3], ubound=1)
828
+ >>> print(t.cnf.clauses)
829
+ [[-1, 4], [-4, 5], [-2, 5], [-5, 6], [-3, 6], [-4, -2, 7], [-7, 8], [-5, -3, 8]]
830
+ >>> print(t.rhs)
831
+ [6, 8]
832
+ >>> t.delete()
833
+ """
834
+
835
+ def __init__(self, lits=[], ubound=1, top_id=None):
836
+ """
837
+ Constructor.
838
+ """
839
+
840
+ # internal totalizer object
841
+ self.tobj = None
842
+
843
+ # its characteristics
844
+ self.lits = []
845
+ self.ubound = 0
846
+ self.top_id = 0
847
+
848
+ # encoding result
849
+ self.cnf = CNF() # CNF formula encoding the totalizer object
850
+ self.rhs = [] # upper bounds on the number of literals (rhs)
851
+
852
+ # number of new clauses
853
+ self.nof_new = 0
854
+
855
+ # this newly created totalizer object is not yet merged in any other
856
+ self._merged = False
857
+
858
+ if lits:
859
+ self.new(lits=lits, ubound=ubound, top_id=top_id)
860
+
861
+ def new(self, lits=[], ubound=1, top_id=None):
862
+ """
863
+ The actual constructor of :class:`ISeqCounter`. Invoked from
864
+ ``self.__init__()``. Creates an object of :class:`ISeqCounter`
865
+ given a list of literals in the sum, the largest potential bound
866
+ to consider, as well as the top variable identifier used so far.
867
+ See the description of :class:`ISeqCounter` for details.
868
+
869
+ """
870
+
871
+ self.lits = list(lits)
872
+ self.top_id = max(map(lambda x: abs(x), self.lits + [top_id if top_id != None else 0]))
873
+
874
+ # Fail if the bound is negative. ITotalizer does not do this, but I am
875
+ # not sure how or if it is handling it lower down the chain, so I will
876
+ # stop it here.
877
+ if ubound < 0:
878
+ raise ValueError("`ubound` cannot be negative")
879
+ else:
880
+ self.ubound = ubound
881
+
882
+ # creating the object
883
+ self.tobj, clauses, self.rhs, self.top_id = pycard.iseq_new(self.lits,
884
+ self.ubound, self.top_id, int(MainThread.check()))
885
+
886
+ # saving the result
887
+ self.cnf.clauses = clauses
888
+ self.cnf.nv = self.top_id
889
+
890
+ # for convenience, keeping the number of clauses
891
+ self.nof_new = len(clauses)
892
+
893
+ def delete(self):
894
+ """
895
+ Destroys a previously constructed :class:`ISeqCounter` object.
896
+ Internal variables ``self.cnf`` and ``self.rhs`` get cleaned.
897
+ """
898
+
899
+ if self.tobj:
900
+ if not self._merged:
901
+ pycard.iseq_del(self.tobj)
902
+
903
+ # otherwise, this totalizer object is merged into a larger one
904
+ # therefore, this memory should be freed in its destructor
905
+
906
+ self.tobj = None
907
+
908
+ self.lits = []
909
+ self.ubound = 0
910
+ self.top_id = 0
911
+
912
+ self.cnf = CNF()
913
+ self.rhs = []
914
+
915
+ self.nof_new = 0
916
+
917
+ def __enter__(self):
918
+ """
919
+ 'with' constructor.
920
+ """
921
+
922
+ return self
923
+
924
+ def __exit__(self, exc_type, exc_value, traceback):
925
+ """
926
+ 'with' destructor.
927
+ """
928
+
929
+ self.delete()
930
+
931
+ def __del__(self):
932
+ """
933
+ Destructor.
934
+ """
935
+
936
+ self.delete()
937
+
938
+ def increase(self, ubound=1, top_id=None):
939
+ """
940
+ Increases a potential upper bound that can be imposed on the
941
+ literals in the sum of an existing :class:`ISeqCounter` object to
942
+ a new value.
943
+
944
+ :param ubound: a new upper bound.
945
+ :param top_id: a new top variable identifier.
946
+
947
+ :type ubound: int
948
+ :type top_id: integer or None
949
+
950
+ The top identifier ``top_id`` applied only if it is greater than
951
+ the one used in ``self``.
952
+
953
+ This method creates additional clauses encoding the existing
954
+ counter up to the new upper bound given and appends them to
955
+ the list of clauses of :class:`.CNF` ``self.cnf``. The number of
956
+ newly created clauses is stored in variable ``self.nof_new``.
957
+
958
+ Also, a list of bounds ``self.rhs`` gets increased and its length
959
+ becomes ``ubound+1``.
960
+
961
+ The method can be used in the following way:
962
+
963
+ .. code-block:: python
964
+
965
+ >>> from pysat.card import ISeqCounter
966
+ >>> t = ISeqCounter(lits=[1, 2, 3], ubound=1)
967
+ >>> print(t.cnf.clauses)
968
+ [[-1, 4], [-4, 5], [-2, 5], [-5, 6], [-3, 6], [-4, -2, 7], [-7, 8], [-5, -3, 8]]
969
+ >>> print(t.rhs)
970
+ [6, 8]
971
+ >>>
972
+ >>> t.increase(ubound=2)
973
+ >>> print(t.cnf.clauses)
974
+ [[-1, 4], [-4, 5], [-2, 5], [-5, 6], [-3, 6], [-4, -2, 7], [-7, 8], [-5, -3, 8], [-7, -3, 9]]
975
+ >>> print(t.cnf.clauses[-t.nof_new:])
976
+ [[-7, -3, 9]]
977
+ >>> print(t.rhs)
978
+ [6, 8, 9]
979
+ >>> t.delete()
980
+ """
981
+
982
+ self.top_id = max(self.top_id, top_id if top_id != None else 0)
983
+
984
+ # do nothing if the bound is set incorrectly
985
+ if ubound <= self.ubound or self.ubound >= len(self.lits):
986
+ self.nof_new = 0
987
+ return
988
+ else:
989
+ self.ubound = ubound
990
+
991
+ # updating the object and adding more variables and clauses
992
+ clauses, self.rhs, self.top_id = pycard.iseq_inc(self.tobj,
993
+ self.ubound, self.top_id, int(MainThread.check()))
994
+
995
+ # saving the result
996
+ self.cnf.clauses.extend(clauses)
997
+ self.cnf.nv = self.top_id
998
+
999
+ # keeping the number of newly added clauses
1000
+ self.nof_new = len(clauses)
1001
+
1002
+ def get_constraint(self, prefix_len, bound):
1003
+ """
1004
+ Get the literal whose negation requires that the sum of the first
1005
+ ``prefix_len`` literals of ``self.lits`` is at most ``bound``.
1006
+ This lets a caller reuse the internal state of a partially-built
1007
+ counter as a standalone constraint, rather than only ever
1008
+ asserting the counter's own top-level bound in ``self.rhs``.
1009
+
1010
+ :param prefix_len: length of the prefix of ``self.lits`` to sum.
1011
+ :param bound: an upper bound already covered by the counter, i.e.
1012
+ ``bound < len(self.rhs)``.
1013
+
1014
+ :type prefix_len: int
1015
+ :type bound: int
1016
+
1017
+ :returns: the requested literal, or ``None`` if ``prefix_len`` and
1018
+ ``bound`` do not satisfy ``0 <= bound < len(self.rhs)`` and
1019
+ ``bound < prefix_len <= len(self.lits)``.
1020
+ :rtype: int or None
1021
+ """
1022
+
1023
+ if 0 <= bound < len(self.rhs) and bound < prefix_len <= len(self.lits):
1024
+ return pycard.iseq_get(self.tobj, prefix_len, bound, int(MainThread.check()))
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-sat
3
- Version: 1.9.dev18
3
+ Version: 1.9.dev19
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
@@ -1,10 +1,10 @@
1
- pycard.cp313-win_amd64.pyd,sha256=PZ50XA6fybcRvw5SPc9j0nJDSNVqB2juDezaMoUVkEM,71680
2
- pyformula.cp313-win_amd64.pyd,sha256=zveu2NsNepVzqxV08-yfzqzkwgNge1bq5-rNFBKrb5E,31232
3
- pysolvers.cp313-win_amd64.pyd,sha256=MIEeH7EN00zm9PaBz4kNWgKvMeR71bpooummkosh_PM,3341824
4
- pysat/__init__.py,sha256=GVL8Ti2mVtexajShuobNXoYUQxcG9MV244bA72LC44M,681
1
+ pycard.cp313-win_amd64.pyd,sha256=TpnGa7pVU8ZfRDyy67ksfOAZyzcHMqCcPsw9xc2gLD4,81408
2
+ pyformula.cp313-win_amd64.pyd,sha256=QIz77z0XSTSH5oWqLQDBKoG2UMTlUMqXtARLQ3MAuqk,31232
3
+ pysolvers.cp313-win_amd64.pyd,sha256=f7sMHAhVZAGqO6FwBS_kWR7sLgQp1sHZsOULvv5jzdY,3341824
4
+ pysat/__init__.py,sha256=pxZqtNyt_wr-BtY5IBN4rWl-Yvv6UECaQmSJ8s7iC0M,681
5
5
  pysat/_fileio.py,sha256=pXRGGAaP7U8r3bpn5ShseCSHROXqi7ygaYe6T6QORto,6700
6
6
  pysat/_utils.py,sha256=4cv40p70FKvjCTKq8GqzS_jlxF74cp_lojTZSim_qJE,1340
7
- pysat/card.py,sha256=j39uYFhgol08nxReT1g7tMEfEdtMmEkQzI_JJ219Uac,29639
7
+ pysat/card.py,sha256=poO6cfZdUwoe78CxecLHWNRwmoHPlbKyGnKQIxWWDrs,38228
8
8
  pysat/engines.py,sha256=yAYA_PzIGr_uRF85M7kL2bipjpLbY7jdfFKTdY-yW8I,46364
9
9
  pysat/formula.py,sha256=qtADpavl5m-pHRDnZ7PDEiosT7TbaCwqY_xpv_--Nlw,215586
10
10
  pysat/integer.py,sha256=_1qPuYuUT8jT0PfbQhHS1ujQBxNyoYRbrEvnD2aIuEQ,97091
@@ -29,22 +29,22 @@ pysat/examples/optux.py,sha256=cZMwxzOxuTzo6TDUvZVVuF3V1tOAlAdZpW6cm6qW1HM,29771
29
29
  pysat/examples/primer.py,sha256=0OeV9R6mWyIr2BKIitkrfgY3q2XE-sV1ZLSiybGRFXw,23375
30
30
  pysat/examples/rc2.py,sha256=dZMslLc2P7PYdH82lekWSaE6dTz8MyDVzj56nwOkYuw,77292
31
31
  pysat/examples/usage.py,sha256=x9luw6pyKAAndlxAeUWFhS4aLSVmD2t_j_5uA9YddHg,2183
32
- python_sat-1.9.dev18.data/scripts/approxmc.py,sha256=h6aMnSpIaYXkTMq-tCSzNWwKb0AG-vTH4vuLWGn5Q4s,13958
33
- python_sat-1.9.dev18.data/scripts/bbscan.py,sha256=xGxklG6Gc_UBaM8QvEJDOtQhEamxAncfsd65E-0JcAc,22696
34
- python_sat-1.9.dev18.data/scripts/bica.py,sha256=659K6gdRBgYeNiLjQc_VnulXhbTHxnUljNYhXx-frwk,28413
35
- python_sat-1.9.dev18.data/scripts/fm.py,sha256=ek1QDsuxiq1zm1PBLbrSXXEE89RP9_DYwVNnyB3eO4s,18650
36
- python_sat-1.9.dev18.data/scripts/genhard.py,sha256=YswufT272W4xTJrSBlOC2ucJx4RK4ntfRv73rASrx30,19520
37
- python_sat-1.9.dev18.data/scripts/lbx.py,sha256=rCQ6zH_DXoVjBrzhZHSDJMfP92-hz2JVwh6e4m44AUc,23874
38
- python_sat-1.9.dev18.data/scripts/lsu.py,sha256=EpXQCu8ZdYoNgi70Uc1b8drOwp1fo82mhGbpjonjIzw,16687
39
- python_sat-1.9.dev18.data/scripts/mcsls.py,sha256=cTJQMIO-4iho412wG0JhvhqXWy81U0RQV8wwOgkri3Q,22690
40
- python_sat-1.9.dev18.data/scripts/models.py,sha256=UmMmklExzyXAIhh-0i038nQb7hTK6CbdV1M6m2GxxSI,5917
41
- python_sat-1.9.dev18.data/scripts/musx.py,sha256=LwK10YuQ8pIf1TJwp0HKp54O0hdk8zBy3TIfGsF1yW0,11277
42
- python_sat-1.9.dev18.data/scripts/optux.py,sha256=9-4ynzXVYq7y67vy-emMbMx_gSlOBMDBX4VWkjSyHgE,30508
43
- python_sat-1.9.dev18.data/scripts/primer.py,sha256=iE9Vy0XyeySIY-7-L_VMwRahsIVCEmm9k04OhLwDvuw,23982
44
- python_sat-1.9.dev18.data/scripts/rc2.py,sha256=YQ3UkYWVd2ge64u-SdqwVzZkHmj0tikYxXZS0O2pXy4,79322
45
- python_sat-1.9.dev18.data/scripts/unigen.py,sha256=e-HC2UxWA8MTN90VslkHX1ZlTPjdhI4etzkn6G8YAX4,17140
46
- python_sat-1.9.dev18.dist-info/licenses/LICENSE.txt,sha256=6QMvEzxqdPXEoiAZUBaZLeLF4hW2S81fjKz_THER0uQ,1109
47
- python_sat-1.9.dev18.dist-info/METADATA,sha256=y415j-u4ZKAjyEiYy8qhEhrBP6T2A5RYZE8HyhGngEc,1854
48
- python_sat-1.9.dev18.dist-info/WHEEL,sha256=fOyJWI5N6P4iPL9_doBC3lf0L4Z-hcIkjNV5ilMSlqY,101
49
- python_sat-1.9.dev18.dist-info/top_level.txt,sha256=0SLg3yVqNpeiqOwFcAo3OxXhqAnflCmb5Fjl6gsl-Do,33
50
- python_sat-1.9.dev18.dist-info/RECORD,,
32
+ python_sat-1.9.dev19.data/scripts/approxmc.py,sha256=h6aMnSpIaYXkTMq-tCSzNWwKb0AG-vTH4vuLWGn5Q4s,13958
33
+ python_sat-1.9.dev19.data/scripts/bbscan.py,sha256=xGxklG6Gc_UBaM8QvEJDOtQhEamxAncfsd65E-0JcAc,22696
34
+ python_sat-1.9.dev19.data/scripts/bica.py,sha256=659K6gdRBgYeNiLjQc_VnulXhbTHxnUljNYhXx-frwk,28413
35
+ python_sat-1.9.dev19.data/scripts/fm.py,sha256=ek1QDsuxiq1zm1PBLbrSXXEE89RP9_DYwVNnyB3eO4s,18650
36
+ python_sat-1.9.dev19.data/scripts/genhard.py,sha256=YswufT272W4xTJrSBlOC2ucJx4RK4ntfRv73rASrx30,19520
37
+ python_sat-1.9.dev19.data/scripts/lbx.py,sha256=rCQ6zH_DXoVjBrzhZHSDJMfP92-hz2JVwh6e4m44AUc,23874
38
+ python_sat-1.9.dev19.data/scripts/lsu.py,sha256=EpXQCu8ZdYoNgi70Uc1b8drOwp1fo82mhGbpjonjIzw,16687
39
+ python_sat-1.9.dev19.data/scripts/mcsls.py,sha256=cTJQMIO-4iho412wG0JhvhqXWy81U0RQV8wwOgkri3Q,22690
40
+ python_sat-1.9.dev19.data/scripts/models.py,sha256=UmMmklExzyXAIhh-0i038nQb7hTK6CbdV1M6m2GxxSI,5917
41
+ python_sat-1.9.dev19.data/scripts/musx.py,sha256=LwK10YuQ8pIf1TJwp0HKp54O0hdk8zBy3TIfGsF1yW0,11277
42
+ python_sat-1.9.dev19.data/scripts/optux.py,sha256=9-4ynzXVYq7y67vy-emMbMx_gSlOBMDBX4VWkjSyHgE,30508
43
+ python_sat-1.9.dev19.data/scripts/primer.py,sha256=iE9Vy0XyeySIY-7-L_VMwRahsIVCEmm9k04OhLwDvuw,23982
44
+ python_sat-1.9.dev19.data/scripts/rc2.py,sha256=YQ3UkYWVd2ge64u-SdqwVzZkHmj0tikYxXZS0O2pXy4,79322
45
+ python_sat-1.9.dev19.data/scripts/unigen.py,sha256=e-HC2UxWA8MTN90VslkHX1ZlTPjdhI4etzkn6G8YAX4,17140
46
+ python_sat-1.9.dev19.dist-info/licenses/LICENSE.txt,sha256=6QMvEzxqdPXEoiAZUBaZLeLF4hW2S81fjKz_THER0uQ,1109
47
+ python_sat-1.9.dev19.dist-info/METADATA,sha256=1eFF2HerF_8vQx0YHOnhVo9-GtwhXnPLML3T4vMpXmk,1854
48
+ python_sat-1.9.dev19.dist-info/WHEEL,sha256=fOyJWI5N6P4iPL9_doBC3lf0L4Z-hcIkjNV5ilMSlqY,101
49
+ python_sat-1.9.dev19.dist-info/top_level.txt,sha256=0SLg3yVqNpeiqOwFcAo3OxXhqAnflCmb5Fjl6gsl-Do,33
50
+ python_sat-1.9.dev19.dist-info/RECORD,,