Very good basic advice of how to write rules for a rete engine can be found in this <a href="http://www.jessrules.com/jess/docs/71/rete.htm">place</a>. You&#39;ll also find a discussion of the technical details in the Drools Expert part of the manual.<br>
<br>-W<br><br><br><div class="gmail_quote">2009/4/3 Michal Bali <span dir="ltr">&lt;<a href="mailto:michalbali@gmail.com">michalbali@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Wolfgang, <br><br>Is it the number of instances or how often they are modified that makes the difference? I am just wondering why it is better.<br><br>Best Regards,<br>Michal<br><br><div class="gmail_quote">2009/4/3 David Sinclair <span dir="ltr">&lt;<a href="mailto:dsinclair@chariotsolutions.com" target="_blank">dsinclair@chariotsolutions.com</a>&gt;</span><div>
<div></div><div class="h5"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Here you go WolfGang<div><br><br>rule shoot-3 <br>    when<br>            $h : Hunter( $target : target)<br>

</div>                  Animal(this == $target)<div><br>    then<br>       $h.shoot( $a );<br>       retract( $a );<br>end<br><br>
</div><div class="gmail_quote">2009/4/3 Wolfgang Laun <span dir="ltr">&lt;<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div><div></div><div>
Given a working memory containing a large number of rather static facts which are from several subclasses (Ape, Bear, Crocodile,...) of some base class (Animal) and a single fact of class Hunter with a field target of type Animal, the shooting of an animal might be written with a rule like this:<br>



<br>rule shoot-1<br>    when<br>        ?h : Hunter( ?target : target )<br>        ?a : Animal()<br>        eval(?target == ?a)<br>    then<br>       ?h.shoot( ?a );<br>       retract( ?a );<br>end<br><br>Avoiding eval (which is said to be inefficient), it could also be written as<br>



<br>rule shoot-2<br>
    when<br>        ?a: Animal()<br>
        ?h : Hunter( target  == ?a )<br>
    then<br>
       ?h.shoot( ?a );<br>
       retract( ?a );<br>
end<br><br>This, however, places the pattern with many instances up front, which is (AFAIK) not so good in a Rete implementation.<br><br>Which one is to be preferred in Drools?<br><br>Ideally, one might want to write <br>



<br>rule shoot-3<br>
    when<br>
        ?h : Hunter( ?target : target )<br>
        ?a == ?target : Animal()                   ### not valid DRL<br>
    then<br>
       ?h.shoot( ?a );<br>
       retract( ?a );<br>
end<br><br>This avoids eval, has the single instance fact up front, but it isn&#39;t available.<br><font color="#888888"><br>-W<br><br><br><br>
</font><br></div></div>_______________________________________________<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>
<br></blockquote></div><br>
<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>
<br></blockquote></div></div></div><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" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>