Today, on this list, I posted a way of getting the DRL from a decision table. We should see the rules that are generated for the 2nd rule table.
And see below... On 10 February 2011 18:11, groovenarula <gnaru...@la-z-boy.com> wrote: > > rule "Set F103 Option price based on Group/Style" > salience 50 > when > $unit : Unit ( group == "010", style == "315" ) > $option : Option (unit == $unit ) > Option (optionPrice == null, code == "F103" ) > This doesn't look right. I'd expect $option : Option (unit == $unit, optionPrice == null, code == "F103" ) -W > then > > $option.setOptionPrice(120.00); > retract ( $option ); > end > > rule "Set F103 Option base price" > salience 5 > when > $option : Option ( optionPrice == null, code == "F103" ) > then > $option.setOptionPrice(100.00); > retract ( $option ); > end > > Question : Is there a better way to implement the rules stated above ? > > The DRL works as expected when I insert one or multiple items in working > memory. The appropriate rules fire and when Group / Style = 010 / 315, the > price for the option is set to 120, but when Group and Style is anything > else, the option does get priced at 100.00. > > However, when I try to implement the same rule using decision tables, I get > different results. To implement the above, I created 2 rule tables : > > 1. The first rule table establishes the pricing of options that are not > specific to a group / style as follows: > > CONDITION PRIORITY > ACTION > $option : Option > code == "$param", optionPrice == null 5 > $option.setOptionPrice($param); retract($option) > > 2. A second rule table that adds the unit constraints as follows (with > PRIORITY 50): > > CONDITION CONDITION CONDITION > $unit : Unit $option : Option > group == "$param" style == "$param" unit == $unit, code == "$param", > optionPrice == null > > ACTION > $option.setOptionPrice($param); retract ( $option); > > There in lies my dilemma. > > When I send one unit with Group Style 010 315 and option F103, it prices > the > option properly @ 120.00. > > When I send in a unit with a different style (same group = 010), it also > prices the option properly at 100. > > When I when I send 2 units together - one with group and style 010 315 and > another having the same group but a different style (515 for example), it > prices the option for both units @ 120 : > > 010 315 option price = 120.00 (correct result) > 010 515 option price = 120.00 (wrong result) > > But if the second unit on the 2 units has a different group (011 for > example), I get the right option prices : > 010 315 option price = 120.00 (correct result) > 011 315 option price = 100.00 (correct result) > > For what ever reason, it does not fire the generic pricing option even > though the second unit's G/S does not match 010 315. > > Can anyone please shed some light on what I'm doing wrong here ? > > Any help will be appreciated. > > Thanks in advance. > Gurvinder > > -- > View this message in context: > http://drools-java-rules-engine.46999.n3.nabble.com/Getting-different-results-from-decision-tables-based-on-number-of-facts-all-other-fact-information-s-tp2467364p2467364.html > Sent from the Drools - User mailing list archive at Nabble.com. > > _______________________________________________ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users >
_______________________________________________ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users