Skip to content

Commit

Permalink
Adding choco (#413)
Browse files Browse the repository at this point in the history
* Creating branch and first tries

* add choco as choice

* Update choco.py

* canonical_comparison transformation

* new transformation used in linearize

* solve and most in post_constraint

* first version of post_constraint()

* all supported global constraints

* objective + solve()

* Update __init__.py

* Update utils.py

* corrections

* correct input to Choco

* solveall() + time_limit exception

* remove unsupported

* remove of only_bv_implies + add indomain + remove unneeded stuff

* fix finding optimal solution

* tests for choco

* cover all cases in tests

* forgotten skip

* remove unneeded checks + cover modulo extreme case

* only_bv_reifies

* reification + implications + correct transformations + cover cases for choco sytax

* remove part from only_bv_implies

* remove only_bv_implies test due to changes

* pychoco has a bug on finding all optimal solutions

* choco wants int and not np.int64

* correct solveAll count

* only_bv_reifies

* canonical comparison transformation

* choco 1 0 instead of True False

* only_implies

* minor

* minor

* minor

* choco docs

* style

* test_only_implies

* change order of transformations

* bring vars to left side in all cases

* handling True and False cases

* translate int to bool for bool variables

* minor

* fix count()

* np.array().tolist()

* polishing

* avoid flatten_objective

* cover case of list of vars in demand for cumulative

* to_var() + covering cases in input for constraints

* take all cases into account

* change order of transform

* cover case for sub

* time limit + finding all optimal solutions

* Move -IV (operator) correctly to lhs

* dealing with 'sub'

* dealing with sub

* canonical_comparison after flatten

* use is_boolexpr is stead of .is_bool

* cover all cases in min, max, abs

* fix count

* div and mod

* cover all cases for element

* Choco Exceptions

* checks in to_var and to_vars

* replicate code to to_var and to_vars

* Bounds and ints are int32 - checks

* ChocoTypeException

* use of is_int()

* convert numbers to int

* some from feedback

* ensure only_numexpr also works in reified

* ensure bv -> bv is not added twice

* update posting interface

* update with new interface

* add n_values constraint

* bounds are always int

* duration can be either var or int

* add Inverse to tests

* cleanup objective posting

* forgot import

* proper translation of status

* ensure always int when making constant_var

* rename and cleanup to_var

* added clarification why constraint can be None

* restructure and cleanup _get_constraint function

* exclude inverse from choco tests

* avoid creating too many vars

* minor fixes

* exclude inverse from Bool solvers

* change inverse tes

* typo

* fix mistake in implied cons

* fix choco tests

* Update test_constraints.py

* remove inverse test - separate PR

* remove inverse tests part 2

* add choco to github tests

---------

Co-authored-by: wout4 <wout.vanroose@gmail.com>
Co-authored-by: ignace <ignace.bleukx@kuleuven.be>
  • Loading branch information
3 people authored Mar 25, 2024
1 parent 83c1ac5 commit 6ec19f8
Show file tree
Hide file tree
Showing 11 changed files with 744 additions and 19 deletions.
1 change: 1 addition & 0 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
pip install z3-solver
pip install exact
pip install pysdd
pip install pychoco
sudo snap install minizinc --classic
pip install minizinc
- name: Test with pytest
Expand Down
6 changes: 6 additions & 0 deletions cpmpy/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ class MinizincNameException(CPMpyException):
class MinizincBoundsException(CPMpyException):
pass

class ChocoTypeException(CPMpyException):
pass

class ChocoBoundsException(CPMpyException):
pass

class NotSupportedError(CPMpyException):
pass

Expand Down
4 changes: 4 additions & 0 deletions cpmpy/solvers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
pysdd
z3
exact
choco
utils
===============
Expand All @@ -33,6 +34,7 @@
CPM_pysdd
CPM_z3
CPM_exact
CPM_choco
=================
List of functions
Expand All @@ -51,3 +53,5 @@
from .pysdd import CPM_pysdd
from .z3 import CPM_z3
from .exact import CPM_exact
from .choco import CPM_choco

Loading

0 comments on commit 6ec19f8

Please sign in to comment.