<div dir="ltr"><div>Thanks <span name="Geoffrey De Smet" class="">Geoffrey. One more question:</span><span name="Geoffrey De Smet" class=""> Is there a planned release date for optaplanner </span>6.0.0.Final ?<br><br></div>

<div>Thanks again<br></div><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/10/25 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">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Upgrade to 6.0.0.CR5 (follow the upgrade recipe txt)<br>
    and take advantage of the new feature called &quot;shadow variables&quot; (see
    docs).<br>
    Also see the VRP with timewindows example for an implementation that
    uses shadow variables :)<div><div class="h5"><br>
    <br>
    <div>On 25-10-13 00:27, Juan Ignacio
      Barisich wrote:<br>
    </div>
    </div></div><blockquote type="cite"><div><div class="h5">
      <div dir="ltr">
        <div>
          <div>
            <div>
              <div>
                <div>
                  <div>
                    <div>Hi again. The problem was a score corruption
                      issue. When I activate de mode debug:<br>
                      <br>
&lt;environmentMode&gt;DEBUG&lt;/environmentMode&gt;<br>
                      <br>
                    </div>
                    some exceptions appear, like:<br>
                    <br>
                    java.lang.IllegalStateException: Score corruption:
                    the workingScore (0hard/-35soft) is not the
                    uncorruptedScore (0hard/-31soft)...<br>
                    <br>
                  </div>
                  I had to fix some rules, but I cant fix one in
                  particular. When I looking at the example rules (with
                  chained variables), the most are based only on the
                  previous item of the chain, e.g.: <br>
                  <br>
                  rule &quot;distanceToPreviousAppearance&quot;<br>
                      when<br>
                          $visit : Visit(previousAppearance != null,
                  $distanceToPreviousAppearance :
                  distanceToPreviousAppearance)<br>
                      then<br>
                          insertLogical(new
                  IntConstraintOccurrence(&quot;distanceToPreviousAppearance&quot;,
                  ConstraintType.NEGATIVE_SOFT,<br>
                                  $distanceToPreviousAppearance,<br>
                                  $visit));<br>
                  end<br>
                  <br>
                </div>
                When optaplanner do the moves while planning, the
                IntConstraintOccurrence works ok, because the drools
                engine &quot;retracts&quot; the IntConstraintOccurrence facts
                properly. But, in my case the score caculation must be
                based on the entire chain. That is:<br>
                <br>
              </div>
              I have some Doctors, and Cases (medical cases). I have to
              write a score rule for consider the delay of attention.
              So, each Case has a request time (when the patient calls)
              and a <span lang="en"><span>approximate duration of the case (in
                  minutes). So, if I have the next chain:<br>
                  <br>
                </span></span></div>
            <span lang="en"><span>Doctor1
                -&gt; Case1 (requestTime:8am, duration:60minutes) -&gt;
                Case2(</span></span><span lang="en"><span><span lang="en"><span>requestTime:8:30am,
                    duration:30minutes</span></span>) -&gt; Case3(</span></span><span lang="en"><span><span lang="en"><span>requestTime:8:30am,
                    duration:30minutes</span></span>)<br>
                <br>
              </span></span></div>
          <span lang="en"><span>the
              delay time for this solution must be: 30min(for Case2) +
              60min(for Case3) = 90 minutes. As yo see, you can&#39;t
              calculate the delay of one Case only </span></span><span lang="en"><span>as from
              its previous on the chain.<br>
              <br>
              I must to implement a rule to calculate a soft constraint,
              to achive less-delay plannings. My first attempt looks
              like:<br>
              <br>
              rule &quot;delaySC&quot;<br>
                  when <br>
                      $case : Case( )<br>
                      eval($case.getDelay() &gt; 0)<br>
                  then<br>
                     insertLogical(new
              IntConstraintOccurrence(&quot;delaySC&quot;,
              ConstraintType.NEGATIVE_SOFT, <br>
                              $case.getDelay(), $case));<br>
              end<br>
              <br>
            </span></span></div>
        <div><span lang="en"><span>I
              have to do an eval(), because a delay can not be negative.
              The getDelay() method process the chain and calculates it.
              The problem of this attempt, an other similars, is when
              the optaplanner engine do the moves while solving, the </span></span><span lang="en"><span>IntConstraintOccurrence
              is not retracted and the </span></span>score corruption
          exception appears.<br>
          <br>
          The question is: ¿have you know similar scenarios, in which
          you have to process the entire chain to calculate the score of
          a solution?<span lang="en"><span> ¿is there a way to solve this?<br>
              <br>
            </span></span></div>
        <div><span lang="en"><span>Thanks<br>
              <br>
            </span></span></div>
        <div><span lang="en"><span>Regards<br>
            </span></span></div>
        <div><span lang="en"><span><br>
              <br>
            </span></span></div>
        <span lang="en"><span></span></span>
        <div>
          <div>
            <div>
              <div><span lang="en"><span></span></span>
                <div><br>
                  <div>
                    <div>
                      <div><br>
                        <br>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">2013/9/2 Juan Ignacio Barisich <span dir="ltr">&lt;<a href="mailto:juan.barisich@gmail.com" target="_blank">juan.barisich@gmail.com</a>&gt;</span><br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">
              <div>
                <div>
                  <div>Hi everybody.<br>
                  </div>
                  I have a problem with chained planning variables.<br>
                </div>
                I&#39;m using optaplanner 5.5.0.Final.<br>
              </div>
              I have a planning entity like:<br>
              <br>
              @PlanningEntity()<br>
              public class Case implements Chained {<br>
                  private Chained previous;<br>
                  @PlanningVariable(chained = true)<br>
                  @ValueRanges({<br>
                          @ValueRange(type =
              ValueRangeType.FROM_SOLUTION_PROPERTY, solutionProperty =
              &quot;doctors&quot;),<br>
                          @ValueRange(type =
              ValueRangeType.FROM_SOLUTION_PROPERTY, solutionProperty =
              &quot;cases&quot;, excludeUninitializedPlanningEntity = true) })<br>
                  public Chained getPrevious() {<br>
                      return previous;<br>
                  }<br>
              }<br clear="all">
              <div><br>
              </div>
              <div>A fact class:<br>
                public class Doctor implements Chained {<br>
                   ...<br>
                }<br>
              </div>
              <div><br>
              </div>
              <div>
                An a solution class:<br>
                public class Plan extends implements
                Solution&lt;HardAndSoftScore&gt; {<br>
                    private List&lt;Doctor&gt; doctors;<br>
                    private List&lt;Case&gt; cases;<br>
                    private HardAndSoftScore score;<br>
                <br>
                    @PlanningEntityCollectionProperty<br>
                    public List&lt;Case&gt; getCases() {<br>
                        return cases;<br>
                    }<br>
                <br>
                    public Collection&lt;? extends Object&gt;
                getProblemFacts() {<br>
                        return new ArrayList&lt;Doctor&gt;(doctors);<br>
                    }<br>
                }<br>
                <br>
              </div>
              <div>The equals / hashCode / clone methods are inspired on
                the TravelingSalesmanTour example.<br>
              </div>
              <div><br>
              </div>
              <div>I want that Optaplanner generates chains like:<br>
              </div>
              <div>DoctorA &lt;- Case1 &lt;- Case2<br>
              </div>
              <div>DoctorB &lt;- Case3<br>
                <br>
              </div>
              <div>This model tries to represent a list of Cases
                assigned to each Doctor.<br>
              </div>
              <div>Suppose I build a solution like:<br>
                <br>
                Plan plan = new Plan();<br>
              </div>
              <div>plan.setDoctors(DoctorA, DoctorB); //pseudo-code<br>
              </div>
              <div>plan.setCases(Case1, Case2); //pseudo-code<br>
                <br>
              </div>
              <div>Then I build a solver:<br>
                Solver solver = getSolverFactory().buildSolver();<br>
                solver.setPlanningProblem(plan);<br>
                solver.solve();<br>
                Plan bestPlan = (Plan) solver.getBestSolution();<br>
                <br>
              </div>
              <div>The problem is that, Optaplanner is not testing all
                the posible combinations of chains. I mean, suppose that
                we know that the better solution (based on the scoring
                rules) is:<br>
              </div>
              <div>DoctorA  <br>
              </div>
              <div>DoctorB &lt;- Case1 &lt;- Case2<br>
              </div>
              <div><br>
              </div>
              <div>But Optaplanner seems to test only chains with
                DoctorA, so the result of calling getBestSolution() is:<br>
                DoctorA &lt;- Case1 &lt;- Case2<br>
              </div>
              <div><br>
                I guess that Optaplanner only test chains whit DoctorA,
                becouse it logs lines like:<br>
                ...<br>
                DEBUG:
                org.drools.planner.core.localsearch.DefaultLocalSearchSolverPhase
                -     Step index (1), time spend (20002), score
                (1hard/2soft),     best score (1hard/2soft),
                accepted/selected move count (0/58187) for picked step
                (Case [id=2, previous=Doctor [id=1]] =&gt; Case [id=1,
                previous=Case [id=2, previous=Doctor [id=1]]]).<br>
                ...<br>
              </div>
              <div>That is, no lines whith &quot;DoctorB&quot; are logged. <br>
                If the doctor list is inverted, the same problem happen
                (the DoctorA is no processed). That is:<br>
                <br>
                Plan plan = new Plan();<br>
                <div>plan.setDoctors(DoctorB, DoctorA); //pseudo-code<br>
                </div>
                <div>plan.setCases(Case1, Case2); //pseudo-code<br>
                  Solver solver = getSolverFactory().buildSolver();<br>
                  solver.setPlanningProblem(plan);<br>
                  solver.solve(); // DoctorA is not part of chains<br>
                </div>
                <br>
                <br>
              </div>
              <div>I guess the problem is on the solver configuration,
                specifically on the localSearch configuration:<br>
                <br>
                &lt;localSearch&gt;<br>
                        &lt;unionMoveSelector&gt;<br>
                            &lt;changeMoveSelector&gt;<br>
                                &lt;valueSelector/&gt;<br>
                            &lt;/changeMoveSelector&gt;<br>
                            &lt;swapMoveSelector /&gt;<br>
                            &lt;subChainChangeMoveSelector&gt;<br>
                               
                &lt;selectReversingMoveToo&gt;true&lt;/selectReversingMoveToo&gt;<br>
                            &lt;/subChainChangeMoveSelector&gt;<br>
                            &lt;subChainSwapMoveSelector&gt;<br>
                               
                &lt;selectReversingMoveToo&gt;true&lt;/selectReversingMoveToo&gt;<br>
                            &lt;/subChainSwapMoveSelector&gt;<br>
                        &lt;/unionMoveSelector&gt;<br>
                        &lt;acceptor&gt;<br>
                           
                &lt;planningEntityTabuSize&gt;9&lt;/planningEntityTabuSize&gt;<br>
                        &lt;/acceptor&gt;<br>
                        &lt;forager&gt;<br>
                           
                &lt;minimalAcceptedSelection&gt;2000&lt;/minimalAcceptedSelection&gt;<br>
                        &lt;/forager&gt;<br>
                    &lt;/localSearch&gt;<br>
                <br>
              </div>
              <div>I tried some alternatives to this configuration, but
                with no success.<br>
                <br>
              </div>
              <div>Do you know what I am doing wrong?<br>
                <br>
              </div>
              <div>Thanks a lot.<br>
                <br>
              </div>
              Regards</div>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      </div></div><pre>_______________________________________________
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>
  </div>

<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">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></blockquote></div><br></div>