Not completely understanding why solver.solve() would only run for 1ms, isn't a partially initialised starting solution a runtime error and (3) have solver.getBestSolution() throw a "SolutionsNotInitialisedException" an option?

On 28 June 2011 10:18, Geoffrey De Smet <ge0ffrey.spam@gmail.com> wrote:
Normally you use Planner like this:

solver.solve()
Solution bestSolution = solver.getBestSolution();
// ... do things with bestSolution
Score bestScore = bestSolution.getScore();

But let's suppose we give it 1 millisecond to plan and use a big,
uninitialized starting solution
and our initialization algorithm actually terminates immediately as
requested.
It won't be able to completely initialize the solution in that case.
What should solver.getBestSolution() return in that case? null or the
partially initialized solution?

1) It returns null. So you 'll need to do null checks:
Solution bestSolution = solver.getBestSolution();
if (bestSolution == null) {
     // ... do things with bestSolution
     Score bestScore = bestSolution.getScore();
}

2) It returns the partially initialized solution. So you'll need to do
isBestSolutionInitialized checks:
Solution bestSolution = solver.getBestSolution();
if (solver.isBestSolutionInitialized()) {
     // ... do things with bestSolution
     Score bestScore = bestSolution.getScore();
}

What makes more sense?

--
With kind regards,
Geoffrey De Smet


_______________________________________________
rules-dev mailing list
rules-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-dev