Unless I am mistaken, using Native you have to "roll your own" condition sharing, as the engine has no way of knowing intrinsically how to share. >From looking at the code it looks like if you implement hashCode and equals correctly, it may be able to share (but I am not sure).
The DRL condition sharing works when conditions are in the same order, and "look the same" (its kind of cheating !). Also not that for 2.5, you have to use the ReteDumper class, NOT the plain Dumper class (just FYI - it uses Dumper behind the scenes, but as there is proxying, you can't use it directly in 2.5). Michael. On 1/6/06, Usha <[EMAIL PROTECTED]> wrote: > > Use Case: > --------- > Test whether an object that has attributes A, B and C passes through a set > of > rules. > Rule 1: pass if Condition1: attribute A = "A1" & Condition2: attribute B = > "Y" > Rule 2: pass if Condition1: attribute A = "A1" & Condition3: attribute C = > "C1" > Rule 3: pass if Condition4: A = "A3". > > An object that has the attributes A="A4", B="Y" and C="C1" is asserted > into > the working memory. > > Scenario 1: Rules are built using a DRL file with the rules hardcoded into > the > DRL file. When the above object is asserted, Rule1/Condition1 is tested, > and > since it doesn't evaluate to true, Rule 2 is not executed. Rule 3 is > tested > however, and I can see from the Dumper output that the rules are organized > into a tree structure based on the results of each condition. > > Scenario 2: The rules are built using the Native method manually building > the > rule set using the Condition and Consequence objects. Rule 2 is tested, > even > if Rule 1 Condition1 does not pass. I do get the correct results from the > Rules engine, but from an execution point of view, it doesn't seem to be > organized/optimized as expected. > > Using the native rule definition method, how do I define the conditions > such > that they are organized as in Scenario 1? So, in the above example, if > Condition1 in Rule 1 does not pass, Rule 2 should not be even tested, but > Rule > 3 should be tested. > > Any help would be greatly appreciated. > > >
