[rules-users] OptaPlanner: Solver.isEveryProblemFactChangeProcessed() return true before the last fact change is processed
Hagai
hagai.shatz at gmail.com
Wed Apr 30 06:17:16 EDT 2014
Using OptaPlanner 6.0.1.Final and following the documentation for real-time
planning:
"Alternatively, you can subscribe to the BestSolutionChangedEvent.
A BestSolutionChangedEvent doesn't guarantee that every ProblemFactChange
has been
processed already, so check Solver.isEveryProblemFactChangeProcessed() and
ignore any
BestSolutionChangedEvent fired while that method returns false."
However, Solver.isEveryProblemFactChangeProcessed() return true before the
last fact change is processed.
This is documented in the code DefaultSolver.java: *// TODO bug: the last
ProblemFactChange might already been polled, but not processed yet*
I believe this can be fixed using the following code in
DefaultSolver.checkProblemFactChanges:
ProblemFactChange problemFactChange =
problemFactChangeQueue*.peek()*;
while (problemFactChange != null) {
score = doProblemFactChange(problemFactChange);
*problemFactChangeQueue.poll();*
count++;
problemFactChange = problemFactChangeQueue*.peek()*;
}
This way the queue will not be empty until the fact change is processed.
--
View this message in context: http://drools.46999.n3.nabble.com/OptaPlanner-Solver-isEveryProblemFactChangeProcessed-return-true-before-the-last-fact-change-is-procd-tp4029389.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
More information about the rules-users
mailing list