Re: [rules-users] Agenda Groups basic question
Hello, Maybe a typo mistake but both of your rules have the same agenda group (Phase1) Regards, Joel De : rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] De la part de Rongala, Kanthi Envoyé : lundi 2 novembre 2009 15:54 À : rules-users@lists.jboss.org Objet : [rules-users] Agenda Groups basic question Hi, I am new to Drools and trying my hands out at Drools 5. I cann't figure out how to use agenda- groups. I have a small drl file with two agenda groups and one rule per agenda-group. This doesn't seem to work. However if I happen to comment out the agenda-group attribute, the results are as expected. Please let me know what I am missing. package com.mscibarra.examples.drools.controllers; import com.mscibarra.examples.drools.domainentities.*; rule "Detect and Remove Duplicate Shelves" agenda-group "Phase1" lock-on-active dialect "mvel" when $universe : LibraryUniverse() $shelf : Shelf() from $universe.shelves $shelf2 : Shelf(this != $shelf) from $universe.shelves then System.out.println("Duplicate Shelves found::"+$shelf); // without the modify(), drools is not alerted about changes // $universe.shelves.remove($shelf); /* modify($universe) { shelves.remove($shelf); }; */ end rule "Singleton Shelf Detector" agenda-group "Phase1" lock-on-active dialect "mvel" when $universe : LibraryUniverse(shelves.size > 1) then System.out.println("Multiple Shelves found::"+$universe.shelves.size); End With Regards, Kanthi Swaroop Rongala NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error. 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
Re: [rules-users] Specific Agenda strategy to control which rulesto fire
Hi Wolgang, Interesting advice ! I need to study it a little bit to fully understand it and to see if it can meet my future requirements. Thanks for taking the time to share your insight, Regards, Joel De : rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] De la part de Wolfgang Laun Envoyé : jeudi 29 octobre 2009 08:09 À : Rules Users List Objet : Re: [rules-users] Specific Agenda strategy to control which rules to fire I don't think you should consider an agenda strategy for this. Add a simple class: class Score{ int level; int coun; Deal deal; Book book; Score( Deal deal, int level ){...} } and insert an instance along with the Deal to be classified: insert( deal ); insert( new Score( deal ) ); Rules for level 2 would be written according to: rule "trader and product" salience 10 when $s : Score( level == 2, $d : deal ) Deal( this == $d, trader=="Alex", product == "GOOG" ) then $s.setCount( $s.getCount() + 1 ); $s.setBook( "B2" ); end Then you'll need a couple of rules handling success and failure: rule "post level success" salience 5 when $s : Score( $l : level, count == 1, $d : deal, $b : book ) then assign $d to $b, retract $d retract( $s ); end rule "post level failure" salience 5 when $s : Score( $l : level, count != 1 ) then modify( $s ){ setLevel( $l - 1 ); } end Rules for level 1 would also be at salience 10. A rule for level == 0 should catch Deals "gone down" through all levels. -W 2009/10/28 Costigliola Joel (EXT) mailto:joel.costigliola-...@natixis.com>> Hello all, I need some help to to set a specific Agenda strategy in order to control finely which activated rules will be fired. Problem context : - 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 ? wich market ? etc ... A booking rule defines a set of criteria and the target book where the deal will classified, it also has a priority, note that it is ok that two booking rule have same priority. I want to implement booking rule as Drools rule. Several booking rule can be applied to a deal, in that case choosing the right booking rule to fire depends on the following algorithm : - look all the activated booking rule of the highest priority, --- if there is a unique rule apply it --- if there is no unique rule (0 rule or more than one), look at rules of a lesser priority and apply the same logic. Next section is an example that will clear things (I hope). Example : - A deal D1 has been done by Alex on NY market to buy Google stocks. We have 3 booking rules : - BR1 : criteria = trader=Alex / book = B1 - BR2 : criteria = trader=Alex and product = google stock / book = B2 As BR2 is more precise than BR1, il will matches the deal and book it in B1 If the deal was on another product, BR1 would have been applied. Things gets more complicated when 2 rules of same priority can be applied. Let's imagine we add the following booking rule - BR3 : criteria = trader=Alex and market = NY / book = B3 We have a problem to book D1 since BR2 and BR3 can be applied but have same priority. We can't choose one over the other thus we must apply a less precise/prioritary rule (if unique at its own precision level). In my example, that would lead to apply BR1. Question : -- If I define BR1,BR2,BR3 as Drools rules, how can I tell Drools : - to execute a rule only if there is no other active rule with same precision that could be applied ? - to look for a unique matching rule with less precision level ? I think it's the Agenda responsibility to take this decision, but I don't know how implement that. Can you give some advices on that ? Thanks for your lights in advance, Regards, Joel 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
Re: [rules-users] Specific Agenda strategy to control which rules to fire
I forgot to give the priority of the booking rules in my example, here it is : - BR1 : low priority (1 - BR2 : higher priority (2) - BR3 : same as BR2 Sorry Joel De : rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] De la part de Costigliola Joel (EXT) Envoyé : mercredi 28 octobre 2009 14:57 À : 'Rules Users List' Objet : [rules-users] Specific Agenda strategy to control which rules to fire Hello all, I need some help to to set a specific Agenda strategy in order to control finely which activated rules will be fired. Problem context : - 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 ? wich market ? etc ... A booking rule defines a set of criteria and the target book where the deal will classified, it also has a priority, note that it is ok that two booking rule have same priority. I want to implement booking rule as Drools rule. Several booking rule can be applied to a deal, in that case choosing the right booking rule to fire depends on the following algorithm : - look all the activated booking rule of the highest priority, --- if there is a unique rule apply it --- if there is no unique rule (0 rule or more than one), look at rules of a lesser priority and apply the same logic. Next section is an example that will clear things (I hope). Example : - A deal D1 has been done by Alex on NY market to buy Google stocks. We have 3 booking rules : - BR1 : criteria = trader=Alex / book = B1 - BR2 : criteria = trader=Alex and product = google stock / book = B2 As BR2 is more precise than BR1, il will matches the deal and book it in B1 If the deal was on another product, BR1 would have been applied. Things gets more complicated when 2 rules of same priority can be applied. Let's imagine we add the following booking rule - BR3 : criteria = trader=Alex and market = NY / book = B3 We have a problem to book D1 since BR2 and BR3 can be applied but have same priority. We can't choose one over the other thus we must apply a less precise/prioritary rule (if unique at its own precision level). In my example, that would lead to apply BR1. Question : -- If I define BR1,BR2,BR3 as Drools rules, how can I tell Drools : - to execute a rule only if there is no other active rule with same precision that could be applied ? - to look for a unique matching rule with less precision level ? I think it's the Agenda responsibility to take this decision, but I don't know how implement that. Can you give some advices on that ? Thanks for your lights in advance, Regards, Joel 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 couv
[rules-users] Specific Agenda strategy to control which rules to fire
Hello all, I need some help to to set a specific Agenda strategy in order to control finely which activated rules will be fired. Problem context : - 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 ? wich market ? etc ... A booking rule defines a set of criteria and the target book where the deal will classified, it also has a priority, note that it is ok that two booking rule have same priority. I want to implement booking rule as Drools rule. Several booking rule can be applied to a deal, in that case choosing the right booking rule to fire depends on the following algorithm : - look all the activated booking rule of the highest priority, --- if there is a unique rule apply it --- if there is no unique rule (0 rule or more than one), look at rules of a lesser priority and apply the same logic. Next section is an example that will clear things (I hope). Example : - A deal D1 has been done by Alex on NY market to buy Google stocks. We have 3 booking rules : - BR1 : criteria = trader=Alex / book = B1 - BR2 : criteria = trader=Alex and product = google stock / book = B2 As BR2 is more precise than BR1, il will matches the deal and book it in B1 If the deal was on another product, BR1 would have been applied. Things gets more complicated when 2 rules of same priority can be applied. Let's imagine we add the following booking rule - BR3 : criteria = trader=Alex and market = NY / book = B3 We have a problem to book D1 since BR2 and BR3 can be applied but have same priority. We can't choose one over the other thus we must apply a less precise/prioritary rule (if unique at its own precision level). In my example, that would lead to apply BR1. Question : -- If I define BR1,BR2,BR3 as Drools rules, how can I tell Drools : - to execute a rule only if there is no other active rule with same precision that could be applied ? - to look for a unique matching rule with less precision level ? I think it's the Agenda responsibility to take this decision, but I don't know how implement that. Can you give some advices on that ? Thanks for your lights in advance, Regards, Joel Ce courriel et toutes les pieces jointes sont confidentiels et peuvent etre couverts par un privilege ou une protection legale. Il est etabli a l'attention exclusive de ses destinataires. Toute utilisation de ce courriel non conforme a sa destination, toute diffusion ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse prealable. Toutes opinions exprimees dans ce courriel ne sauraient necessairement refleter celle de Natixis, de ses filiales. Elles sont aussi susceptibles de modification sans notification prealable. Si vous recevez ce courriel par erreur, merci de le detruire et d'en avertir immediatement l'expediteur. L'Internet ne permettant pas d'assurer l'integrite de ce courriel, Natixis decline toute responsabilite s'il a ete altere, deforme ou falsifie et chaque destinataire qui utilise ce mode de communication est suppose 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
Re: [rules-users] How complex can be an expression in given rule...
Yes. Just have a look at the doc (Rule Language Conditional Elements section) : http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/html/ch04.html#RuleLanguage-ConditionalElements -Message d'origine- De : rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] De la part de Madhav Bhamidipati Envoyé : jeudi 15 octobre 2009 08:39 À : rules-users@lists.jboss.org Objet : [rules-users] How complex can be an expression in given rule... Hi, Are the expressions in a rule can be as complex as a regular language support. For example can the expression be as complex as (a == b || (a <= d && a > e )? Where can I find the info. about what sort of expressions supported? Madhav ___ 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. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
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-boun...@lists.jboss.org [mailto:rules-users-boun...@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) mailto:joel.costigliola-...@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 W
[rules-users] infinite loop rules problem
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 o
[rules-users] Struggling to improve my rules performance !
Hello, I would like to improve the performance of my Drools process, I have already done some enhancements like removing the use of "collect" and "eval". I must say I'm a Drools newbie struggling to determine what causes my performance problems. Before asking, I need to explain in 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. I'm using Drools to : 1. find all booking rules matching deals made by traders 2. apply the right booking rule on the deal among the ones matching the deal (i.e. that is book the deal) I'm testing the booking process with 1000 deals and 229 booking rule. It takes 60 seconds for Drools to book the 1000 deals, which is too slow to be put in production. On the 60 seconds, I have 7 seconds for facts insertion and the remaining for process (after session.fireAllRules) Do you think such numbers are normal/expected ? Like I said I don't really know where the performance bottlenecks are ... I'm thinking of exploring the following possibilities : * splitting my rules into very simple rules * starting the booking process with fewer data and running it several times (instead of one booking process on 1000, run 10 booking processes on 100 deals each) I have put my rules code below (for courageous people), if you see some obvious performance problems or if you can give some hint to explore, you would be very welcome. Thanks in advance for your lights, Regards, Joël Costigliola Ps : rules details I have defined a flow composed of 3 steps/rules group, each group has one rule, here's the flow and the rules. Flow : -- "Find matching booking rules" -> "Refresh" -> "Apply booking rule group" Rules : -- The job of this rule is to store in DealMatchingBookingRules all the booking rule matching a specific deal (each DealMatchingBookingRules instance has a unique Deal). 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 Logger log = LoggerFactory.getLogger("Matching booking rules LOGGER"); log.info("Found a level 1 matching rule for deal : " + $dealModel + ", rule is " + $bookingRule); $dealMatchingBookingRules.addMatchingBookingRule($bookingRule); end // used to tell Drools that our $dealMatchingBookingRules are ready for next step in flow 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 rule "Apply level 1 booking rule" no-loop ruleflow-group "Apply level 1 booking rule group" when $dealMatchingBookingRules : DealMatchingBookingRules(hasSingleMatchingLevel1BookingRule == true) then BTExecutionBookingRuleModel effectiveBookingRuleModel = $dealMatchingBookingRules.getSingleMatchingLevel1BookingRule(); effectiveBookingRuleModel.applyRuleOnDeal($dealMatchingBookingRules.getDeal()); retract($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édite