<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">On 28-10-13 17:27, Juan Ignacio
      Barisich wrote:<br>
    </div>
    <blockquote
cite="mid:CAFGE-fW6KixOcN3hJKM-tCvzi6eKqtw9CrtDqe6pQX2xcZ3TwA@mail.gmail.com"
      type="cite">
      <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>
        </div>
      </div>
    </blockquote>
    When the rest of drools and jbpm and ready to release. We're on the
    same release train :)<br>
    But optaplanner 6 is ready for prime time, don't let the "CR5"
    suffix make you believe otherwise.<br>
    <blockquote
cite="mid:CAFGE-fW6KixOcN3hJKM-tCvzi6eKqtw9CrtDqe6pQX2xcZ3TwA@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div><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 moz-do-not-send="true"
              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 "shadow
              variables" (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 "distanceToPreviousAppearance"<br>
                                &nbsp;&nbsp;&nbsp; when<br>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $visit :
                                Visit(previousAppearance != null,
                                $distanceToPreviousAppearance :
                                distanceToPreviousAppearance)<br>
                                &nbsp;&nbsp;&nbsp; then<br>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insertLogical(new
                                IntConstraintOccurrence("distanceToPreviousAppearance",
                                ConstraintType.NEGATIVE_SOFT,<br>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                $distanceToPreviousAppearance,<br>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $visit));<br>
                                end<br>
                                <br>
                              </div>
                              When optaplanner do the moves while
                              planning, the IntConstraintOccurrence
                              works ok, because the drools engine
                              "retracts" 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'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 "delaySC"<br>
                            &nbsp;&nbsp;&nbsp; when <br>
                            &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $case : Case( )<br>
                            &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; eval($case.getDelay() &gt; 0)<br>
                            &nbsp;&nbsp;&nbsp; then<br>
                            &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; insertLogical(new
                            IntConstraintOccurrence("delaySC",
                            ConstraintType.NEGATIVE_SOFT, <br>
                            &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $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: &iquest;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> &iquest;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
                            moz-do-not-send="true"
                            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'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>
                            &nbsp;&nbsp;&nbsp; private Chained previous;<br>
                            &nbsp;&nbsp;&nbsp; @PlanningVariable(chained = true)<br>
                            &nbsp;&nbsp;&nbsp; @ValueRanges({<br>
                            &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; @ValueRange(type =
                            ValueRangeType.FROM_SOLUTION_PROPERTY,
                            solutionProperty = "doctors"),<br>
                            &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; @ValueRange(type =
                            ValueRangeType.FROM_SOLUTION_PROPERTY,
                            solutionProperty = "cases",
                            excludeUninitializedPlanningEntity = true)
                            })<br>
                            &nbsp;&nbsp;&nbsp; public Chained getPrevious() {<br>
                            &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return previous;<br>
                            &nbsp;&nbsp;&nbsp; }<br>
                            }<br clear="all">
                            <div><br>
                            </div>
                            <div>A fact class:<br>
                              public class Doctor implements Chained {<br>
                              &nbsp;&nbsp; ...<br>
                              }<br>
                            </div>
                            <div><br>
                            </div>
                            <div> An a solution class:<br>
                              public class Plan extends implements
                              Solution&lt;HardAndSoftScore&gt; {<br>
                              &nbsp;&nbsp;&nbsp; private List&lt;Doctor&gt; doctors;<br>
                              &nbsp;&nbsp;&nbsp; private List&lt;Case&gt; cases;<br>
                              &nbsp;&nbsp;&nbsp; private HardAndSoftScore score;<br>
                              <br>
                              &nbsp;&nbsp;&nbsp; @PlanningEntityCollectionProperty<br>
                              &nbsp;&nbsp;&nbsp; public List&lt;Case&gt; getCases() {<br>
                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return cases;<br>
                              &nbsp;&nbsp;&nbsp; }<br>
                              <br>
                              &nbsp;&nbsp;&nbsp; public Collection&lt;? extends
                              Object&gt; getProblemFacts() {<br>
                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return new
                              ArrayList&lt;Doctor&gt;(doctors);<br>
                              &nbsp;&nbsp;&nbsp; }<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&nbsp; <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
                              -&nbsp;&nbsp;&nbsp;&nbsp; Step index (1), time spend (20002),
                              score (1hard/2soft),&nbsp;&nbsp;&nbsp;&nbsp; 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 "DoctorB" 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>
                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;unionMoveSelector&gt;<br>
                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;changeMoveSelector&gt;<br>
                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;valueSelector/&gt;<br>
                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/changeMoveSelector&gt;<br>
                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;swapMoveSelector /&gt;<br>
                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
                              &lt;subChainChangeMoveSelector&gt;<br>
                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
                              &lt;selectReversingMoveToo&gt;true&lt;/selectReversingMoveToo&gt;<br>
                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
                              &lt;/subChainChangeMoveSelector&gt;<br>
                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
                              &lt;subChainSwapMoveSelector&gt;<br>
                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
                              &lt;selectReversingMoveToo&gt;true&lt;/selectReversingMoveToo&gt;<br>
                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
                              &lt;/subChainSwapMoveSelector&gt;<br>
                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/unionMoveSelector&gt;<br>
                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;acceptor&gt;<br>
                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
                              &lt;planningEntityTabuSize&gt;9&lt;/planningEntityTabuSize&gt;<br>
                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/acceptor&gt;<br>
                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;forager&gt;<br>
                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
                              &lt;minimalAcceptedSelection&gt;2000&lt;/minimalAcceptedSelection&gt;<br>
                              &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;/forager&gt;<br>
                              &nbsp;&nbsp;&nbsp; &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 moz-do-not-send="true" href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a moz-do-not-send="true" 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 moz-do-not-send="true"
              href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
            <a moz-do-not-send="true"
              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>
      <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>