[rules-users] Misunderstanding salience?
Peter Ashford
petera at bestpractice.org.nz
Tue Mar 8 19:30:31 EST 2011
Hi There
I'm new to drools. I've just set up the Drools-Server and it is (finally!) working and serving my test rule-set. The one thing that's not working as I expect it is the rule ordering via salience. This is my simple test rule set:
rule "General brain eating advice"
when
p : Patient(eatsBrains == true)
then
p.setAdvice("Stop eating brains, or at least, try to cut down");
end
rule "Zombie exception to brain eating advice"
salience -50
when
p : Patient(eatsBrains == true, isZombie == true)
then
p.setAdvice("Evidence suggests that the undead cannot contract Kuru or that the effects are irellevant given the " +
"patient's current zombified state.\nSuggest euthenasing patient lest he/she eat your (or someone " +
"else's) brains");
end
The idea is that the first rule fires all the time unless the patient happens to be a zombie, in which case the exception rule (the second rule) kicks in. Now, as I have it here, with the exception at salience at -50 it actually works, which is the opposite of what I was expecting. I'd thought that I would have had to have the exception at a higher salience to fire first. That was what I tried first but that didn't work - everyone got the general advice, zombies included.
What am I misunderstanding here?
Thanks!
Peter.
---
"It is very difficult to get a man to understand something when his tribal identity depends on his not understanding it" - Michael Bérubé on Republican climate change denial.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110309/afe83521/attachment.html
More information about the rules-users
mailing list