On 30-04-14 12:17, Hagai wrote:
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.
Thanks for reporting.
This is definitely an issue indeed, if
isEveryProblemFactChangeProcessed() is called from a different thread
than then solver thread.
The javadoc clearly promises that isEveryProblemFactChangeProcessed() is
thread-safe.
I 'll take a look into fixing it with your suggestion.
Note: In practice, you 'll usually call
isEveryProblemFactChangeProcessed() in the bestSolutionChanged() event,
which is called in the solver thread,
so it's not an issue in that particular case.
For 6.1.0.Beta4, I 've cleaned up the docs to describe that usage
pattern better:
https://github.com/droolsjbpm/optaplanner/commit/256fa1fe285392f8ad81b1a4...
--
View this message in context:
http://drools.46999.n3.nabble.com/OptaPlanner-Solver-isEveryProblemFactCh...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users