python-constraint2 2.3.1__tar.gz → 2.3.2__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_constraint2-2.3.1 → python_constraint2-2.3.2}/PKG-INFO +12 -15
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/README.rst +9 -12
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/constraint/parser.c +2213 -1580
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/constraint/parser.py +9 -0
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/constraint/problem.c +553 -475
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/constraint/problem.py +3 -1
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/pyproject.toml +3 -3
- python_constraint2-2.3.2/tests/test_doctests.py +65 -0
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/tests/test_parser.py +26 -7
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/tests/test_solvers.py +37 -3
- python_constraint2-2.3.1/tests/test_doctests.py +0 -10
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/LICENSE +0 -0
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/constraint/__init__.py +0 -0
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/constraint/constraints.c +0 -0
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/constraint/constraints.py +0 -0
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/constraint/domain.c +0 -0
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/constraint/domain.py +0 -0
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/constraint/solvers.c +0 -0
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/constraint/solvers.py +0 -0
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/cythonize_build.py +0 -0
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/tests/__init__.py +0 -0
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/tests/benchmarks.py +0 -0
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/tests/setup_teardown.py +0 -0
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/tests/test_compilation.py +0 -0
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/tests/test_constraint.py +0 -0
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/tests/test_problem.py +0 -0
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/tests/test_some_not_in_set.py +0 -0
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/tests/test_toml_file.py +0 -0
- {python_constraint2-2.3.1 → python_constraint2-2.3.2}/tests/test_util_benchmark.py +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: python-constraint2
|
|
3
|
-
Version: 2.3.
|
|
3
|
+
Version: 2.3.2
|
|
4
4
|
Summary: python-constraint is a module for efficiently solving CSPs (Constraint Solving Problems) over finite domains.
|
|
5
5
|
License: BSD-2-Clause
|
|
6
6
|
Keywords: CSP,constraint solving problems,problem solver,SMT,satisfiability modulo theory,SAT
|
|
7
|
-
Author:
|
|
8
|
-
Author-email:
|
|
7
|
+
Author: Floris-Jan Willemsen
|
|
8
|
+
Author-email: fjwillemsen97@gmail.com
|
|
9
9
|
Maintainer: Floris-Jan Willemsen
|
|
10
10
|
Maintainer-email: fjwillemsen97@gmail.com
|
|
11
11
|
Requires-Python: >= 3.9
|
|
@@ -74,11 +74,11 @@ This interactive Python session demonstrates basic operations:
|
|
|
74
74
|
>>> problem = Problem()
|
|
75
75
|
>>> problem.addVariable("a", [1,2,3])
|
|
76
76
|
>>> problem.addVariable("b", [4,5,6])
|
|
77
|
-
>>> problem.getSolutions()
|
|
77
|
+
>>> problem.getSolutions() # doctest: +NORMALIZE_WHITESPACE
|
|
78
78
|
[{'a': 3, 'b': 6}, {'a': 3, 'b': 5}, {'a': 3, 'b': 4},
|
|
79
79
|
{'a': 2, 'b': 6}, {'a': 2, 'b': 5}, {'a': 2, 'b': 4},
|
|
80
80
|
{'a': 1, 'b': 6}, {'a': 1, 'b': 5}, {'a': 1, 'b': 4}]
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
>>> problem.addConstraint("a*2 == b") # string constraints are preferable over the black-box problem.addConstraint(lambda a, b: a*2 == b, ("a", "b"))
|
|
83
83
|
>>> problem.getSolutions()
|
|
84
84
|
[{'a': 3, 'b': 6}, {'a': 2, 'b': 4}]
|
|
@@ -86,7 +86,7 @@ This interactive Python session demonstrates basic operations:
|
|
|
86
86
|
>>> problem = Problem()
|
|
87
87
|
>>> problem.addVariables(["a", "b"], [1, 2, 3])
|
|
88
88
|
>>> problem.addConstraint(AllDifferentConstraint())
|
|
89
|
-
>>> problem.getSolutions()
|
|
89
|
+
>>> problem.getSolutions() # doctest: +NORMALIZE_WHITESPACE
|
|
90
90
|
[{'a': 3, 'b': 2}, {'a': 3, 'b': 1}, {'a': 2, 'b': 3},
|
|
91
91
|
{'a': 2, 'b': 1}, {'a': 1, 'b': 2}, {'a': 1, 'b': 3}]
|
|
92
92
|
|
|
@@ -105,11 +105,9 @@ The following example solves the classical Eight Rooks problem:
|
|
|
105
105
|
>>> for col1 in cols:
|
|
106
106
|
... for col2 in cols:
|
|
107
107
|
... if col1 < col2:
|
|
108
|
-
... problem.addConstraint(lambda row1, row2: row1 != row2,
|
|
109
|
-
... (col1, col2))
|
|
108
|
+
... problem.addConstraint(lambda row1, row2: row1 != row2, (col1, col2))
|
|
110
109
|
>>> solutions = problem.getSolutions()
|
|
111
|
-
>>> solutions
|
|
112
|
-
>>> solutions
|
|
110
|
+
>>> solutions # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
|
|
113
111
|
[{0: 7, 1: 6, 2: 5, 3: 4, 4: 3, 5: 2, 6: 1, 7: 0},
|
|
114
112
|
{0: 7, 1: 6, 2: 5, 3: 4, 4: 3, 5: 2, 6: 0, 7: 1},
|
|
115
113
|
{0: 7, 1: 6, 2: 5, 3: 4, 4: 3, 5: 1, 6: 2, 7: 0},
|
|
@@ -136,12 +134,10 @@ This example solves a 4x4 magic square:
|
|
|
136
134
|
>>> problem.addConstraint(ExactSumConstraint(34), [0, 5, 10, 15])
|
|
137
135
|
>>> problem.addConstraint(ExactSumConstraint(34), [3, 6, 9, 12])
|
|
138
136
|
>>> for row in range(4):
|
|
139
|
-
... problem.addConstraint(ExactSumConstraint(34),
|
|
140
|
-
[row * 4 + i for i in range(4)])
|
|
137
|
+
... problem.addConstraint(ExactSumConstraint(34), [row * 4 + i for i in range(4)])
|
|
141
138
|
>>> for col in range(4):
|
|
142
|
-
... problem.addConstraint(ExactSumConstraint(34),
|
|
143
|
-
|
|
144
|
-
>>> solutions = problem.getSolutions()
|
|
139
|
+
... problem.addConstraint(ExactSumConstraint(34), [col + 4 * i for i in range(4)])
|
|
140
|
+
>>> solutions = problem.getSolutions() # doctest: +SKIP
|
|
145
141
|
|
|
146
142
|
Features
|
|
147
143
|
--------
|
|
@@ -214,6 +210,7 @@ For an overview of recent changes, visit the `Changelog <https://github.com/pyth
|
|
|
214
210
|
|
|
215
211
|
Planned development:
|
|
216
212
|
|
|
213
|
+
- Support constant modifiers on parsed (variable) constraints instead defaulting to `FunctionConstraint`, e.g. :code:`problem.addConstraint("a+2 == b")` or :code:`problem.addConstraint("x / y == 100")`
|
|
217
214
|
- Rewrite hotspots in C / Pyx instead of pure python mode
|
|
218
215
|
- Improvements to make the ParallelSolver competitive (experiments reveal the freethreading mode to be promising)
|
|
219
216
|
- Versioned documentation
|
|
@@ -41,11 +41,11 @@ This interactive Python session demonstrates basic operations:
|
|
|
41
41
|
>>> problem = Problem()
|
|
42
42
|
>>> problem.addVariable("a", [1,2,3])
|
|
43
43
|
>>> problem.addVariable("b", [4,5,6])
|
|
44
|
-
>>> problem.getSolutions()
|
|
44
|
+
>>> problem.getSolutions() # doctest: +NORMALIZE_WHITESPACE
|
|
45
45
|
[{'a': 3, 'b': 6}, {'a': 3, 'b': 5}, {'a': 3, 'b': 4},
|
|
46
46
|
{'a': 2, 'b': 6}, {'a': 2, 'b': 5}, {'a': 2, 'b': 4},
|
|
47
47
|
{'a': 1, 'b': 6}, {'a': 1, 'b': 5}, {'a': 1, 'b': 4}]
|
|
48
|
-
|
|
48
|
+
|
|
49
49
|
>>> problem.addConstraint("a*2 == b") # string constraints are preferable over the black-box problem.addConstraint(lambda a, b: a*2 == b, ("a", "b"))
|
|
50
50
|
>>> problem.getSolutions()
|
|
51
51
|
[{'a': 3, 'b': 6}, {'a': 2, 'b': 4}]
|
|
@@ -53,7 +53,7 @@ This interactive Python session demonstrates basic operations:
|
|
|
53
53
|
>>> problem = Problem()
|
|
54
54
|
>>> problem.addVariables(["a", "b"], [1, 2, 3])
|
|
55
55
|
>>> problem.addConstraint(AllDifferentConstraint())
|
|
56
|
-
>>> problem.getSolutions()
|
|
56
|
+
>>> problem.getSolutions() # doctest: +NORMALIZE_WHITESPACE
|
|
57
57
|
[{'a': 3, 'b': 2}, {'a': 3, 'b': 1}, {'a': 2, 'b': 3},
|
|
58
58
|
{'a': 2, 'b': 1}, {'a': 1, 'b': 2}, {'a': 1, 'b': 3}]
|
|
59
59
|
|
|
@@ -72,11 +72,9 @@ The following example solves the classical Eight Rooks problem:
|
|
|
72
72
|
>>> for col1 in cols:
|
|
73
73
|
... for col2 in cols:
|
|
74
74
|
... if col1 < col2:
|
|
75
|
-
... problem.addConstraint(lambda row1, row2: row1 != row2,
|
|
76
|
-
... (col1, col2))
|
|
75
|
+
... problem.addConstraint(lambda row1, row2: row1 != row2, (col1, col2))
|
|
77
76
|
>>> solutions = problem.getSolutions()
|
|
78
|
-
>>> solutions
|
|
79
|
-
>>> solutions
|
|
77
|
+
>>> solutions # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
|
|
80
78
|
[{0: 7, 1: 6, 2: 5, 3: 4, 4: 3, 5: 2, 6: 1, 7: 0},
|
|
81
79
|
{0: 7, 1: 6, 2: 5, 3: 4, 4: 3, 5: 2, 6: 0, 7: 1},
|
|
82
80
|
{0: 7, 1: 6, 2: 5, 3: 4, 4: 3, 5: 1, 6: 2, 7: 0},
|
|
@@ -103,12 +101,10 @@ This example solves a 4x4 magic square:
|
|
|
103
101
|
>>> problem.addConstraint(ExactSumConstraint(34), [0, 5, 10, 15])
|
|
104
102
|
>>> problem.addConstraint(ExactSumConstraint(34), [3, 6, 9, 12])
|
|
105
103
|
>>> for row in range(4):
|
|
106
|
-
... problem.addConstraint(ExactSumConstraint(34),
|
|
107
|
-
[row * 4 + i for i in range(4)])
|
|
104
|
+
... problem.addConstraint(ExactSumConstraint(34), [row * 4 + i for i in range(4)])
|
|
108
105
|
>>> for col in range(4):
|
|
109
|
-
... problem.addConstraint(ExactSumConstraint(34),
|
|
110
|
-
|
|
111
|
-
>>> solutions = problem.getSolutions()
|
|
106
|
+
... problem.addConstraint(ExactSumConstraint(34), [col + 4 * i for i in range(4)])
|
|
107
|
+
>>> solutions = problem.getSolutions() # doctest: +SKIP
|
|
112
108
|
|
|
113
109
|
Features
|
|
114
110
|
--------
|
|
@@ -181,6 +177,7 @@ For an overview of recent changes, visit the `Changelog <https://github.com/pyth
|
|
|
181
177
|
|
|
182
178
|
Planned development:
|
|
183
179
|
|
|
180
|
+
- Support constant modifiers on parsed (variable) constraints instead defaulting to `FunctionConstraint`, e.g. :code:`problem.addConstraint("a+2 == b")` or :code:`problem.addConstraint("x / y == 100")`
|
|
184
181
|
- Rewrite hotspots in C / Pyx instead of pure python mode
|
|
185
182
|
- Improvements to make the ParallelSolver competitive (experiments reveal the freethreading mode to be promising)
|
|
186
183
|
- Versioned documentation
|