<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    <div class="moz-cite-prefix">Op 13-02-13 17:00, Andr&eacute; Fr&oacute;es schreef:<br>
    </div>
    <blockquote
cite="mid:CAC8f_wWLG+c0x0NPzmU42nyC2G1UaN0NVgRWw7ZD_kerQCi=0g@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hello, I am getting an NPE when trying to solve a
        simple problem with 3 workorder and 3 engineers.
        <div>------------</div>
        <div>
          <div>Exception in thread "main" java.lang.NullPointerException</div>
          <div>
            <span class="" style="white-space:pre"> </span>at
            java.util.ArrayList.addAll(Unknown Source)</div>
          <div><span class="" style="white-space:pre"> </span>at
org.drools.planner.core.domain.solution.SolutionDescriptor.getAllFacts(SolutionDescriptor.java:178)</div>
        </div>
      </div>
    </blockquote>
    Take a look at<br>
    &nbsp;
<a class="moz-txt-link-freetext" href="https://github.com/droolsjbpm/drools-planner/blob/5.5.x/drools-planner-core/src/main/java/org/drools/planner/core/domain/solution/SolutionDescriptor.java#L178">https://github.com/droolsjbpm/drools-planner/blob/5.5.x/drools-planner-core/src/main/java/org/drools/planner/core/domain/solution/SolutionDescriptor.java#L178</a><br>
    Looks like your Solution implementation doesn't respect the
    Solution.getProblemFacts() contract.<br>
    <blockquote
cite="mid:CAC8f_wWLG+c0x0NPzmU42nyC2G1UaN0NVgRWw7ZD_kerQCi=0g@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div><span class="" style="white-space:pre"> </span>at
org.drools.planner.core.score.director.drools.DroolsScoreDirector.getWorkingFacts(DroolsScoreDirector.java:88)</div>
          <div><span class="" style="white-space:pre"> </span>at
org.drools.planner.core.score.director.drools.DroolsScoreDirector.resetWorkingMemory(DroolsScoreDirector.java:81)</div>
          <div><span class="" style="white-space:pre"> </span>at
org.drools.planner.core.score.director.drools.DroolsScoreDirector.setWorkingSolution(DroolsScoreDirector.java:70)</div>
          <div><span class="" style="white-space:pre"> </span>at
org.drools.planner.core.solver.scope.DefaultSolverScope.setWorkingSolutionFromBestSolution(DefaultSolverScope.java:158)</div>
          <div><span class="" style="white-space:pre"> </span>at
org.drools.planner.core.solver.DefaultSolver.solvingStarted(DefaultSolver.java:176)</div>
          <div><span class="" style="white-space:pre"> </span>at
org.drools.planner.core.solver.DefaultSolver.solve(DefaultSolver.java:154)</div>
          <div><span class="" style="white-space:pre"> </span>at
            com.swa.planner.snap1.app.SortWorkOrder.main(SortWorkOrder.java:41)</div>
        </div>
        <div>-----------------</div>
        <div><br>
        </div>
        <div style="">the rule for it is simple (adapted from
          cloudbalancing):</div>
        <div style=""><br>
        </div>
        <div style="">----------</div>
        <div style="">
          <div>rule "requiredWorkTimeTotal"</div>
          <div>&nbsp; &nbsp; when</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; $engineer : Engineer($worktime : worktime )</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; $requiredEngineerWorktimeTotal : Number(intValue
            &gt; $worktime) from accumulate(</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WorkOrder(</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; engineer == $engineer,</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $requiredWorktime : requiredWorktime ),</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum($requiredWorktime)</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; )</div>
          <div>&nbsp; &nbsp; then</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; insertLogical(new
            IntConstraintOccurrence("requiredWorkTimeTotal",
            ConstraintType.NEGATIVE_HARD,</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $requiredEngineerWorktimeTotal.intValue()
            - $worktime,</div>
          <div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $engineer));</div>
          <div>end</div>
          <div>----------</div>
          <div><br>
          </div>
          <div style="">I'm rebuilding the app bit by bit and then
            evolve it. The skill is not considered yet to make the
            comparison, just worktime. This is the data i'm working with
            right now:</div>
          <div style=""><br>
          </div>
          <div style="">-----------</div>
          <div style="">
            <div>List&lt;Engineer&gt; engineerList = new
              ArrayList&lt;Engineer&gt;();</div>
            <div>engineerList.add(new Engineer(1l, 8, ABC1, "Fabio"));</div>
            <div>engineerList.add(new Engineer(2l, 8, ABC2, "Qwert"));</div>
            <div>engineerList.add(new Engineer(3l, 8, ABC3, "Trewq"));</div>
            <div><br>
            </div>
            <div>List&lt;WorkOrder&gt; workOrderList = new
              ArrayList&lt;WorkOrder&gt;();</div>
            <div>workOrderList.add(new WorkOrder(101l, 8, ABC1));</div>
            <div>workOrderList.add(new WorkOrder(102L, 8, ABC2));</div>
            <div>workOrderList.add(new WorkOrder(103L, 8, ABC3));</div>
            <div>-----------</div>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
rules-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a></pre>
    </blockquote>
    <br>
  </body>
</html>