diff --git a/cpmpy/solvers/exact.py b/cpmpy/solvers/exact.py index efb706a7c..c250cbe8a 100644 --- a/cpmpy/solvers/exact.py +++ b/cpmpy/solvers/exact.py @@ -223,6 +223,9 @@ def solveAll(self, display=None, time_limit=None, solution_limit=None, call_from timelim = time_limit if time_limit is not None else 0 if self.has_objective(): + if not call_from_model: + warnings.warn("Adding constraints to solver object to find all solutions, solver state will be invalid after this call!") + (my_status, objval) = self.xct_solver.toOptimum(timelim) # fix the solution to the optimal objective if my_status == "UNSAT": # found unsatisfiability self._fillObjAndVars() # erases the solution @@ -231,7 +234,8 @@ def solveAll(self, display=None, time_limit=None, solution_limit=None, call_from raise ValueError("Error: inconsistency during solveAll should not happen, please warn the developers of this bug") elif my_status == "TIMEOUT": # found timeout return 0 - + else: + assert my_status == "SAT", "Unexpected status from Exact" self += self.objective_ == objval # fix obj val solsfound = 0