<div>Well, what is the realtion between id, usage and the result that'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> <<a href="mailto:nesta.fdb@163.com">nesta.fdb@163.com</a>> 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 "The crude duplication of rules where only the constant to<br>be matched with<br>Product.id varies can, most likely, be avoided."<br><br>How to avoid it in this scenario?<br>
<br><br>Wolfgang Laun-2 wrote:<br>><br>> It's difficult to suggest an optimized form for your rules 1-infinity,<br>> since<br>> we do not know what you want to achieve.<br>><br>> The crude duplication of rules where only the constant to be matched with<br>
> Product.id varies can, most likely, be avoided.<br>><br>> -W<br>><br>><br>><br>> On Sun, Jul 19, 2009 at 3:15 PM, nesta <<a href="mailto:nesta.fdb@163.com">nesta.fdb@163.com</a>> wrote:<br>><br>
>><br>>> Hi,<br>>><br>>> I am a newbie in drools. There are a lot of simple rules in a scenario.<br>>> For example<br>>> rule 1<br>>> when<br>>> Product( id ==1, usage == 1)<br>
>> $decision : Decision()<br>>> then<br>>> $decision.setValue(1);<br>>> end<br>>><br>>> rule 2<br>>> when Product( id ==2, usage == 1)<br>>> $decision : Decision()<br>
>> rule 3<br>>> when Product( id ==3, usage == 1)<br>>> $decision : Decision()<br>>> rule 4<br>>> when Product( id ==4, usage == 1)<br>>> $decision : Decision()<br>>> rule 5<br>
>> when Product( id ==5, usage == 1)<br>>> $decision : Decision()<br>>> ......<br>>><br>>> I have a Product fact whose id = 5 and usage = 1, in my first thinking,<br>>> only<br>>> rule 5 is matched, there should be not much more different between 1 rule<br>
>> and a lot of rules in runtime.<br>>><br>>> But the result shows that they are different. More rules will cost more<br>>> time. If there are 1 thousand rules, some Node and Sink will execute 1<br>
>> thousand times.<br>>><br>>> My question is how to optimize this scenario?<br>>> --<br>>> View this message in context:<br>>> <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>
>> 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>>><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>><br>
><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>