Another thing to remember is that activations occurs when you insert/update/retract facts and the execution itself happens when you call fireAllRules() ( or fireUntilHalt() ).<br><br><div class="gmail_quote">2010/6/11 Swindells, Thomas <span dir="ltr">&lt;<a href="mailto:TSwindells@nds.com">TSwindells@nds.com</a>&gt;</span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">





<div lang="EN-GB" link="blue" vlink="purple">
<div>
<p class="MsoNormal"><span style="color:#1F497D">You technical description isn’t at all accurate.</span></p>
<p class="MsoNormal"><span style="color:#1F497D">You need to read up on Rete Trees, I’m still a bit vague on them myself but a hopefully slightly more accurate description is as follows:</span></p>
<p class="MsoNormal"><span style="color:#1F497D">When the rules are compiled each of their conditions is converted to a node on the graph.  If rules share the same initial set of conditions then they will share those nodes in the tree.  These nodes contain
 references to the data in the working memory that they match against.  When an object is added or updated in working memory then the knowledge of this allows just the relevant nodes to be re-evaluated trickling down the tree.  If a leaf node is reached with
 a particular set of Objects then this means that the rule can then be placed on the activation queue with that set of data.</span></p>
<p class="MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="color:#1F497D">This Rete graph is designed to solve the problem you are describing which is why we have a rules engine rather than doing the naive procedural implementation of ‘firing rules’.  Of course if all your rules are
 disjoint but rely on the same set of Objects then there isn’t any choice but to evaluate all the rules, after all they may all do different things and normally you want multiple rules to fire.</span></p>
<p class="MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="color:#1F497D">How you write your rules can also have a massive impact on performance and the shape of the graph (which you can see in eclipse), are you worrying about this purely from a theoretical viewpoint or are you having
 a concrete performance problem?</span></p>
<p class="MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="color:#1F497D">Hope this helps your understanding,
</span></p>
<p class="MsoNormal"><span style="color:#1F497D"> </span></p>
<p class="MsoNormal"><span style="color:#1F497D">Thomas</span></p>
<p class="MsoNormal"><span style="color:#1F497D"> </span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:10.0pt">From:</span></b><span lang="EN-US" style="font-size:10.0pt"> <a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a> [mailto:<a href="mailto:rules-users-bounces@lists.jboss.org" target="_blank">rules-users-bounces@lists.jboss.org</a>]
<b>On Behalf Of </b>Nikhil S. Kulkarni<br>
<b>Sent:</b> 11 June 2010 12:27<br>
<b>To:</b> <a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<b>Subject:</b> [rules-users] How to break the rules execution if one has been satisfied ??</span></p>
</div>
</div><div><div></div><div class="h5">
<p class="MsoNormal"> </p>
<p class="MsoNormal"><span lang="EN-US">Hi,</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">In rules, in a particular rule set, all the when’s are executed. In technical terms, the activation is first created. For all the rules in a rule set the when condition is first evaluated and if the when condition is
 satisfied for any rule then the rule is marked as ready to fire. Once all the when part for all the rules are evaluated then all the ones that were marked for fire are fired.</span></p>
<p class="MsoNormal"><span lang="EN-US">The performance issue that if there are some 1500 rows. Hence, when the rule is fired there are 1500 when conditions that are firstly checked. And only after this the then part is fired. There is no way to break the when
 checks on successful satisfaction of a particular rule when. </span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">Example:</span></p>
<p class="MsoNormal"><span lang="EN-US">If I have say a group of 1000 rules as mentioned below</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">Rule_1</span></p>
<p class="MsoNormal"><span lang="EN-US">Salience 1000 </span></p>
<p class="MsoNormal"><span lang="EN-US">When</span></p>
<p class="MsoNormal"><span lang="EN-US">                Some_Conditions_1</span></p>
<p class="MsoNormal"><span lang="EN-US">Then</span></p>
<p class="MsoNormal"><span lang="EN-US">                Some_Actions_1</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">Rule_2</span></p>
<p class="MsoNormal"><span lang="EN-US">Salience 999</span></p>
<p class="MsoNormal"><span lang="EN-US">When</span></p>
<p class="MsoNormal"><span lang="EN-US">                Some_Conditions_2</span></p>
<p class="MsoNormal"><span lang="EN-US">Then</span></p>
<p class="MsoNormal"><span lang="EN-US">                Some_Actions_2</span></p>
<p class="MsoNormal"><span lang="EN-US">.</span></p>
<p class="MsoNormal"><span lang="EN-US">.</span></p>
<p class="MsoNormal"><span lang="EN-US">.</span></p>
<p class="MsoNormal"><span lang="EN-US">Rule_1000</span></p>
<p class="MsoNormal"><span lang="EN-US">Salience 1</span></p>
<p class="MsoNormal"><span lang="EN-US">When</span></p>
<p class="MsoNormal"><span lang="EN-US">                Some_Conditions_1000</span></p>
<p class="MsoNormal"><span lang="EN-US">Then</span></p>
<p class="MsoNormal"><span lang="EN-US">                Some_Actions_1000</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">Let’s assume that Some_conditions_2 = true</span></p>
<p class="MsoNormal"><span lang="EN-US">Now even though I have an ordering using salience, the rule engine will still execute all the when conditions (Some_Conditions_1 .. Some_Conditions_1000)</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">Is it possible for me to break this when evaluation even if one has been satisfied?</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US">Thanks &amp; Regards,</span></p>
<p class="MsoNormal"><span lang="EN-US">Nikhil S. Kulkarni</span></p>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span lang="EN-US" style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;"> </span></p>
<table border="0" cellpadding="0" style="background:white">
<tbody>
<tr>
<td style="padding:.75pt .75pt .75pt .75pt">
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;;color:black"><br>
MASTEK LTD.<br>
Mastek is in NASSCOM&#39;s &#39;India Top 20&#39; Software Service Exporters List.<br>
In the US, we&#39;re called MAJESCOMASTEK<br>
<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server.<br>


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</span></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,&quot;serif&quot;"> </span></p>
</div></div></div>
</div>
<br>
<hr>
<font face="Arial" color="Gray" size="1"><br>
**************************************************************************************<br>
This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the <a href="mailto:postmaster@nds.com" target="_blank">postmaster@nds.com</a> and delete it from your system as well as any copies. The content of e-mails as well as traffic data
 may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary.<br>
<br>
NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00<br>
**************************************************************************************<br>
</font>
</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>
<br></blockquote></div><br><br clear="all"><br>-- <br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br><br>Esteban Aliverti<br>