NuCS 4.4.4__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.
- nucs-4.4.4/LICENSE.md +21 -0
- nucs-4.4.4/NuCS.egg-info/PKG-INFO +152 -0
- nucs-4.4.4/NuCS.egg-info/SOURCES.txt +150 -0
- nucs-4.4.4/NuCS.egg-info/dependency_links.txt +1 -0
- nucs-4.4.4/NuCS.egg-info/requires.txt +3 -0
- nucs-4.4.4/NuCS.egg-info/top_level.txt +6 -0
- nucs-4.4.4/PKG-INFO +152 -0
- nucs-4.4.4/README.md +125 -0
- nucs-4.4.4/docs/source/conf.py +54 -0
- nucs-4.4.4/nucs/__init__.py +0 -0
- nucs-4.4.4/nucs/constants.py +127 -0
- nucs-4.4.4/nucs/examples/__init__.py +0 -0
- nucs-4.4.4/nucs/examples/alpha/__init__.py +0 -0
- nucs-4.4.4/nucs/examples/alpha/__main__.py +37 -0
- nucs-4.4.4/nucs/examples/alpha/alpha_problem.py +104 -0
- nucs-4.4.4/nucs/examples/bibd/__init__.py +0 -0
- nucs-4.4.4/nucs/examples/bibd/__main__.py +39 -0
- nucs-4.4.4/nucs/examples/bibd/bibd_problem.py +75 -0
- nucs-4.4.4/nucs/examples/donald/__init__.py +0 -0
- nucs-4.4.4/nucs/examples/donald/__main__.py +37 -0
- nucs-4.4.4/nucs/examples/donald/donald_problem.py +61 -0
- nucs-4.4.4/nucs/examples/golomb/__init__.py +0 -0
- nucs-4.4.4/nucs/examples/golomb/__main__.py +52 -0
- nucs-4.4.4/nucs/examples/golomb/golomb_problem.py +189 -0
- nucs-4.4.4/nucs/examples/knapsack/__init__.py +0 -0
- nucs-4.4.4/nucs/examples/knapsack/__main__.py +42 -0
- nucs-4.4.4/nucs/examples/knapsack/knapsack_problem.py +35 -0
- nucs-4.4.4/nucs/examples/magic_sequence/__init__.py +0 -0
- nucs-4.4.4/nucs/examples/magic_sequence/__main__.py +39 -0
- nucs-4.4.4/nucs/examples/magic_sequence/magic_sequence_problem.py +34 -0
- nucs-4.4.4/nucs/examples/magic_square/__init__.py +0 -0
- nucs-4.4.4/nucs/examples/magic_square/__main__.py +38 -0
- nucs-4.4.4/nucs/examples/magic_square/magic_square_problem.py +61 -0
- nucs-4.4.4/nucs/examples/quasigroup/__init__.py +0 -0
- nucs-4.4.4/nucs/examples/quasigroup/__main__.py +44 -0
- nucs-4.4.4/nucs/examples/quasigroup/quasigroup_problem.py +116 -0
- nucs-4.4.4/nucs/examples/queens/__init__.py +0 -0
- nucs-4.4.4/nucs/examples/queens/__main__.py +58 -0
- nucs-4.4.4/nucs/examples/queens/queens_problem.py +43 -0
- nucs-4.4.4/nucs/examples/schur_lemma/__init__.py +0 -0
- nucs-4.4.4/nucs/examples/schur_lemma/__main__.py +32 -0
- nucs-4.4.4/nucs/examples/schur_lemma/schur_lemma_problem.py +44 -0
- nucs-4.4.4/nucs/examples/sports_tournament_scheduling/__init__.py +0 -0
- nucs-4.4.4/nucs/examples/sports_tournament_scheduling/__main__.py +42 -0
- nucs-4.4.4/nucs/examples/sports_tournament_scheduling/sports_tournament_scheduling_problem.py +117 -0
- nucs-4.4.4/nucs/examples/sudoku/__init__.py +0 -0
- nucs-4.4.4/nucs/examples/sudoku/sudoku_problem.py +35 -0
- nucs-4.4.4/nucs/examples/tsp/__init__.py +0 -0
- nucs-4.4.4/nucs/examples/tsp/__main__.py +71 -0
- nucs-4.4.4/nucs/examples/tsp/total_cost_propagator.py +90 -0
- nucs-4.4.4/nucs/examples/tsp/tsp_instances.py +72 -0
- nucs-4.4.4/nucs/examples/tsp/tsp_problem.py +47 -0
- nucs-4.4.4/nucs/examples/tsp/tsp_var_heuristic.py +52 -0
- nucs-4.4.4/nucs/heuristics/__init__.py +0 -0
- nucs-4.4.4/nucs/heuristics/first_not_instantiated_var_heuristic.py +35 -0
- nucs-4.4.4/nucs/heuristics/greatest_domain_var_heuristic.py +40 -0
- nucs-4.4.4/nucs/heuristics/heuristics.py +60 -0
- nucs-4.4.4/nucs/heuristics/max_regret_var_heuristic.py +57 -0
- nucs-4.4.4/nucs/heuristics/max_value_dom_heuristic.py +58 -0
- nucs-4.4.4/nucs/heuristics/mid_value_dom_heuristic.py +47 -0
- nucs-4.4.4/nucs/heuristics/min_cost_dom_heuristic.py +52 -0
- nucs-4.4.4/nucs/heuristics/min_value_dom_heuristic.py +58 -0
- nucs-4.4.4/nucs/heuristics/smallest_domain_var_heuristic.py +42 -0
- nucs-4.4.4/nucs/heuristics/split_high_dom_heuristic.py +58 -0
- nucs-4.4.4/nucs/heuristics/split_low_dom_heuristic.py +58 -0
- nucs-4.4.4/nucs/heuristics/value_dom_heuristic.py +78 -0
- nucs-4.4.4/nucs/numba_helper.py +38 -0
- nucs-4.4.4/nucs/numpy_helper.py +32 -0
- nucs-4.4.4/nucs/problems/__init__.py +0 -0
- nucs-4.4.4/nucs/problems/circuit_problem.py +36 -0
- nucs-4.4.4/nucs/problems/latin_square_problem.py +103 -0
- nucs-4.4.4/nucs/problems/permutation_problem.py +34 -0
- nucs-4.4.4/nucs/problems/problem.py +196 -0
- nucs-4.4.4/nucs/propagators/__init__.py +0 -0
- nucs-4.4.4/nucs/propagators/affine_eq_propagator.py +69 -0
- nucs-4.4.4/nucs/propagators/affine_geq_propagator.py +83 -0
- nucs-4.4.4/nucs/propagators/affine_leq_propagator.py +83 -0
- nucs-4.4.4/nucs/propagators/alldifferent_propagator.py +219 -0
- nucs-4.4.4/nucs/propagators/and_propagator.py +67 -0
- nucs-4.4.4/nucs/propagators/count_eq_propagator.py +74 -0
- nucs-4.4.4/nucs/propagators/dummy_propagator.py +46 -0
- nucs-4.4.4/nucs/propagators/element_iv_propagator.py +81 -0
- nucs-4.4.4/nucs/propagators/element_lic_propagator.py +70 -0
- nucs-4.4.4/nucs/propagators/element_liv_propagator.py +84 -0
- nucs-4.4.4/nucs/propagators/exactly_eq_propagator.py +73 -0
- nucs-4.4.4/nucs/propagators/exactly_true_propagator.py +70 -0
- nucs-4.4.4/nucs/propagators/gcc_propagator.py +456 -0
- nucs-4.4.4/nucs/propagators/lexicographic_leq_propagator.py +159 -0
- nucs-4.4.4/nucs/propagators/max_eq_propagator.py +63 -0
- nucs-4.4.4/nucs/propagators/max_leq_propagator.py +69 -0
- nucs-4.4.4/nucs/propagators/min_eq_propagator.py +63 -0
- nucs-4.4.4/nucs/propagators/min_geq_propagator.py +69 -0
- nucs-4.4.4/nucs/propagators/no_sub_cycle_propagator.py +81 -0
- nucs-4.4.4/nucs/propagators/permutation_aux_propagator.py +65 -0
- nucs-4.4.4/nucs/propagators/propagators.py +175 -0
- nucs-4.4.4/nucs/propagators/relation_propagator.py +63 -0
- nucs-4.4.4/nucs/propagators/scc_propagator.py +75 -0
- nucs-4.4.4/nucs/solvers/__init__.py +0 -0
- nucs-4.4.4/nucs/solvers/backtrack_solver.py +602 -0
- nucs-4.4.4/nucs/solvers/bound_consistency_algorithm.py +136 -0
- nucs-4.4.4/nucs/solvers/choice_points.py +133 -0
- nucs-4.4.4/nucs/solvers/consistency_algorithms.py +32 -0
- nucs-4.4.4/nucs/solvers/multiprocessing_solver.py +132 -0
- nucs-4.4.4/nucs/solvers/shaving_consistency_algorithm.py +213 -0
- nucs-4.4.4/nucs/solvers/solver.py +121 -0
- nucs-4.4.4/pyproject.toml +46 -0
- nucs-4.4.4/setup.cfg +4 -0
- nucs-4.4.4/tests/__init__.py +0 -0
- nucs-4.4.4/tests/examples/test_alpha.py +54 -0
- nucs-4.4.4/tests/examples/test_bibd.py +28 -0
- nucs-4.4.4/tests/examples/test_donald.py +27 -0
- nucs-4.4.4/tests/examples/test_golomb.py +35 -0
- nucs-4.4.4/tests/examples/test_knapsack.py +30 -0
- nucs-4.4.4/tests/examples/test_latin_square.py +51 -0
- nucs-4.4.4/tests/examples/test_magic_sequence.py +35 -0
- nucs-4.4.4/tests/examples/test_magic_square.py +36 -0
- nucs-4.4.4/tests/examples/test_quasigroup.py +62 -0
- nucs-4.4.4/tests/examples/test_queens.py +37 -0
- nucs-4.4.4/tests/examples/test_schur_lemma.py +48 -0
- nucs-4.4.4/tests/examples/test_sports_tournament_scheduling.py +107 -0
- nucs-4.4.4/tests/examples/test_sudokus.py +54 -0
- nucs-4.4.4/tests/examples/test_tsp.py +57 -0
- nucs-4.4.4/tests/heuristics/__init__.py +0 -0
- nucs-4.4.4/tests/heuristics/test_max_value_dom_heuristic.py +24 -0
- nucs-4.4.4/tests/heuristics/test_mid_value_dom_heuristic.py +24 -0
- nucs-4.4.4/tests/heuristics/test_min_value_dom_heuristic.py +24 -0
- nucs-4.4.4/tests/problems/__init__.py +0 -0
- nucs-4.4.4/tests/problems/test_circuit_problem.py +36 -0
- nucs-4.4.4/tests/problems/test_permutation_problem.py +35 -0
- nucs-4.4.4/tests/problems/test_problem.py +40 -0
- nucs-4.4.4/tests/propagators/__init__.py +0 -0
- nucs-4.4.4/tests/propagators/test_affine_eq.py +58 -0
- nucs-4.4.4/tests/propagators/test_affine_geq.py +41 -0
- nucs-4.4.4/tests/propagators/test_affine_leq.py +41 -0
- nucs-4.4.4/tests/propagators/test_alldifferent.py +58 -0
- nucs-4.4.4/tests/propagators/test_count_eq.py +54 -0
- nucs-4.4.4/tests/propagators/test_element_iv.py +36 -0
- nucs-4.4.4/tests/propagators/test_element_lic.py +36 -0
- nucs-4.4.4/tests/propagators/test_element_liv.py +42 -0
- nucs-4.4.4/tests/propagators/test_exactly_eq.py +42 -0
- nucs-4.4.4/tests/propagators/test_gcc.py +54 -0
- nucs-4.4.4/tests/propagators/test_lexicographic_leq.py +85 -0
- nucs-4.4.4/tests/propagators/test_max_eq.py +46 -0
- nucs-4.4.4/tests/propagators/test_max_leq.py +47 -0
- nucs-4.4.4/tests/propagators/test_min_eq.py +46 -0
- nucs-4.4.4/tests/propagators/test_min_geq.py +47 -0
- nucs-4.4.4/tests/propagators/test_no_sub_cycle.py +32 -0
- nucs-4.4.4/tests/propagators/test_relation.py +53 -0
- nucs-4.4.4/tests/propagators/test_scc.py +32 -0
- nucs-4.4.4/tests/solvers/__init__.py +0 -0
- nucs-4.4.4/tests/solvers/test_backtrack_solver.py +106 -0
- nucs-4.4.4/tests/solvers/test_multiprocessing_solver.py +65 -0
nucs-4.4.4/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
## Copyright (c) 2024 Yan Georget
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: NuCS
|
|
3
|
+
Version: 4.4.4
|
|
4
|
+
Summary: A Numpy and Numba based Python library for solving Constraint Satisfaction Problems over finite domains
|
|
5
|
+
Author-email: Yan Georget <yan.georget@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/yangeorget/nucs
|
|
7
|
+
Project-URL: Issues, https://github.com/yangeorget/nucs/issues
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE.md
|
|
24
|
+
Requires-Dist: numba==0.60.0
|
|
25
|
+
Requires-Dist: numpy<2.1
|
|
26
|
+
Requires-Dist: rich
|
|
27
|
+
|
|
28
|
+

|
|
29
|
+
|
|
30
|
+
|
|
31
|
+

|
|
32
|
+

|
|
33
|
+
|
|
34
|
+

|
|
35
|
+

|
|
36
|
+
|
|
37
|
+

|
|
38
|
+

|
|
39
|
+

|
|
40
|
+
|
|
41
|
+
## TLDR
|
|
42
|
+
NuCS is a Python library for solving Constraint Satisfaction and Optimization Problems.
|
|
43
|
+
Because it is 100% written in Python,
|
|
44
|
+
NuCS is easy to install and allows to model complex problems in a few lines of code.
|
|
45
|
+
The NuCS solver is also very fast because it is powered by [Numpy](https://numpy.org/) and [Numba](https://numba.pydata.org/).
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
```bash
|
|
49
|
+
pip install nucs
|
|
50
|
+
```
|
|
51
|
+
## Documentation
|
|
52
|
+
Check out [NUCS documentation](https://nucs.readthedocs.io/).
|
|
53
|
+
|
|
54
|
+
## With NuCS, in a few seconds you can ...
|
|
55
|
+
### Find all 14200 solutions to the [12-queens problem](https://www.csplib.org/Problems/prob054/)
|
|
56
|
+
```bash
|
|
57
|
+
NUMBA_CACHE_DIR=.numba/cache python -m nucs.examples.queens -n 12 --log_level=INFO
|
|
58
|
+
```
|
|
59
|
+
```bash
|
|
60
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.solver - Problem has 3 propagators
|
|
61
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.solver - Problem has 12 variables
|
|
62
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses variable heuristic 0
|
|
63
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses domain heuristic 0
|
|
64
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses consistency algorithm 0
|
|
65
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.backtrack_solver - Choice points stack has a maximal height of 128
|
|
66
|
+
2024-11-12 17:24:49,200 - INFO - nucs.solvers.multiprocessing_solver - MultiprocessingSolver has 1 processors
|
|
67
|
+
{
|
|
68
|
+
'ALG_BC_NB': 262011,
|
|
69
|
+
'ALG_BC_WITH_SHAVING_NB': 0,
|
|
70
|
+
'ALG_SHAVING_NB': 0,
|
|
71
|
+
'ALG_SHAVING_CHANGE_NB': 0,
|
|
72
|
+
'ALG_SHAVING_NO_CHANGE_NB': 0,
|
|
73
|
+
'PROPAGATOR_ENTAILMENT_NB': 0,
|
|
74
|
+
'PROPAGATOR_FILTER_NB': 2269980,
|
|
75
|
+
'PROPAGATOR_FILTER_NO_CHANGE_NB': 990450,
|
|
76
|
+
'PROPAGATOR_INCONSISTENCY_NB': 116806,
|
|
77
|
+
'SOLVER_BACKTRACK_NB': 131005,
|
|
78
|
+
'SOLVER_CHOICE_NB': 131005,
|
|
79
|
+
'SOLVER_CHOICE_DEPTH': 10,
|
|
80
|
+
'SOLVER_SOLUTION_NB': 14200
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Compute the 92 solutions to the [BIBD(8,14,7,4,3) problem](https://www.csplib.org/Problems/prob028/)
|
|
85
|
+
```bash
|
|
86
|
+
NUMBA_CACHE_DIR=.numba/cache python -m nucs.examples.bibd -v 8 -b 14 -r 7 -k 4 -l 3 --symmetry_breaking --log_level=INFO
|
|
87
|
+
```
|
|
88
|
+
```bash
|
|
89
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.solver - Problem has 462 propagators
|
|
90
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.solver - Problem has 504 variables
|
|
91
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses variable heuristic 0
|
|
92
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses domain heuristic 1
|
|
93
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses consistency algorithm 0
|
|
94
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.backtrack_solver - Choice points stack has a maximal height of 128
|
|
95
|
+
{
|
|
96
|
+
'ALG_BC_NB': 1425,
|
|
97
|
+
'ALG_BC_WITH_SHAVING_NB': 0,
|
|
98
|
+
'ALG_SHAVING_NB': 0,
|
|
99
|
+
'ALG_SHAVING_CHANGE_NB': 0,
|
|
100
|
+
'ALG_SHAVING_NO_CHANGE_NB': 0,
|
|
101
|
+
'PROPAGATOR_ENTAILMENT_NB': 4711,
|
|
102
|
+
'PROPAGATOR_FILTER_NB': 104392,
|
|
103
|
+
'PROPAGATOR_FILTER_NO_CHANGE_NB': 73792,
|
|
104
|
+
'PROPAGATOR_INCONSISTENCY_NB': 621,
|
|
105
|
+
'SOLVER_BACKTRACK_NB': 712,
|
|
106
|
+
'SOLVER_CHOICE_NB': 712,
|
|
107
|
+
'SOLVER_CHOICE_DEPTH': 19,
|
|
108
|
+
'SOLVER_SOLUTION_NB': 92
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Demonstrate that the optimal [10-marks Golomb ruler](https://www.csplib.org/Problems/prob006/) length is 55
|
|
113
|
+
```bash
|
|
114
|
+
NUMBA_CACHE_DIR=.numba/cache python -m nucs.examples.golomb -n 10 --symmetry_breaking --log_level=INFO
|
|
115
|
+
```
|
|
116
|
+
```bash
|
|
117
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.solver - Problem has 82 propagators
|
|
118
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.solver - Problem has 45 variables
|
|
119
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses variable heuristic 0
|
|
120
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses domain heuristic 0
|
|
121
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses consistency algorithm 2
|
|
122
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.backtrack_solver - Choice points stack has a maximal height of 128
|
|
123
|
+
2024-11-12 17:27:45,172 - INFO - nucs.solvers.backtrack_solver - Minimizing variable 8
|
|
124
|
+
2024-11-12 17:27:45,644 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 80
|
|
125
|
+
2024-11-12 17:27:45,677 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 75
|
|
126
|
+
2024-11-12 17:27:45,677 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 73
|
|
127
|
+
2024-11-12 17:27:45,678 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 72
|
|
128
|
+
2024-11-12 17:27:45,679 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 70
|
|
129
|
+
2024-11-12 17:27:45,682 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 68
|
|
130
|
+
2024-11-12 17:27:45,687 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 66
|
|
131
|
+
2024-11-12 17:27:45,693 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 62
|
|
132
|
+
2024-11-12 17:27:45,717 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 60
|
|
133
|
+
2024-11-12 17:27:45,977 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 55
|
|
134
|
+
{
|
|
135
|
+
'ALG_BC_NB': 22652,
|
|
136
|
+
'ALG_BC_WITH_SHAVING_NB': 0,
|
|
137
|
+
'ALG_SHAVING_NB': 0,
|
|
138
|
+
'ALG_SHAVING_CHANGE_NB': 0,
|
|
139
|
+
'ALG_SHAVING_NO_CHANGE_NB': 0,
|
|
140
|
+
'PROPAGATOR_ENTAILMENT_NB': 107911,
|
|
141
|
+
'PROPAGATOR_FILTER_NB': 2813035,
|
|
142
|
+
'PROPAGATOR_FILTER_NO_CHANGE_NB': 1745836,
|
|
143
|
+
'PROPAGATOR_INCONSISTENCY_NB': 11289,
|
|
144
|
+
'SOLVER_BACKTRACK_NB': 11288,
|
|
145
|
+
'SOLVER_CHOICE_NB': 11353,
|
|
146
|
+
'SOLVER_CHOICE_DEPTH': 9,
|
|
147
|
+
'SOLVER_SOLUTION_NB': 10
|
|
148
|
+
}
|
|
149
|
+
[ 1 6 10 23 26 34 41 53 55]
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
LICENSE.md
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
NuCS.egg-info/PKG-INFO
|
|
5
|
+
NuCS.egg-info/SOURCES.txt
|
|
6
|
+
NuCS.egg-info/dependency_links.txt
|
|
7
|
+
NuCS.egg-info/requires.txt
|
|
8
|
+
NuCS.egg-info/top_level.txt
|
|
9
|
+
docs/source/conf.py
|
|
10
|
+
nucs/__init__.py
|
|
11
|
+
nucs/constants.py
|
|
12
|
+
nucs/numba_helper.py
|
|
13
|
+
nucs/numpy_helper.py
|
|
14
|
+
nucs/examples/__init__.py
|
|
15
|
+
nucs/examples/alpha/__init__.py
|
|
16
|
+
nucs/examples/alpha/__main__.py
|
|
17
|
+
nucs/examples/alpha/alpha_problem.py
|
|
18
|
+
nucs/examples/bibd/__init__.py
|
|
19
|
+
nucs/examples/bibd/__main__.py
|
|
20
|
+
nucs/examples/bibd/bibd_problem.py
|
|
21
|
+
nucs/examples/donald/__init__.py
|
|
22
|
+
nucs/examples/donald/__main__.py
|
|
23
|
+
nucs/examples/donald/donald_problem.py
|
|
24
|
+
nucs/examples/golomb/__init__.py
|
|
25
|
+
nucs/examples/golomb/__main__.py
|
|
26
|
+
nucs/examples/golomb/golomb_problem.py
|
|
27
|
+
nucs/examples/knapsack/__init__.py
|
|
28
|
+
nucs/examples/knapsack/__main__.py
|
|
29
|
+
nucs/examples/knapsack/knapsack_problem.py
|
|
30
|
+
nucs/examples/magic_sequence/__init__.py
|
|
31
|
+
nucs/examples/magic_sequence/__main__.py
|
|
32
|
+
nucs/examples/magic_sequence/magic_sequence_problem.py
|
|
33
|
+
nucs/examples/magic_square/__init__.py
|
|
34
|
+
nucs/examples/magic_square/__main__.py
|
|
35
|
+
nucs/examples/magic_square/magic_square_problem.py
|
|
36
|
+
nucs/examples/quasigroup/__init__.py
|
|
37
|
+
nucs/examples/quasigroup/__main__.py
|
|
38
|
+
nucs/examples/quasigroup/quasigroup_problem.py
|
|
39
|
+
nucs/examples/queens/__init__.py
|
|
40
|
+
nucs/examples/queens/__main__.py
|
|
41
|
+
nucs/examples/queens/queens_problem.py
|
|
42
|
+
nucs/examples/schur_lemma/__init__.py
|
|
43
|
+
nucs/examples/schur_lemma/__main__.py
|
|
44
|
+
nucs/examples/schur_lemma/schur_lemma_problem.py
|
|
45
|
+
nucs/examples/sports_tournament_scheduling/__init__.py
|
|
46
|
+
nucs/examples/sports_tournament_scheduling/__main__.py
|
|
47
|
+
nucs/examples/sports_tournament_scheduling/sports_tournament_scheduling_problem.py
|
|
48
|
+
nucs/examples/sudoku/__init__.py
|
|
49
|
+
nucs/examples/sudoku/sudoku_problem.py
|
|
50
|
+
nucs/examples/tsp/__init__.py
|
|
51
|
+
nucs/examples/tsp/__main__.py
|
|
52
|
+
nucs/examples/tsp/total_cost_propagator.py
|
|
53
|
+
nucs/examples/tsp/tsp_instances.py
|
|
54
|
+
nucs/examples/tsp/tsp_problem.py
|
|
55
|
+
nucs/examples/tsp/tsp_var_heuristic.py
|
|
56
|
+
nucs/heuristics/__init__.py
|
|
57
|
+
nucs/heuristics/first_not_instantiated_var_heuristic.py
|
|
58
|
+
nucs/heuristics/greatest_domain_var_heuristic.py
|
|
59
|
+
nucs/heuristics/heuristics.py
|
|
60
|
+
nucs/heuristics/max_regret_var_heuristic.py
|
|
61
|
+
nucs/heuristics/max_value_dom_heuristic.py
|
|
62
|
+
nucs/heuristics/mid_value_dom_heuristic.py
|
|
63
|
+
nucs/heuristics/min_cost_dom_heuristic.py
|
|
64
|
+
nucs/heuristics/min_value_dom_heuristic.py
|
|
65
|
+
nucs/heuristics/smallest_domain_var_heuristic.py
|
|
66
|
+
nucs/heuristics/split_high_dom_heuristic.py
|
|
67
|
+
nucs/heuristics/split_low_dom_heuristic.py
|
|
68
|
+
nucs/heuristics/value_dom_heuristic.py
|
|
69
|
+
nucs/problems/__init__.py
|
|
70
|
+
nucs/problems/circuit_problem.py
|
|
71
|
+
nucs/problems/latin_square_problem.py
|
|
72
|
+
nucs/problems/permutation_problem.py
|
|
73
|
+
nucs/problems/problem.py
|
|
74
|
+
nucs/propagators/__init__.py
|
|
75
|
+
nucs/propagators/affine_eq_propagator.py
|
|
76
|
+
nucs/propagators/affine_geq_propagator.py
|
|
77
|
+
nucs/propagators/affine_leq_propagator.py
|
|
78
|
+
nucs/propagators/alldifferent_propagator.py
|
|
79
|
+
nucs/propagators/and_propagator.py
|
|
80
|
+
nucs/propagators/count_eq_propagator.py
|
|
81
|
+
nucs/propagators/dummy_propagator.py
|
|
82
|
+
nucs/propagators/element_iv_propagator.py
|
|
83
|
+
nucs/propagators/element_lic_propagator.py
|
|
84
|
+
nucs/propagators/element_liv_propagator.py
|
|
85
|
+
nucs/propagators/exactly_eq_propagator.py
|
|
86
|
+
nucs/propagators/exactly_true_propagator.py
|
|
87
|
+
nucs/propagators/gcc_propagator.py
|
|
88
|
+
nucs/propagators/lexicographic_leq_propagator.py
|
|
89
|
+
nucs/propagators/max_eq_propagator.py
|
|
90
|
+
nucs/propagators/max_leq_propagator.py
|
|
91
|
+
nucs/propagators/min_eq_propagator.py
|
|
92
|
+
nucs/propagators/min_geq_propagator.py
|
|
93
|
+
nucs/propagators/no_sub_cycle_propagator.py
|
|
94
|
+
nucs/propagators/permutation_aux_propagator.py
|
|
95
|
+
nucs/propagators/propagators.py
|
|
96
|
+
nucs/propagators/relation_propagator.py
|
|
97
|
+
nucs/propagators/scc_propagator.py
|
|
98
|
+
nucs/solvers/__init__.py
|
|
99
|
+
nucs/solvers/backtrack_solver.py
|
|
100
|
+
nucs/solvers/bound_consistency_algorithm.py
|
|
101
|
+
nucs/solvers/choice_points.py
|
|
102
|
+
nucs/solvers/consistency_algorithms.py
|
|
103
|
+
nucs/solvers/multiprocessing_solver.py
|
|
104
|
+
nucs/solvers/shaving_consistency_algorithm.py
|
|
105
|
+
nucs/solvers/solver.py
|
|
106
|
+
tests/__init__.py
|
|
107
|
+
tests/examples/test_alpha.py
|
|
108
|
+
tests/examples/test_bibd.py
|
|
109
|
+
tests/examples/test_donald.py
|
|
110
|
+
tests/examples/test_golomb.py
|
|
111
|
+
tests/examples/test_knapsack.py
|
|
112
|
+
tests/examples/test_latin_square.py
|
|
113
|
+
tests/examples/test_magic_sequence.py
|
|
114
|
+
tests/examples/test_magic_square.py
|
|
115
|
+
tests/examples/test_quasigroup.py
|
|
116
|
+
tests/examples/test_queens.py
|
|
117
|
+
tests/examples/test_schur_lemma.py
|
|
118
|
+
tests/examples/test_sports_tournament_scheduling.py
|
|
119
|
+
tests/examples/test_sudokus.py
|
|
120
|
+
tests/examples/test_tsp.py
|
|
121
|
+
tests/heuristics/__init__.py
|
|
122
|
+
tests/heuristics/test_max_value_dom_heuristic.py
|
|
123
|
+
tests/heuristics/test_mid_value_dom_heuristic.py
|
|
124
|
+
tests/heuristics/test_min_value_dom_heuristic.py
|
|
125
|
+
tests/problems/__init__.py
|
|
126
|
+
tests/problems/test_circuit_problem.py
|
|
127
|
+
tests/problems/test_permutation_problem.py
|
|
128
|
+
tests/problems/test_problem.py
|
|
129
|
+
tests/propagators/__init__.py
|
|
130
|
+
tests/propagators/test_affine_eq.py
|
|
131
|
+
tests/propagators/test_affine_geq.py
|
|
132
|
+
tests/propagators/test_affine_leq.py
|
|
133
|
+
tests/propagators/test_alldifferent.py
|
|
134
|
+
tests/propagators/test_count_eq.py
|
|
135
|
+
tests/propagators/test_element_iv.py
|
|
136
|
+
tests/propagators/test_element_lic.py
|
|
137
|
+
tests/propagators/test_element_liv.py
|
|
138
|
+
tests/propagators/test_exactly_eq.py
|
|
139
|
+
tests/propagators/test_gcc.py
|
|
140
|
+
tests/propagators/test_lexicographic_leq.py
|
|
141
|
+
tests/propagators/test_max_eq.py
|
|
142
|
+
tests/propagators/test_max_leq.py
|
|
143
|
+
tests/propagators/test_min_eq.py
|
|
144
|
+
tests/propagators/test_min_geq.py
|
|
145
|
+
tests/propagators/test_no_sub_cycle.py
|
|
146
|
+
tests/propagators/test_relation.py
|
|
147
|
+
tests/propagators/test_scc.py
|
|
148
|
+
tests/solvers/__init__.py
|
|
149
|
+
tests/solvers/test_backtrack_solver.py
|
|
150
|
+
tests/solvers/test_multiprocessing_solver.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
nucs-4.4.4/PKG-INFO
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: NuCS
|
|
3
|
+
Version: 4.4.4
|
|
4
|
+
Summary: A Numpy and Numba based Python library for solving Constraint Satisfaction Problems over finite domains
|
|
5
|
+
Author-email: Yan Georget <yan.georget@gmail.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/yangeorget/nucs
|
|
7
|
+
Project-URL: Issues, https://github.com/yangeorget/nucs/issues
|
|
8
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
9
|
+
Classifier: Intended Audience :: Developers
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Requires-Python: >=3.9
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE.md
|
|
24
|
+
Requires-Dist: numba==0.60.0
|
|
25
|
+
Requires-Dist: numpy<2.1
|
|
26
|
+
Requires-Dist: rich
|
|
27
|
+
|
|
28
|
+

|
|
29
|
+
|
|
30
|
+
|
|
31
|
+

|
|
32
|
+

|
|
33
|
+
|
|
34
|
+

|
|
35
|
+

|
|
36
|
+
|
|
37
|
+

|
|
38
|
+

|
|
39
|
+

|
|
40
|
+
|
|
41
|
+
## TLDR
|
|
42
|
+
NuCS is a Python library for solving Constraint Satisfaction and Optimization Problems.
|
|
43
|
+
Because it is 100% written in Python,
|
|
44
|
+
NuCS is easy to install and allows to model complex problems in a few lines of code.
|
|
45
|
+
The NuCS solver is also very fast because it is powered by [Numpy](https://numpy.org/) and [Numba](https://numba.pydata.org/).
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
```bash
|
|
49
|
+
pip install nucs
|
|
50
|
+
```
|
|
51
|
+
## Documentation
|
|
52
|
+
Check out [NUCS documentation](https://nucs.readthedocs.io/).
|
|
53
|
+
|
|
54
|
+
## With NuCS, in a few seconds you can ...
|
|
55
|
+
### Find all 14200 solutions to the [12-queens problem](https://www.csplib.org/Problems/prob054/)
|
|
56
|
+
```bash
|
|
57
|
+
NUMBA_CACHE_DIR=.numba/cache python -m nucs.examples.queens -n 12 --log_level=INFO
|
|
58
|
+
```
|
|
59
|
+
```bash
|
|
60
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.solver - Problem has 3 propagators
|
|
61
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.solver - Problem has 12 variables
|
|
62
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses variable heuristic 0
|
|
63
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses domain heuristic 0
|
|
64
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses consistency algorithm 0
|
|
65
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.backtrack_solver - Choice points stack has a maximal height of 128
|
|
66
|
+
2024-11-12 17:24:49,200 - INFO - nucs.solvers.multiprocessing_solver - MultiprocessingSolver has 1 processors
|
|
67
|
+
{
|
|
68
|
+
'ALG_BC_NB': 262011,
|
|
69
|
+
'ALG_BC_WITH_SHAVING_NB': 0,
|
|
70
|
+
'ALG_SHAVING_NB': 0,
|
|
71
|
+
'ALG_SHAVING_CHANGE_NB': 0,
|
|
72
|
+
'ALG_SHAVING_NO_CHANGE_NB': 0,
|
|
73
|
+
'PROPAGATOR_ENTAILMENT_NB': 0,
|
|
74
|
+
'PROPAGATOR_FILTER_NB': 2269980,
|
|
75
|
+
'PROPAGATOR_FILTER_NO_CHANGE_NB': 990450,
|
|
76
|
+
'PROPAGATOR_INCONSISTENCY_NB': 116806,
|
|
77
|
+
'SOLVER_BACKTRACK_NB': 131005,
|
|
78
|
+
'SOLVER_CHOICE_NB': 131005,
|
|
79
|
+
'SOLVER_CHOICE_DEPTH': 10,
|
|
80
|
+
'SOLVER_SOLUTION_NB': 14200
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Compute the 92 solutions to the [BIBD(8,14,7,4,3) problem](https://www.csplib.org/Problems/prob028/)
|
|
85
|
+
```bash
|
|
86
|
+
NUMBA_CACHE_DIR=.numba/cache python -m nucs.examples.bibd -v 8 -b 14 -r 7 -k 4 -l 3 --symmetry_breaking --log_level=INFO
|
|
87
|
+
```
|
|
88
|
+
```bash
|
|
89
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.solver - Problem has 462 propagators
|
|
90
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.solver - Problem has 504 variables
|
|
91
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses variable heuristic 0
|
|
92
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses domain heuristic 1
|
|
93
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses consistency algorithm 0
|
|
94
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.backtrack_solver - Choice points stack has a maximal height of 128
|
|
95
|
+
{
|
|
96
|
+
'ALG_BC_NB': 1425,
|
|
97
|
+
'ALG_BC_WITH_SHAVING_NB': 0,
|
|
98
|
+
'ALG_SHAVING_NB': 0,
|
|
99
|
+
'ALG_SHAVING_CHANGE_NB': 0,
|
|
100
|
+
'ALG_SHAVING_NO_CHANGE_NB': 0,
|
|
101
|
+
'PROPAGATOR_ENTAILMENT_NB': 4711,
|
|
102
|
+
'PROPAGATOR_FILTER_NB': 104392,
|
|
103
|
+
'PROPAGATOR_FILTER_NO_CHANGE_NB': 73792,
|
|
104
|
+
'PROPAGATOR_INCONSISTENCY_NB': 621,
|
|
105
|
+
'SOLVER_BACKTRACK_NB': 712,
|
|
106
|
+
'SOLVER_CHOICE_NB': 712,
|
|
107
|
+
'SOLVER_CHOICE_DEPTH': 19,
|
|
108
|
+
'SOLVER_SOLUTION_NB': 92
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Demonstrate that the optimal [10-marks Golomb ruler](https://www.csplib.org/Problems/prob006/) length is 55
|
|
113
|
+
```bash
|
|
114
|
+
NUMBA_CACHE_DIR=.numba/cache python -m nucs.examples.golomb -n 10 --symmetry_breaking --log_level=INFO
|
|
115
|
+
```
|
|
116
|
+
```bash
|
|
117
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.solver - Problem has 82 propagators
|
|
118
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.solver - Problem has 45 variables
|
|
119
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses variable heuristic 0
|
|
120
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses domain heuristic 0
|
|
121
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses consistency algorithm 2
|
|
122
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.backtrack_solver - Choice points stack has a maximal height of 128
|
|
123
|
+
2024-11-12 17:27:45,172 - INFO - nucs.solvers.backtrack_solver - Minimizing variable 8
|
|
124
|
+
2024-11-12 17:27:45,644 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 80
|
|
125
|
+
2024-11-12 17:27:45,677 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 75
|
|
126
|
+
2024-11-12 17:27:45,677 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 73
|
|
127
|
+
2024-11-12 17:27:45,678 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 72
|
|
128
|
+
2024-11-12 17:27:45,679 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 70
|
|
129
|
+
2024-11-12 17:27:45,682 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 68
|
|
130
|
+
2024-11-12 17:27:45,687 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 66
|
|
131
|
+
2024-11-12 17:27:45,693 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 62
|
|
132
|
+
2024-11-12 17:27:45,717 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 60
|
|
133
|
+
2024-11-12 17:27:45,977 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 55
|
|
134
|
+
{
|
|
135
|
+
'ALG_BC_NB': 22652,
|
|
136
|
+
'ALG_BC_WITH_SHAVING_NB': 0,
|
|
137
|
+
'ALG_SHAVING_NB': 0,
|
|
138
|
+
'ALG_SHAVING_CHANGE_NB': 0,
|
|
139
|
+
'ALG_SHAVING_NO_CHANGE_NB': 0,
|
|
140
|
+
'PROPAGATOR_ENTAILMENT_NB': 107911,
|
|
141
|
+
'PROPAGATOR_FILTER_NB': 2813035,
|
|
142
|
+
'PROPAGATOR_FILTER_NO_CHANGE_NB': 1745836,
|
|
143
|
+
'PROPAGATOR_INCONSISTENCY_NB': 11289,
|
|
144
|
+
'SOLVER_BACKTRACK_NB': 11288,
|
|
145
|
+
'SOLVER_CHOICE_NB': 11353,
|
|
146
|
+
'SOLVER_CHOICE_DEPTH': 9,
|
|
147
|
+
'SOLVER_SOLUTION_NB': 10
|
|
148
|
+
}
|
|
149
|
+
[ 1 6 10 23 26 34 41 53 55]
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
|
nucs-4.4.4/README.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+
|
|
14
|
+
## TLDR
|
|
15
|
+
NuCS is a Python library for solving Constraint Satisfaction and Optimization Problems.
|
|
16
|
+
Because it is 100% written in Python,
|
|
17
|
+
NuCS is easy to install and allows to model complex problems in a few lines of code.
|
|
18
|
+
The NuCS solver is also very fast because it is powered by [Numpy](https://numpy.org/) and [Numba](https://numba.pydata.org/).
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
```bash
|
|
22
|
+
pip install nucs
|
|
23
|
+
```
|
|
24
|
+
## Documentation
|
|
25
|
+
Check out [NUCS documentation](https://nucs.readthedocs.io/).
|
|
26
|
+
|
|
27
|
+
## With NuCS, in a few seconds you can ...
|
|
28
|
+
### Find all 14200 solutions to the [12-queens problem](https://www.csplib.org/Problems/prob054/)
|
|
29
|
+
```bash
|
|
30
|
+
NUMBA_CACHE_DIR=.numba/cache python -m nucs.examples.queens -n 12 --log_level=INFO
|
|
31
|
+
```
|
|
32
|
+
```bash
|
|
33
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.solver - Problem has 3 propagators
|
|
34
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.solver - Problem has 12 variables
|
|
35
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses variable heuristic 0
|
|
36
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses domain heuristic 0
|
|
37
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses consistency algorithm 0
|
|
38
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.backtrack_solver - Choice points stack has a maximal height of 128
|
|
39
|
+
2024-11-12 17:24:49,200 - INFO - nucs.solvers.multiprocessing_solver - MultiprocessingSolver has 1 processors
|
|
40
|
+
{
|
|
41
|
+
'ALG_BC_NB': 262011,
|
|
42
|
+
'ALG_BC_WITH_SHAVING_NB': 0,
|
|
43
|
+
'ALG_SHAVING_NB': 0,
|
|
44
|
+
'ALG_SHAVING_CHANGE_NB': 0,
|
|
45
|
+
'ALG_SHAVING_NO_CHANGE_NB': 0,
|
|
46
|
+
'PROPAGATOR_ENTAILMENT_NB': 0,
|
|
47
|
+
'PROPAGATOR_FILTER_NB': 2269980,
|
|
48
|
+
'PROPAGATOR_FILTER_NO_CHANGE_NB': 990450,
|
|
49
|
+
'PROPAGATOR_INCONSISTENCY_NB': 116806,
|
|
50
|
+
'SOLVER_BACKTRACK_NB': 131005,
|
|
51
|
+
'SOLVER_CHOICE_NB': 131005,
|
|
52
|
+
'SOLVER_CHOICE_DEPTH': 10,
|
|
53
|
+
'SOLVER_SOLUTION_NB': 14200
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Compute the 92 solutions to the [BIBD(8,14,7,4,3) problem](https://www.csplib.org/Problems/prob028/)
|
|
58
|
+
```bash
|
|
59
|
+
NUMBA_CACHE_DIR=.numba/cache python -m nucs.examples.bibd -v 8 -b 14 -r 7 -k 4 -l 3 --symmetry_breaking --log_level=INFO
|
|
60
|
+
```
|
|
61
|
+
```bash
|
|
62
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.solver - Problem has 462 propagators
|
|
63
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.solver - Problem has 504 variables
|
|
64
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses variable heuristic 0
|
|
65
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses domain heuristic 1
|
|
66
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses consistency algorithm 0
|
|
67
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.backtrack_solver - Choice points stack has a maximal height of 128
|
|
68
|
+
{
|
|
69
|
+
'ALG_BC_NB': 1425,
|
|
70
|
+
'ALG_BC_WITH_SHAVING_NB': 0,
|
|
71
|
+
'ALG_SHAVING_NB': 0,
|
|
72
|
+
'ALG_SHAVING_CHANGE_NB': 0,
|
|
73
|
+
'ALG_SHAVING_NO_CHANGE_NB': 0,
|
|
74
|
+
'PROPAGATOR_ENTAILMENT_NB': 4711,
|
|
75
|
+
'PROPAGATOR_FILTER_NB': 104392,
|
|
76
|
+
'PROPAGATOR_FILTER_NO_CHANGE_NB': 73792,
|
|
77
|
+
'PROPAGATOR_INCONSISTENCY_NB': 621,
|
|
78
|
+
'SOLVER_BACKTRACK_NB': 712,
|
|
79
|
+
'SOLVER_CHOICE_NB': 712,
|
|
80
|
+
'SOLVER_CHOICE_DEPTH': 19,
|
|
81
|
+
'SOLVER_SOLUTION_NB': 92
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Demonstrate that the optimal [10-marks Golomb ruler](https://www.csplib.org/Problems/prob006/) length is 55
|
|
86
|
+
```bash
|
|
87
|
+
NUMBA_CACHE_DIR=.numba/cache python -m nucs.examples.golomb -n 10 --symmetry_breaking --log_level=INFO
|
|
88
|
+
```
|
|
89
|
+
```bash
|
|
90
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.solver - Problem has 82 propagators
|
|
91
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.solver - Problem has 45 variables
|
|
92
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses variable heuristic 0
|
|
93
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses domain heuristic 0
|
|
94
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses consistency algorithm 2
|
|
95
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.backtrack_solver - Choice points stack has a maximal height of 128
|
|
96
|
+
2024-11-12 17:27:45,172 - INFO - nucs.solvers.backtrack_solver - Minimizing variable 8
|
|
97
|
+
2024-11-12 17:27:45,644 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 80
|
|
98
|
+
2024-11-12 17:27:45,677 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 75
|
|
99
|
+
2024-11-12 17:27:45,677 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 73
|
|
100
|
+
2024-11-12 17:27:45,678 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 72
|
|
101
|
+
2024-11-12 17:27:45,679 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 70
|
|
102
|
+
2024-11-12 17:27:45,682 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 68
|
|
103
|
+
2024-11-12 17:27:45,687 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 66
|
|
104
|
+
2024-11-12 17:27:45,693 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 62
|
|
105
|
+
2024-11-12 17:27:45,717 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 60
|
|
106
|
+
2024-11-12 17:27:45,977 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 55
|
|
107
|
+
{
|
|
108
|
+
'ALG_BC_NB': 22652,
|
|
109
|
+
'ALG_BC_WITH_SHAVING_NB': 0,
|
|
110
|
+
'ALG_SHAVING_NB': 0,
|
|
111
|
+
'ALG_SHAVING_CHANGE_NB': 0,
|
|
112
|
+
'ALG_SHAVING_NO_CHANGE_NB': 0,
|
|
113
|
+
'PROPAGATOR_ENTAILMENT_NB': 107911,
|
|
114
|
+
'PROPAGATOR_FILTER_NB': 2813035,
|
|
115
|
+
'PROPAGATOR_FILTER_NO_CHANGE_NB': 1745836,
|
|
116
|
+
'PROPAGATOR_INCONSISTENCY_NB': 11289,
|
|
117
|
+
'SOLVER_BACKTRACK_NB': 11288,
|
|
118
|
+
'SOLVER_CHOICE_NB': 11353,
|
|
119
|
+
'SOLVER_CHOICE_DEPTH': 9,
|
|
120
|
+
'SOLVER_SOLUTION_NB': 10
|
|
121
|
+
}
|
|
122
|
+
[ 1 6 10 23 26 34 41 53 55]
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Configuration file for the Sphinx documentation builder.
|
|
2
|
+
|
|
3
|
+
# -- Project information
|
|
4
|
+
|
|
5
|
+
project = 'NuCS'
|
|
6
|
+
copyright = '2024, Yan Georget'
|
|
7
|
+
author = 'Yan Georget'
|
|
8
|
+
|
|
9
|
+
release = '4.4.4'
|
|
10
|
+
version = '4.4.4'
|
|
11
|
+
|
|
12
|
+
# -- General configuration
|
|
13
|
+
|
|
14
|
+
tls_verify = False
|
|
15
|
+
|
|
16
|
+
extensions = [
|
|
17
|
+
'sphinx.ext.linkcode',
|
|
18
|
+
'sphinx.ext.duration',
|
|
19
|
+
'sphinx.ext.doctest',
|
|
20
|
+
'sphinx.ext.autodoc',
|
|
21
|
+
'sphinx.ext.autosummary',
|
|
22
|
+
'sphinx.ext.intersphinx',
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
intersphinx_mapping = {
|
|
26
|
+
'python': ('https://docs.python.org/3/', None),
|
|
27
|
+
'sphinx': ('https://www.sphinx-doc.org/en/master/', None),
|
|
28
|
+
}
|
|
29
|
+
intersphinx_disabled_domains = ['std']
|
|
30
|
+
|
|
31
|
+
templates_path = ['_templates']
|
|
32
|
+
|
|
33
|
+
# -- Options for HTML output
|
|
34
|
+
|
|
35
|
+
html_theme = 'sphinx_rtd_theme'
|
|
36
|
+
|
|
37
|
+
html_context = {
|
|
38
|
+
"display_github": True, # Integrate GitHub
|
|
39
|
+
"github_user": "yangeorget", # Username
|
|
40
|
+
"github_repo": "nucs", # Repo name
|
|
41
|
+
"github_version": "main", # Version
|
|
42
|
+
"conf_py_path": "/docs/source/", # Path in the checkout to the docs root
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
# -- Options for EPUB output
|
|
46
|
+
epub_show_urls = 'footnote'
|
|
47
|
+
|
|
48
|
+
def linkcode_resolve(domain, info):
|
|
49
|
+
if domain != 'py':
|
|
50
|
+
return None
|
|
51
|
+
if info['module']:
|
|
52
|
+
filename = info['module'].replace('.', '/')
|
|
53
|
+
return f"https://github.com/yangeorget/nucs/tree/main/{filename}.py"
|
|
54
|
+
return None
|
|
File without changes
|