[rules-users] Evaluate rules for multiple facts of the same type within a StateuflSession

Wolfgang Laun wolfgang.laun at gmail.com
Mon Feb 18 04:23:55 EST 2013


On 18/02/2013, pdario <dario.piantanida at gmail.com> wrote:
> Hello, the "tinting" example from the whitepaper assumes each Tint fits
> exactly one Param, right?
> This is not my case, as a Cart can match different discounts and we want to
> assign the highest possible.

There is always just one fit; it just seems that there are multiple
fits - when you define your individual cases sloppily. The correct
definition must be extended to exclude any fit with a smaller discount
:-)

>
> Is the pattern still suitable?

Certainly, the rule merely has to be a little more circumspect when
overlaps are possible, excluding the match of another set of values
with a higher discount.

>
> Another thing I see is Param is evaluating plain attributes from the Tints,
> but (not sure if this is the correct pattern) I'm using this to find if a
> Cart contains a specific item
>
> when
>   Cart ($items : buyingItems, payment == Card....)
>   i : Item (code == XXXXX) from $items
> then

I don't see why "XXXXX" shouldn't come from a parameter fact.

As a general strategy, I try to avoid the "on-the-fly" objects
available with "from" and prefer these subordinate items to be
properly inserted facts. Usually this simplifies writing rules.

-W


More information about the rules-users mailing list