The answer to your question is not simple.
Basically, the constraint evaluation will follow a priority order, in the
following way:
1) all alpha constraints are evaluated
2) all beta indexable constraints are evaluated
3) all beta non indexable constraints are evaluated
Inside each of the categories above, the constraints are evaluated in the
order they are written in the patterns.
At any time a constraint fails, they will short circuit and not evaluate
later constraints.
The above ordering is made so that the engine executes them in "optimal"
order for performance. Obviously, this may not be the "best" order, but it
is the best the engine can infer.
So, I guess what is happening in your use case is that the constraint you
want to evaluate later is falling in a previous category, so that is the
reason it is being evaluated out of your desired order.
Having said that, "timeRight == true" is an alpha constraint, so it
"should" be executing first. Can you please get a self contained test that
shows this case? I will take a look in it and check if we have a bug or not.
There are workarounds, but I would like to investigate this one.
Regards,
Edson
2007/4/5, Rahul Phadnis <rahul.phadnis(a)fatspaniel.com>:
I have the following rule in my DRL file
rule "inverteroff-evaluate-based-on-pvpower"
# the if part
when
alertDefinition : Alert
($configID:alertConfigID)
alertCondition: AlertCondition(name ==
"InverterOff")
context: EvaluationContext (
timeRight == true,
pvPower!= null,
pvPower <= 0
)
then
# what do we do if the rule evaluates to true
log("Triggered inverteroff alert for
alertConfigID" + $configID);
alertDefinition.setState(AlertState.TRIGGERED);
log("Context info:" + context);
end
I would like to know if I assert an EvaluationContext
for which timeRight == false, will the getPvPower()
method still be called ? (logically it shouldn't be
called since the "," separated conditions are "AND"
conditions)
>From my tests it seems like the getPvPower method is
called irrespective of the value of timeRight.
If that is the expected behaviour how can I improve my
rule definition to ensure that getPvPower isn't called
if it is not necessary.
Thank you,
Rahul Phadnis
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Edson Tirelli
Software Engineer - JBoss Rules Core Developer
Office: +55 11 3124-6000
Mobile: +55 11 9218-4151
JBoss, a division of Red Hat @
www.jboss.com