<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">Op 06-12-12 14:37, Michiel Vermandel
      schreef:<br>
    </div>
    <blockquote
      cite="mid:1354801057.28135.YahooMailNeo@web161304.mail.bf1.yahoo.com"
      type="cite">
      <div style="color:#000; background-color:#fff; font-family:tahoma,
        new york, times, serif;font-size:10pt">Hi,<br>
        <br>
        I have got a Planning entity which takes several planning
        variables.<br>
        The provided variable-lists never contain null elements.<br>
        Though, in my rules I get planning entities with uninitialized
        planning variables (null).<br>
        Why is that?<br>
      </div>
    </blockquote>
    The construction heuristics first need to insert all planning
    entities (uninitialized) into the working memory.<br>
    This means the planning variables are still null at that time.<br>
    <br>
    The best way to make your rules null safe is to use null safe
    getters:<br>
    <br>
    class ShiftAssignment { ...<br>
    &nbsp;&nbsp;&nbsp; public Contract getContract() {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (employee == null) {<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return null;<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return employee.getContract();<br>
    &nbsp;&nbsp;&nbsp; }<br>
    }<br>
    <br>
    when ShiftAssignment (contract != null, ...)<br>
    <br>
    <blockquote
      cite="mid:1354801057.28135.YahooMailNeo@web161304.mail.bf1.yahoo.com"
      type="cite">
      <div style="color:#000; background-color:#fff; font-family:tahoma,
        new york, times, serif;font-size:10pt">Can this be avoided?<br>
      </div>
    </blockquote>
    No, the gain of using construction heuristics is too way big to
    ignore them.<br>
    <br>
    It's an open discussion currently:<br>
    - Users suffer because they need to make their rules null safe. I
    recognize this.<br>
    - Planner implementation wise, it makes far more sense to require
    the rules to be null safe<br>
    -- avoids certain bugs<br>
    - What should Planner return if no initialized solution has been
    found yet?<br>
    -- (the constr heuristics aren't finished yet)<br>
    -- What would be the Score of that uninitialized solution?<br>
    - How does PlanningVariable(nullable = true) affect this?<br>
    -- Returning an uninitialized best solution is much better than
    returning a null best solution<br>
    - What can Drools Expert provide to make it easier to have null-safe
    rules?<br>
    -- They now support an elvis-like operator but it's slower because
    it falls back on mvel.<br>
    <blockquote
      cite="mid:1354801057.28135.YahooMailNeo@web161304.mail.bf1.yahoo.com"
      type="cite">
      <div style="color:#000; background-color:#fff; font-family:tahoma,
        new york, times, serif;font-size:10pt"><br>
        Thanks<br>
        <div><span><br>
          </span></div>
        <div>&nbsp;</div>
        <div>-----------------<br>
          <a class="moz-txt-link-freetext" href="http://www.codessentials.com">http://www.codessentials.com</a> - Your essential software, for
          free!<br>
          Follow us at <a class="moz-txt-link-freetext" href="http://twitter.com/#!/Codessentials">http://twitter.com/#!/Codessentials</a></div>
      </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>