Back with (good) news :)

Removing the update has a tremendous effect; process time (ie. session.fireAllRule) has decreased from 10s to less than 1.

On the other hand, changing && to constraint group had no visible effect.

 

Is there a way to evaluate rules performance just at looking at rete tree ?

Do you have some good articles on that ?

 

Thanks all for your help,

 

Joel

 


De : rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] De la part de Costigliola Joel (EXT)
Envoyé : mardi 29 septembre 2009 10:37
À : 'Rules Users List'
Objet : Re: [rules-users] infinite loop rules problem

 

Nice suggestion for removing the update !

I also will remove the && for constraint group, another user of this mailing list has given me the same advice on my previous mail (it was Greg Barton by the way).

 

Many thanks,

 

Joel

 


De : rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] De la part de Wolfgang Laun
Envoyé : lundi 28 septembre 2009 19:37
À : Rules Users List
Objet : Re: [rules-users] infinite loop rules problem

 

Collecting stuff from several matches into a single Collector fact is best done
by letting matches occur with rules at salience N. Then, put a single rule
matching the Collector, without any constraints, at salience < N.
This matches any Collector fact, and, in the consequence you should
remove this fact, which has done its duty. To distinguish (as in your case)
the successful case (one match) from others, you might just use an if
statement in the consequence. (Well, yes, this isn't quite comme-il-faut,
but it'll get the job done.) So, don't bother with updates on the Collector fact.

As for the frequently used && to connect the constraints, it is preferred
to use individual constraint groups, separated by a comma, for matches
with different fact attributes. Constraint groups can be shared among
rules (in the Rete node network) which is the essence of Rete being
fast enough to cope with the many-many pattern matching effort.

-W
 

2009/9/28 Costigliola Joel (EXT) <joel.costigliola-ext@natixis.com>

Hello,

 

Me again and no it is not spamming, and I’m still drools newbie ;-)

 

I was facing a problem of infinite loop with one of my rule, I have solved it but I’m wondering if my solution is not too costful on a performance point of view.

So my question is really on the most efficient way of solving the infinite loop problem I’m gonna expose you right now.

 

First of all, a few words the problem I want to solve with Drools :

My company is a bank where traders are making deals on markets, these deals must be classified in book, this is what we call “booking process”.

Booking is done according to booking criteria : which trader has made the deal ? on which product ? etc …

A booking rule defines a set of criteria and the target book where the deal will classified.

 

The guilty rule’s job was to fill DealMatchingBookingRules with the booking rules applicable on a deal, (DealMatchingBookingRules references a unique deal).  

I have put below a corrected version by commenting the update($dealMatchingBookingRules) instruction of the RHS.

 

With update uncommented, the problem occurred when 2 booking rule were matching the same deal in here’s my understanding of the problem

Facts inserted in the session :

-         dmbr1 (instance of DealMatchingBookingRule) referencing a deal

-         br1 and br2 matching the deal referenced in dmr1

Results :

  1. rule is activated with (dmbr1, br1), dmbr1 is updated
  2. rule is activated with (dmbr1, br2), dmbr1 is updated - (dmbr1, br1) does not activate the rule because of no-loop rule attribute
  3. rule is activated AGAIN with (dmbr1, br1), dmbr1 is updated : back to step 1
  4. rule is activated AGAIN with (dmbr1, br2), dmbr1 is updated : back to step 2
  5. infinite loop on step1 & step 2

 

I have fixed the problem by removing the call to update, but for the next steps of my process (not shown here) Drools need to aware of the modified DealMatchingBookingRules. I thus have written a rule which only update all DealMatchingBookingRules.

 

Is there a better way to solve this infinite loop ?

Feel free to make comments, I’m really open to any suggestion/enhancement.   

 

Regards,

 

Joël Costigliola

 

 

rule "Find matching level 1 booking rules by deal"

  salience 10

  no-loop

  ruleflow-group "Find level 1 matching booking rules by deal group"

 

  when

    $dealMatchingBookingRules : DealMatchingBookingRules($dealModel : deal, $dealProductRelatedIndexes : dealProductRelatedIndexes)

    $bookingRule : BTExecutionBookingRuleModel (

      priority == 1

      // when a criterion is not set, it is considered as satisfied.

      && (traderCriterion == null || $dealModel.trader == traderCriterion)

      && (portfolioCriterion == null || $dealModel.portfolio == portfolioCriterion)

      // when a product type criterion is set to unknown, it is considered as satisfied whatever deal product type is.

      && (productTypeStringCriterion == null || productTypeCriterion == ProductType.Unknown 

          || $dealModel.product.productType == productTypeCriterion) 

      && (listedIndexCriterion == null || $dealProductRelatedIndexes.relatedIndexes contains listedIndexCriterion)

    )

  then

    $dealMatchingBookingRules.addMatchingBookingRule($bookingRule);

    // update($dealMatchingBookingRules) : COMMENTED BECAUSE WAS CAUSING INFINITE LOOP !

end

 

// Does the job of update($dealMatchingBookingRules) but without INFINITE LOOP.

rule "Refresh facts in level 1 booking rule process"

  salience 5

  no-loop

  ruleflow-group "Refresh facts in level 1 booking rule process group"

 

  when

    $dealMatchingBookingRules : DealMatchingBookingRules()

  then

    update($dealMatchingBookingRules);

end

 

 

 


 

Ce courriel et toutes les pièces jointes sont confidentiels et peuvent être couverts par un privilège ou une protection légale. Il est établi à l’attention exclusive de ses destinataires. Toute utilisation de ce courriel non conforme à sa destination, toute diffusion ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse préalable. Toutes opinions exprimées dans ce courriel ne sauraient nécessairement refléter celle de Natixis, de ses filiales. Elles sont aussi susceptibles de modification sans notification préalable. Si vous recevez ce courriel par erreur, merci de le détruire et d’en avertir immédiatement l’expéditeur. L’Internet ne permettant pas d’assurer l’intégrité de ce courriel, Natixis décline toute responsabilité s’il a été altéré, déformé ou falsifié et chaque destinataire qui utilise ce mode de communication est supposé en accepter les risques.

 

This email and any attachment are confidential and may be legally privileged or otherwise protected from disclosure. It is intended only for the stated addressee(s) and access to it by any other person(s) is unauthorised. Any use, dissemination or disclosure not in accordance with its purpose, either in whole or in part, is prohibited without our prior formal approval. Any opinion expressed in this email may not necessarily reflect the opinion of Natixis, its affiliates. It may also be subject to change without prior notice. If you are not an addressee, you must not disclose, copy, circulate or in any other way use or rely on the information contained in this email. If you have received it in error, please inform us immediately and delete all copies. The Internet can not guarantee the integrity of this email therefore Natixis shall not be liable for the email if altered, changed or falsified and anyone who communicates with us by e-mail is taken to accept these risks.



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

 


 

Ce courriel et toutes les pièces jointes sont confidentiels et peuvent être couverts par un privilège ou une protection légale. Il est établi à l’attention exclusive de ses destinataires. Toute utilisation de ce courriel non conforme à sa destination, toute diffusion ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse préalable. Toutes opinions exprimées dans ce courriel ne sauraient nécessairement refléter celle de Natixis, de ses filiales. Elles sont aussi susceptibles de modification sans notification préalable. Si vous recevez ce courriel par erreur, merci de le détruire et d’en avertir immédiatement l’expéditeur. L’Internet ne permettant pas d’assurer l’intégrité de ce courriel, Natixis décline toute responsabilité s’il a été altéré, déformé ou falsifié et chaque destinataire qui utilise ce mode de communication est supposé en accepter les risques.

 

This email and any attachment are confidential and may be legally privileged or otherwise protected from disclosure. It is intended only for the stated addressee(s) and access to it by any other person(s) is unauthorised. Any use, dissemination or disclosure not in accordance with its purpose, either in whole or in part, is prohibited without our prior formal approval. Any opinion expressed in this email may not necessarily reflect the opinion of Natixis, its affiliates. It may also be subject to change without prior notice. If you are not an addressee, you must not disclose, copy, circulate or in any other way use or rely on the information contained in this email. If you have received it in error, please inform us immediately and delete all copies. The Internet can not guarantee the integrity of this email therefore Natixis shall not be liable for the email if altered, changed or falsified and anyone who communicates with us by e-mail is taken to accept these risks.



 
Ce courriel et toutes les pièces jointes sont confidentiels et peuvent être couverts par un privilège ou une protection légale. Il est établi à l’attention exclusive de ses destinataires. Toute utilisation de ce courriel non conforme à sa destination, toute diffusion ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse préalable. Toutes opinions exprimées dans ce courriel ne sauraient nécessairement refléter celle de Natixis, de ses filiales. Elles sont aussi susceptibles de modification sans notification préalable. Si vous recevez ce courriel par erreur, merci de le détruire et d’en avertir immédiatement l’expéditeur. L’Internet ne permettant pas d’assurer l’intégrité de ce courriel, Natixis décline toute responsabilité s’il a été altéré, déformé ou falsifié et chaque destinataire qui utilise ce mode de communication est supposé en accepter les risques.
 
This email and any attachment are confidential and may be legally privileged or otherwise protected from disclosure. It is intended only for the stated addressee(s) and access to it by any other person(s) is unauthorised. Any use, dissemination or disclosure not in accordance with its purpose, either in whole or in part, is prohibited without our prior formal approval. Any opinion expressed in this email may not necessarily reflect the opinion of Natixis, its affiliates. It may also be subject to change without prior notice. If you are not an addressee, you must not disclose, copy, circulate or in any other way use or rely on the information contained in this email. If you have received it in error, please inform us immediately and delete all copies. The Internet can not guarantee the integrity of this email therefore Natixis shall not be liable for the email if altered, changed or falsified and anyone who communicates with us by e-mail is taken to accept these risks.