[rules-users] Tuples discrimination

Edson Tirelli tirelli at post.com
Wed Sep 12 10:33:23 EDT 2007


   Eymeric,

   This is a fairly common case of finding the "best" of multiple choices
(usually, the max, min, etc). You can find some examples and explanation in
the wiki:

http://wiki.jboss.org/wiki/Wiki.jsp?page=RulesFindMax

    So, the answer to your question is: it must be done in the LHS.
AgendaFilters, IMO, should be used only for debug purposes, since they are
beyond the control of the rule writers.

    BTW, the wiki was written when we had only Drools 3.0, so there is no
example of 4.0 features like accumulate, DSL, etc, so, feel free to improve
the docs with your findings and examples... :)

    Thanks,
        Edson



2007/9/12, Eymeric VIEUILLE <evieuille at gfi.fr>:
>
> Hi !
>
> After solving the problem of Out of Memory, I come back with another
> question :
>
> I currently implemented rules that give me tuples like this (in the
> agenda, before firing rules) : M1xM2xM3xM4.
>
>
> But now, I want to select THE tuple that as M1xM2xM3xM4 with a property
> p as little as possible to execute the right hand of the rule.
>
> For sample, I have the two following tuples activated in the agenda :
>
> M'1(date = "09/25/2006")      M'1(date = "09/25/2006")
> M'2(date = "09/26/2006")      M'2(date = "09/26/2006")
> M'3(date = "09/29/2006")      M"3(date = "09/27/2006")
> M'4(date = "09/31/2006")      M"4(date = "09/30/2006")
>
> I would like the second tuples to be selected for executing the right
> hand of the rule because dates of M'2, M"3, M"4 are the closest dates
> compared to M'1.
>
> The problem is that I do not know on what layer this selection must be
> made : in the Left Hand of the rule ? Or in a AgendaFilter (selecting
> the better tuple to use) ?
>
> For the LH, I thought to the "accumate" CE, but I am affraid to have
> unreadle rules (impossible to maintain). And I don't see quite well how
> to implement this with "accumulate" CE (knowing that I use a DSL).
>
> For the AgendaFilter, I saw that only the current activation is
> accessible...so impossible to compare whith other tuples
> values....Moreover, I am affraid to make performance fall.
>
> Is this selection possible ? And what would be the best practice to
> implement it ?
>
> Regards,
> Eymeric.
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070912/b0343949/attachment.html 


More information about the rules-users mailing list