[rules-users] No-loop \ salience issue - could somebody explain?

Edson Tirelli tirelli at post.com
Fri Mar 23 08:26:41 EDT 2007


   Michael,

   No-loop applies only to the rule triggering itself again in a loop. 
So, with the same salience, I would guess (didn't tested) bellow rules 
would execute:

R2
R1
R3

   Remember, this is non-determinist and could also fire like:

R1
R2
R3
R1

   The differences are due to conflict resolution strategies that may be 
different.

   Having different saliences as the commented ones, I would guess 
(didn't tested) that they would fire:

R1
R2
R1
R3

   Read about conflict resolution and you will get a few tips on it.

   []s
   Edson 

Anstis, Michael (M.) wrote:

> Hi,
>
> I've noticed some "interesting" behaviour with the use of no-loop and 
> salience that I wonder if anybody can explain to me?
>
> Given the following rules:-
>
> *package* drools.debug
>
> *rule* "Rule 1- (Fired)"
> //salience 500
> *no-loop** true*
> *when*
>         $m : Machine ( )
> *then*
>         System.out.println("DEBUG [Rule 1-]---> Do nothing!");
> *end*
>
> *rule* "Rule 1a (Fired)"
> //salience 400
> *no-loop** true*
> *when*
>         $m : Machine ( )
> *then*
>         System.out.println("DEBUG [Rule 1a]---> Setting 
> Attribute(\"TEST3\") on Machine");
>         Attribute a =* new* Attribute("TEST1", 100);
>         $m.setAttribute(a);
>        * modify*($m);
>        * assert*(a);
> *end*
>
> *rule* "Rule 1b (Fired)"
> //salience 300
> *no-loop** true*
> *when*
>         $a : Attribute( name == "TEST1" )
>         $m : Machine ( attribute == $a )
> *then*
>         System.out.println("DEBUG [Rule 1b]---> Found!");
> *end*
>
> 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?
>
> With kind regards,
>
> Mike
>
>------------------------------------------------------------------------
>
>_______________________________________________
>rules-users mailing list
>rules-users at lists.jboss.org
>https://lists.jboss.org/mailman/listinfo/rules-users
>  
>


-- 
 Edson Tirelli
 Software Engineer - JBoss Rules Core Developer
 Office: +55 11 3124-6000
 Mobile: +55 11 9218-4151
 JBoss, a division of Red Hat @ www.jboss.com





More information about the rules-users mailing list