NuCS 4.4.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. NuCS-4.4.4.dist-info/LICENSE.md +21 -0
  2. NuCS-4.4.4.dist-info/METADATA +152 -0
  3. NuCS-4.4.4.dist-info/RECORD +147 -0
  4. NuCS-4.4.4.dist-info/WHEEL +5 -0
  5. NuCS-4.4.4.dist-info/top_level.txt +3 -0
  6. docs/source/conf.py +54 -0
  7. nucs/__init__.py +0 -0
  8. nucs/constants.py +127 -0
  9. nucs/examples/__init__.py +0 -0
  10. nucs/examples/alpha/__init__.py +0 -0
  11. nucs/examples/alpha/__main__.py +37 -0
  12. nucs/examples/alpha/alpha_problem.py +104 -0
  13. nucs/examples/bibd/__init__.py +0 -0
  14. nucs/examples/bibd/__main__.py +39 -0
  15. nucs/examples/bibd/bibd_problem.py +75 -0
  16. nucs/examples/donald/__init__.py +0 -0
  17. nucs/examples/donald/__main__.py +37 -0
  18. nucs/examples/donald/donald_problem.py +61 -0
  19. nucs/examples/golomb/__init__.py +0 -0
  20. nucs/examples/golomb/__main__.py +52 -0
  21. nucs/examples/golomb/golomb_problem.py +189 -0
  22. nucs/examples/knapsack/__init__.py +0 -0
  23. nucs/examples/knapsack/__main__.py +42 -0
  24. nucs/examples/knapsack/knapsack_problem.py +35 -0
  25. nucs/examples/magic_sequence/__init__.py +0 -0
  26. nucs/examples/magic_sequence/__main__.py +39 -0
  27. nucs/examples/magic_sequence/magic_sequence_problem.py +34 -0
  28. nucs/examples/magic_square/__init__.py +0 -0
  29. nucs/examples/magic_square/__main__.py +38 -0
  30. nucs/examples/magic_square/magic_square_problem.py +61 -0
  31. nucs/examples/quasigroup/__init__.py +0 -0
  32. nucs/examples/quasigroup/__main__.py +44 -0
  33. nucs/examples/quasigroup/quasigroup_problem.py +116 -0
  34. nucs/examples/queens/__init__.py +0 -0
  35. nucs/examples/queens/__main__.py +58 -0
  36. nucs/examples/queens/queens_problem.py +43 -0
  37. nucs/examples/schur_lemma/__init__.py +0 -0
  38. nucs/examples/schur_lemma/__main__.py +32 -0
  39. nucs/examples/schur_lemma/schur_lemma_problem.py +44 -0
  40. nucs/examples/sports_tournament_scheduling/__init__.py +0 -0
  41. nucs/examples/sports_tournament_scheduling/__main__.py +42 -0
  42. nucs/examples/sports_tournament_scheduling/sports_tournament_scheduling_problem.py +117 -0
  43. nucs/examples/sudoku/__init__.py +0 -0
  44. nucs/examples/sudoku/sudoku_problem.py +35 -0
  45. nucs/examples/tsp/__init__.py +0 -0
  46. nucs/examples/tsp/__main__.py +71 -0
  47. nucs/examples/tsp/total_cost_propagator.py +90 -0
  48. nucs/examples/tsp/tsp_instances.py +72 -0
  49. nucs/examples/tsp/tsp_problem.py +47 -0
  50. nucs/examples/tsp/tsp_var_heuristic.py +52 -0
  51. nucs/heuristics/__init__.py +0 -0
  52. nucs/heuristics/first_not_instantiated_var_heuristic.py +35 -0
  53. nucs/heuristics/greatest_domain_var_heuristic.py +40 -0
  54. nucs/heuristics/heuristics.py +60 -0
  55. nucs/heuristics/max_regret_var_heuristic.py +57 -0
  56. nucs/heuristics/max_value_dom_heuristic.py +58 -0
  57. nucs/heuristics/mid_value_dom_heuristic.py +47 -0
  58. nucs/heuristics/min_cost_dom_heuristic.py +52 -0
  59. nucs/heuristics/min_value_dom_heuristic.py +58 -0
  60. nucs/heuristics/smallest_domain_var_heuristic.py +42 -0
  61. nucs/heuristics/split_high_dom_heuristic.py +58 -0
  62. nucs/heuristics/split_low_dom_heuristic.py +58 -0
  63. nucs/heuristics/value_dom_heuristic.py +78 -0
  64. nucs/numba_helper.py +38 -0
  65. nucs/numpy_helper.py +32 -0
  66. nucs/problems/__init__.py +0 -0
  67. nucs/problems/circuit_problem.py +36 -0
  68. nucs/problems/latin_square_problem.py +103 -0
  69. nucs/problems/permutation_problem.py +34 -0
  70. nucs/problems/problem.py +196 -0
  71. nucs/propagators/__init__.py +0 -0
  72. nucs/propagators/affine_eq_propagator.py +69 -0
  73. nucs/propagators/affine_geq_propagator.py +83 -0
  74. nucs/propagators/affine_leq_propagator.py +83 -0
  75. nucs/propagators/alldifferent_propagator.py +219 -0
  76. nucs/propagators/and_propagator.py +67 -0
  77. nucs/propagators/count_eq_propagator.py +74 -0
  78. nucs/propagators/dummy_propagator.py +46 -0
  79. nucs/propagators/element_iv_propagator.py +81 -0
  80. nucs/propagators/element_lic_propagator.py +70 -0
  81. nucs/propagators/element_liv_propagator.py +84 -0
  82. nucs/propagators/exactly_eq_propagator.py +73 -0
  83. nucs/propagators/exactly_true_propagator.py +70 -0
  84. nucs/propagators/gcc_propagator.py +456 -0
  85. nucs/propagators/lexicographic_leq_propagator.py +159 -0
  86. nucs/propagators/max_eq_propagator.py +63 -0
  87. nucs/propagators/max_leq_propagator.py +69 -0
  88. nucs/propagators/min_eq_propagator.py +63 -0
  89. nucs/propagators/min_geq_propagator.py +69 -0
  90. nucs/propagators/no_sub_cycle_propagator.py +81 -0
  91. nucs/propagators/permutation_aux_propagator.py +65 -0
  92. nucs/propagators/propagators.py +175 -0
  93. nucs/propagators/relation_propagator.py +63 -0
  94. nucs/propagators/scc_propagator.py +75 -0
  95. nucs/solvers/__init__.py +0 -0
  96. nucs/solvers/backtrack_solver.py +602 -0
  97. nucs/solvers/bound_consistency_algorithm.py +136 -0
  98. nucs/solvers/choice_points.py +133 -0
  99. nucs/solvers/consistency_algorithms.py +32 -0
  100. nucs/solvers/multiprocessing_solver.py +132 -0
  101. nucs/solvers/shaving_consistency_algorithm.py +213 -0
  102. nucs/solvers/solver.py +121 -0
  103. tests/__init__.py +0 -0
  104. tests/examples/test_alpha.py +54 -0
  105. tests/examples/test_bibd.py +28 -0
  106. tests/examples/test_donald.py +27 -0
  107. tests/examples/test_golomb.py +35 -0
  108. tests/examples/test_knapsack.py +30 -0
  109. tests/examples/test_latin_square.py +51 -0
  110. tests/examples/test_magic_sequence.py +35 -0
  111. tests/examples/test_magic_square.py +36 -0
  112. tests/examples/test_quasigroup.py +62 -0
  113. tests/examples/test_queens.py +37 -0
  114. tests/examples/test_schur_lemma.py +48 -0
  115. tests/examples/test_sports_tournament_scheduling.py +107 -0
  116. tests/examples/test_sudokus.py +54 -0
  117. tests/examples/test_tsp.py +57 -0
  118. tests/heuristics/__init__.py +0 -0
  119. tests/heuristics/test_max_value_dom_heuristic.py +24 -0
  120. tests/heuristics/test_mid_value_dom_heuristic.py +24 -0
  121. tests/heuristics/test_min_value_dom_heuristic.py +24 -0
  122. tests/problems/__init__.py +0 -0
  123. tests/problems/test_circuit_problem.py +36 -0
  124. tests/problems/test_permutation_problem.py +35 -0
  125. tests/problems/test_problem.py +40 -0
  126. tests/propagators/__init__.py +0 -0
  127. tests/propagators/test_affine_eq.py +58 -0
  128. tests/propagators/test_affine_geq.py +41 -0
  129. tests/propagators/test_affine_leq.py +41 -0
  130. tests/propagators/test_alldifferent.py +58 -0
  131. tests/propagators/test_count_eq.py +54 -0
  132. tests/propagators/test_element_iv.py +36 -0
  133. tests/propagators/test_element_lic.py +36 -0
  134. tests/propagators/test_element_liv.py +42 -0
  135. tests/propagators/test_exactly_eq.py +42 -0
  136. tests/propagators/test_gcc.py +54 -0
  137. tests/propagators/test_lexicographic_leq.py +85 -0
  138. tests/propagators/test_max_eq.py +46 -0
  139. tests/propagators/test_max_leq.py +47 -0
  140. tests/propagators/test_min_eq.py +46 -0
  141. tests/propagators/test_min_geq.py +47 -0
  142. tests/propagators/test_no_sub_cycle.py +32 -0
  143. tests/propagators/test_relation.py +53 -0
  144. tests/propagators/test_scc.py +32 -0
  145. tests/solvers/__init__.py +0 -0
  146. tests/solvers/test_backtrack_solver.py +106 -0
  147. tests/solvers/test_multiprocessing_solver.py +65 -0
@@ -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
+ ![NucS logo](https://github.com/yangeorget/nucs/blob/main/assets/nucs.png?raw=true)
29
+
30
+
31
+ ![pypi version](https://img.shields.io/pypi/v/nucs?color=blue&label=pypi%20version&logo=pypi&logoColor=white)
32
+ ![pypi downloads](https://img.shields.io/pypi/dm/NUCS)
33
+
34
+ ![numba version](https://img.shields.io/badge/numba-v0.60-blue)
35
+ ![numpy version](https://img.shields.io/badge/numpy-v2.0-blue)
36
+
37
+ ![tests](https://github.com/yangeorget/nucs/actions/workflows/test.yml/badge.svg)
38
+ ![doc](https://img.shields.io/readthedocs/nucs)
39
+ ![license](https://img.shields.io/github/license/yangeorget/nucs)
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,147 @@
1
+ docs/source/conf.py,sha256=cvDQ0FUW5qAB2oyqlNf9jNGHU7D5Or2A_FEhOqEVyjs,1276
2
+ nucs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ nucs/constants.py,sha256=zQYwKie0a1232-0syLn0I2NqAs5wfqNIZpXaQqC-0Eo,4756
4
+ nucs/numba_helper.py,sha256=_VUNexo50aFJtqbZgfYAJ3nelG4YTnMkJZYdX4Ay5Zs,1408
5
+ nucs/numpy_helper.py,sha256=9EYK3dcniZJqA0qvWgFqzNJvLF2BpT8wExDn0uqf4cs,987
6
+ nucs/examples/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ nucs/examples/alpha/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ nucs/examples/alpha/__main__.py,sha256=fUmvpFptKFTOVFJFk95R209z02ENz8kBgjcmCdqGJc0,1472
9
+ nucs/examples/alpha/alpha_problem.py,sha256=6Pd2u7yYJLTLsW_C0XhB65blz6kBwucj8Ns5-Dx8fMw,4219
10
+ nucs/examples/bibd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ nucs/examples/bibd/__main__.py,sha256=Wn83zV0LqH4CsQvrT2_M2o2uWMmW0GRRblnhx6ikUTQ,1732
12
+ nucs/examples/bibd/bibd_problem.py,sha256=EyQGhW6YIqpYwWvgPGA5zTQIm_SZTkbgelxGSlhccZ4,3278
13
+ nucs/examples/donald/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
14
+ nucs/examples/donald/__main__.py,sha256=9erogAn_NP9jdmARzMEZdOPuMA9zBhM1DTDdrxp7Fus,1479
15
+ nucs/examples/donald/donald_problem.py,sha256=EqoKWQTGaMmKvW8R60jkd404tGZMjOz9c2xZe_dBlJs,1877
16
+ nucs/examples/golomb/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
+ nucs/examples/golomb/__main__.py,sha256=vZswqdN-YIVrXH3WtyejX_tj7bhQcpiVLJ1u2_BSpJ4,2393
18
+ nucs/examples/golomb/golomb_problem.py,sha256=5vy2et5GtUI2SQbvTiUc9UehvUYAP9BYO9ysCKwPaE8,7129
19
+ nucs/examples/knapsack/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
+ nucs/examples/knapsack/__main__.py,sha256=CrSzscnsqZKwj01Up24tR7FazLlQDTVleEk6MSJzuTw,1807
21
+ nucs/examples/knapsack/knapsack_problem.py,sha256=njuNB-jXBnt9hLhk5GwRf9ZDoF81fddsVbA_1K_YfDY,1297
22
+ nucs/examples/magic_sequence/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
+ nucs/examples/magic_sequence/__main__.py,sha256=bEmwXvkt21bO2KwdQPJ_TRj-uXCUt-u4uUKtx9dY2ek,1623
24
+ nucs/examples/magic_sequence/magic_sequence_problem.py,sha256=yesK69Rndgi8vn6l3-wIaLyVP0OBdO-bi0OSGP6ppis,1277
25
+ nucs/examples/magic_square/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
26
+ nucs/examples/magic_square/__main__.py,sha256=8pPmdiDN9LpSi8iQC7Qv5hPATHHR9ousClC6jhUWZOI,1650
27
+ nucs/examples/magic_square/magic_square_problem.py,sha256=1I98kNc25nnMlpMQblawYRKYbZlZ1RajHx3TRSwBU_4,2561
28
+ nucs/examples/quasigroup/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
29
+ nucs/examples/quasigroup/__main__.py,sha256=l_nRVQF_mSyeQuUVyY3SoTkl8n-LIyCTKDF03vXoAIA,2190
30
+ nucs/examples/quasigroup/quasigroup_problem.py,sha256=kET3aTk6pFljaPylLecNTA648EaqMWIS-dFrfNW1s1Q,5099
31
+ nucs/examples/queens/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
32
+ nucs/examples/queens/__main__.py,sha256=Z4Azi9dLON8q84QvKqJ9GOkmsal9d-PQ-zpvD7NB0zY,2617
33
+ nucs/examples/queens/queens_problem.py,sha256=c3o96RihI8YtXPfNuaSz2IpqfToovNKMeVa6tJOlln0,1461
34
+ nucs/examples/schur_lemma/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
+ nucs/examples/schur_lemma/__main__.py,sha256=pbOh4ymkPUGwIbogUsXq7hVjQ0bcxOS3sbVtO1L1Cgc,1445
36
+ nucs/examples/schur_lemma/schur_lemma_problem.py,sha256=CZLMlzqq4C7riJqbGvVo9eRL8ErZE3LecOAwx1iueV8,1730
37
+ nucs/examples/sports_tournament_scheduling/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
+ nucs/examples/sports_tournament_scheduling/__main__.py,sha256=ZOY-qBD2pLi1vtp3s1AFWKwwYPIWMWxKji5331FxkAU,1811
39
+ nucs/examples/sports_tournament_scheduling/sports_tournament_scheduling_problem.py,sha256=hrG2aeH9Y7JcZtBGd7Ix7qrdzGS-WQtamB7Ho1SWcKc,4710
40
+ nucs/examples/sudoku/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
+ nucs/examples/sudoku/sudoku_problem.py,sha256=pKxivNYoXeveBuGPVL15R85OHMMvDGJUxCIWV7PZ6Ic,1206
42
+ nucs/examples/tsp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
+ nucs/examples/tsp/__main__.py,sha256=QfQM9sv4rWhuHpVmkwZh-EOAvQAjvkMfDh42T4W222Y,3260
44
+ nucs/examples/tsp/total_cost_propagator.py,sha256=Yap4zcpwP7itWXOdz_H17UD9CTXBGslqPnHyx1DI2sQ,3271
45
+ nucs/examples/tsp/tsp_instances.py,sha256=nMf6DZH3ROvCxEtIBn5d7zVEJ5aU_Lh4Mxd3Oxisnzo,6880
46
+ nucs/examples/tsp/tsp_problem.py,sha256=dUlhyC_5vx2wZap1YF8y-ksLCZe1YaizCInZMSkedTw,2302
47
+ nucs/examples/tsp/tsp_var_heuristic.py,sha256=Lhfig18Fht5xv1BNxr3KJV_89lU0Y9VWkSa0565TBR0,1889
48
+ nucs/heuristics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
49
+ nucs/heuristics/first_not_instantiated_var_heuristic.py,sha256=cg7UH-WL0cNkonlqkawReji7HylgIwWa_mH2AnKuXYQ,1353
50
+ nucs/heuristics/greatest_domain_var_heuristic.py,sha256=9n9olek1M8LnKf5jLTjFlphJQiT8Clx8CcGX83TQhpI,1489
51
+ nucs/heuristics/heuristics.py,sha256=pJpYoS5fUtZjP48z6zDMLVOKkWsHJVmbYAY4I6i2Zqw,2949
52
+ nucs/heuristics/max_regret_var_heuristic.py,sha256=2is67hJp2Fcy7Wdq5MiqFx7X1MVgpIdskF0kNtFTRb4,2027
53
+ nucs/heuristics/max_value_dom_heuristic.py,sha256=r6L2DuDxa1TilGLaxEMCkn54hHb3hGB5kqEEZ8X2u5k,1994
54
+ nucs/heuristics/mid_value_dom_heuristic.py,sha256=cy9C8gmgSlYzGzQ8xPwTI-HnZaMaF9b3RfQ9QACBItk,1657
55
+ nucs/heuristics/min_cost_dom_heuristic.py,sha256=Hw5AuB7hgDzWVcxeC8zAIr7KLAtD39iR8YxFXpN8C6Q,1886
56
+ nucs/heuristics/min_value_dom_heuristic.py,sha256=ie8JZKNE2MDPHcG_KNK7eCUp2WFUV4_iIMIqgqxxpd4,2005
57
+ nucs/heuristics/smallest_domain_var_heuristic.py,sha256=dJxqBi09zwiURIRRSjR4_jemgnJbcM2izeRPnV0d89E,1496
58
+ nucs/heuristics/split_high_dom_heuristic.py,sha256=bZ0ix0tnu4Vzv-Jlcc4hDql5ZxVPDJNAcgagf-hC4Uc,2040
59
+ nucs/heuristics/split_low_dom_heuristic.py,sha256=ImL3S_nqtk3XJN1IYfd9BztmKNYSf5On_CuMz3JKzD8,2038
60
+ nucs/heuristics/value_dom_heuristic.py,sha256=lRVdvVY2Fbs4S1WZ4oDJxDMEPYhJL33LwQELxwjOC-U,2992
61
+ nucs/problems/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
62
+ nucs/problems/circuit_problem.py,sha256=YWFmqZDTBUml6QQOSVYz6WlA8jpGQqJLriepjJEWoGo,1374
63
+ nucs/problems/latin_square_problem.py,sha256=CGtgKHZYCPlo8c5v1G2iOUuvRzgMEYQ9eeNkxY12rfY,4686
64
+ nucs/problems/permutation_problem.py,sha256=tTN8d_LPbbRxM0tjqnoCBSTeaV9xCX6bebxKTsqDm9I,1270
65
+ nucs/problems/problem.py,sha256=JweaKlE8s8XzCB0GmkL2n4h45dEg4g6EY7PfCbp-4zE,9365
66
+ nucs/propagators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
67
+ nucs/propagators/affine_eq_propagator.py,sha256=zZz5J9hBTpmbudvR9YlerhztLgn8U8j9J7Uy49Jgi8g,2720
68
+ nucs/propagators/affine_geq_propagator.py,sha256=79SigRzUIRKvBOP_dGT0lArY-HzCk239G32avN952YI,2814
69
+ nucs/propagators/affine_leq_propagator.py,sha256=5lpTNweZZfDM-CMWeSns4IFQS0nHFVO6SaHOr6pMcaw,2812
70
+ nucs/propagators/alldifferent_propagator.py,sha256=ouSfw1u2x1FLPBFfdsxuvKNWI5fs4qZRittWOa-pM7E,6884
71
+ nucs/propagators/and_propagator.py,sha256=khCzVKm6C1oMRZzYnsMOQjm9DkecZ5xc-CzowD899EI,2188
72
+ nucs/propagators/count_eq_propagator.py,sha256=AjMQtUY9KagibVF35CIORVK_MgXRzoeZHC6j7ho-e8U,2693
73
+ nucs/propagators/dummy_propagator.py,sha256=B8lEYioN6ybFx2NZ_0wACeL_MFSkY8mJmxqpnnI_R3A,1551
74
+ nucs/propagators/element_iv_propagator.py,sha256=aPi05TP8Q7NB7lySTSxbUdRqwPPez9u88irPCkjI5fM,2620
75
+ nucs/propagators/element_lic_propagator.py,sha256=lYbZFHThqGGETlUyF-aCJ1Pft_RSSC4opj_Ed7mfvO4,2423
76
+ nucs/propagators/element_liv_propagator.py,sha256=qwH90Dlr5Yjaiu75eTbqE9rZZnyPto3IaIOSCis6gcY,2785
77
+ nucs/propagators/exactly_eq_propagator.py,sha256=6sr3dluMHmT_A3i3UNvRLZyjc42XwIQVqMiRWFTpz64,2739
78
+ nucs/propagators/exactly_true_propagator.py,sha256=iRfqegj9k0qMh4ySmP2l4Vm9ZhCOyz0Vzn3jRen0ccw,2636
79
+ nucs/propagators/gcc_propagator.py,sha256=gnVyDiudpBgpdXBG_XwlSNYugSeLwE1hVJE830C_psE,15594
80
+ nucs/propagators/lexicographic_leq_propagator.py,sha256=gyICaTn8eF7DL42S6uTcsgTOuiP70BCFBoKzFKBqQ-s,5483
81
+ nucs/propagators/max_eq_propagator.py,sha256=4GjM6HG2N1PVh-1cabk5fOMPVGTeRDwCxh1YRryFBtw,2091
82
+ nucs/propagators/max_leq_propagator.py,sha256=ztQkKH2ex6aBUh3fWoSJxCZ7PXODcEsZTXFQ9_6rLYI,2114
83
+ nucs/propagators/min_eq_propagator.py,sha256=o1hsfQ02xUL0PPdlb1hIIgAKfh4MQG-W_HFk9SddqKM,2091
84
+ nucs/propagators/min_geq_propagator.py,sha256=2VWO4XsKNSGYCT9jkVILD9SYWBpRlroqkhES51jl1Ao,2114
85
+ nucs/propagators/no_sub_cycle_propagator.py,sha256=qULnvmsO7-tYInpwYNTaoztLQi0T82PUgto-BHSVVMM,2999
86
+ nucs/propagators/permutation_aux_propagator.py,sha256=jKk9lzG0tkPxV1jZpwcg6-X-Iyl6avq_kG0AvDDBD6M,2216
87
+ nucs/propagators/propagators.py,sha256=IJXBzOjju0Ve7FEdNm5JuD8VBgx9NaLqUHiOCrj3r28,7772
88
+ nucs/propagators/relation_propagator.py,sha256=feDQ0cC40SVdiYtlR2MzzF_b30-IlYZHhjnvNEEvFRc,2464
89
+ nucs/propagators/scc_propagator.py,sha256=Z8CotxBazXJSWJua58DYfgueW4CFiwJEd4T1AQMqGfw,2560
90
+ nucs/solvers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
91
+ nucs/solvers/backtrack_solver.py,sha256=GCzfTwn6W3YWvqhwWdnjEr9gATuH3o_hctmhebgMpdI,26726
92
+ nucs/solvers/bound_consistency_algorithm.py,sha256=rL1xnolzM9wAZ5FcTyeMUlJkHu05pc6q6x18bWnzn84,6126
93
+ nucs/solvers/choice_points.py,sha256=5I4yvagiTP1Mgml-P7j2BNsLj4uURLKaQUNP4f6oduo,4845
94
+ nucs/solvers/consistency_algorithms.py,sha256=Jp5DiO4zQQ1ArE566cQGDzfsOFpMJOI1EEQ-TSLS2Bw,1298
95
+ nucs/solvers/multiprocessing_solver.py,sha256=etVnZEjWQzIs-kFK39cpBceEnn9ni7DAS80vsz2eJNc,5717
96
+ nucs/solvers/shaving_consistency_algorithm.py,sha256=GNZ0D3nrtDQofdz5ixsCDs68Yr8oTpUMmoAfP0inze4,7707
97
+ nucs/solvers/solver.py,sha256=Z50cVFgjJBH73gyTIfJ-I88Hp15rYF-5cNOGvDqM-co,3920
98
+ tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
99
+ tests/examples/test_alpha.py,sha256=owTEvjwz60JgAjEp7hzft9hCfs7ZV8TaXTT5H2xAqzo,1559
100
+ tests/examples/test_bibd.py,sha256=EbsB0cd4TJ06U50k77g3vQIgyRyxdhPYwk2xVDc4S98,1127
101
+ tests/examples/test_donald.py,sha256=c_Aoh3XnJ_czVZGaWoPqJfh33CBgkBqVHVS7C43NSBs,1172
102
+ tests/examples/test_golomb.py,sha256=UVoDW92lO5HisWzPxAtiQPdoKgGSs_sXtdgQq4zwTNs,1571
103
+ tests/examples/test_knapsack.py,sha256=fBYbM7XFdC89A9g7RxTt6OYlSAJnP4qfmhUcwXMPFfY,1311
104
+ tests/examples/test_latin_square.py,sha256=mZfHm04POuXZvROlMPyuIn81Cnrfqm4wy4VYMNwUws4,1651
105
+ tests/examples/test_magic_sequence.py,sha256=Tmtl5RX1PNpg9-SCpFP9sKok5SWxjTUMSZ0TSq4cXgo,1447
106
+ tests/examples/test_magic_square.py,sha256=gnXLZNv1VzmP-c3HZIz6CmNk5h2PUS7I_a1UzSos57w,1475
107
+ tests/examples/test_quasigroup.py,sha256=ywexQRKzbzCD67frWI6tDLMlHys3hfxyia-wVO6MnUI,2168
108
+ tests/examples/test_queens.py,sha256=Ln3AHeSX-ZDPBmOeyxuny0B-jeu3SwlnDCjCFJkHsFM,1528
109
+ tests/examples/test_schur_lemma.py,sha256=qUjOA4SmOkQRVr3WNS2ddgNrfQh43bgGRnuBYFqTxKg,1441
110
+ tests/examples/test_sports_tournament_scheduling.py,sha256=K4VCbjq6F4JZxXwKFiI1axZep5nVwcq5L1oRxjyM5z8,3200
111
+ tests/examples/test_sudokus.py,sha256=6GTt75Fl3f08VdajyD9o1q_ngiOq_cIWPcS0JjZEHdI,1898
112
+ tests/examples/test_tsp.py,sha256=vn9oss3KCEpDm_rZaTtfLc_lBoX_hzqpRD0SgAZSr8Q,2291
113
+ tests/heuristics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
114
+ tests/heuristics/test_max_value_dom_heuristic.py,sha256=B_9jYk00H3g2UBrVfHIBc-11XtfH_YIoFSOseEPtvO4,962
115
+ tests/heuristics/test_mid_value_dom_heuristic.py,sha256=fpo98vU-urqNowpRJAEFbFDNr7kwG47q4clZ0Wjhv98,977
116
+ tests/heuristics/test_min_value_dom_heuristic.py,sha256=Bf52n5s-y90seapxjXHbH8RKlUNQgKmqjhkwhqaZcl4,962
117
+ tests/problems/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
118
+ tests/problems/test_circuit_problem.py,sha256=JiT8fDy5jWWqjpEKjoP0-UDfP9AwZxuj1pkafJEaNDE,1502
119
+ tests/problems/test_permutation_problem.py,sha256=x7oDCyobulrCUjd7WYK5SJmJZozH01FnX0jOEwnX3Sg,1375
120
+ tests/problems/test_problem.py,sha256=7T65Irj8C0rjM2UnAfwvcX8PvnaNFbsV7MoHbHkBgsA,1611
121
+ tests/propagators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
122
+ tests/propagators/test_affine_eq.py,sha256=3DAz4eTNeecGZc9WO77c5iLsSgrGnYxV8Cl6SR9dpiA,2748
123
+ tests/propagators/test_affine_geq.py,sha256=8IG290rjT6A4SevKnaTb7l7dmtcwKpljyZBfRFGkTZc,1863
124
+ tests/propagators/test_affine_leq.py,sha256=5YZdUpVMadWVqB9k0aGMCAdxmvpPJR7RyyEuycVq8W0,1838
125
+ tests/propagators/test_alldifferent.py,sha256=cTK4Fg9LZaA47pbmpRvSHJqvDu6ts7CkvFxv9sMAYtU,2434
126
+ tests/propagators/test_count_eq.py,sha256=d__FnHuTdTuUDxhYGTTLBobm4v6W6jlM29oMRRby5MY,2778
127
+ tests/propagators/test_element_iv.py,sha256=0rgC5ui_cLDDanU_W7oTIEfFFn6nU4GYNGe4rhz7v2o,1619
128
+ tests/propagators/test_element_lic.py,sha256=_55NUVFchU59Z89h-cYkgG8uTnpPDDfPZkHSXmCTCMo,1633
129
+ tests/propagators/test_element_liv.py,sha256=Xs2BG1ppIQzDX9K8StmLc3CvwrSC2cxgt8cDkyo-IOw,2019
130
+ tests/propagators/test_exactly_eq.py,sha256=lMsPYBWcJfkXb_z4uzAD9tNUHYCFV5Viua0t5C_CufM,2046
131
+ tests/propagators/test_gcc.py,sha256=VwKU8unRjvw7uxn0VNvl-9iKovz9g3aeRoWwiIDq-t0,2784
132
+ tests/propagators/test_lexicographic_leq.py,sha256=b2s8y5xIrrlydnX83IquR-bEMp-OfEcNeOdiFAYmf_4,3587
133
+ tests/propagators/test_max_eq.py,sha256=4Q4eql1IJDDvfE0QsIIfVjKcUBLinzOagPZ_F11wrjI,2048
134
+ tests/propagators/test_max_leq.py,sha256=FtTJXZ6ux_Rod31Vbt6Yk0aQVYVSPqIvyJYqEo786hk,2139
135
+ tests/propagators/test_min_eq.py,sha256=i1oXyAidSCP52g9si4kmja2BFwZu0p0MhpPbP-AobeA,2048
136
+ tests/propagators/test_min_geq.py,sha256=g8H5qtrrXROWg7dOppNhOAsILBRRkslYf2hSozlUTsA,2139
137
+ tests/propagators/test_no_sub_cycle.py,sha256=UleY08obAYNtzze9fAyXjmmDRpyuYDfPxBlB1FaFTP4,1465
138
+ tests/propagators/test_relation.py,sha256=k8yCUMtBs-PHYV-eVe6lvUFYnWXHeJNcZYDTbD46PVI,2822
139
+ tests/propagators/test_scc.py,sha256=ZnQYmQqA4wLwDjTHXerzf07EAyMgPedaEn-i3cVVfOw,1401
140
+ tests/solvers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
141
+ tests/solvers/test_backtrack_solver.py,sha256=rRceFxlS-BCzRQ1r0r_M2AhAy_ivmDAlyQWqCuhKG5k,4516
142
+ tests/solvers/test_multiprocessing_solver.py,sha256=dcMRlIXvMtq3-xkHAN4r-t4fxgq9RdLkg5Swgp15Cxk,2824
143
+ NuCS-4.4.4.dist-info/LICENSE.md,sha256=MqbogGRoftDA7kJ5LzCwNDT8JE4nJZbdB7NN0dPvklE,1072
144
+ NuCS-4.4.4.dist-info/METADATA,sha256=dAbtswGq9JPI3Y6LbXL9RnlzmzOjNGaKA04P-B2ouQs,7246
145
+ NuCS-4.4.4.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
146
+ NuCS-4.4.4.dist-info/top_level.txt,sha256=rlOWPmROiPsaCDsuV3R_Eie_jj1rBdsD4FdFqJU6nEo,16
147
+ NuCS-4.4.4.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.6.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ docs
2
+ nucs
3
+ tests
docs/source/conf.py ADDED
@@ -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
nucs/__init__.py ADDED
File without changes
nucs/constants.py ADDED
@@ -0,0 +1,127 @@
1
+ ###############################################################################
2
+ # __ _ _____ _____
3
+ # | \ | | / ____| / ____|
4
+ # | \| | _ _ | | | (___
5
+ # | . ` | | | | | | | \___ \
6
+ # | |\ | | |_| | | |____ ____) |
7
+ # |_| \_| \__,_| \_____| |_____/
8
+ #
9
+ # Fast constraint solving in Python - https://github.com/yangeorget/nucs
10
+ #
11
+ # Copyright 2024 - Yan Georget
12
+ ###############################################################################
13
+ import os
14
+
15
+ from numba import bool, int32, int64, types, uint8, uint16 # type: ignore
16
+
17
+ OPTIM_RESET = "RESET"
18
+ OPTIM_PRUNE = "PRUNE"
19
+ OPTIM_MODES = [OPTIM_RESET, OPTIM_PRUNE]
20
+
21
+ RG_START = 0 # index corresponding the start of a values range
22
+ RG_END = 1 # index corresponding the end of a values range
23
+
24
+ MIN = 0 # min value of a domain
25
+ MAX = 1 # max value of a domain
26
+
27
+ DOM_UPDATE_IDX = 0
28
+ DOM_UPDATE_EVENTS = 1
29
+
30
+ EVENT_MASK_MIN = 1 << 0
31
+ EVENT_MASK_MAX = 1 << 1
32
+ EVENT_MASK_GROUND = 1 << 2
33
+ EVENT_MASK_MIN_MAX = EVENT_MASK_MIN | EVENT_MASK_MAX
34
+ EVENT_MASK_MIN_GROUND = EVENT_MASK_MIN | EVENT_MASK_GROUND
35
+ EVENT_MASK_MAX_GROUND = EVENT_MASK_MAX | EVENT_MASK_GROUND
36
+ EVENT_MASK_MIN_MAX_GROUND = EVENT_MASK_MIN | EVENT_MASK_MAX | EVENT_MASK_GROUND
37
+
38
+
39
+ PROP_INCONSISTENCY = 0 # returned by a propagator when inconsistent
40
+ PROP_CONSISTENCY = 1 # returned by a propagator when consistent
41
+ PROP_ENTAILMENT = 2 # returned by a propagator when entailed
42
+
43
+ PROBLEM_INCONSISTENT = 0 # returned when the filtering of a problem detects an inconsistency
44
+ PROBLEM_UNBOUND = 1 # returned when the filtering of a problem has been completed but the problem is not solved
45
+ PROBLEM_BOUND = 2 # returned when a problem is solved
46
+
47
+ SIGNATURE_COMPUTE_DOMAINS = int64(int32[:, :], int32[:]) # domains, parameters
48
+ SIGNATURE_CONSISTENCY_ALG = int64(
49
+ int64[:], # statistics
50
+ uint8[:], # algorithms
51
+ uint16[:, :], # var_bounds
52
+ uint16[:, :], # param_bounds
53
+ uint16[:], # dom_indices_arr
54
+ int32[:], # dom_offsets_arr
55
+ uint16[:], # props_dom_indices
56
+ int32[:, :], # props_dom_offsets
57
+ int32[:], # props_parameters
58
+ uint8[:, :], # shr_domains_propagators
59
+ int32[:, :, :], # shr_domains_stack
60
+ bool[:, :], # not_entailed_propagators_stack
61
+ uint16[:, :], # dom_update_stack
62
+ uint8[:], # stacks_top
63
+ bool[:], # triggered_propagators
64
+ int64[:], # compute_domains_addrs
65
+ uint16[:], # decision_domains
66
+ )
67
+ SIGNATURE_DOM_HEURISTIC = int64(
68
+ int32[:, :, :], # shr_domains_stack
69
+ bool[:, :], # not_entailed_propagators_stack
70
+ uint16[:, :], # dom_update_stack
71
+ uint8[:], # stacks_top
72
+ int64, # dom_idx
73
+ int64[:, :], # dom_heuristic_params
74
+ )
75
+ SIGNATURE_VAR_HEURISTIC = int64(
76
+ uint16[:], # decision_variables
77
+ int32[:, :, :], # shr_domains_stack
78
+ uint8[:], # stacks_top
79
+ int64[:, :], # var_heuristic_params
80
+ )
81
+
82
+
83
+ TYPE_COMPUTE_DOMAINS = types.FunctionType(SIGNATURE_COMPUTE_DOMAINS)
84
+ TYPE_DOM_HEURISTIC = types.FunctionType(SIGNATURE_DOM_HEURISTIC)
85
+ TYPE_VAR_HEURISTIC = types.FunctionType(SIGNATURE_VAR_HEURISTIC)
86
+ TYPE_CONSISTENCY_ALG = types.FunctionType(SIGNATURE_CONSISTENCY_ALG)
87
+
88
+ NUMBA_DISABLE_JIT = os.getenv("NUMBA_DISABLE_JIT")
89
+
90
+ LOG_FORMAT = "[ %(asctime)s | %(processName)s | %(levelname)s ] %(name)s.%(funcName)s - %(message)s"
91
+ LOG_LEVEL_DEBUG = "DEBUG"
92
+ LOG_LEVEL_INFO = "INFO"
93
+ LOG_LEVEL_WARNING = "WARNING"
94
+ LOG_LEVEL_ERROR = "ERROR"
95
+ LOG_LEVEL_CRITICAL = "CRITICAL"
96
+ LOG_LEVELS = [LOG_LEVEL_DEBUG, LOG_LEVEL_INFO, LOG_LEVEL_WARNING, LOG_LEVEL_ERROR, LOG_LEVEL_CRITICAL]
97
+
98
+ STATS_MAX = 13
99
+ (
100
+ STATS_IDX_ALG_BC_NB,
101
+ STATS_IDX_ALG_BC_WITH_SHAVING_NB,
102
+ STATS_IDX_ALG_SHAVING_NB,
103
+ STATS_IDX_ALG_SHAVING_CHANGE_NB,
104
+ STATS_IDX_ALG_SHAVING_NO_CHANGE_NB,
105
+ STATS_IDX_PROPAGATOR_ENTAILMENT_NB,
106
+ STATS_IDX_PROPAGATOR_FILTER_NB,
107
+ STATS_IDX_PROPAGATOR_FILTER_NO_CHANGE_NB,
108
+ STATS_IDX_PROPAGATOR_INCONSISTENCY_NB,
109
+ STATS_IDX_SOLVER_BACKTRACK_NB,
110
+ STATS_IDX_SOLVER_CHOICE_NB,
111
+ STATS_IDX_SOLVER_CHOICE_DEPTH,
112
+ STATS_IDX_SOLVER_SOLUTION_NB,
113
+ ) = tuple(range(STATS_MAX))
114
+
115
+ STATS_LBL_ALG_BC_NB = "ALG_BC_NB"
116
+ STATS_LBL_ALG_BC_WITH_SHAVING_NB = "ALG_BC_WITH_SHAVING_NB"
117
+ STATS_LBL_ALG_SHAVING_NB = "ALG_SHAVING_NB"
118
+ STATS_LBL_ALG_SHAVING_CHANGE_NB = "ALG_SHAVING_CHANGE_NB"
119
+ STATS_LBL_ALG_SHAVING_NO_CHANGE_NB = "ALG_SHAVING_NO_CHANGE_NB"
120
+ STATS_LBL_PROPAGATOR_ENTAILMENT_NB = "PROPAGATOR_ENTAILMENT_NB"
121
+ STATS_LBL_PROPAGATOR_FILTER_NB = "PROPAGATOR_FILTER_NB"
122
+ STATS_LBL_PROPAGATOR_FILTER_NO_CHANGE_NB = "PROPAGATOR_FILTER_NO_CHANGE_NB"
123
+ STATS_LBL_PROPAGATOR_INCONSISTENCY_NB = "PROPAGATOR_INCONSISTENCY_NB"
124
+ STATS_LBL_SOLVER_BACKTRACK_NB = "SOLVER_BACKTRACK_NB"
125
+ STATS_LBL_SOLVER_CHOICE_NB = "SOLVER_CHOICE_NB"
126
+ STATS_LBL_SOLVER_CHOICE_DEPTH = "SOLVER_CHOICE_DEPTH"
127
+ STATS_LBL_SOLVER_SOLUTION_NB = "SOLVER_SOLUTION_NB"
File without changes
File without changes
@@ -0,0 +1,37 @@
1
+ ###############################################################################
2
+ # __ _ _____ _____
3
+ # | \ | | / ____| / ____|
4
+ # | \| | _ _ | | | (___
5
+ # | . ` | | | | | | | \___ \
6
+ # | |\ | | |_| | | |____ ____) |
7
+ # |_| \_| \__,_| \_____| |_____/
8
+ #
9
+ # Fast constraint solving in Python - https://github.com/yangeorget/nucs
10
+ #
11
+ # Copyright 2024 - Yan Georget
12
+ ###############################################################################
13
+ import argparse
14
+
15
+ from rich import print
16
+
17
+ from nucs.constants import LOG_LEVEL_INFO, LOG_LEVELS
18
+ from nucs.examples.alpha.alpha_problem import AlphaProblem
19
+ from nucs.heuristics.heuristics import DOM_HEURISTIC_MIN_VALUE, VAR_HEURISTIC_SMALLEST_DOMAIN
20
+ from nucs.solvers.backtrack_solver import BacktrackSolver
21
+
22
+ # Run with the following command (the second run is much faster because the code has been compiled):
23
+ # NUMBA_CACHE_DIR=.numba/cache python -m nucs.examples.alpha
24
+ if __name__ == "__main__":
25
+ parser = argparse.ArgumentParser()
26
+ parser.add_argument("--log_level", choices=LOG_LEVELS, default=LOG_LEVEL_INFO)
27
+ args = parser.parse_args()
28
+ problem = AlphaProblem()
29
+ solver = BacktrackSolver(
30
+ problem,
31
+ var_heuristic_idx=VAR_HEURISTIC_SMALLEST_DOMAIN,
32
+ dom_heuristic_idx=DOM_HEURISTIC_MIN_VALUE,
33
+ log_level=args.log_level,
34
+ )
35
+ solutions = solver.find_all()
36
+ print(solver.get_statistics())
37
+ print(problem.solution_as_dict(solutions[0]))