0

Every once in a while my building time jumps from 5s to around 200. And sometimes I don't get any solution even though I got around 17 in the same time with the same data.

Is it possible to stop the solver, check if there has been a solution and if yes continue, otherwise restart, maybe with changed constraints?

This is what I got so far:

SMF.limitTime(solver, 60000);
solver.set(new ObjectiveManager<IntVar, Integer>(score, ResolutionPolicy.MINIMIZE, false));
solver.findSolution();
if(solver.isFeasible() == ESat.TRUE){
   System.out.println("first solution found");
   SMF.limitTime(solver, 180000);
   solver.nextSolution();
} else {
   //restart
}
do{
 if(solver.isFeasible() == ESat.TRUE){
     System.out.println(score.getValue());
 }
}while(solver.nextSolution());
try {
   solver.restoreLastSolution();
} catch (ContradictionException e) {
   throw new UnsupportedOperationException("restoring the last solution ended in a failure");
} finally {
   solver.getEngine().flush();
}

But the limit that is used is still one minute and is not increased to three after the first solution is found.

Is there a way to do that? And how can I restart the solver?

A related question: If I do get a solution, restored that solution but I think with a little bit more time I would get a better one, can I start a solver with this solution as the starting point?

Dora
  • 47
  • 1
  • 8
  • A bit offtopic, but where did you learn how to use different search strategies? In the Choco quickguide I found little information in this matter and I need to learn this. By the way, shouldn't you call `SMF.limitTime()` before calling `solver.findSolution()`? – dabadaba Mar 28 '16 at 09:05
  • I haven't really learned that, that is one thing that really frustrates me with choco. I am currently using solver.set(IntStrategyFactory.domOverWDeg(ArrayUtils.flatten(as), System.currentTimeMillis())); but I have no idea if there are ones that are better suited. And I do set the time limit before findsolution, but with the second one I wanted to change the time limit, which is not working. That is part of my question. – Dora Mar 28 '16 at 09:50
  • I don't think you can modify the time limit after starting the solution process can you? And back to my first question. Alright so we're in the same situation haha, I am also using `domgOverWDeg` but still... I can see you used `solver.set(new ObjectiveManager())`. What does it do? Where did you learn that? I am sure that has something to do with search strategies because the `Solver.set` method method is used precisely to set strategies. – dabadaba Mar 28 '16 at 12:37
  • I got that from here http://choco-solver.org/user_guide/4_advanced.html to 1) optimize without having to use findoptimalsolution and 2) to use walking with the "false" at the end, so that not only better solutions are used, but also solutions with the same score – Dora Mar 29 '16 at 16:21

0 Answers0