<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">the language statement "this in ($joe, $bob, $tom)" sounds &amp; looks great to me - more intuitive than the eval. imho it<DIV>shortens down the overall LHS...</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Considering rule-performance, one should imho fail-as-early-as-possible... but for the example that surely does not matter...</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>thanx for this improvement...</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>will you commit this to the next release, so this sample works "as expected" from now on?</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>regards from (sunny) Cologne,</DIV><DIV>Gernot</DIV><DIV><BR><DIV><DIV>Am 11.08.2007 um 20:45 schrieb Edson Tirelli:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><BR>    Gernot,<BR><BR>    Thanks for taking the time to investigate and report your findings. I implemented a fix in a similar way to your suggestion, but instead of writing an eval() in the end, I reordered the patterns leaving the Fred's neighbor pattern as the last pattern: <BR><BR>          // The golfer to Fred's immediate right<BR>          // is wearing blue pants<BR>        $fn : Golfer( position == ( $fredsPosition + 1 ),<BR>                      color == "blue",<BR>                      this in ( $joe, $bob, $tom ) ) <BR><BR>    What do you think about this solution? It now correctly solves the problem, but I'm not sure it is as elegant solution as you was looking for. <BR><BR>    If you want to take a look, just make sure you use drools-core jar from trunk (not GA), since I found and fixed a minor bug while changing the golfer example. <BR><BR>   Edson<BR><BR><DIV><SPAN class="gmail_quote">2007/8/10, Dr. Gernot Starke &lt;<A href="mailto:gs@gernotstarke.de">gs@gernotstarke.de</A>&gt;:</SPAN><BLOCKQUOTE class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Hi there,<BR><BR>some people complained that the Golfer-example from the JBoss-Drools<BR>distribution finds two identical solutions.<BR>I investigated a little and found the "problem":<BR><BR>The rule is underspecified: It binds five Golfer objects, but only <BR>four of those are completely specified by their respective<BR>condition elements. The fifth, the "Freds right neighbour", lacks<BR>that completeness...<BR><BR>What happens is the following: The "unknown golfer" can be bound to <BR>two different facts: I had the "unknown" golfer<BR>printed out - and see what happened:<BR><BR>Fred 1 orange, Joe 2 blue, Bob 4 plaid, Tom 3 red<BR>unknown Tom 2 blue<BR><BR>Fred 1 orange, Joe 2 blue, Bob 4 plaid, Tom 3 red <BR>unknown Joe 2 blue<BR><BR>As the unknown golfer is NOT compared to the actual neighbor, Joe,<BR>there are two possible instantiations<BR>for our "unknown" golfer...<BR><BR>The solution would be to constraint the unknown-golfer (= Fred's <BR>right neighbour) to the set of (Bob, Joe, Tom)...<BR>an eval sounds great - too bad the "in" constraint doesn't work...<BR><BR>       // freds right neighbour is either Tom, Bob or Joe!<BR>         eval (($fn == $joe) || ($fn == $bob) || ($fn == $tom)) <BR><BR><BR>The simple (but un-elegant) solution is setting an agenda-group rule-<BR>attribute, prohibing the rule from firing twice.<BR><BR>In his book on JESS, E. Friedemann-Hill shows JESS to deliver only a<BR>single solution ... I translated the Drools-version <BR>literally to his JESS version (I had to create GolferColor and<BR>GolferPosition classes, but needed only 32 facts in working memory,<BR>instead of 64 with the combined Golfer-drools version)....<BR><BR>regards,<BR>Gernot <BR><BR><BR>Dr. Gernot Starke<BR>Doing IT Right<BR><BR>---<BR>Willi-Lauf Allee 43, D-50858 Köln<BR><A href="mailto:gs@gernotstarke.de">gs@gernotstarke.de</A>,<BR>  +49 (0) 177 - 728 2570<BR><A href="http://www.gernotstarke.de"> http://www.gernotstarke.de</A><BR>Blog: <A href="http://it-and-more.blogspot.com">http://it-and-more.blogspot.com</A><BR>****************************************<BR>Das freie Portal für Software-Architekten:<BR><A href="http://www.arc42.de"> http://www.arc42.de</A><BR><BR><BR><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"> https://lists.jboss.org/mailman/listinfo/rules-users</A><BR></BLOCKQUOTE></DIV><BR><BR clear="all"><BR>-- <BR>  Edson Tirelli<BR>  Software Engineer - JBoss Rules Core Developer<BR>  Office: +55 11 3529-6000<BR>  Mobile: +55 11 9287-5646 <BR>  JBoss, a division of Red Hat @ <A href="http://www.jboss.com">www.jboss.com</A><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">_______________________________________________</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">rules-users mailing list</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</A></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><A href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</A></DIV> </BLOCKQUOTE></DIV><BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV>Dr. Gernot Starke</DIV><DIV>Doing IT Right</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>---</DIV><DIV>Willi-Lauf Allee 43, D-50858 Köln</DIV><DIV><A href="mailto:gs@gernotstarke.de">gs@gernotstarke.de</A>, </DIV><DIV> +49 (0) 177 - 728 2570</DIV><DIV><A href="http://www.gernotstarke.de">http://www.gernotstarke.de</A></DIV><DIV>Blog: <A href="http://it-and-more.blogspot.com">http://it-and-more.blogspot.com</A></DIV><DIV>****************************************</DIV><DIV>Das freie Portal für Software-Architekten:</DIV><DIV><A href="http://www.arc42.de">http://www.arc42.de</A></DIV><BR class="Apple-interchange-newline"></SPAN> </DIV><BR></DIV></BODY></HTML>