Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: CPMpy/cpmpy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.5.2
Choose a base ref
...
head repository: CPMpy/cpmpy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Loading
Showing with 54,147 additions and 2,873 deletions.
  1. +5 −15 .github/workflows/pypi-release.yml
  2. +19 −32 .github/workflows/python-test.yml
  3. +11 −1 .gitignore
  4. +13 −4 .readthedocs.yml → .readthedocs.yaml
  5. +130 −112 README.md
  6. +375 −0 changelog.md
  7. +16 −87 cpmpy/__init__.py
  8. +45 −0 cpmpy/exceptions.py
  9. +0 −491 cpmpy/expressions.py
  10. +31 −0 cpmpy/expressions/__init__.py
  11. +846 −0 cpmpy/expressions/core.py
  12. +1,025 −0 cpmpy/expressions/globalconstraints.py
  13. +470 −0 cpmpy/expressions/globalfunctions.py
  14. +177 −0 cpmpy/expressions/python_builtins.py
  15. +216 −0 cpmpy/expressions/utils.py
  16. +777 −0 cpmpy/expressions/variables.py
  17. +0 −19 cpmpy/globalconstraints.py
  18. +295 −98 cpmpy/model.py
  19. 0 cpmpy/model_tools/__init__.py
  20. +0 −298 cpmpy/model_tools/flatten_model.py
  21. +0 −36 cpmpy/model_tools/get_variables.py
  22. +0 −1 cpmpy/solver_interfaces/__init__.py
  23. +0 −14 cpmpy/solver_interfaces/__util.py
  24. +0 −103 cpmpy/solver_interfaces/minizinc_python.py
  25. +0 −138 cpmpy/solver_interfaces/minizinc_text.py
  26. +0 −240 cpmpy/solver_interfaces/ortools_python.py
  27. +0 −1 cpmpy/solver_interfaces/psyat_python.py
  28. +0 −98 cpmpy/solver_interfaces/solver_interface.py
  29. +462 −0 cpmpy/solvers/TEMPLATE.py
  30. +71 −0 cpmpy/solvers/__init__.py
  31. +619 −0 cpmpy/solvers/choco.py
  32. +516 −0 cpmpy/solvers/cpo.py
  33. +584 −0 cpmpy/solvers/exact.py
  34. +667 −0 cpmpy/solvers/gcs.py
  35. +540 −0 cpmpy/solvers/gurobi.py
  36. +783 −0 cpmpy/solvers/minizinc.py
  37. +792 −0 cpmpy/solvers/ortools.py
  38. +498 −0 cpmpy/solvers/pysat.py
  39. +398 −0 cpmpy/solvers/pysdd.py
  40. +362 −0 cpmpy/solvers/solver_interface.py
  41. +179 −0 cpmpy/solvers/utils.py
  42. +506 −0 cpmpy/solvers/z3.py
  43. +18 −0 cpmpy/tools/__init__.py
  44. +127 −0 cpmpy/tools/dimacs.py
  45. +26 −0 cpmpy/tools/explain/__init__.py
  46. +92 −0 cpmpy/tools/explain/marco.py
  47. +62 −0 cpmpy/tools/explain/mcs.py
  48. +115 −0 cpmpy/tools/explain/mss.py
  49. +301 −0 cpmpy/tools/explain/mus.py
  50. +38 −0 cpmpy/tools/explain/utils.py
  51. +81 −0 cpmpy/tools/maximal_propagate.py
  52. +3 −0 cpmpy/tools/mus.py
  53. +173 −0 cpmpy/tools/tune_solver.py
  54. +42 −0 cpmpy/transformations/__init__.py
  55. +84 −0 cpmpy/transformations/comparison.py
  56. +305 −0 cpmpy/transformations/decompose_global.py
  57. +557 −0 cpmpy/transformations/flatten_model.py
  58. +107 −0 cpmpy/transformations/get_variables.py
  59. +661 −0 cpmpy/transformations/linearize.py
  60. +140 −0 cpmpy/transformations/negation.py
  61. +241 −0 cpmpy/transformations/normalize.py
  62. +188 −0 cpmpy/transformations/reification.py
  63. +251 −0 cpmpy/transformations/safening.py
  64. +82 −0 cpmpy/transformations/to_cnf.py
  65. +0 −1 cpmpy/utils/__init__.py
  66. +0 −8 cpmpy/utils/exceptions.py
  67. +0 −138 cpmpy/variables.py
  68. +8 −0 docs/README.md
  69. +110 −0 docs/adding_solver.md
  70. +4 −3 docs/api/expressions.rst
  71. +7 −0 docs/api/expressions/core.rst
  72. +7 −0 docs/api/expressions/globalconstraints.rst
  73. +7 −0 docs/api/expressions/globalfunctions.rst
  74. +7 −0 docs/api/expressions/python_builtins.rst
  75. +7 −0 docs/api/expressions/utils.rst
  76. +8 −0 docs/api/expressions/variables.rst
  77. +0 −6 docs/api/globalconstraints.rst
  78. +5 −4 docs/api/model.rst
  79. +0 −15 docs/api/solver_interfaces.rst
  80. +8 −0 docs/api/solvers.rst
  81. +7 −0 docs/api/solvers/choco.rst
  82. +7 −0 docs/api/solvers/cpo.rst
  83. +7 −0 docs/api/solvers/exact.rst
  84. +7 −0 docs/api/solvers/gcs.rst
  85. +7 −0 docs/api/solvers/gurobi.rst
  86. +7 −0 docs/api/solvers/minizinc.rst
  87. +7 −0 docs/api/solvers/ortools.rst
  88. +7 −0 docs/api/solvers/pysat.rst
  89. +7 −0 docs/api/solvers/pysdd.rst
  90. +7 −0 docs/api/solvers/solver_interface.rst
  91. +7 −0 docs/api/solvers/utils.rst
  92. +7 −0 docs/api/solvers/z3.rst
  93. +6 −0 docs/api/tools.rst
  94. +7 −0 docs/api/tools/dimacs.rst
  95. +39 −0 docs/api/tools/explain.rst
  96. +7 −0 docs/api/tools/explain/marco.rst
  97. +7 −0 docs/api/tools/explain/mcs.rst
  98. +7 −0 docs/api/tools/explain/mss.rst
  99. +7 −0 docs/api/tools/explain/mus.rst
  100. +7 −0 docs/api/tools/explain/utils.rst
  101. +7 −0 docs/api/tools/maximal_propagate.rst
  102. +7 −0 docs/api/tools/tune_solver.rst
  103. +18 −0 docs/api/transformations.rst
  104. +9 −0 docs/api/transformations/comparison.rst
  105. +7 −0 docs/api/transformations/decompose_global.rst
  106. +7 −0 docs/api/transformations/flatten_model.rst
  107. +7 −0 docs/api/transformations/get_variables.rst
  108. +7 −0 docs/api/transformations/linearize.rst
  109. +7 −0 docs/api/transformations/negation.rst
  110. +7 −0 docs/api/transformations/normalize.rst
  111. +7 −0 docs/api/transformations/reification.rst
  112. +7 −0 docs/api/transformations/safening.rst
  113. +7 −0 docs/api/transformations/to_cnf.rst
  114. +0 −6 docs/api/variables.rst
  115. +183 −0 docs/beginner_tutorial.rst
  116. +24 −10 docs/{preface → }/behind_the_scenes.rst
  117. +34 −15 docs/conf.py
  118. +67 −0 docs/developers.md
  119. +37 −0 docs/docs_todo.md
  120. +0 −4 docs/examples/all_examples.rst
  121. +0 −167 docs/examples/explaining_smm.ipynb
  122. +0 −57 docs/examples/explaining_smm.md
  123. +166 −0 docs/how_to_debug.md
  124. +105 −19 docs/index.rst
  125. +57 −0 docs/installation_instructions.rst
  126. +806 −0 docs/modeling.md
  127. +160 −0 docs/multiple_solutions.md
  128. +0 −95 docs/preface/cppy_intro.md
  129. +0 −5 docs/preface/overview.rst
  130. +1 −0 docs/requirements.in
  131. +5 −1 docs/requirements.txt
  132. +91 −0 docs/solver_parameters.md
  133. +180 −0 docs/solvers.md
  134. +157 −0 docs/summary.rst
  135. +48 −0 docs/unsat_core_extraction.md
  136. BIN docs/waterfall.png
  137. +134 −0 examples/README.md
  138. +534 −0 examples/advanced/VRP by learning from historical data.ipynb
  139. +257 −0 examples/advanced/counterfactual_explain.py
  140. +190 −0 examples/advanced/cp_explanations.py
  141. +38 −0 examples/advanced/diverse_solutions.py
  142. +82 −0 examples/advanced/exact_maximal_propagate.py
  143. +399 −0 examples/advanced/explain_stepwise_csp.ipynb
  144. +61 −0 examples/advanced/hyperparameter_search.py
  145. +211 −0 examples/advanced/marco_musmss_enumeration.py
  146. +42 −0 examples/advanced/musx.py
  147. +277 −0 examples/advanced/ocus_explanations.py
  148. +42 −0 examples/advanced/ortools_presolve_propagate.py
  149. +906 −0 examples/advanced/predict_plus_optimize.ipynb
  150. +71 −0 examples/advanced/quickxplain.py
  151. +869 −0 examples/advanced/visual_sudoku.ipynb
  152. BIN examples/assets/automaton.png
  153. +39 −0 examples/assets/room_assignment.csv
  154. BIN examples/assets/t-rex.png
  155. BIN examples/assets/visual_sudoku_lenet_mnist_weights.pt
  156. +50 −0 examples/bibd.py
  157. +249 −0 examples/blocks_world.py
  158. +7 −6 examples/bus_schedule.py
  159. +312 −0 examples/car_sequencing.ipynb
  160. +201 −0 examples/chess-recognition.py
  161. +2,634 −0 examples/csplib/prob001_car_sequence.json
  162. +107 −0 examples/csplib/prob001_car_sequence.py
  163. +149 −0 examples/csplib/prob001_convert_data.py
  164. +64 −0 examples/csplib/prob002_template_design.json
  165. +119 −0 examples/csplib/prob002_template_design.py
  166. +56 −0 examples/csplib/prob005_auto_correlation.py
  167. +65 −0 examples/csplib/prob006_golomb.py
  168. +73 −0 examples/csplib/prob007_all_interval.py
  169. +30 −0 examples/csplib/prob008_vessel_loading.json
  170. +109 −0 examples/csplib/prob008_vessel_loading.py
  171. +46 −0 examples/csplib/prob009_perfect_squares.json
  172. +111 −0 examples/csplib/prob009_perfect_squares.py
  173. +119 −0 examples/csplib/prob010_social_golfers.py
  174. +185 −0 examples/csplib/prob011_basketball_schedule.py
  175. +724 −0 examples/csplib/prob012_nonogram.json
  176. +126 −0 examples/csplib/prob012_nonogram.py
  177. +72 −0 examples/csplib/prob013_progressive_party.json
  178. +114 −0 examples/csplib/prob013_progressive_party.py
  179. +46 −0 examples/csplib/prob015_shur_lemma.py
  180. +54 −0 examples/csplib/prob019_magic_sequence.py
  181. +75 −0 examples/csplib/prob024_langford.py
  182. +69 −0 examples/csplib/prob026_sport_scheduling.py
  183. +76 −0 examples/csplib/prob028_bibd.py
  184. +73 −0 examples/csplib/prob033_word_design.py
  185. +70 −0 examples/csplib/prob044_steiner.py
  186. +58 −0 examples/csplib/prob049_number_partitioning.py
  187. +96 −0 examples/csplib/prob050_diamond_free.py
  188. +59 −0 examples/csplib/prob053_gracefull_graphs.py
  189. +59 −0 examples/csplib/prob054_n_queens.py
  190. +95 −0 examples/csplib/prob076_costas_arrays.py
  191. +50 −0 examples/csplib/prob084_hadamard_matrix.py
  192. +75 −0 examples/flexible_jobshop.py
  193. +11 −10 { → examples}/frietkot.py
  194. +157 −0 examples/graph_coloring.ipynb
  195. +64 −0 examples/jobshop.py
  196. +12 −10 examples/knapsack.py
  197. +91 −0 examples/lpcp21_p1_frog.py
  198. +184 −0 examples/map_coloring_oz.ipynb
  199. +14 −15 examples/mario.py
  200. +70 −0 examples/minesweeper.py
  201. +344 −0 examples/nonogram_ortools.ipynb
  202. +121 −0 examples/npuzzle.py
  203. +49 −0 examples/nqueens.py
  204. +334 −0 examples/nqueens_1000.ipynb
  205. +205 −0 examples/packing_rectangles.ipynb
  206. +31 −0 examples/palindrome_days.py
  207. +54 −0 examples/pareto_optimal.py
  208. +82 −0 examples/pctsp_ortools.py
  209. +91 −21 examples/quickstart_sudoku.ipynb
  210. +57 −0 examples/rcpsp.py
  211. +1,269 −0 examples/room_assignment.ipynb
  212. +196 −0 examples/scheduling.ipynb
  213. +9 −8 examples/send_more_money.py
  214. +314 −0 examples/set_game.ipynb
  215. +23 −11 examples/sudoku.py
  216. +140 −0 examples/sudoku_chockablock.py
  217. +126 −0 examples/sudoku_ratrun1.py
  218. +106 −0 examples/sudoku_removeandrepeat.py
  219. +97 −0 examples/sudoku_schrodingers_flatmates.py
  220. +313 −0 examples/tsp.ipynb
  221. +62 −0 examples/tsp.py
  222. +14 −0 examples/tutorial/README.md
  223. BIN examples/tutorial/cpmpy_tutorial_cp21.pdf
  224. +211 −0 examples/tutorial/marco_musmss_enumeration.py
  225. +283 −0 examples/tutorial/ocus_explanations.py
  226. +1,397 −0 examples/tutorial/part1.ipynb
  227. +577 −0 examples/tutorial/part2.ipynb
  228. +7,918 −0 examples/tutorial_ijcai22/1_room_assignment_incr.ipynb
  229. +162 −0 examples/tutorial_ijcai22/2_multi_solver_knapsack.ipynb
  230. +340 −0 examples/tutorial_ijcai22/3_musx.ipynb
  231. +284 −0 examples/tutorial_ijcai22/4_marco-mus-mcs-enumeration.ipynb
  232. +357 −0 examples/tutorial_ijcai22/5_ocus_explanations.ipynb
  233. +560 −0 examples/tutorial_ijcai22/6_explain_sudoku.ipynb
  234. +281 −0 examples/tutorial_ijcai22/7_counterfactual_explain.ipynb
  235. +25 −0 examples/tutorial_ijcai22/README.md
  236. BIN examples/tutorial_ijcai22/part1_solvers_as_oracle.pdf
  237. BIN examples/tutorial_ijcai22/part2_explaining_unsat_sat.pdf
  238. BIN examples/tutorial_ijcai22/part3_explaining_optimisation.pdf
  239. +2,295 −0 examples/vehicle_routing.ipynb
  240. +90 −0 examples/vrp.py
  241. +89 −0 examples/vrp_ortools.py
  242. +24 −25 examples/who_killed_agatha.py
  243. +61 −0 examples/wolf_goat_cabbage.py
  244. +75 −0 examples/zebra.py
  245. 0 extras/place_holder.py
  246. +0 −327 flatten.ipynb
  247. +3 −3 requirements.txt
  248. +42 −5 setup.py
  249. +129 −0 tests/test_builtins.py
  250. +313 −0 tests/test_constraints.py
  251. +143 −0 tests/test_direct.py
  252. +58 −6 tests/test_examples.py
  253. +607 −9 tests/test_expressions.py
  254. +171 −39 tests/test_flatten.py
  255. +1,307 −6 tests/test_globalconstraints.py
  256. +14 −0 tests/test_inequality_chaining.py
  257. +118 −0 tests/test_model.py
  258. +211 −0 tests/test_pysat_cardinality.py
  259. +67 −0 tests/test_pysat_interrupt.py
  260. +98 −0 tests/test_pysat_wsum.py
  261. +57 −0 tests/test_solveAll.py
  262. +89 −0 tests/test_solverinterface.py
  263. +854 −10 tests/test_solvers.py
  264. +41 −0 tests/test_solvers_solhint.py
  265. +76 −0 tests/test_tocnf.py
  266. +102 −0 tests/test_tool_dimacs.py
  267. +204 −0 tests/test_tools_mus.py
  268. +76 −0 tests/test_tools_tuner.py
  269. +580 −0 tests/test_trans_linearize.py
  270. +136 −0 tests/test_trans_safen.py
  271. +135 −0 tests/test_trans_simplify.py
  272. +29 −0 tests/test_transf_comp.py
  273. +104 −0 tests/test_transf_decompose.py
  274. +98 −0 tests/test_transf_reif.py
  275. +91 −20 tests/test_variables.py
20 changes: 5 additions & 15 deletions .github/workflows/pypi-release.yml
Original file line number Diff line number Diff line change
@@ -9,13 +9,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
ref: master
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
@@ -24,12 +23,9 @@ jobs:
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
TWINE_TEST_PASSWORD: ${{ secrets.PYPI_TEST_API_TOKEN }}
TESTPYPI_REPO: https://test.pypi.org/legacy/
PYPI_REPO: https://upload.pypi.org/legacy/
run: |
python setup.py sdist bdist_wheel
twine upload --repository-url $TESTPYPI_REPO -u $TWINE_USERNAME -p $TWINE_TEST_PASSWORD dist/*
twine upload --repository-url $PYPI_REPO dist/*
# - name: Install pypa/build
# run: >-
@@ -44,13 +40,7 @@ jobs:
# --sdist
# --wheel
# --outdir dist/
# .
# - name: Publish distribution to Test PyPI
# uses: pypa/gh-action-pypi-publish@master
# with:
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository_url: https://test.pypi.org/legacy/
# - name: Publish distribution to PyPI
# uses: pypa/gh-action-pypi-publish@master
# with:
# password: ${{ secrets.PYPI_API_TOKEN }}
# password: ${{ secrets.PYPI_API_TOKEN }}
51 changes: 19 additions & 32 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,22 @@
name: Test-code
# Triggers the workflow on push or pull request events
on: [push, pull_request]

name: Github Tests
on: [push] # Can also put pull_request here, but then we dont run it when directly pushing to master
jobs:
# Set the job key. The key is displayed as the job name
# when a job name is not provided
test-current:
# Name the Job
name: Testing code base
# Set the type of machine to run on
build:
runs-on: ubuntu-latest

steps:
# Checks out a copy of your repository on the ubuntu-latest machine
- uses: actions/checkout@v2
# Runs Setup python action
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# - name: Lint with flake8
# run: |
# # stop the build if there are Python syntax errors or undefined names
# flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install ".[test, z3, choco, exact, pysat, pysdd, choco, minizinc]"
pip install pypblib # dependency of pysat for PB constraints
pip install pytest-xdist
sudo snap install minizinc --classic
- name: Test with pytest
run: |
python -m pytest -n 4 tests/
12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
changelog.md
.vscode
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
@@ -136,3 +136,13 @@ dmypy.json

# Cython debug symbols
cython_debug/
.DS_Store
bugs/

# Intellij
.idea/

# VeriPB proof log files (from Glasgow Constraint solver)
*.veripb
*.opb
*.pbp
17 changes: 13 additions & 4 deletions .readthedocs.yml → .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -2,13 +2,22 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

version: 1
version: 2

build:
os: "ubuntu-22.04"
tools:
python: "3.7"

python:
version: 3.7
install:
- requirements: docs/requirements.txt

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py
builder: html
configuration: docs/conf.py
fail_on_warning: false

formats:
- pdf
- epub
Loading