<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7651.59">
<TITLE>No-loop \ salience issue - could somebody explain?</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P><FONT SIZE=2 FACE="Arial">Hi,</FONT>
</P>

<P><FONT SIZE=2 FACE="Arial">I've noticed some &quot;interesting&quot; behaviour with the use of no-loop and salience that I wonder if anybody can explain to me?</FONT></P>

<P><FONT SIZE=2 FACE="Arial">Given the following rules:-</FONT>
</P>

<P><B><FONT COLOR="#960000" SIZE=2 FACE="Courier New">package</FONT></B><FONT COLOR="#000000" SIZE=2 FACE="Courier New"> drools.debug</FONT>
</P>

<P><B><FONT COLOR="#960000" SIZE=2 FACE="Courier New">rule</FONT></B><FONT COLOR="#000000" SIZE=2 FACE="Courier New"></FONT> <FONT COLOR="#008000" SIZE=2 FACE="Courier New">&quot;Rule 1- (Fired)&quot;</FONT>

<BR><FONT COLOR="#808000" SIZE=2 FACE="Courier New">//salience 500</FONT>

<BR><B><FONT COLOR="#960000" SIZE=2 FACE="Courier New">no-loop</FONT></B><FONT COLOR="#000000" SIZE=2 FACE="Courier New"></FONT><B> <FONT COLOR="#960000" SIZE=2 FACE="Courier New">true</FONT></B>

<BR><B><FONT COLOR="#960000" SIZE=2 FACE="Courier New">when</FONT></B>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT COLOR="#000000" SIZE=2 FACE="Courier New">$m : Machine ( )</FONT>

<BR><B><FONT COLOR="#960000" SIZE=2 FACE="Courier New">then</FONT></B>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT COLOR="#000000" SIZE=2 FACE="Courier New">System.out.println(</FONT><FONT COLOR="#008000" SIZE=2 FACE="Courier New">&quot;DEBUG [Rule 1-]---&gt; Do nothing!&quot;</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New">);</FONT>

<BR><B><FONT COLOR="#960000" SIZE=2 FACE="Courier New">end</FONT></B>
</P>

<P><B><FONT COLOR="#960000" SIZE=2 FACE="Courier New">rule</FONT></B><FONT COLOR="#000000" SIZE=2 FACE="Courier New"></FONT> <FONT COLOR="#008000" SIZE=2 FACE="Courier New">&quot;Rule 1a (Fired)&quot;</FONT>

<BR><FONT COLOR="#808000" SIZE=2 FACE="Courier New">//salience 400</FONT>

<BR><B><FONT COLOR="#960000" SIZE=2 FACE="Courier New">no-loop</FONT></B><FONT COLOR="#000000" SIZE=2 FACE="Courier New"></FONT><B> <FONT COLOR="#960000" SIZE=2 FACE="Courier New">true</FONT></B>

<BR><B><FONT COLOR="#960000" SIZE=2 FACE="Courier New">when</FONT></B>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT COLOR="#000000" SIZE=2 FACE="Courier New">$m : Machine ( )</FONT>

<BR><B><FONT COLOR="#960000" SIZE=2 FACE="Courier New">then</FONT></B>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT COLOR="#000000" SIZE=2 FACE="Courier New">System.out.println(</FONT><FONT COLOR="#008000" SIZE=2 FACE="Courier New">&quot;DEBUG [Rule 1a]---&gt; Setting Attribute(\&quot;TEST3\&quot;) on Machine&quot;</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New">);</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT COLOR="#000000" SIZE=2 FACE="Courier New">Attribute a =</FONT><B> <FONT COLOR="#960000" SIZE=2 FACE="Courier New">new</FONT></B><FONT COLOR="#000000" SIZE=2 FACE="Courier New"> Attribute(</FONT><FONT COLOR="#008000" SIZE=2 FACE="Courier New">&quot;TEST1&quot;</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New">, 100);</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT COLOR="#000000" SIZE=2 FACE="Courier New">$m.setAttribute(a);</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B> <FONT COLOR="#960000" SIZE=2 FACE="Courier New">modify</FONT></B><FONT COLOR="#000000" SIZE=2 FACE="Courier New">($m);</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B> <FONT COLOR="#960000" SIZE=2 FACE="Courier New">assert</FONT></B><FONT COLOR="#000000" SIZE=2 FACE="Courier New">(a);</FONT>

<BR><B><FONT COLOR="#960000" SIZE=2 FACE="Courier New">end</FONT></B>
</P>

<P><B><FONT COLOR="#960000" SIZE=2 FACE="Courier New">rule</FONT></B><FONT COLOR="#000000" SIZE=2 FACE="Courier New"></FONT> <FONT COLOR="#008000" SIZE=2 FACE="Courier New">&quot;Rule 1b (</FONT><FONT COLOR="#008000" SIZE=2 FACE="Courier New">F</FONT><FONT COLOR="#008000" SIZE=2 FACE="Courier New">ired)&quot;</FONT>

<BR><FONT COLOR="#808000" SIZE=2 FACE="Courier New">//salience 300</FONT>

<BR><B><FONT COLOR="#960000" SIZE=2 FACE="Courier New">no-loop</FONT></B><FONT COLOR="#000000" SIZE=2 FACE="Courier New"></FONT><B> <FONT COLOR="#960000" SIZE=2 FACE="Courier New">true</FONT></B>

<BR><B><FONT COLOR="#960000" SIZE=2 FACE="Courier New">when</FONT></B>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT COLOR="#000000" SIZE=2 FACE="Courier New">$a : Attribute( name ==</FONT> <FONT COLOR="#008000" SIZE=2 FACE="Courier New">&quot;TEST1&quot;</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New"> )</FONT>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT COLOR="#000000" SIZE=2 FACE="Courier New">$m : Machine ( attribute == $a )</FONT>

<BR><B><FONT COLOR="#960000" SIZE=2 FACE="Courier New">then</FONT></B>

<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <FONT COLOR="#000000" SIZE=2 FACE="Courier New">System.out.println(</FONT><FONT COLOR="#008000" SIZE=2 FACE="Courier New">&quot;DEBUG [Rule 1b]---&gt; Found!&quot;</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New">);</FONT>

<BR><B><FONT COLOR="#960000" SIZE=2 FACE="Courier New">end</FONT></B>
</P>

<P><FONT SIZE=2 FACE="Arial">Assuming only one Machine Fact is present in Working Memory and the salience lines above are commented out &quot;Rule 1- (Fired)&quot;, &quot;Rule 1a (Fired)&quot; and &quot;Rule 1b (Fired)&quot; are activated and fired once (and once only). If however the salience values are uncommented rule &quot;Rule 1- (Fired)&quot; is fired twice (even though it is has the &quot;no-loop&quot; attribute). If the salience statements remain but have the same value then the rules only fire once as well (as I'd expect). It appears that &quot;no-loop&quot; only applies to rules with the same salience. Is this correct? Can somebody provide some reason as to why this occurs as it is different to what I'd expect?</FONT></P>

<P><FONT COLOR="#000000" SIZE=2 FACE="Arial">With kind regards,</FONT>
</P>

<P><FONT COLOR="#000000" SIZE=2 FACE="Arial">Mike</FONT>
</P>

</BODY>
</HTML>