Originally posted by: Vgoel77
I am implementing an iterative search algorithm where I repeatedly solve the same CP model. At each iteration, I might add a new constraint that ensures that the solve will generate a better solution than the one I already have. The solve is run with specified branch limits, so some times it may not be able to generate any solution. In that case, I will either a) remove the constraint that I added in the previous iteration and replace it with a weaker constraint, or b) increase the branch limit.
I am wondering if I should/need to re-extract my model at every iteration. More specifically, I am wondering if I do not re-extract the model at every iteration, is CPO able to re-use some of the information it gathered during the solve in iteration k to improve its performance during the solve at iteration k+1 (since the models are either exactly the same with a larger branch limit; or the models differ by a couple of constraints only.
The (pseudo-)code structure looks like this
while (termination condition not met)
{ cp.extract(model); foundSol = cp.solve();
if(foundSol)
{ model.add(
/* new tight constraint */);
}
else
{
if( condition )
{
/* increase branch limit */
}
else
{ model.remove(
/* constraint added at previous iteration */); model.add(
/* new weak constraint */);
}
}
}
Your feedback is appreciated
Regards
#CPOptimizer#DecisionOptimization