[rules-dev] Planner: should getBestSolution() return null when there is no initialized solution?

Michael Anstis michael.anstis at gmail.com
Tue Jun 28 05:23:12 EDT 2011


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 at 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 at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-dev/attachments/20110628/08ef735f/attachment.html 


More information about the rules-dev mailing list