@@ -837,15 +837,12 @@ def test_installed_solvers(self, solver):
837837 ~ z
838838 )
839839
840- try :
841- model .solve (solver = solver )
842- assert [int (a ) for a in v .value ()] == [0 , 1 , 0 ]
840+ model .solve (solver = solver )
841+ assert [int (a ) for a in v .value ()] == [0 , 1 , 0 ]
843842
844- s = cp .SolverLookup .get (solver )
845- s .solve ()
846- assert [int (a ) for a in v .value ()] == [0 , 1 , 0 ]
847- except (NotImplementedError , NotSupportedError ):
848- pass
843+ s = cp .SolverLookup .get (solver )
844+ s .solve ()
845+ assert [int (a ) for a in v .value ()] == [0 , 1 , 0 ]
849846
850847 def test_time_limit (self , solver ):
851848 if solver == "pysdd" : # pysdd does not support time limit
@@ -908,21 +905,26 @@ def test_value_cleared(self, solver):
908905 sat_model = cp .Model (cp .any ([x ,y ,z ]))
909906 unsat_model = cp .Model ([x | y | z , ~ x , ~ y ,~ z ])
910907
911- try :
912- assert sat_model .solve (solver = solver )
913- for v in (x ,y ,z ):
914- assert v .value () is not None
915- assert not unsat_model .solve (solver = solver )
916- for v in (x ,y ,z ):
917- assert v .value () is None
918- except (NotImplementedError , NotSupportedError ):
919- pass
908+ assert sat_model .solve (solver = solver )
909+ for v in (x ,y ,z ):
910+ assert v .value () is not None
911+ assert not unsat_model .solve (solver = solver )
912+ for v in (x ,y ,z ):
913+ assert v .value () is None
920914
921915 def test_incremental_objective (self , solver ):
922- if solver in ("choco" , "gcs" , "rc2" ):
923- pytest .skip ("does not support incremental objective" )
924-
925916 x = cp .intvar (0 ,10 ,shape = 3 )
917+
918+ if solver == "choco" :
919+ """
920+ Choco does not support first optimizing and then adding a constraint.
921+ During optimization, additional constraints get added to the solver,
922+ which removes feasible solutions.
923+ No straightforward way to resolve this for now.
924+ """
925+ return
926+ if solver == "gcs" :
927+ return
926928 s = cp .SolverLookup .get (solver )
927929 try :
928930 s .minimize (cp .sum (x ))
@@ -981,6 +983,7 @@ def test_incremental_assumptions(self, solver):
981983 assert s .solve (assumptions = [])
982984
983985 def test_vars_not_removed (self , solver ):
986+
984987 bvs = cp .boolvar (shape = 3 )
985988 m = cp .Model ([cp .any (bvs ) <= 2 ])
986989
@@ -1008,10 +1011,7 @@ def test_vars_not_removed(self, solver):
10081011 # minizinc: ignore inconsistency warning when deliberately testing unsatisfiable model
10091012 @pytest .mark .filterwarnings ("ignore:model inconsistency detected" )
10101013 def test_false (self , solver ):
1011- try :
1012- assert not cp .Model ([cp .boolvar (), False ]).solve (solver = solver )
1013- except (NotImplementedError , NotSupportedError ):
1014- pass
1014+ assert not cp .Model ([cp .boolvar (), False ]).solve (solver = solver )
10151015
10161016 def test_partial_div_mod (self , solver ):
10171017 if solver in ("pysdd" , "pysat" , "pindakaas" , "pumpkin" , "rc2" ): # don't support div or mod with vars
@@ -1040,6 +1040,7 @@ def test_partial_div_mod(self, solver):
10401040
10411041
10421042 def test_status (self , solver ):
1043+
10431044 bv = cp .boolvar (shape = 3 , name = "bv" )
10441045 m = cp .Model (cp .any (bv ))
10451046
0 commit comments