<div>Well, what is the realtion between id, usage and the result that&#39;s to be stored in a Decision or a global?</div>
<div> </div>
<div>Typically, such rules could be written as</div>
<div> </div>
<div>rule x</div>
<div>no-loop true</div>
<div>when</div>
<div>    $d : Decision()<br>    $p :Product( id == 1, $usage : usage )<br>then</div>
<div>    compute/store value, depending on the formula for id == 1 (using usage)</div>
<div>end</div>
<div>// similar rule for id == 2,3,...</div>
<div> </div>
<div>If value is a straightforward function of id (and usage), then implement a function compValue and use a single rule, e.g.:</div>
<div> </div>
<div>rule x</div>
<div>no-loop true</div>
<div>when</div>
<div>    $d : Decision()</div>
<div>    Product( $id : id, $usage : usage)</div>
<div>then</div>
<div>   modify $d value to compValue( $id, $usage )</div>
<div> </div>
<div>Distinguishing all individual combinations of id and usage on the LHS seems excessive.</div>
<div> </div>
<div>The ordering of CEs also affects execution times.</div>
<div> </div>
<div>-W</div>
<div> </div>
<div><span class="gmail_quote">On 7/20/09, <b class="gmail_sendername">nesta</b> &lt;<a href="mailto:nesta.fdb@163.com">nesta.fdb@163.com</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><br>In this scenario, there are 1000 products, different product has different<br>price, besides this, the price is affected by usage. I want to use<br>
Product.id to match the rules.<br><br>As you mentioned &quot;The crude duplication of rules where only the constant to<br>be matched with<br>Product.id varies can, most likely, be avoided.&quot;<br><br>How to avoid it in this scenario?<br>
<br><br>Wolfgang Laun-2 wrote:<br>&gt;<br>&gt; It&#39;s difficult to suggest an optimized form for your rules 1-infinity,<br>&gt; since<br>&gt; we do not know what you want to achieve.<br>&gt;<br>&gt; The crude duplication of rules where only the constant to be matched with<br>
&gt; Product.id varies can, most likely, be avoided.<br>&gt;<br>&gt; -W<br>&gt;<br>&gt;<br>&gt;<br>&gt; On Sun, Jul 19, 2009 at 3:15 PM, nesta &lt;<a href="mailto:nesta.fdb@163.com">nesta.fdb@163.com</a>&gt; wrote:<br>&gt;<br>
&gt;&gt;<br>&gt;&gt; Hi,<br>&gt;&gt;<br>&gt;&gt; I am a newbie in drools. There are a lot of simple rules in a scenario.<br>&gt;&gt; For example<br>&gt;&gt; rule 1<br>&gt;&gt;    when<br>&gt;&gt;        Product( id ==1, usage == 1)<br>
&gt;&gt;        $decision : Decision()<br>&gt;&gt;    then<br>&gt;&gt;         $decision.setValue(1);<br>&gt;&gt; end<br>&gt;&gt;<br>&gt;&gt; rule 2<br>&gt;&gt; when Product( id ==2, usage == 1)<br>&gt;&gt;  $decision : Decision()<br>
&gt;&gt; rule 3<br>&gt;&gt; when Product( id ==3, usage == 1)<br>&gt;&gt;  $decision : Decision()<br>&gt;&gt; rule 4<br>&gt;&gt; when Product( id ==4, usage == 1)<br>&gt;&gt;  $decision : Decision()<br>&gt;&gt; rule 5<br>
&gt;&gt; when Product( id ==5, usage == 1)<br>&gt;&gt;  $decision : Decision()<br>&gt;&gt; ......<br>&gt;&gt;<br>&gt;&gt; I have a Product fact whose id = 5 and usage = 1, in my first thinking,<br>&gt;&gt; only<br>&gt;&gt; rule 5 is matched, there should be not much more different between 1 rule<br>
&gt;&gt; and a lot of rules in runtime.<br>&gt;&gt;<br>&gt;&gt; But the result shows that they are different. More rules will cost more<br>&gt;&gt; time. If there are 1 thousand rules, some Node and Sink will execute 1<br>
&gt;&gt; thousand times.<br>&gt;&gt;<br>&gt;&gt; My question is how to optimize this scenario?<br>&gt;&gt; --<br>&gt;&gt; View this message in context:<br>&gt;&gt; <a href="http://www.nabble.com/optimization-on-a-lot-of-simple-rules-tp24556724p24556724.html">http://www.nabble.com/optimization-on-a-lot-of-simple-rules-tp24556724p24556724.html</a><br>
&gt;&gt; Sent from the drools - user mailing list archive at Nabble.com.<br>&gt;&gt;<br>&gt;&gt; _______________________________________________<br>&gt;&gt; rules-users mailing list<br>&gt;&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>&gt;&gt;<br>&gt;<br>&gt; _______________________________________________<br>&gt; rules-users mailing list<br>
&gt; <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>&gt;<br>
&gt;<br><br>--<br>View this message in context: <a href="http://www.nabble.com/optimization-on-a-lot-of-simple-rules-tp24556724p24563725.html">http://www.nabble.com/optimization-on-a-lot-of-simple-rules-tp24556724p24563725.html</a><br>
Sent from the drools - user mailing list archive at Nabble.com.<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>