Hi,
you might try something like one of the following two variants:
a) Checking for Location only first, inserting a Fact for the respective
location and doing a second rule for each location that checks for this fact
and the age (using salience to ensure only one rule fires and this in the
correct order).
In this case, exactly one of the rules without the additional facts will
fire:
- if it is one of the first three, it will fire first, then after that the
rule with the additional fact will fire and give the correct result
- else, your "else" rule fires right away.
b) using different agenda-groups for the different locations and setting
focus to the location-specific agenda-group in a first step. If I get it
correctly (I am a newbie too and don't have the time to try it out), this
should work.
True, you have two rules for each location, but I find this acceptable:
- Rules should be simple and (close to) declarative
- If I read your requirements correctly, you typically filter on location,
so in the long run, there will be location-specific agenda-groups anyway if
you build a complete rule base.
Variant B could look like this:
rule "Rule One"
activation-group "CheckLocation"
salience 300
when
Person(location == "A" )
Then
drools.setFocus("Location-A");
end
rule "Location A: age>60"
agenda-group 'Location-A'
when
Person(age>60)
then
do_something();
end
rule "Rule Two"
activation-group "CheckLocation"
salience 200
when
Person(location == "B" )
Then
drools.setFocus("Location-B");
end
rule "Location B: age>70"
agenda-group "Location-B"
when
Person(age>70)
then
do_something();
end
rule "Rule Three"
activation-group "CheckLocation"
salience 100
when
Person(location == "C" )
Then
drools.setFocus("Location-C");
end
rule "Location C: age>80"
agenda-group "Location-C"
when
Person(age>80)
then
do_something();
end
rule 'Rule Else'
activation-group "CheckLocation"
salience 0
when
Person (age > 65 )
Then
do_something();
end
--
View this message in context:
http://drools.46999.n3.nabble.com/rules-users-multi-factor-rule-tp3531130...
Sent from the Drools: User forum mailing list archive at
Nabble.com.