<br><br><div class="gmail_quote">2011/10/14 Geoffrey De Smet <span dir="ltr">&lt;<a href="mailto:ge0ffrey.spam@gmail.com" target="_blank">ge0ffrey.spam@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<u></u>

  
    
  
  <div text="#000000" bgcolor="#ffffff">
    In your doMove you&#39;re doing:<br>
    <br>
    crew.<span>addActivity</span><span>(</span>activity<span>)</span>;<br>
    remainingActivities.<span>remove</span><span>(</span>activity<span>)</span>;<br>
    <br>
    If crew and/or remainingActivities are used by your score rules, the
    working memory should be notified of their changes.<br>
    That&#39;s causing the corruption<br>
    <br></div></blockquote><div><br></div><div>Hmm, actually the only object that are being used by the score rules is an activity. Here&#39;s the corresponding .drl:</div><div><br></div><div><div><font face="&#39;courier new&#39;, monospace">rule &quot;remainingActivitiesCount&quot;</font></div>

<div><font face="&#39;courier new&#39;, monospace"><span style="white-space:pre-wrap">        </span>when</font></div><div><font face="&#39;courier new&#39;, monospace">    <span style="white-space:pre-wrap">        </span>$remainingCount : Number() from accumulate(</font></div>

<div><font face="&#39;courier new&#39;, monospace">         <span style="white-space:pre-wrap">        </span>$activity : ActivityBundle(),</font></div><div><font face="&#39;courier new&#39;, monospace">           <span style="white-space:pre-wrap">        </span>sum(1)</font></div>

<div><font face="&#39;courier new&#39;, monospace">        )</font></div><div><font face="&#39;courier new&#39;, monospace">    then</font></div><div><font face="&#39;courier new&#39;, monospace">        insertLogical(new IntConstraintOccurrence(&quot;remainingActivitiesCount&quot;, </font></div>

<div><font face="&#39;courier new&#39;, monospace">                ConstraintType.NEGATIVE_HARD,</font></div><div><font face="&#39;courier new&#39;, monospace">                $remainingCount.intValue(),</font></div>
<div><font face="&#39;courier new&#39;, monospace">                null));</font></div><div><font face="&#39;courier new&#39;, monospace">end</font></div></div><div> </div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#ffffff">
    <br>
    Extra advice:<br>
    I think you&#39;re making your moves too complex and your domain model
    too complex.<br>
    If you upgrade to 5.3, it will be hard to identify the planning
    entities. There will be many (and I doubt you need more than 1).<br>
    Read<br>
     
<a href="http://docs.jboss.org/drools/release/5.3.0.CR1/drools-planner-docs/html_single/index.html#d0e1411" target="_blank">http://docs.jboss.org/drools/release/5.3.0.CR1/drools-planner-docs/html_single/index.html#d0e1411</a><br>


    and specificly this note in that chapter:<br>
    <blockquote type="cite">
      <p><span><a><em>Do not create
              unnecessary planning entity classes.</em></a></span><a> This leads to difficult <code>Move</code>
          implementations and slower score calculation.</a></p>
      <p><a>For example, do not create a planning entity
          class to hold the total free time of a teacher, which needs to
          be kept up to date as the <code>Lecture</code>
          planning entities change. Instead, calculate the free time in
          the score constraints and put the result per teacher into a
          logically inserted score object.</a></p>
      <p><a>If historic data needs to be considered too,
          then create problem fact to hold the historic data up to, but
          <span><em>not including</em></span>, the
          planning window (so it doesn&#39;t change when a planning entity
          changes) and let the score constraints take it into account.</a></p></blockquote></div></blockquote><div><br></div><div>Thanks for the advice. I&#39;ll rethink my model and try to use a single planning entity.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#ffffff"><blockquote type="cite">
    </blockquote>
    <br>
    <br>
    <br>
    Op 14-10-11 15:48, Guilherme Kunigami schreef:
    <div><div></div><div><blockquote type="cite"><br>
      <br>
      <div class="gmail_quote">2011/10/14 Geoffrey De Smet <span dir="ltr">&lt;<a href="mailto:ge0ffrey.spam@gmail.com" target="_blank">ge0ffrey.spam@gmail.com</a>&gt;</span><br>
        <blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
          <div text="#000000" bgcolor="#ffffff"> Probably you forgot to
            notify the workingMemory.update in the doMove method:<br>
            <br>
                public void doMove(WorkingMemory workingMemory) {<br>
                    FactHandle factHandle =
            workingMemory.getFactHandle(activity);<br>
                    activity.setAssignee(...);<br>
                    workingMemory.update(factHandle, activity);<br>
                }<br>
            <br>
            Op 14-10-11 09:21, Geoffrey De Smet schreef:
            <div>
              <div>
                <blockquote type="cite"> A corrupted score normally
                  indicates a problem with the Move implementation (or
                  sometimes the score drl).<br>
                  <br>
                  Basically this happened: for a number of moves, it did
                  the move, calculated the score and undo the move.<br>
                  One of those move was associated with a score
                  -10hard/0soft, that was the best one.<br>
                  Now, it does that move (which is now called the
                  &quot;step&quot;) and when it calculates the score it&#39;s a
                  different score 0hard/0soft.<br>
                  <br>
                  Try TRACE environment and see if it crashes sooner.
                  Copy paste your Move implementation here.<br>
                </blockquote>
              </div>
            </div>
          </div>
        </blockquote>
        <div><br>
        </div>
        <div>Using the TRACE environment gave the same results of DEBUG.</div>
        <div><br>
        </div>
        <div>Here&#39;s my move implementation, as well as the snipet of
          drools rule file that calculates the score based on remaining
          activities:</div>
        <div> </div>
        <div><a href="http://pastebin.mozilla.org/1355014" target="_blank">http://pastebin.mozilla.org/1355014</a></div>
        <div> </div>
        <blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
          <div text="#000000" bgcolor="#ffffff">
            <div>
              <div>
                <blockquote type="cite"> In Planner 5.4 there will be 2
                  out-of-the-box Move implementations to use, so writing
                  Move&#39;s become optional.<br>
                </blockquote>
              </div>
            </div>
          </div>
        </blockquote>
        <div>Cool!</div>
        <div><br>
        </div>
        <div>By the way, I&#39;m using Drools 5.2.0 final.</div>
        <div><br>
        </div>
        <div>Thanks,</div>
        <blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">
          <div text="#000000" bgcolor="#ffffff">
            <div>
              <div>
                <blockquote type="cite"> <br>
                  Op <a href="tel:13-10-11%2016" value="+13101116" target="_blank">13-10-11 16</a>:37,
                  Guilherme Kunigami schreef:
                  <blockquote type="cite">
                    <div>Hi,</div>
                    <div><br>
                    </div>
                    <div>I&#39;ve implemented a very simple application
                      using drools planner consisting of a bunch of
                      activities. My rule file is very simple too and
                      just counts the number of activities not assigned.
                      When I run Solver.solve(), I get the following
                      error message:</div>
                    <div><br>
                    </div>
                    <div><font face="&#39;courier new&#39;, monospace">Exception
                        in thread &quot;AWT-EventQueue-0&quot;
                        java.lang.IllegalStateException: The
                        presumedScore (-10hard/0soft) is corrupted
                        because it is not the realScore  (0hard/0soft).</font></div>
                    <div><font face="&#39;courier new&#39;, monospace"><br>
                      </font></div>
                    <div><font face="&#39;courier new&#39;, monospace">Presumed
                        workingMemory:</font></div>
                    <div><font face="&#39;courier new&#39;, monospace">  Score
                        rule (remainingActivitiesCount) has count (1)
                        and weight total (11).</font></div>
                    <div><font face="&#39;courier new&#39;, monospace">Real
                        workingMemory:</font></div>
                    <div><font face="&#39;courier new&#39;, monospace">  Score
                        rule (remainingActivitiesCount) has count (1)
                        and weight total (0).</font></div>
                    <div><font face="&#39;courier new&#39;, monospace"><br>
                      </font></div>
                    <div><font face="arial, helvetica, sans-serif">I&#39;ve
                        tracked down this message and found this piece
                        of code
                        @DefaultLocalSearchSolver.solveImplementation():</font></div>
                    <div><font face="&#39;courier new&#39;, monospace"><br>
                      </font></div>
                    <div>
                      <div style="font-family:&#39;courier new&#39;,monospace">
                        <div>// there is no need to recalculate the
                          score, but we still need to set it</div>
                        <div>localSearchSolverScope.getWorkingSolution().setScore(localSearchStepScope.getScore());</div>
                        <div>if (assertStepScoreIsUncorrupted) {</div>
                        <div>   
localSearchSolverScope.assertWorkingScore(localSearchStepScope.getScore());</div>
                        <div>}</div>
                      </div>
                      <div style="font-family:&#39;courier new&#39;,monospace"><br>
                      </div>
                      <div><font face="arial, helvetica, sans-serif">It
                          seems that the working score is never updated
                          along the algorithm, but the score in the
                          working memory changes. Thus, when we use the
                          DEBUG environment,
                          assertStepScoreIsUncorrupted is turned on and
                          the assertion fails. </font></div>
                    </div>
                    <div><font face="arial, helvetica, sans-serif"><br>
                      </font></div>
                    <div><font face="arial, helvetica, sans-serif">Should
                        the score be updated or am I using the library
                        incorrectly?</font></div>
                    <div><font face="arial, helvetica, sans-serif"><br>
                      </font></div>
                    <div><font face="arial, helvetica, sans-serif">Thanks,</font></div>
                    <pre><fieldset></fieldset>
_______________________________________________
rules-users mailing list
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
                  </blockquote>
                  <br>
                  <pre cols="72">-- 
With kind regards,
Geoffrey De Smet</pre>
                  <pre><fieldset></fieldset>
_______________________________________________
rules-users mailing list
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
                </blockquote>
                <br>
                <pre cols="72">-- 
With kind regards,
Geoffrey De Smet</pre>
              </div>
            </div>
          </div>
          <br>
          _______________________________________________<br>
          rules-users mailing list<br>
          <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
          <a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
          <br>
        </blockquote>
      </div>
      <br>
      <pre><fieldset></fieldset>
_______________________________________________
rules-users mailing list
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
    </blockquote>
    <br>
    <pre cols="72">-- 
With kind regards,
Geoffrey De Smet</pre>
  </div></div></div>

<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>