<!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 "interesting" 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">"Rule 1- (Fired)"</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> <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> <FONT COLOR="#000000" SIZE=2 FACE="Courier New">System.out.println(</FONT><FONT COLOR="#008000" SIZE=2 FACE="Courier New">"DEBUG [Rule 1-]---> Do nothing!"</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">"Rule 1a (Fired)"</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> <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> <FONT COLOR="#000000" SIZE=2 FACE="Courier New">System.out.println(</FONT><FONT COLOR="#008000" SIZE=2 FACE="Courier New">"DEBUG [Rule 1a]---> Setting Attribute(\"TEST3\") on Machine"</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New">);</FONT>
<BR> <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">"TEST1"</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New">, 100);</FONT>
<BR> <FONT COLOR="#000000" SIZE=2 FACE="Courier New">$m.setAttribute(a);</FONT>
<BR> <B> <FONT COLOR="#960000" SIZE=2 FACE="Courier New">modify</FONT></B><FONT COLOR="#000000" SIZE=2 FACE="Courier New">($m);</FONT>
<BR> <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">"Rule 1b (</FONT><FONT COLOR="#008000" SIZE=2 FACE="Courier New">F</FONT><FONT COLOR="#008000" SIZE=2 FACE="Courier New">ired)"</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> <FONT COLOR="#000000" SIZE=2 FACE="Courier New">$a : Attribute( name ==</FONT> <FONT COLOR="#008000" SIZE=2 FACE="Courier New">"TEST1"</FONT><FONT COLOR="#000000" SIZE=2 FACE="Courier New"> )</FONT>
<BR> <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> <FONT COLOR="#000000" SIZE=2 FACE="Courier New">System.out.println(</FONT><FONT COLOR="#008000" SIZE=2 FACE="Courier New">"DEBUG [Rule 1b]---> Found!"</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 "Rule 1- (Fired)", "Rule 1a (Fired)" and "Rule 1b (Fired)" are activated and fired once (and once only). If however the salience values are uncommented rule "Rule 1- (Fired)" is fired twice (even though it is has the "no-loop" 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 "no-loop" 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>