NUCS 2.1.0__tar.gz → 2.2.0__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-2.2.0/NUCS.egg-info/PKG-INFO +147 -0
- nucs-2.2.0/PKG-INFO +147 -0
- nucs-2.2.0/README.md +125 -0
- {nucs-2.1.0 → nucs-2.2.0}/docs/source/conf.py +2 -2
- {nucs-2.1.0 → nucs-2.2.0}/nucs/constants.py +8 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/alpha/__main__.py +10 -1
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/bibd/__main__.py +3 -1
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/donald/__main__.py +10 -1
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/golomb/__main__.py +3 -1
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/knapsack/__main__.py +10 -1
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/magic_sequence/__main__.py +6 -1
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/magic_square/__main__.py +6 -1
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/quasigroup/__main__.py +6 -1
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/queens/__main__.py +3 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/schur_lemma/__main__.py +3 -1
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/sports_tournament_scheduling/__main__.py +6 -1
- {nucs-2.1.0 → nucs-2.2.0}/nucs/solvers/backtrack_solver.py +24 -9
- {nucs-2.1.0 → nucs-2.2.0}/nucs/solvers/multiprocessing_solver.py +13 -2
- {nucs-2.1.0 → nucs-2.2.0}/nucs/solvers/solver.py +14 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/statistics.py +1 -9
- {nucs-2.1.0 → nucs-2.2.0}/pyproject.toml +1 -1
- nucs-2.1.0/NUCS.egg-info/PKG-INFO +0 -114
- nucs-2.1.0/PKG-INFO +0 -114
- nucs-2.1.0/README.md +0 -92
- {nucs-2.1.0 → nucs-2.2.0}/LICENSE.md +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/NUCS.egg-info/SOURCES.txt +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/NUCS.egg-info/dependency_links.txt +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/NUCS.egg-info/requires.txt +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/NUCS.egg-info/top_level.txt +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/alpha/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/alpha/alpha_problem.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/bibd/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/bibd/bibd_problem.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/donald/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/donald/donald_problem.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/golomb/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/golomb/golomb_problem.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/knapsack/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/knapsack/knapsack_problem.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/magic_sequence/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/magic_sequence/magic_sequence_problem.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/magic_square/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/magic_square/magic_square_problem.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/quasigroup/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/quasigroup/quasigroup_problem.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/queens/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/queens/queens_problem.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/schur_lemma/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/schur_lemma/schur_lemma_problem.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/sports_tournament_scheduling/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/sports_tournament_scheduling/sports_tournament_scheduling_problem.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/sudoku/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/examples/sudoku/sudoku_problem.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/numba_helper.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/numpy_helper.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/problems/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/problems/latin_square_problem.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/problems/problem.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/propagators/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/propagators/affine_eq_propagator.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/propagators/affine_geq_propagator.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/propagators/affine_leq_propagator.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/propagators/alldifferent_propagator.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/propagators/and_propagator.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/propagators/count_eq_propagator.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/propagators/dummy_propagator.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/propagators/element_lic_propagator.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/propagators/element_liv_propagator.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/propagators/exactly_eq_propagator.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/propagators/exactly_true_propagator.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/propagators/gcc_propagator.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/propagators/lexicographic_leq_propagator.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/propagators/max_eq_propagator.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/propagators/max_leq_propagator.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/propagators/min_eq_propagator.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/propagators/min_geq_propagator.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/propagators/propagators.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/propagators/relation_propagator.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/solvers/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/solvers/bound_consistency_algorithm.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/solvers/choice_points.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/solvers/consistency_algorithms.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/solvers/heuristics.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/nucs/solvers/shaving_consistency_algorithm.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/setup.cfg +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/examples/test_alpha.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/examples/test_bibd.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/examples/test_donald.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/examples/test_golomb.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/examples/test_knapsack.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/examples/test_latin_square.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/examples/test_magic_sequence.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/examples/test_magic_square.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/examples/test_quasigroup.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/examples/test_queens.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/examples/test_schur_lemma.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/examples/test_sports_tournament_scheduling.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/examples/test_sudokus.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/problems/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/problems/test_problem.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/propagators/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/propagators/test_affine_eq.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/propagators/test_affine_geq.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/propagators/test_affine_leq.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/propagators/test_alldifferent.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/propagators/test_count_eq.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/propagators/test_element_lic.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/propagators/test_element_liv.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/propagators/test_exactly_eq.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/propagators/test_gcc.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/propagators/test_lexicographic_leq.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/propagators/test_max_eq.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/propagators/test_max_leq.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/propagators/test_min_eq.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/propagators/test_min_geq.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/propagators/test_relation.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/solvers/__init__.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/solvers/test_backtrack_solver.py +0 -0
- {nucs-2.1.0 → nucs-2.2.0}/tests/solvers/test_multiprocessing_solver.py +0 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: NUCS
|
|
3
|
+
Version: 2.2.0
|
|
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 :: 4 - Beta
|
|
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: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
16
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
17
|
+
Requires-Python: >=3.9
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE.md
|
|
20
|
+
Requires-Dist: numba==0.60.0
|
|
21
|
+
Requires-Dist: numpy==2.0.1
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
|
|
26
|
+

|
|
27
|
+

|
|
28
|
+
|
|
29
|
+

|
|
30
|
+

|
|
31
|
+
|
|
32
|
+

|
|
33
|
+

|
|
34
|
+

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

|
|
24
|
+
|
|
25
|
+
|
|
26
|
+

|
|
27
|
+

|
|
28
|
+
|
|
29
|
+

|
|
30
|
+

|
|
31
|
+
|
|
32
|
+

|
|
33
|
+

|
|
34
|
+

|
|
35
|
+
|
|
36
|
+
## TLDR
|
|
37
|
+
NuCS is a Python library for solving Constraint Satisfaction and Optimization Problems.
|
|
38
|
+
Because it is 100% written in Python,
|
|
39
|
+
NuCS is easy to install and allows to model complex problems in a few lines of code.
|
|
40
|
+
The NuCS solver is also very fast because it is powered by [Numpy](https://numpy.org/) and [Numba](https://numba.pydata.org/).
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
```bash
|
|
44
|
+
pip install nucs
|
|
45
|
+
```
|
|
46
|
+
## Documentation
|
|
47
|
+
Check out [NUCS documentation](https://nucs.readthedocs.io/).
|
|
48
|
+
|
|
49
|
+
## With NuCS, in a few seconds you can ...
|
|
50
|
+
### Find all 14200 solutions to the [12-queens problem](https://www.csplib.org/Problems/prob054/)
|
|
51
|
+
```bash
|
|
52
|
+
NUMBA_CACHE_DIR=.numba/cache python -m nucs.examples.queens -n 12 --log_level=INFO
|
|
53
|
+
```
|
|
54
|
+
```bash
|
|
55
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.solver - Problem has 3 propagators
|
|
56
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.solver - Problem has 12 variables
|
|
57
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses variable heuristic 0
|
|
58
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses domain heuristic 0
|
|
59
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses consistency algorithm 0
|
|
60
|
+
2024-11-12 17:24:49,061 - INFO - nucs.solvers.backtrack_solver - Choice points stack has a maximal height of 128
|
|
61
|
+
2024-11-12 17:24:49,200 - INFO - nucs.solvers.multiprocessing_solver - MultiprocessingSolver has 1 processors
|
|
62
|
+
{
|
|
63
|
+
'OPTIMIZER_SOLUTION_NB': 0,
|
|
64
|
+
'PROBLEM_FILTER_NB': 262011,
|
|
65
|
+
'PROBLEM_SHAVING_NB': 0,
|
|
66
|
+
'PROBLEM_SHAVING_CHANGE_NB': 0,
|
|
67
|
+
'PROBLEM_SHAVING_NO_CHANGE_NB': 0,
|
|
68
|
+
'PROPAGATOR_ENTAILMENT_NB': 0,
|
|
69
|
+
'PROPAGATOR_FILTER_NB': 2269980,
|
|
70
|
+
'PROPAGATOR_FILTER_NO_CHANGE_NB': 990450,
|
|
71
|
+
'PROPAGATOR_INCONSISTENCY_NB': 116806,
|
|
72
|
+
'SOLVER_BACKTRACK_NB': 131005,
|
|
73
|
+
'SOLVER_CHOICE_NB': 131005,
|
|
74
|
+
'SOLVER_CHOICE_DEPTH': 10,
|
|
75
|
+
'SOLVER_SOLUTION_NB': 14200
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Compute the 92 solutions to the [BIBD(8,14,7,4,3) problem](https://www.csplib.org/Problems/prob028/)
|
|
80
|
+
```bash
|
|
81
|
+
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
|
|
82
|
+
```
|
|
83
|
+
```bash
|
|
84
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.solver - Problem has 462 propagators
|
|
85
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.solver - Problem has 504 variables
|
|
86
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses variable heuristic 0
|
|
87
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses domain heuristic 1
|
|
88
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses consistency algorithm 0
|
|
89
|
+
2024-11-12 17:26:39,734 - INFO - nucs.solvers.backtrack_solver - Choice points stack has a maximal height of 128
|
|
90
|
+
{
|
|
91
|
+
'OPTIMIZER_SOLUTION_NB': 0,
|
|
92
|
+
'PROBLEM_FILTER_NB': 1425,
|
|
93
|
+
'PROBLEM_SHAVING_NB': 0,
|
|
94
|
+
'PROBLEM_SHAVING_CHANGE_NB': 0,
|
|
95
|
+
'PROBLEM_SHAVING_NO_CHANGE_NB': 0,
|
|
96
|
+
'PROPAGATOR_ENTAILMENT_NB': 4711,
|
|
97
|
+
'PROPAGATOR_FILTER_NB': 104392,
|
|
98
|
+
'PROPAGATOR_FILTER_NO_CHANGE_NB': 73792,
|
|
99
|
+
'PROPAGATOR_INCONSISTENCY_NB': 621,
|
|
100
|
+
'SOLVER_BACKTRACK_NB': 712,
|
|
101
|
+
'SOLVER_CHOICE_NB': 712,
|
|
102
|
+
'SOLVER_CHOICE_DEPTH': 19,
|
|
103
|
+
'SOLVER_SOLUTION_NB': 92
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Demonstrate that the optimal [10-marks Golomb ruler](https://www.csplib.org/Problems/prob006/) length is 55
|
|
108
|
+
```bash
|
|
109
|
+
NUMBA_CACHE_DIR=.numba/cache python -m nucs.examples.golomb -n 10 --symmetry_breaking --log_level=INFO
|
|
110
|
+
```
|
|
111
|
+
```bash
|
|
112
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.solver - Problem has 82 propagators
|
|
113
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.solver - Problem has 45 variables
|
|
114
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses variable heuristic 0
|
|
115
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses domain heuristic 0
|
|
116
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.backtrack_solver - BacktrackSolver uses consistency algorithm 2
|
|
117
|
+
2024-11-12 17:27:45,110 - INFO - nucs.solvers.backtrack_solver - Choice points stack has a maximal height of 128
|
|
118
|
+
2024-11-12 17:27:45,172 - INFO - nucs.solvers.backtrack_solver - Minimizing variable 8
|
|
119
|
+
2024-11-12 17:27:45,644 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 80
|
|
120
|
+
2024-11-12 17:27:45,677 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 75
|
|
121
|
+
2024-11-12 17:27:45,677 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 73
|
|
122
|
+
2024-11-12 17:27:45,678 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 72
|
|
123
|
+
2024-11-12 17:27:45,679 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 70
|
|
124
|
+
2024-11-12 17:27:45,682 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 68
|
|
125
|
+
2024-11-12 17:27:45,687 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 66
|
|
126
|
+
2024-11-12 17:27:45,693 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 62
|
|
127
|
+
2024-11-12 17:27:45,717 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 60
|
|
128
|
+
2024-11-12 17:27:45,977 - INFO - nucs.solvers.backtrack_solver - Found a (new) solution: 55
|
|
129
|
+
{
|
|
130
|
+
'OPTIMIZER_SOLUTION_NB': 10,
|
|
131
|
+
'PROBLEM_FILTER_NB': 22652,
|
|
132
|
+
'PROBLEM_SHAVING_NB': 0,
|
|
133
|
+
'PROBLEM_SHAVING_CHANGE_NB': 0,
|
|
134
|
+
'PROBLEM_SHAVING_NO_CHANGE_NB': 0,
|
|
135
|
+
'PROPAGATOR_ENTAILMENT_NB': 107911,
|
|
136
|
+
'PROPAGATOR_FILTER_NB': 2813035,
|
|
137
|
+
'PROPAGATOR_FILTER_NO_CHANGE_NB': 1745836,
|
|
138
|
+
'PROPAGATOR_INCONSISTENCY_NB': 11289,
|
|
139
|
+
'SOLVER_BACKTRACK_NB': 11288,
|
|
140
|
+
'SOLVER_CHOICE_NB': 11353,
|
|
141
|
+
'SOLVER_CHOICE_DEPTH': 9,
|
|
142
|
+
'SOLVER_SOLUTION_NB': 10
|
|
143
|
+
}
|
|
144
|
+
[ 1 6 10 23 26 34 41 53 55]
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
|
nucs-2.2.0/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
|
+
'OPTIMIZER_SOLUTION_NB': 0,
|
|
42
|
+
'PROBLEM_FILTER_NB': 262011,
|
|
43
|
+
'PROBLEM_SHAVING_NB': 0,
|
|
44
|
+
'PROBLEM_SHAVING_CHANGE_NB': 0,
|
|
45
|
+
'PROBLEM_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
|
+
'OPTIMIZER_SOLUTION_NB': 0,
|
|
70
|
+
'PROBLEM_FILTER_NB': 1425,
|
|
71
|
+
'PROBLEM_SHAVING_NB': 0,
|
|
72
|
+
'PROBLEM_SHAVING_CHANGE_NB': 0,
|
|
73
|
+
'PROBLEM_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
|
+
'OPTIMIZER_SOLUTION_NB': 10,
|
|
109
|
+
'PROBLEM_FILTER_NB': 22652,
|
|
110
|
+
'PROBLEM_SHAVING_NB': 0,
|
|
111
|
+
'PROBLEM_SHAVING_CHANGE_NB': 0,
|
|
112
|
+
'PROBLEM_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
|
+
|
|
@@ -56,3 +56,11 @@ TYPE_VAR_HEURISTIC = types.FunctionType(SIGNATURE_VAR_HEURISTIC)
|
|
|
56
56
|
TYPE_CONSISTENCY_ALG = types.FunctionType(SIGNATURE_CONSISTENCY_ALG)
|
|
57
57
|
|
|
58
58
|
NUMBA_DISABLE_JIT = os.getenv("NUMBA_DISABLE_JIT")
|
|
59
|
+
|
|
60
|
+
LOG_FORMAT = "%(asctime)s - %(levelname)s - %(name)s - %(message)s"
|
|
61
|
+
LOG_LEVEL_DEBUG = "DEBUG"
|
|
62
|
+
LOG_LEVEL_INFO = "INFO"
|
|
63
|
+
LOG_LEVEL_WARNING = "WARNING"
|
|
64
|
+
LOG_LEVEL_ERROR = "ERROR"
|
|
65
|
+
LOG_LEVEL_CRITICAL = "CRITICAL"
|
|
66
|
+
LOG_LEVELS = [LOG_LEVEL_DEBUG, LOG_LEVEL_INFO, LOG_LEVEL_WARNING, LOG_LEVEL_ERROR, LOG_LEVEL_CRITICAL]
|
|
@@ -10,8 +10,11 @@
|
|
|
10
10
|
#
|
|
11
11
|
# Copyright 2024 - Yan Georget
|
|
12
12
|
###############################################################################
|
|
13
|
+
import argparse
|
|
14
|
+
|
|
13
15
|
from rich import print
|
|
14
16
|
|
|
17
|
+
from nucs.constants import LOG_LEVEL_INFO, LOG_LEVELS
|
|
15
18
|
from nucs.examples.alpha.alpha_problem import AlphaProblem
|
|
16
19
|
from nucs.solvers.backtrack_solver import BacktrackSolver
|
|
17
20
|
from nucs.solvers.heuristics import DOM_HEURISTIC_MIN_VALUE, VAR_HEURISTIC_SMALLEST_DOMAIN
|
|
@@ -20,9 +23,15 @@ from nucs.statistics import get_statistics
|
|
|
20
23
|
# Run with the following command (the second run is much faster because the code has been compiled):
|
|
21
24
|
# NUMBA_CACHE_DIR=.numba/cache PYTHONPATH=. python -m nucs.examples.alpha
|
|
22
25
|
if __name__ == "__main__":
|
|
26
|
+
parser = argparse.ArgumentParser()
|
|
27
|
+
parser.add_argument("--log_level", choices=LOG_LEVELS, default=LOG_LEVEL_INFO)
|
|
28
|
+
args = parser.parse_args()
|
|
23
29
|
problem = AlphaProblem()
|
|
24
30
|
solver = BacktrackSolver(
|
|
25
|
-
problem,
|
|
31
|
+
problem,
|
|
32
|
+
var_heuristic_idx=VAR_HEURISTIC_SMALLEST_DOMAIN,
|
|
33
|
+
dom_heuristic_idx=DOM_HEURISTIC_MIN_VALUE,
|
|
34
|
+
log_level=args.log_level,
|
|
26
35
|
)
|
|
27
36
|
solutions = solver.find_all()
|
|
28
37
|
print(get_statistics(solver.statistics))
|
|
@@ -14,6 +14,7 @@ import argparse
|
|
|
14
14
|
|
|
15
15
|
from rich import print
|
|
16
16
|
|
|
17
|
+
from nucs.constants import LOG_LEVEL_INFO, LOG_LEVELS
|
|
17
18
|
from nucs.examples.bibd.bibd_problem import BIBDProblem
|
|
18
19
|
from nucs.solvers.backtrack_solver import BacktrackSolver
|
|
19
20
|
from nucs.solvers.heuristics import DOM_HEURISTIC_MAX_VALUE
|
|
@@ -29,8 +30,9 @@ if __name__ == "__main__":
|
|
|
29
30
|
parser.add_argument("-k", type=int)
|
|
30
31
|
parser.add_argument("-l", type=int)
|
|
31
32
|
parser.add_argument("--symmetry_breaking", action=argparse.BooleanOptionalAction, default=True)
|
|
33
|
+
parser.add_argument("--log_level", choices=LOG_LEVELS, default=LOG_LEVEL_INFO)
|
|
32
34
|
args = parser.parse_args()
|
|
33
35
|
problem = BIBDProblem(args.v, args.b, args.r, args.k, args.l, args.symmetry_breaking)
|
|
34
|
-
solver = BacktrackSolver(problem, dom_heuristic_idx=DOM_HEURISTIC_MAX_VALUE)
|
|
36
|
+
solver = BacktrackSolver(problem, dom_heuristic_idx=DOM_HEURISTIC_MAX_VALUE, log_level=args.log_level)
|
|
35
37
|
solver.solve_all()
|
|
36
38
|
print(get_statistics(solver.statistics))
|
|
@@ -10,8 +10,11 @@
|
|
|
10
10
|
#
|
|
11
11
|
# Copyright 2024 - Yan Georget
|
|
12
12
|
###############################################################################
|
|
13
|
+
import argparse
|
|
14
|
+
|
|
13
15
|
from rich import print
|
|
14
16
|
|
|
17
|
+
from nucs.constants import LOG_LEVEL_INFO, LOG_LEVELS
|
|
15
18
|
from nucs.examples.donald.donald_problem import DonaldProblem
|
|
16
19
|
from nucs.solvers.backtrack_solver import BacktrackSolver
|
|
17
20
|
from nucs.solvers.heuristics import DOM_HEURISTIC_MIN_VALUE, VAR_HEURISTIC_SMALLEST_DOMAIN
|
|
@@ -20,9 +23,15 @@ from nucs.statistics import get_statistics
|
|
|
20
23
|
# Run with the following command (the second run is much faster because the code has been compiled):
|
|
21
24
|
# NUMBA_CACHE_DIR=.numba/cache PYTHONPATH=. python -m nucs.examples.donald
|
|
22
25
|
if __name__ == "__main__":
|
|
26
|
+
parser = argparse.ArgumentParser()
|
|
27
|
+
parser.add_argument("--log_level", choices=LOG_LEVELS, default=LOG_LEVEL_INFO)
|
|
28
|
+
args = parser.parse_args()
|
|
23
29
|
problem = DonaldProblem()
|
|
24
30
|
solver = BacktrackSolver(
|
|
25
|
-
problem,
|
|
31
|
+
problem,
|
|
32
|
+
var_heuristic_idx=VAR_HEURISTIC_SMALLEST_DOMAIN,
|
|
33
|
+
dom_heuristic_idx=DOM_HEURISTIC_MIN_VALUE,
|
|
34
|
+
log_level=args.log_level,
|
|
26
35
|
)
|
|
27
36
|
print(get_statistics(solver.statistics))
|
|
28
37
|
for solution in solver.solve():
|
|
@@ -14,6 +14,7 @@ import argparse
|
|
|
14
14
|
|
|
15
15
|
from rich import print
|
|
16
16
|
|
|
17
|
+
from nucs.constants import LOG_LEVEL_INFO, LOG_LEVELS
|
|
17
18
|
from nucs.examples.golomb.golomb_problem import GolombProblem, golomb_consistency_algorithm
|
|
18
19
|
from nucs.solvers.backtrack_solver import BacktrackSolver
|
|
19
20
|
from nucs.solvers.consistency_algorithms import register_consistency_algorithm
|
|
@@ -25,10 +26,11 @@ if __name__ == "__main__":
|
|
|
25
26
|
parser = argparse.ArgumentParser()
|
|
26
27
|
parser.add_argument("-n", type=int, default=10)
|
|
27
28
|
parser.add_argument("--symmetry_breaking", action=argparse.BooleanOptionalAction, default=True)
|
|
29
|
+
parser.add_argument("--log_level", choices=LOG_LEVELS, default=LOG_LEVEL_INFO)
|
|
28
30
|
args = parser.parse_args()
|
|
29
31
|
problem = GolombProblem(args.n, args.symmetry_breaking)
|
|
30
32
|
consistency_alg_golomb = register_consistency_algorithm(golomb_consistency_algorithm)
|
|
31
|
-
solver = BacktrackSolver(problem, consistency_alg_idx=consistency_alg_golomb)
|
|
33
|
+
solver = BacktrackSolver(problem, consistency_alg_idx=consistency_alg_golomb, log_level=args.log_level)
|
|
32
34
|
solution = solver.minimize(problem.length_idx)
|
|
33
35
|
print(get_statistics(solver.statistics))
|
|
34
36
|
if solution is not None:
|
|
@@ -10,8 +10,11 @@
|
|
|
10
10
|
#
|
|
11
11
|
# Copyright 2024 - Yan Georget
|
|
12
12
|
###############################################################################
|
|
13
|
+
import argparse
|
|
14
|
+
|
|
13
15
|
from rich import print
|
|
14
16
|
|
|
17
|
+
from nucs.constants import LOG_LEVEL_INFO, LOG_LEVELS
|
|
15
18
|
from nucs.examples.knapsack.knapsack_problem import KnapsackProblem
|
|
16
19
|
from nucs.solvers.backtrack_solver import BacktrackSolver
|
|
17
20
|
from nucs.solvers.heuristics import DOM_HEURISTIC_MAX_VALUE, VAR_HEURISTIC_FIRST_NOT_INSTANTIATED
|
|
@@ -20,13 +23,19 @@ from nucs.statistics import get_statistics
|
|
|
20
23
|
# Run with the following command (the second run is much faster because the code has been compiled):
|
|
21
24
|
# NUMBA_CACHE_DIR=.numba/cache PYTHONPATH=. python -m nucs.examples.knapsack
|
|
22
25
|
if __name__ == "__main__":
|
|
26
|
+
parser = argparse.ArgumentParser()
|
|
27
|
+
parser.add_argument("--log_level", choices=LOG_LEVELS, default=LOG_LEVEL_INFO)
|
|
28
|
+
args = parser.parse_args()
|
|
23
29
|
problem = KnapsackProblem(
|
|
24
30
|
[40, 40, 38, 38, 36, 36, 34, 34, 32, 32, 30, 30, 28, 28, 26, 26, 24, 24, 22, 22],
|
|
25
31
|
[40, 40, 38, 38, 36, 36, 34, 34, 32, 32, 30, 30, 28, 28, 26, 26, 24, 24, 22, 22],
|
|
26
32
|
55,
|
|
27
33
|
)
|
|
28
34
|
solver = BacktrackSolver(
|
|
29
|
-
problem,
|
|
35
|
+
problem,
|
|
36
|
+
var_heuristic_idx=VAR_HEURISTIC_FIRST_NOT_INSTANTIATED,
|
|
37
|
+
dom_heuristic_idx=DOM_HEURISTIC_MAX_VALUE,
|
|
38
|
+
log_level=args.log_level,
|
|
30
39
|
)
|
|
31
40
|
solution = solver.maximize(problem.weight)
|
|
32
41
|
print(get_statistics(solver.statistics))
|
|
@@ -14,6 +14,7 @@ import argparse
|
|
|
14
14
|
|
|
15
15
|
from rich import print
|
|
16
16
|
|
|
17
|
+
from nucs.constants import LOG_LEVEL_INFO, LOG_LEVELS
|
|
17
18
|
from nucs.examples.magic_sequence.magic_sequence_problem import MagicSequenceProblem
|
|
18
19
|
from nucs.solvers.backtrack_solver import BacktrackSolver
|
|
19
20
|
from nucs.solvers.heuristics import DOM_HEURISTIC_MIN_VALUE, VAR_HEURISTIC_LAST_NOT_INSTANTIATED
|
|
@@ -24,10 +25,14 @@ from nucs.statistics import get_statistics
|
|
|
24
25
|
if __name__ == "__main__":
|
|
25
26
|
parser = argparse.ArgumentParser()
|
|
26
27
|
parser.add_argument("-n", type=int, default=100)
|
|
28
|
+
parser.add_argument("--log_level", choices=LOG_LEVELS, default=LOG_LEVEL_INFO)
|
|
27
29
|
args = parser.parse_args()
|
|
28
30
|
problem = MagicSequenceProblem(args.n)
|
|
29
31
|
solver = BacktrackSolver(
|
|
30
|
-
problem,
|
|
32
|
+
problem,
|
|
33
|
+
var_heuristic_idx=VAR_HEURISTIC_LAST_NOT_INSTANTIATED,
|
|
34
|
+
dom_heuristic_idx=DOM_HEURISTIC_MIN_VALUE,
|
|
35
|
+
log_level=args.log_level,
|
|
31
36
|
)
|
|
32
37
|
solver.solve_all()
|
|
33
38
|
print(get_statistics(solver.statistics))
|
|
@@ -14,6 +14,7 @@ import argparse
|
|
|
14
14
|
|
|
15
15
|
from rich import print
|
|
16
16
|
|
|
17
|
+
from nucs.constants import LOG_LEVEL_INFO, LOG_LEVELS
|
|
17
18
|
from nucs.examples.magic_square.magic_square_problem import MagicSquareProblem
|
|
18
19
|
from nucs.solvers.backtrack_solver import BacktrackSolver
|
|
19
20
|
from nucs.solvers.heuristics import DOM_HEURISTIC_MAX_VALUE, VAR_HEURISTIC_SMALLEST_DOMAIN
|
|
@@ -25,10 +26,14 @@ if __name__ == "__main__":
|
|
|
25
26
|
parser = argparse.ArgumentParser()
|
|
26
27
|
parser.add_argument("-n", type=int)
|
|
27
28
|
parser.add_argument("--symmetry_breaking", action=argparse.BooleanOptionalAction, default=True)
|
|
29
|
+
parser.add_argument("--log_level", choices=LOG_LEVELS, default=LOG_LEVEL_INFO)
|
|
28
30
|
args = parser.parse_args()
|
|
29
31
|
problem = MagicSquareProblem(args.n, args.symmetry_breaking)
|
|
30
32
|
solver = BacktrackSolver(
|
|
31
|
-
problem,
|
|
33
|
+
problem,
|
|
34
|
+
var_heuristic_idx=VAR_HEURISTIC_SMALLEST_DOMAIN,
|
|
35
|
+
dom_heuristic_idx=DOM_HEURISTIC_MAX_VALUE,
|
|
36
|
+
log_level=args.log_level,
|
|
32
37
|
)
|
|
33
38
|
solver.solve_all()
|
|
34
39
|
print(get_statistics(solver.statistics))
|
|
@@ -14,6 +14,7 @@ import argparse
|
|
|
14
14
|
|
|
15
15
|
from rich import print
|
|
16
16
|
|
|
17
|
+
from nucs.constants import LOG_LEVEL_INFO, LOG_LEVELS
|
|
17
18
|
from nucs.examples.quasigroup.quasigroup_problem import Quasigroup5Problem
|
|
18
19
|
from nucs.solvers.backtrack_solver import BacktrackSolver
|
|
19
20
|
from nucs.solvers.heuristics import DOM_HEURISTIC_MIN_VALUE, VAR_HEURISTIC_SMALLEST_DOMAIN
|
|
@@ -25,10 +26,14 @@ if __name__ == "__main__":
|
|
|
25
26
|
parser = argparse.ArgumentParser()
|
|
26
27
|
parser.add_argument("-n", type=int, default=10)
|
|
27
28
|
parser.add_argument("--symmetry_breaking", action=argparse.BooleanOptionalAction, default=True)
|
|
29
|
+
parser.add_argument("--log_level", choices=LOG_LEVELS, default=LOG_LEVEL_INFO)
|
|
28
30
|
args = parser.parse_args()
|
|
29
31
|
problem = Quasigroup5Problem(args.n, args.symmetry_breaking)
|
|
30
32
|
solver = BacktrackSolver(
|
|
31
|
-
problem,
|
|
33
|
+
problem,
|
|
34
|
+
var_heuristic_idx=VAR_HEURISTIC_SMALLEST_DOMAIN,
|
|
35
|
+
dom_heuristic_idx=DOM_HEURISTIC_MIN_VALUE,
|
|
36
|
+
log_level=args.log_level,
|
|
32
37
|
)
|
|
33
38
|
solver.solve_all()
|
|
34
39
|
print(get_statistics(solver.statistics))
|