Hi Guarav,<br><br>I might not be understanding your problem, but think you might be making the problem more complicated than it needs to be. Could you try something like the following:<br><br>$ruleToChoose : RoutingRule (listPriceFrom &lt;= $tssListPrice, listPriceTo &gt; $tssListPrice<br>
                                &amp;&amp; discountPriceFrom &lt;= $tssDisc, discountPriceTo &gt;  $tssDisc,<br>                                nonStdTerm ==&quot;TSS&quot;, $nodeOfRule : nodeOfRule) from $tssRoutingRuleList<br>
<br>not RoutingRule (listPriceFrom &lt;= $tssListPrice, listPriceTo 
&gt; $tssListPrice<br>
                                , discountPriceFrom &lt;= 
$tssDisc, discountPriceTo &gt;  $tssDisc,<br>
                                nonStdTerm ==&quot;TSS&quot;, nodeOfRule &gt; $nodeOfRule) from 
$tssRoutingRuleList<br><br>Note that this logic states:<br> Assign to $ruleToChoose a RoutingRule that satisfies our conditions when there is no other RoutingRule that also satisfies our conditions but has a higher nodeOfRule value.<br>
<br>Also note that I removed you &quot;&amp;&amp;&quot; operators and replaced them with &quot;,&quot; (comma).<br><br>Let me know if I have misunderstood your problem.<br><br>Hope it helps!<br><br>Enda<br><br><div class="gmail_quote">
On Thu, Mar 11, 2010 at 5:47 PM, Gaurav <span dir="ltr">&lt;<a href="mailto:gaurav.goyal123@gmail.com">gaurav.goyal123@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br>
Hi All,<br>
<br>
I have aother question on drools.<br>
There can le level1 to level6 present in a rule and we need to pick always<br>
the highest level rule which satisfied list price and discount comdition.<br>
<br>
Following code is giving me expected results but do we have any better way<br>
to implement the same. Can I avoid last 2 iternations and combine it to<br>
first one iteration.<br>
<br>
RoutingRule.java<br>
----------------<br>
        private String level1 = &quot;&quot;;<br>
        private String level2 = &quot;&quot;;<br>
        private String level3 = &quot;&quot;;<br>
        private String level4 = &quot;&quot;;<br>
        private String level5 = &quot;&quot;;<br>
        private String level6 = &quot;&quot;;<br>
        private String serviceSalesPath = &quot;&quot;;<br>
        private String productSalesPath = &quot;&quot;;<br>
        private String nonStdTerm = &quot;&quot;;<br>
        private String currency = &quot;&quot;;<br>
        private double listPriceFrom = Double.MAX_VALUE ;<br>
        private double listPriceTo = Double.MAX_VALUE ;<br>
        private double discountPriceFrom = 100;<br>
        private double discountPriceTo = 100 ;<br>
        private double nodeOfRule =0;<br>
<br>
Rule<br>
-----<br>
<br>
$selectedTSSRulesWithOutHier : ArrayList()<br>
                from collect ($routingRule : RoutingRule(currency == $curr<br>
                &amp;&amp; (<br>
                        listPriceFrom &lt;= $tssListPrice &amp;&amp; listPriceTo &gt; $tssListPrice<br>
                        &amp;&amp; discountPriceFrom &lt;= $tssDisc &amp;&amp; discountPriceTo &gt;  $tssDisc &amp;&amp;<br>
nonStdTerm ==&quot;TSS&quot; )<br>
                )<br>
                from $tssRoutingRuleList)<br>
<br>
                $lowestNodeTSS : Double(intValue &gt; 0)<br>
                from accumulate ( RoutingRule($nodeOfRule : nodeOfRule)<br>
                from $selectedTSSRulesWithOutHier, max($nodeOfRule))<br>
<br>
                $lowestNodeTSSRule : ArrayList()<br>
                from collect( $ruleObj : RoutingRule( eval(nodeOfRule == $lowestNodeTSS) )<br>
                from $selectedTSSRulesWithOutHier )<br>
<br>
Many thanks in advance,<br>
Gaurav<br>
<font color="#888888">--<br>
View this message in context: <a href="http://n3.nabble.com/Better-way-to-find-rule-with-max-value-tp442484p442484.html" target="_blank">http://n3.nabble.com/Better-way-to-find-rule-with-max-value-tp442484p442484.html</a><br>

Sent from the Drools - User mailing list archive at Nabble.com.<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>
</font></blockquote></div><br><br clear="all"><br>-- <br>Enda J Diggins<br>