[rules-users] Why double rule activation?
Bagwell, Allen F
afbagwe at sandia.gov
Wed Apr 16 15:49:46 EDT 2008
I've encountered rule engine behavior I'm knocking my head against the wall trying to figure out. I'm a Drools newbie, so please forgive if this I am doing something bone-headed wrong.
Basically I'm inserting an object into my working memory. The object itself has a default setting of 0.0 for a brightness value, and this setting matches the LHS condition for my first rule. The problem is the rule activates twice for a single object insertion as described in the audit log. It consequently executes twice when I fire all rules. Then whenever I change the value in question, any single update to the same object also causes double rule activation and execution.
The rules I've written are not complex. Here's my drl file:
package dimmerie;
#list any import classes here.
import knowledgebase.*;
import NipcLogger;
#declare any global variables here
global NipcLogger IELogger;
rule "Light is off"
when
$brightness : MyVariable(uniqueName == "ds1 at brightness", currentValue == 0.0)
then
IELogger.info("DimmerSwitch1 has no brightness value");
end
rule "Light Below 50%"
when
$brightness : MyVariable(uniqueName == "ds1 at brightness", currentValue < 0.50, currentValue > 0.0)
then
IELogger.info("DimmerSwitch1 is below 50% brightness");
end
rule "Light 50% or Above"
when
$brightness : MyVariable(uniqueName == "ds1 at brightness", currentValue >= 0.5)
then
IELogger.info("DimmerSwitch1 is at or above 50% brightness");
end
I'm hoping I've described enough without having to post additional code. Can anyone suggest why this is happening?
Thanks,
Allen
More information about the rules-users
mailing list