[rules-users] using "from accumulate" with wrong return type

Wolfgang Laun wolfgang.laun at gmail.com
Sat Nov 24 08:43:53 EST 2012


Each (not *the*) Recommendation with the maximum recommValue can be found
using

   $recMax: Recommendation( slot == 1, $recommValue: recommValue)
   not Recommendation( slot == 1, recommValue > $recommValue )

with $recMax being bound to one of the Recommendations with the maximum,
and the maximum value being bound to $recommValue.

-W

On 24 November 2012 13:18, raffi <christian.koehler at s2008.tu-chemnitz.de>wrote:

> Hello,
>
> I have a problem with using the /from accumulate/ statement. It is because
> I'd like to optmize my code a liitle bit. There are two rules that I like
> to
> merge.
>
> /query "max recomm value for slot 1"
>         accumulate (Recommendation(slot == 1, $recomm_value : recommValue),
>                                 max     : max($recomm_value))
> end/
>
> and
>
> /query "recomms for slot 1"
>         recomm  : Recommendation(slot == 1)
> end/
>
> So with the first rule I get the maximum of the variable recommValue. The
> second rule is for searching exactly this Recommendation-fact with this
> value. Now I tried to merge them in the following way:
> /
> query "recomm for slot 1"
>         $recomm : Recommendation() from
>                                         accumulate(Recommendation(
>                                                 slot == 1, $recomm_value :
> recommValue),
>                                                 max($recomm_value)
>                                         )
> end/
>
> But the returned value always is a double one. Is it because of the usage
> of
> the maximum function? Is it possible to solve this problem with only one
> query (getting that Recommendation-fact with the highest recommValue)?
>
> Regards...
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/using-from-accumulate-with-wrong-return-type-tp4020957.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20121124/b1ac968a/attachment.html 


More information about the rules-users mailing list