Not completely understanding why solver.solve() would only run for 1ms, isn&#39;t a partially initialised starting solution a runtime error and (3) have solver.getBestSolution() throw a &quot;SolutionsNotInitialisedException&quot; an option?<br>
<br><div class="gmail_quote">On 28 June 2011 10:18, Geoffrey De Smet <span dir="ltr">&lt;<a href="mailto:ge0ffrey.spam@gmail.com">ge0ffrey.spam@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Normally you use Planner like this:<br>
<br>
solver.solve()<br>
Solution bestSolution = solver.getBestSolution();<br>
// ... do things with bestSolution<br>
Score bestScore = bestSolution.getScore();<br>
<br>
But let&#39;s suppose we give it 1 millisecond to plan and use a big,<br>
uninitialized starting solution<br>
and our initialization algorithm actually terminates immediately as<br>
requested.<br>
It won&#39;t be able to completely initialize the solution in that case.<br>
What should solver.getBestSolution() return in that case? null or the<br>
partially initialized solution?<br>
<br>
1) It returns null. So you &#39;ll need to do null checks:<br>
Solution bestSolution = solver.getBestSolution();<br>
if (bestSolution == null) {<br>
      // ... do things with bestSolution<br>
      Score bestScore = bestSolution.getScore();<br>
}<br>
<br>
2) It returns the partially initialized solution. So you&#39;ll need to do<br>
isBestSolutionInitialized checks:<br>
Solution bestSolution = solver.getBestSolution();<br>
if (solver.isBestSolutionInitialized()) {<br>
      // ... do things with bestSolution<br>
      Score bestScore = bestSolution.getScore();<br>
}<br>
<br>
What makes more sense?<br>
<br>
--<br>
With kind regards,<br>
Geoffrey De Smet<br>
<br>
<br>
_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
</blockquote></div><br>