<br>&nbsp;&nbsp;&nbsp; Geoffrey,<br><br>&nbsp;&nbsp;&nbsp; The &quot;sum&quot; 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>&nbsp;&nbsp;&nbsp;&nbsp; Number( $total : intValue ) from accumulate(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Hop($distance : distance ), // distance is an int<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sum($distance)<br>&nbsp;&nbsp;&nbsp;&nbsp; );<br><br>&nbsp;&nbsp;&nbsp; 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.&nbsp; 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>&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp; Find attached the HTML doc page I&#39;m talking about.<br><br>&nbsp;&nbsp;&nbsp; []s<br>&nbsp;&nbsp;&nbsp; Edson
<br><br><br><div><span class="gmail_quote">2007/7/22, Geoffrey De Smet &lt;<a href="mailto:ge0ffrey.spam@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
ge0ffrey.spam@gmail.com</a>&gt;:</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&#39;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 &#39;ve proven that summing integers in double&#39;s<br>instead of int&#39;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 &quot;ScoreCalculator&quot;<br>&nbsp;&nbsp; when<br>&nbsp;&nbsp;&nbsp;&nbsp; $scoreFact : ScoreFact(); // singleton<br>&nbsp;&nbsp;&nbsp;&nbsp; $total : Integer() from accumulate(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Hop($distance : distance ), // distance is an int
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sum($distance)<br>&nbsp;&nbsp;&nbsp;&nbsp; );<br>&nbsp;&nbsp; then<br>&nbsp;&nbsp;&nbsp;&nbsp; $scoreFact.setSoftConstraintsBroken($total);<br>end<br><br><br>svn is still here, till it&#39;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>&nbsp;&nbsp;Edson Tirelli<br>
&nbsp;&nbsp;Software Engineer - JBoss Rules Core Developer<br>&nbsp;&nbsp;Office: +55 11 3529-6000<br>&nbsp;&nbsp;Mobile: +55 11 9287-5646<br>&nbsp;&nbsp;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>