<br> Geoffrey,<br><br> The "sum" function that is shipped with drools always uses double internally, but all numeric accumulate functions must have return type Number to avoid class cast exceptions... I must write that in the docs... so, recommendation is to do:
<br><br> Number( $total : intValue ) from accumulate(<br> Hop($distance : distance ), // distance is an int<br> sum($distance)<br> );<br><br> Now, having said that, the decision to use double is because we needed a one size fits all to ship with drools. On the other hand I tried to make as simple as possible to plug new or replace built-in functions. So, if you want a sum function that uses only integers, you can easily develop and plug it your own. Since I just wrote the docs on how to do it, may I ask you please to read them and provide a feedback if they are good, need more info, shall I write them in another way, etc?
<br> BTW, when I say it is really simple to create another sum function, I mean, you can do it in about 20 minutes. Really!<br><br> Find attached the HTML doc page I'm talking about.<br><br> []s<br> Edson
<br><br><br><div><span class="gmail_quote">2007/7/22, Geoffrey De Smet <<a href="mailto:ge0ffrey.spam@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
ge0ffrey.spam@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;">Hi guys,<br><br>I finally got around to experimenting with the accumulate support in
<br>LocalSearchSolver. Thanks for implementing it :)<br><br>I use nothing but int's in my calculations,<br>but I get a ClassCastExceptions, as sum() always returns a Double and<br>setSoftConstraintsBroken(int) failes.
<br><br>In a previous benchmarks I 've proven that summing integers in double's<br>instead of int's hurts performance for 10% or more (which is rather big).<br><br>Is there a sumInteger() available (or do I need to write it)? Or can it
<br>be overloaded over sum() in a much cleaner way?<br><br><br><br>rule "ScoreCalculator"<br> when<br> $scoreFact : ScoreFact(); // singleton<br> $total : Integer() from accumulate(<br> Hop($distance : distance ), // distance is an int
<br> sum($distance)<br> );<br> then<br> $scoreFact.setSoftConstraintsBroken($total);<br>end<br><br><br>svn is still here, till it's ready for drools:<br><a href="https://taseree.svn.sourceforge.net/svnroot/taseree/trunk" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
https://taseree.svn.sourceforge.net/svnroot/taseree/trunk</a><br><br>--<br>With kind regards,<br>Geoffrey De Smet<br><br>_______________________________________________<br>rules-dev mailing list<br><a href="mailto:rules-dev@lists.jboss.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
rules-dev@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
</blockquote></div><br><br clear="all"><br>-- <br> Edson Tirelli<br>
Software Engineer - JBoss Rules Core Developer<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" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
www.jboss.com</a>