<br> Sudhir:<br><br> In Rete, you must tell the engine a fact has changed, either by using a modify() block (recommended), or update() or property listeners.<br><br> LEAPS is a different algorithm that was originally maintained by a community user that long ago abandoned it. It is no longer included in the drools distribution.<br>
<br> []s<br> Edson<br><br><div class="gmail_quote">2009/1/9 Sudhir M <span dir="ltr"><<a href="mailto:sudhir.cse@gmail.com">sudhir.cse@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi All,<div><br></div><div>I don't know whether I have encountered a strange problem or my understanding of drools is wrong.</div><div><br></div><div>I have 3 rules out of which two are dependent. Between the dependent ones one rule makes the other rule eligible to fire but I don't know why the dependent rule is not firing. Below are the rules I have written.</div>
<div><div>package com.valueMomentum;</div><div>import com.valuemomentum.eligibilitymodel.oo.*;</div><div>import java.util.ArrayList;</div><div>global java.util.ArrayList list;</div><div><br></div><div><span style="font-weight: bold;"><span style="color: rgb(255, 0, 0);">rule "PolicyTierClassification"</span></span></div>
<div><span style="white-space: pre;">        </span> no-loop true</div><div><span style="white-space: pre;">        </span> when</div><div><span style="white-space: pre;">                </span>healthInsuredbindings : HealthInsured( weight >= 134 , weight < 157 , height == "4ft 10in" , gender == "Male" )</div>
<div><br></div><div><span style="white-space: pre;">        </span> then</div><div><span style="white-space: pre;">                </span>healthInsuredbindings.setPolicyTier("Standard I");</div>
<div><br></div><div><span style="white-space: pre;">                </span>System.out.println("PolicyTierClassification");</div><div>list.add("To determine tier based on insured gender, height and weight(weight>=134 , weight<157 , height==4ft 10in , gender==Male ) -> (PolicyTier = Standard I)"); ;end</div>
<div><br></div><div><span style="font-weight: bold;"><span style="color: rgb(255, 0, 0);">rule "AlcoholConsumptionClassRule"</span></span></div><div><span style="white-space: pre;">        </span> no-loop true</div>
<div><span style="white-space: pre;">        </span> when</div><div><span style="white-space: pre;">                </span>healthInsuredbindings : HealthInsured( alcoholConsumptionFrequencyPerWeek == "2-3" )</div>
<div><br></div><div><span style="white-space: pre;">        </span> then</div><div>healthInsuredbindings.setAlcoholConsumptionClass("B");</div><div> System.out.println("AlcoholConsumptionClassRule");<br>
</div><div>list.add("To derive the alcohol consumption class based on consumption frequencyalcoholConsumptionFrequencyPerWeek==2-3 -> (AlcoholConsumptionClass = B)"); end</div><div><br></div><div><br></div><div>
<span style="color: rgb(255, 0, 0);"><span style="font-weight: bold;">rule "UnderwritingFactorRule"</span></span></div><div><span style="white-space: pre;">        </span> no-loop true</div>
<div><span style="white-space: pre;">        </span> when</div><div><span style="white-space: pre;">                </span>healthInsuredbindings : HealthInsured( alcoholConsumptionClass =="B" )</div>
<div><br></div><div><span style="white-space: pre;">        </span> then</div><div><span style="white-space: pre;">        </span> healthInsuredbindings.setUnderwritingFactor(1);</div><div><span style="white-space: pre;">        </span> System.out.println("UnderwritingFactorRule");</div>
<div> list.add("To derive UnderwritingFactor from alcoholConsumptionClass==B -> (UnderwritingFactor = 1)");end</div><div><br></div><div>this my initial fact HealthInsured healthInsured = new HealthInsured();</div>
<div><span style="white-space: pre;">                        </span>healthInsured.setAge(25);<br></div><div><span style="white-space: pre;">                        </span>healthInsured.setGender("Male");</div><div>
<span style="white-space: pre;">                        </span>healthInsured.setWeight(140);</div><div><span style="white-space: pre;">                        </span>healthInsured.setHeight("4ft 10in");</div><div>
<span style="white-space: pre;">                        </span>healthInsured.setTobaccoUser("No");</div><div><span style="white-space: pre;">                        </span>healthInsured.setMotorcycleRider("No");</div>
<div><span style="white-space: pre;">                        </span>healthInsured.setRelationToInsured("Insured");</div><div><span style="white-space: pre;">                        </span>healthInsured.setUnderwritingFactor(0);</div>
<div><span style="white-space: pre;">                        </span>healthInsured.setPolicyTier("Preferred");</div><div><span style="white-space: pre;">                        </span>healthInsured.setAlcoholConsumptionFrequencyPerWeek("2-3");</div>
<div><span style="white-space: pre;">                        </span>healthInsured.setAlcoholConsumptionClass("A");</div><div>Based on the above fact <span style="color: rgb(255, 0, 0); font-weight: bold;">PolicyTierClassification, AlcoholConsumptionClassRule </span>are eligible to fire. <span style="font-weight: bold;"><span style="color: rgb(255, 0, 0);">AlcoholConsumptionClassRule</span></span> is setting a property alcoholConsumptionClass to B based on which<span style="font-weight: bold;"> </span><span style="font-weight: bold;"><span style="color: rgb(255, 0, 0);">UnderwritingFactorRule </span></span>rule becomes eligible fire but in this case the dependent rule is not firing. I think we can use <span style="font-weight: bold;"><span style="color: rgb(204, 0, 0);">update </span></span>in <span style="color: rgb(255, 0, 0); font-weight: bold;">AlcoholConsumptionClassRule </span>but I think if we have to manage those dependencies it will be more error prone and the results are might be more inconsistent. </div>
<div><br></div><div>I have tested it Using RETEOO in drools 3.x and 4.x which yields me the same results. But when I used LEAPS algorithm then i even got the dependent rule i.e <span style="color: rgb(255, 0, 0); font-weight: bold;">UnderwritingFactorRule </span><span style="color: rgb(255, 0, 0);"> </span>rule also fired<span style="font-weight: bold;">.</span></div>
<div><span style="font-weight: bold;"><br></span></div><div><span style="font-weight: bold;">Thanks in Advance,</span></div><div><span style="font-weight: bold;"><br>
</span></div><div><span style="font-weight: bold;">sudhir.</span></div><div><br></div></div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a><br>