The requiredCpuPowerTotal is just a short-hand way of reusing existing functions, such as sum, count, max, ....
It shouldn't be slower, nor faster: it's just an overloading and reuse of out-of-the-box functions.

Op 22-01-13 10:04, Michiel Vermandel schreef:
Hi,

In lots of rules in the drools planner examples the accumulate function is used in this way:

rule "requiredCpuPowerTotal"
    when
        $computer : CloudComputer($cpuPower : cpuPower)
        $requiredCpuPowerTotal : Number(intValue > $cpuPower) from accumulate(
            CloudProcess(
                computer == $computer,
                $requiredCpuPower : requiredCpuPower),
            sum($requiredCpuPower)
        )
    then
        insertLogical(new IntConstraintOccurrence("requiredCpuPowerTotal", ConstraintType.NEGATIVE_HARD,
                $requiredCpuPowerTotal.intValue() - $cpuPower,
                $computer));
end

(example from cloudBalancing).

Though, documentation says (http://docs.jboss.org/drools/release/5.5.0.Final/drools-expert-docs/html_single/#d0e6921) one should this syntax:

<result pattern> from accumulate( <source pattern>,
                                  init( <init code> ),
                                  action( <action code> ),
                                  reverse( <reverse code> ),
                                  result( <result expression> ) )


Does this mean that the axemples could be optimized and that I should go for that syntaxt as well rather than using the syntax like rule "requiredCpuPowerTotal" ?

Thanks


-----------------
http://www.codessentials.com - Your essential software, for free!
Follow us at http://twitter.com/#!/Codessentials


_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users