[rules-users] Reusing a Solution in Drools Planner

Cedric Hurst cedric at spantree.net
Fri May 4 13:11:40 EDT 2012


I would imagine using an existing solution should be pretty straightforward,
you'd simply set the previous solution as the initial solution in your next
run:

solver.setPlanningProblem(oldSolution);
solver.solve();

There's unfortunately some unavoidable upfront cost to doing things that
way, but the advantage is that you don't have to keep the solver running
while you're waiting on a change. You can persist your previous solution
and fire up a new solver if something changes.

The other option is the real-time planning option mentioned in chapter 12.
I haven't worked with it yet, but I believe you'd simply need to create a
ProblemFactChange() with an onChange() method that applies the change to
working memory the same way you would in doMove(), with
scoreDirector.afterVariableChanged() calls, etc. I'm not quite sure how
stable the real-time planning option is at the moment, though.

--
View this message in context: http://drools.46999.n3.nabble.com/Reusing-a-Solution-in-Drools-Planner-tp3962821p3962954.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list