<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><span></span></div><div><div dir="ltr"><div>Thanks! <br></div>It turns out that it was bad data in my factory to create the initial solution that made some of <br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Dec 13, 2013 at 11:51 AM, Geoffrey De Smet <span dir="ltr">&lt;<a href="mailto:ge0ffrey.spam@gmail.com" target="_blank">ge0ffrey.spam@gmail.com</a>&gt;</span> wrote:<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><div class="h5">
    <br>
    <div>On 13-12-13 10:39, Mats Norén wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">Bad choice of words. Entities. :-)
        <div><br>
        </div>
        <div>I've got three classes:</div>
        <div><br>
        </div>
        <div>
          <div>@PlanningEntity(movableEntitySelectionFilter =
            MovableWorkersSelectionFilter.class)</div>
          <div>public class Person extends Property {</div>
          <div><br>
          </div>
          <div>&nbsp; &nbsp; String signature;</div>
          <div>&nbsp; &nbsp; String name;</div>
          <div>&nbsp; &nbsp; Desk desk;</div>
          <div>&nbsp; &nbsp; boolean movable;<br>
          </div>
          <div>&nbsp; &nbsp; ...</div>
          <div>}</div>
          <div><br>
          </div>
          <div>Fact:</div>
          <div><br>
          </div>
          <div>public class Desk extends Property {<br>
          </div>
          <div>
            <div><br>
            </div>
            <div>&nbsp; &nbsp; double x;</div>
            <div>&nbsp; &nbsp; double y;</div>
            <div><br>
            </div>
            <div>&nbsp; &nbsp; public Desk() {</div>
            <div>&nbsp; &nbsp; }</div>
          </div>
          <div>&nbsp; &nbsp; ...</div>
          <div>}</div>
          <div><br>
            <div class="gmail_extra">Solution:</div>
            <div class="gmail_extra">
              <br>
            </div>
            <div class="gmail_extra">
              <div class="gmail_extra">@PlanningSolution</div>
              <div class="gmail_extra">public class
                DeskAssignmentSolution implements
                Solution&lt;HardSoftScore&gt; &nbsp;{</div>
              <div class="gmail_extra"><br>
              </div>
              <div class="gmail_extra">&nbsp; &nbsp; private List&lt;Person&gt;
                persons;</div>
              <div class="gmail_extra">&nbsp; &nbsp; private List&lt;Desk&gt;
                desks;</div>
              <div class="gmail_extra">&nbsp; &nbsp; private HardSoftScore score;</div>
              <div class="gmail_extra">
                <br>
              </div>
              <div class="gmail_extra">&nbsp; &nbsp;
                @PlanningEntityCollectionProperty</div>
              <div class="gmail_extra">&nbsp; &nbsp; public List&lt;Person&gt;
                getPersons() {</div>
              <div class="gmail_extra">&nbsp; &nbsp; &nbsp; &nbsp; return persons;</div>
              <div class="gmail_extra">
                &nbsp; &nbsp; }</div>
              <div class="gmail_extra"><br>
              </div>
              <div class="gmail_extra">&nbsp; &nbsp; public void
                setPersons(List&lt;Person&gt; persons) {</div>
              <div class="gmail_extra">&nbsp; &nbsp; &nbsp; &nbsp; this.persons = persons;</div>
              <div class="gmail_extra">&nbsp; &nbsp; }</div>
              <div class="gmail_extra"><br>
              </div>
              <div class="gmail_extra">&nbsp; &nbsp; public void
                setDesks(List&lt;Desk&gt; desks) {</div>
              <div class="gmail_extra">&nbsp; &nbsp; &nbsp; &nbsp; this.desks = desks;</div>
              <div class="gmail_extra">&nbsp; &nbsp; }</div>
              <div class="gmail_extra">
                <br>
              </div>
              <div class="gmail_extra">&nbsp; &nbsp;
                @ValueRangeProvider(id="deskRange")</div>
              <div class="gmail_extra">&nbsp; &nbsp; public List&lt;Desk&gt;
                getDesks() {</div>
              <div class="gmail_extra">&nbsp; &nbsp; &nbsp; &nbsp; return desks;</div>
              <div class="gmail_extra">
                &nbsp; &nbsp; }</div>
              <div class="gmail_extra">&nbsp; &nbsp; ...</div>
              <div class="gmail_extra"><br>
              </div>
              <div class="gmail_extra">}</div>
              <div class="gmail_extra"><br>
              </div>
              <div class="gmail_extra">A desk is assigned to a person
                and makes up a desk assignment solution.&nbsp;</div>
              <div class="gmail_extra"><br>
              </div>
              <div class="gmail_extra">Certain desks should not be
                assigned since the are all ready occupied. The are
                correctly assigned to the right person in the initial
                solution.</div>
            </div>
          </div>
        </div>
      </div>
    </blockquote></div></div>
    Ah.<br>
    So there are 2 requirements:<br>
    - Some persons are immovable: they are already assigned to a desk
    (MovableWorkersSelectionFilter somehow recognizes those and filters
    them out). <br>
    - Since no 2 persons can share the same desk, there's little point
    in putting a desk that is already assigned to an immovable person in
    the value range. You can filter them out of the value range (by
    putting filters in the CH and local search etc), but I wouldn't
    bother with that improvement: your original hard constraint "no 2
    persons can share the same desk" will gives those moves an
    infeasible score, so they are unlikely to be picked anyway (and if
    they are picked it can actually be a good thing: tunnel through an
    infeasible solution to a better feasible solution).<div><div class="h5"><br>
    <blockquote type="cite">
      <div dir="ltr">
        <div>
          <div>
            <div class="gmail_extra">
              <div class="gmail_extra">
                <br>
              </div>
              <div class="gmail_extra">Does the SelectionFilter prevent
                the desk being assigned somehow? &nbsp;I thought a
                SelectionFilter&lt;Person&gt; would only prevent a move
                of the Person but it's the Desk being assigned?</div>
              <div class="gmail_extra"><br>
              </div>
              <div class="gmail_extra">Regards,</div>
              <div class="gmail_extra">Mats</div>
              <div class="gmail_extra"><br>
              </div>
              <div class="gmail_extra"><br>
              </div>
            </div>
            <div class="gmail_extra">
              <div class="gmail_quote">
                On Fri, Dec 13, 2013 at 9:32 AM, Geoffrey De Smet <span dir="ltr">&lt;<a href="mailto:ge0ffrey.spam@gmail.com" target="_blank">ge0ffrey.spam@gmail.com</a>&gt;</span>
                wrote:<br>
                <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
                  <div bgcolor="#FFFFFF" text="#000000"> <br>
                    <div>On 12-12-13 18:11, Mats Norén wrote:<br>
                    </div>
                    <blockquote type="cite">
                      <div dir="ltr">
                        <div>Hi,<br>
                          I've got a domain with the following entities:<br>
                        </div>
                      </div>
                    </blockquote>
                    entities? you mean classes?<br>
                    <blockquote type="cite">
                      <div dir="ltr">
                        <div>- Person (planning entity)<br>
                          - Desk (planning variable)<br>
                        </div>
                      </div>
                    </blockquote>
                    a class cannot be a variable. This probably a
                    problem fact that and person.getDesk() nor
                    DeskAssignement.getPerson() is the planning
                    variables.<br>
                    <blockquote type="cite">
                      <div dir="ltr">
                        <div>- DeskAssignment (solution)<br>
                        </div>
                      </div>
                    </blockquote>
                    Now I am totally confused :)<br>
                    in the official examples, something called
                    Assignment is a planning entity.<br>
                    <blockquote type="cite">
                      <div dir="ltr">
                        <div><br>
                        </div>
                        <div>All persons should be assigned to a desk
                          according to some rules. <br>
                        </div>
                        <div>What I would like to do is to make certain
                          Persons and their Desk immovable, ie, they are
                          assigned a desk in the initial solution and
                          should be fixed there. They are only there for
                          the score calculation. <br>
                        </div>
                      </div>
                    </blockquote>
                    agreed, "immovable" is the correct concept to use
                    for that<br>
                    <blockquote type="cite">
                      <div dir="ltr">
                        <div><br>
                        </div>
                        <div>I looked at 14.3.1 Immovable planning
                          entities but couldn't really see how I would
                          apply it to my use case. <br>
                        </div>
                      </div>
                    </blockquote>
                    Take a look at the course scheduling example.<br>
                    Here's a demo of immovable planning entities in that
                    example:<br>
                    &nbsp; <a href="http://www.youtube.com/watch?v=4meWIhPRVn8" target="_blank">http://www.youtube.com/watch?v=4meWIhPRVn8</a><br>
                    <blockquote type="cite">
                      <div dir="ltr">
                        <div>Why is the filter applied at the planning
                          entity level? Since it's the planning variable
                          that changes I thought that I should somehow
                          filter the allowed values for the Desk. <br>
                        </div>
                      </div>
                    </blockquote>
                    Don't mix the concept of "(im)movable entities"
                    (which is what you want) with the concept of
                    "limiting value ranges per entity" or the concept of
                    "filtering specific move selectors" (which is
                    overkill and convoluted for your needs).<br>
                    <blockquote type="cite">
                      <div dir="ltr">
                        <div> </div>
                        <div><br>
                        </div>
                        <div>Regards, <br>
                        </div>
                        <div>Mats<br>
                        </div>
                        <div><br>
                        </div>
                        <div><br>
                        </div>
                        <div><br>
                        </div>
                        <div>&nbsp;<br>
                        </div>
                      </div>
                      <br>
                      <fieldset></fieldset>
                      <br>
                      <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" 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>
                </blockquote>
              </div>
              <br>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      <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></div></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>
</div></body></html>