[rules-users] Anyway to get Failed Reason for Failed Rule?

Davide Sottara dsotty at gmail.com
Thu Aug 9 18:12:34 EDT 2012


Hi, you have several option then

You can use drools-verifier for a static analysis of your rule base. In a
nutshell, it converts the rules into "descriptor" facts and inserts them in
a drools sessions, where you can apply some meta-rules. Drools verifier
comes with a few consistency check rules, but you can add your own.

You can attach listeners to the working memory and to the agenda: they will
process events (in the java sense) which the engine generates as it
processes data. 

You can use the "declarative agenda": every time a rule activation is
created, it is insert in the workingmemory, where you can use rules to
process it. Notice that, unlike drools verifier which works on rules
("offline"), this works on rule activations ("online").

This said, the concept of "failed condition" is quite debatable. Coming to
your second question: when Drools evaluates the premise of a rule, it
alternates select-like and join-like operations (I recommend you take a look
at the RETE algorithm and the drools documentation). A premise can be
matched or not, but the individual conditions that make up the patterns
might be 1) satisfied, 2) violated, 3) not evaluated at all because other
conditions make their evaluation not necessary. 

Moreover, one might consider differently rules which MUST fail - e.g.
Person( age < 10 && > 20 ) - from rules which MUST succeed - e.g. Object() -
from "normal" rules which might or might not fail, but that will depend
heavily on your facts. 

My gut feeling, without knowing your precise requirements, is as this: if
you need to check the consistency of a rule base, try verifier. if you want
to optimize a rule base (e.g. give priorities
to rules which are used more often, remove unused ones etc), use the
declarative agenda or the listeners and monitor the runtime execution. If
you have critical conditions in your data that you must evaluate, use
explicit positive and negative conditions: "when Person( age < 18 ) then A",
"when Patient( age >= 18) then B" (or, with a slightly different semantics,
"not Patient( age < 18 )" )

Davide



--
View this message in context: http://drools.46999.n3.nabble.com/Anyway-to-get-Failed-Reason-for-Failed-Rule-tp4019070p4019078.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list