Hi,

If you do not want to check for all alternative cases, you might need a
showstopper to stop the firings of unwanted rules.

This can be achieved by executing insert(new ShowStopper() ); in your RHS.
All LHS of the rules will check for not( ShowStopper() )

Alternatively, you can use the new -experimental - feature of drools called
"declarative agenda". You could use this to block activations of rules
directly.

Also, be aware that relying on salience alone is very hard to maintain over
time.

Regards,
Frank


ronalbury wrote
> 
> Hi - I am a Drools newbie and I apologize in advance if the answer to my
> question is intuitively obvious to the casual user.
> 
> I have an object that has two fields: location(there are more than 50
> locations) and age.  I am having difficulty building clean rules for the
> following pseudo-code
> 
> 
> // Rule One
> if(location == "A") {
>    if(age > 60)
>       do_something();
> }
> // Rule Two
> else if(location == "B") {
>     if(age > 70)
>         do_something();
> }
> // Rule Three
> else if(location == "C") {
>     if(age > 80)
>         do_something();
> }
> // Rule Four
> else {
>     if(age > 65)
>         do_something();
> }
> 
> The issue comes with Rule Four.  How do I avoid writing the rule so that I
> don't have to say (location!="A"&&location!="B"&&location!="C") ?  I also
> don't want to have to write an explicit rule for every possible location.
> 
> I considered an activation-group with salience to have the rules executed
> in order, but the problem is that if rules 1-3 do not fire, then rule 4
> fires for all locations - I can get a hit if location=="C" and age==70.
> 
> Is it possible to have a 'Map' and do something like
> (age>map.get(location)) ?  I could live with creating a map with all
> possible locations for key, although I'd rather not go this route.
> 
> This problem is typical for the types of rules I'll be writing ... there
> can be completely different sets of rule criteria depending on location.
> 
> 
> Thanks in advance for your suggestions and your patience.
> 
> _______________________________________________
> rules-users mailing list
> rules-users@.jboss
> https://lists.jboss.org/mailman/listinfo/rules-users
> 


--
View this message in context: 
http://drools.46999.n3.nabble.com/rules-users-multi-factor-rule-tp3531130p3531237.html
Sent from the Drools: User forum mailing list archive at Nabble.com.
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to