Sorry to repost again....  But I also realized after sending that if you have 
to exclude locations A, B, and C from the else rule, then you do not need 
salience, nor activation group, since all the rules are not mutually 
exclusive..  This this (much easier too now)


rule 'Rule One'

when

                Person (location == 'A',  age > 60 )

Then

                do_something();

end



rule 'Rule Two'

when

                Person (location == 'B',  age > 70 )

Then

                do_something();

end



rule 'Rule Three'

when

                Person (location == 'C',  age > 80 )

Then

                do_something();

end



rule 'Rule Else'

when

                Person (location not in ('A','B','C'), age > 65 )

Then

                do_something();

end


--Armand

From: [email protected] 
[mailto:[email protected]] On Behalf Of Welsh, Armand
Sent: Wednesday, November 23, 2011 12:50 PM
To: Rules Users List
Subject: Re: [rules-users] multi-factor rule

Oh... I misread the pseudo code.  I missed that the if (age>60) is inside the 
if(location=="A") rule. This is easy enough to fix.  It's would essentially be 
the same thing as the otherwise, but in DRL:


rule 'Rule One'

activation-group 'age-test'

salience 300

when

                Person (location == 'A',  age > 60 )

Then

                do_something();

end



rule 'Rule Two'

activation-group 'age-test'

salience 200

when

                Person (location == 'B',  age > 70 )

Then

                do_something();

end



rule 'Rule Three'

activation-group 'age-test'

salience 100

when

                Person (location == 'C',  age > 80 )

Then

                do_something();

end



rule 'Rule Else'

activation-group 'age-test'

when

                Person (location not in ('A','B','C'), age > 65 )

Then

                do_something();

end


This is a good example why it can be difficult to model rules from procedural 
language.  With a rule, you are reacting to a given condition, but with 
procedural language waterfall logic, you automatically exclude conditions as 
you fall through the logic.  With rules, there is not waterfall effect.  You 
have to simulate the waterfall logic with explicit exclusions.

This is best represented with a lot of if() but no else clauses in procedural 
language logic.

Not the only rule I modified to make this work was my else rule.

Regards,
Armand

From: [email protected] 
[mailto:[email protected]] On Behalf Of Ronald Albury
Sent: Wednesday, November 23, 2011 11:22 AM
To: [email protected]
Subject: Re: [rules-users] multi-factor rule

Armand

I don't think that works if location=='B' and age=68

_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to