<br> Barath,<br><br> Your mistake is treating NOT as a boolean operator instead of existential quantifier. <br> In other words: NOT is an EXISTENTIAL quantifier. It will be true only if there are no facts that satisfy your pattern. So, the rule engine will bind a fact to the first pattern and will try to match the existential quantifier NOT against all existing facts:<br>
<br>Case 1 : $a : Order($value : 1)<br> not Order( value > 1)<br> <br> So match is false because there are Orders whose value are 2 and 3.<br><br>Case 2 : $a : Order($value : 2)<br>
not Order( value > 2)<br>
<br>
So match is false because there is an Order whose value is 3.<br>
<br> Case 3 : $a : Order($value : 3)<br>
not Order( value > 3)<br>
<br>
So match is TRUE because there are NO Orders whose value is greater than 3. <br> Rule will fire and retract Order( value : 3)<br><br>
Case 4 : $a : Order($value : 2)<br>
not Order( value > 2)<br>
<br> Now, this match is true, because there are no more Orders whose value is greater than 2, since Order( value : 3 ) was retracted in the previous step.<br><br> And so on...<br><br> Hope it helps,<br>
Edson<br><br><br><div><span class="gmail_quote">2008/2/21, Barath <<a href="mailto:barathguna@gmail.com">barathguna@gmail.com</a>>:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br> Hi,<br> <br> I apologize for my logic fault i made in previous post.<br> <br> The correct logic as follows,<br> <br><br> rule "Descending order"<br> when<br> $a : Order( $value : value )<br> not Order( value > $value)<br>
then<br> System.out.println("value :"+$value);<br> retract($a);<br> end<br> <br> 1. Order value=1<br> <br>2. Order value=2<br> 3. Order value=3<br> <br> <br>Case 1 : $a : Order($value : 1)<br>
not Order(2 > 1)<br> <br> So rule is False.<br> <br><br> Case 2 : $a : Order($value : 1)<br> not Order(3 > 1)<br> <br> So rule is False.<br> <br><br> Case 3 : $a : Order($value : 2)<br>
<br> not Order(1 > 2)<br> So rule is True.<br> <br><br> Case 4 : $a : Order($value : 2)<br> <br> not Order(3 > 2)<br> So rule is False.<br> <br><br> Case 5 : $a : Order($value : 3)<br>
<br> not Order(1 > 3)<br> So rule is True.<br> <br><br> Case 6 : $a : Order($value : 3)<br> <br> not Order(2 > 3)<br> So rule is True.<br> <br><br> This indicates the rule should fire for three times but its not the case.<br>
I know i going wrong some where but i couldn't figure out.<br> Plz do help me.....<br> <br> Barath.<br> <br>--<br> View this message in context: <a href="http://www.nabble.com/Plz-reply-%3A-Descending-order-rule-tp15606103p15610848.html">http://www.nabble.com/Plz-reply-%3A-Descending-order-rule-tp15606103p15610848.html</a><br>
<br>Sent from the drools - user mailing list archive at <a href="http://Nabble.com">Nabble.com</a>.<br> <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">https://lists.jboss.org/mailman/listinfo/rules-users</a><br> </blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br> JBoss Drools Core Development<br>
Office: +55 11 3529-6000<br> Mobile: +55 11 9287-5646<br> JBoss, a division of Red Hat @ <a href="http://www.jboss.com">www.jboss.com</a>