[rules-dev] [accumulate] sum is always a double? What if it's only an int?

Geoffrey De Smet ge0ffrey.spam at gmail.com
Sun Jul 22 14:52:00 EDT 2007


Hi guys,

I finally got around to experimenting with the accumulate support in 
LocalSearchSolver. Thanks for implementing it :)

I use nothing but int's in my calculations,
but I get a ClassCastExceptions, as sum() always returns a Double and 
setSoftConstraintsBroken(int) failes.

In a previous benchmarks I 've proven that summing integers in double's 
instead of int's hurts performance for 10% or more (which is rather big).

Is there a sumInteger() available (or do I need to write it)? Or can it 
be overloaded over sum() in a much cleaner way?



rule "ScoreCalculator"
   when
     $scoreFact : ScoreFact(); // singleton
     $total : Integer() from accumulate(
        Hop($distance : distance ), // distance is an int
        sum($distance)
     );
   then
     $scoreFact.setSoftConstraintsBroken($total);
end


svn is still here, till it's ready for drools:
https://taseree.svn.sourceforge.net/svnroot/taseree/trunk

-- 
With kind regards,
Geoffrey De Smet




More information about the rules-dev mailing list