<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 04-11-13 14:24, Juan Ignacio
      Barisich wrote:<br>
    </div>
    <blockquote
cite="mid:CAFGE-fXJP8e=8SXKhQVoqVZsaxgoL0OK=xqUwM87rFYjC-G=zQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>You are right. <br>
          Do you <span id="result_box" class="" lang="en"><span
              class="">think</span></span> that is a bug? Or is there a
          hack to solve this?<br>
        </div>
      </div>
    </blockquote>
    User problem :)<br>
    Do something like:<br>
    &nbsp;
toRemove.getPreviousStandstill().setNextStandstill(toRemove.getNextStandstill);<br>
    &nbsp;
toRemove.getNextStandstill().setPreviousStandstill(toRemove.getPreviousStandstill);<br>
    It might need a cast and instanceof check to Customer.<br>
    <blockquote
cite="mid:CAFGE-fXJP8e=8SXKhQVoqVZsaxgoL0OK=xqUwM87rFYjC-G=zQ@mail.gmail.com"
      type="cite">
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">
          2013/11/4 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">
              <div class="im"> <br>
                <div>On 04-11-13 13:10, Juan Ignacio Barisich wrote:<br>
                </div>
                <blockquote type="cite">
                  <div dir="ltr">
                    <div>
                      <div>
                        <div>
                          <div>
                            <div><span name="Geoffrey De Smet">Geoffrey,
                                thanks for response.<br>
                              </span></div>
                            <span name="Geoffrey De Smet">The </span>the
                            Customer "toRemove" instance IS the same
                            instance as which is in the
                            workingSolution's Customer list. In fact, in
                            the test example I have attached, I get that
                            instance via:<br>
                            <br>
                            final Customer toRemove =
                            workingSolution.getCustomerList().get(0);<br>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </blockquote>
              </div>
              Ok, then that's not the problem indeed.
              <div class="im"><br>
                <blockquote type="cite">
                  <div dir="ltr">
                    <div>
                      <div>
                        <div>
                          <div><br>
                          </div>
                          I try to reproduce the hack in
                          CloudBalancing's problemFactChange
                          implementation, but with no success. I mean, I
                          tried:<br>
                          <br>
                        </div>
                        <div>&nbsp;&nbsp; // to clean the next variable of
                          previous in the chain<br>
                        </div>
                        <div>&nbsp;&nbsp; Standstill prev =
                          toRemove.getPreviousStandstill();<br>
                          &nbsp;&nbsp; scoreDirector.beforeEntityRemoved(prev);<br>
                          &nbsp;&nbsp; prev.setNextCustomer(null);<br>
                          &nbsp;&nbsp; scoreDirector.afterEntityRemoved(prev);<br>
                          &nbsp;&nbsp; <br>
                        </div>
                        but this throw an exception like:<br>
                        java.lang.IllegalStateException: The entity
                        (1(after 66)) has a variable
                        (previousStandstill) with value (66(after 51))
                        which has a mappedBy variable (nextCustomer)
                        with a value (null) which is not that entity.<br>
                      </div>
                    </div>
                  </div>
                </blockquote>
              </div>
              Ah, that explains it.<br>
              <br>
              Although you remove the customer instance toRemove,<br>
              one of the other customers still has it as
              previousStandstill<br>
              and/or one of the other customers still has it as
              nextStandstill.
              <div>
                <div class="h5">
                  <blockquote type="cite">
                    <div dir="ltr">
                      <div>
                        <div> <br>
                        </div>
                        Also, i try to clean the previous variable of
                        the following item in the chain:<br>
                        <br>
                        &nbsp;&nbsp; // to clean the previous variable of the
                        following customer in the chain<br>
                        &nbsp;&nbsp; Customer nextCustomer =
                        toRemove.getNextCustomer();<br>
                        &nbsp;&nbsp; if (nextCustomer != null) {<br>
                        &nbsp;&nbsp; &nbsp;&nbsp;
                        scoreDirector.beforeEntityRemoved(nextCustomer);<br>
                        &nbsp;&nbsp; &nbsp;&nbsp; nextCustomer.setPreviousStandstill(null);<br>
                        &nbsp;&nbsp; &nbsp;&nbsp;
                        scoreDirector.beforeEntityRemoved(nextCustomer);<br>
                        &nbsp;&nbsp; }<br>
                        <br>
                        but this throw an exception like:<br>
                        java.lang.IllegalStateException: The
                        ScoreDirector (class
                        org.optaplanner.core.impl.score.director.common.TrailingEntityMapSupport)

                        is corrupted, because the entity (10(after
                        null)) for chained planningVariable
                        (previousStandstill) cannot be retracted: it was
                        never inserted.<br>
                        <br>
                      </div>
                      <div>Can you take a look to the test I have
                        attached and <span lang="en"><span>guide me to
                            solve this?<br>
                            <br>
                            Thanks a lot.<br>
                          </span></span></div>
                      <div><span lang="en"><span>Regards<br>
                          </span></span></div>
                      <div>
                        <div><br>
                          &nbsp;<br>
                          <br>
                          <div><br>
                            <div><br>
                            </div>
                          </div>
                        </div>
                      </div>
                    </div>
                    <div class="gmail_extra"><br>
                      <br>
                      <div class="gmail_quote">2013/11/4 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">
                            <div> <br>
                              <div>On 01-11-13 19:38, Juan Ignacio
                                Barisich wrote:<br>
                              </div>
                              <blockquote type="cite">
                                <div dir="ltr">
                                  <div>
                                    <div>
                                      <div>
                                        <div>
                                          <div>
                                            <div>
                                              <div>Hi everybody<br>
                                              </div>
                                              I am using optaplanner in
                                              real-time style. My
                                              application domain is
                                              similar to the "Vehicle
                                              Routing" example (<a
                                                moz-do-not-send="true"
href="http://docs.jboss.org/drools/release/6.0.0.CR5/optaplanner-docs/html_single/index.html#vehicleRouting"
                                                target="_blank">http://docs.jboss.org/drools/release/6.0.0.CR5/optaplanner-docs/html_single/index.html#vehicleRouting</a>).


                                              I mean, I am using chained
                                              variables and shadow
                                              variables. I have a
                                              problem while trying to
                                              remove a fact (an entity),
                                              via a ProblemFactChange:<br>
                                              <br>
                                              java.lang.IllegalArgumentException:
                                              The entity instance (...)
                                              was never added to this
                                              ScoreDirector. Usually the
                                              cause is that that
                                              specific instance was not
                                              in your Solution's
                                              entities.<br>
                                              <br>
                                            </div>
                                            The fact removing that I
                                            made is like:<br>
                                            <br>
                                            solver.addProblemFactChange(new

                                            ProblemFactChange() {<br>
                                            <br>
                                            &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; @Override<br>
                                            &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; public void
                                            doChange(ScoreDirector
                                            scoreDirector) {<br>
                                            &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ...<br>
                                            &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
                                            scoreDirector.beforeEntityRemoved(toRemove);<br>
                                            &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
                                            workingSolution.getCustomerList().remove(toRemove);<br>
                                          </div>
                                        </div>
                                      </div>
                                    </div>
                                  </div>
                                </div>
                              </blockquote>
                            </div>
                            the remove() method will make no difference
                            because the Customer "toRemove" instance<br>
                            is not the same instance as which is in the
                            workingSolution's Customer list.<br>
                            <br>
                            See the CloudBalancing's PRoblemFactChange
                            implementation how to solve this.<br>
                            And one of the warnings in the Real-time
                            planning section of the docs to understand
                            it better:)<br>
                            <blockquote type="cite">
                              <div>
                                <div dir="ltr">
                                  <div>
                                    <div>
                                      <div>
                                        <div>
                                          <div>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
                                            scoreDirector.afterEntityRemoved(toRemove);<br>
                                            &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; }<br>
                                            &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; });<br>
                                            <br>
                                          </div>
                                          I think the problem is there.
                                          Do you know what I'm doing
                                          wrong?<br>
                                        </div>
                                        I have attached a test case
                                        based on the "Vehicle Routing".
                                        To run it, just put that file
                                        into the
                                        optaplanner-distribution-6.0.0.CR5/examples/sources/src/test/java/org/optaplanner/examples/vehiclerouting/app/


                                        directory.<br>
                                        <br>
                                      </div>
                                      <a moz-do-not-send="true"
                                        href="http://drools.46999.n3.nabble.com/file/n4017760/serverlog.zip"
                                        rel="nofollow" target="_blank"><span></span></a><span>I'd


                                        appreciate any ideas on how to
                                        resolve this.</span></div>
                                    Best regards,<br>
                                    <br>
                                  </div>
                                  Juan Ignacio Barisich<br>
                                  <div>
                                    <div>
                                      <div>
                                        <div><br>
                                          <br>
                                          <br>
                                          <br>
                                        </div>
                                      </div>
                                    </div>
                                  </div>
                                </div>
                                <br>
                                <fieldset></fieldset>
                                <br>
                              </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"
                            target="_blank">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></fieldset>
                    <br>
                    <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>
              </div>
            </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>