Re: [rules-users] Drools Roadmap - Planned Release 6.0.0.Final release date
This seems like a recipe for trouble. Devs could be continually working on the latest and greatest, moving on when they're "complete," but leaving releases in their wake that have failing tests. Unreleasable releases could continually pile up. From: Mark Proctor To: Rules Users List Sent: Monday, October 28, 2013 3:01 PM Subject: Re: [rules-users] Drools Roadmap - Planned Release 6.0.0.Final release date We went to publish it last week, there were a few failing tests. Once those are fixed, it can be released. Fixing that though relies on community involvement, as core engineers prioritise working on the most recent branches. Davide Sottara, from the community, has been tirelessly trying to resolve those things. If anyone wants to help, please contact him. Quicker those are fixed, quicker it can be released. Mark On 28 Oct 2013, at 19:44, Jonathan Knehr wrote: Can we get 5.6 out before 6.0? Feel like it's been awhile now > > > >On Oct 28, 2013, at 3:36 PM, Mark Proctor wrote: > > >We are working on documentation,and trying to scan the code for mistakes or >missed things. >> >> >>Mark >> >>On 28 Oct 2013, at 19:26, Juan Ignacio Barisich >>wrote: >> >>There is enough information for me. >>> >>>Thanks a lot Mauricio. >>> >>> >>> >>> >>>2013/10/28 Mauricio Salatino >>> >>>We are working hard on get it out soon, but there is no definitive date as >>>far as I know.. Maybe early next week (??) On Mon, Oct 28, 2013 at 6:53 PM, Juan Ignacio Barisich wrote: Hi everybody. >I need to know if is there a planned release date for Drools platform >6.0.0.Final. > >Thanks >Regards > > > >___ >rules-users mailing list >rules-users@lists.jboss.org >https://lists.jboss.org/mailman/listinfo/rules-users > -- - MyJourney @ http://salaboy.wordpress.com/ - Co-Founder @ http://www.jugargentina.org/ - Co-Founder @ http://www.jbug.com.ar/ - Salatino "Salaboy" Mauricio - ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users >>> ___ >>>rules-users mailing list >>>rules-users@lists.jboss.org >>>https://lists.jboss.org/mailman/listinfo/rules-users >> >___ >>rules-users mailing list >>rules-users@lists.jboss.org >>https://lists.jboss.org/mailman/listinfo/rules-users___ >rules-users mailing list >rules-users@lists.jboss.org >https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Monitoring sensor parameter change
rule "first Reading" when $r: Reading() not LastReading( this == $r ) then insert( new LastReading( $r ) ); end From: Wolfgang Laun To: Rules Users List Sent: Tuesday, June 11, 2013 12:07 PM Subject: Re: [rules-users] Monitoring sensor parameter change Basically a good approach. declare LastReading last : Reading end // fire once, to set up LastReading with the very first Reading rule "first Reading" when $r: Reading() not LastReading() then insert( new LastReading( $r ) ); end // based on the existence of a previous reading... rule "next Reading" when $lr: LastReading( $last: last ) Reading( this == $last, $pp: power ) then end // ...detect and handle an increment beyond the threshold rule "next Reading, big increment" extends "next Reading" when $new: Reading( $np: power > $pp + 2 ) then update( $lr ){ setLast( $new ) } ... code for big increment end // ...detect and handle an increment below the threshold rule "next Reading, small increment" extends "next Reading" when $new: Reading( this != $last, $np: power <= $pp + 2 ) then update( $lr ){ setLast( $new ) } end All of this is untested and may contain syntax errors. - The additional constraint (this != $last) in the last rule avoids looping. -W On 11 June 2013 14:46, rjr201 wrote: If I understand your question right, you could create a class called >LastReading( SensorRead() ) and then your rules would look something like: > >rule 1 //check to see if the increase is > 2 >when > $last : LastReading( SensorRead($lastPower : power) ) > SensorRead( $lastPower - power > 2) >then > System.out.println("Power increased more than 2") >end > >rule2 //update which sensor read is the lastest reading >salience 100 >when > $last : LastReading( ) > $new : SensorRead() >then > retract($last) > insert(new LastReading($new)) >end > > > >-- >View this message in context: >http://drools.46999.n3.nabble.com/rules-users-Monitoring-sensor-parameter-change-tp4024242p4024243.html >Sent from the Drools: User forum mailing list archive at Nabble.com. > >___ >rules-users mailing list >rules-users@lists.jboss.org >https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Dedication to Wolfgang Laun - Thank You
Agreed. You've awesome Wolfgang. Thanks for all you've contributed to drools. From: Salaboy To: Rules Users List Cc: Rules Users List Sent: Sunday, January 6, 2013 10:11 AM Subject: Re: [rules-users] Dedication to Wolfgang Laun - Thank You Definitely, people like Wolfgang makes open source project a wonderful place to work! Sent from my iPhone On 6 Jan 2013, at 14:44, Reinis wrote: > I want to thank you all. > > You, the members of drools community, for making this platform alive by > giving away your knowledge and contributing the development of drools by > sharing your thought and inducing the discussion. > > You, the developers of drools, for having ability to make it work and > for actually making it work! > > And this time I want to say a special thanks to you, Wolfgang Laun, for > being selfless, humble and having the gift of explaining things not > because you're a doctor (of math btw) but because you have it down pat. > And I thank you for sacrificing a lot of your private time to help me to > solve my drools problem. > > So cheers to you, Wolfgang - a scientist, a mentor, a friend. > > Reinis > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] DROOLs 'Guarded entry/block' tactics for Rules synchronization and ordinality?
Not a problem. Actually I prefer to perform flow control using working memory objects like that instead of using the keywords, but I'm old school. :) GreG On Nov 29, 2012, at 11:11, "Cotton, Ben" wrote: > Ø Have you looked at agenda-group or ruleflow-group? > > Sweet. > > Ø You've reinvented some of their functionality here. > > Gak! I figured I must have been doing that (and that’s the last thing I want > to do). Got stuck in my “Drools newbie deep dive” … knew had to hit this > forum and “surface for air”. THANKS! > > > From: rules-users-boun...@lists.jboss.org > [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Greg Barton > Sent: Thursday, November 29, 2012 12:00 PM > To: Rules Users List > Subject: Re: [rules-users] DROOLs 'Guarded entry/block' tactics for Rules > synchronization and ordinality? > > Have you looked at agenda-group or ruleflow-group? You've reinvented some of > their functionality here. > > From: "Cotton, Ben" > To: "rules-users@lists.jboss.org" > Cc: "O'Brien, Patrick" > Sent: Thursday, November 29, 2012 10:47 AM > Subject: [rules-users] DROOLs 'Guarded entry/block' tactics for Rules > synchronization and ordinality? > > Hi, > > I have finally gained a tiny bit of control (and maybe even some competency) > in using the DROOLs language operators ‘no-loop’ and ‘lock-on-active’ as a > basis for controlling rule set firing behavior in response to Fact mutation > events (during consequence processing). > > I now want to (competently!) use DROOLs language tactics that give me ever > finer grained control over managing rule set firing behavior on Fact mutation > events. Specifically, I want to be able to implement some form of ‘Guarded > entry/block’ controls. > > E.g. let’s say I have a Fact (InsertedFactPOJO) that I insert into the KS > and want to have its ‘fireAllRules()’ AgendaSet(s) renedered in exact > incremental ordinal stages and in perfect isolation. To do this, I am > testing the inclusion of a ‘countdownLatch’ Semaphore reference as a Fact > member (initialized to N=`total rule count` value). I then use this to > ‘Guard’ individual rule entry, by generating an explicit predicate participant > > (InsertedFactPOJO(countdownLatch == i) ) > > @ each ith Rule producedby my template. > > Is this approach a valid/sound/complete way to implement ‘Guarded > entry/block’ controls in DROOLs? Is there a better way? > > As always, my sincerest gratitude to this community for its generosity (and > its genius). > > Ben > > package > com.ms.fast.triclear.eligibility.rules.drools_community.questions.posted; > import com.ms.fast.triclear.eligibility.InsertedFactPOJO; > //fact:(backed by Class 'InsertedFactPOJO' has > //- 'countdownLatch' (Semaphore) member > //- 'aList' (List)member > > rule "RULE_ALL_RULES_HAVE_FIRED_ONCE_ORDINALLY" > when > fact:InsertedFactPOJO() > InsertedFactPOJO(countdownLatch == 0) > then > System.out.format("\tALL RULES have fired *EXACTLY* once, *EXACTLY* > ordinally. "+ > " fact.countdownLatch=%d \n\t fact.aList=%s\n\n", > fact.countdownLatch, > fact.aList.toString()); > end > > rule "RULE_3" > when > fact:InsertedFactPOJO() > InsertedFactPOJO(countdownLatch == 3) > //bunch of other L-Value PREDICATES > then > System.out.format("\t %20.20s"+ > " \t(DROOLS agenda: consequence fired for L-value > predicate match @RULE="+ > "3"+" -- fact.countDownLatch=%d)\n", "Rule > 3",fact.countdownLatch); > modify (fact) { > countdownLatch = fact.countdownLatch - 1, > aList.add("Rule 3 pattern-match event added to POJO 'aList' > field"); > } > end > > rule "RULE_2" > when > fact:InsertedFactPOJO() > InsertedFactPOJO(countdownLatch == 2) > //bunch of other L-Value PREDICATES > then > System.out.format("\t %20.20s"+ > " \t(DROOLS agenda: consequence fired for L-value > predicate match @RULE="+ > "2"+" -- fact.countDownLatch=%d)\n", "Rule > 2",fact.countdownLatch); > modify (fact) { > countdownLatch = fact.countd
Re: [rules-users] DROOLs 'Guarded entry/block' tactics for Rules synchronization and ordinality?
Have you looked at agenda-group or ruleflow-group? You've reinvented some of their functionality here. From: "Cotton, Ben" To: "rules-users@lists.jboss.org" Cc: "O'Brien, Patrick" Sent: Thursday, November 29, 2012 10:47 AM Subject: [rules-users] DROOLs 'Guarded entry/block' tactics for Rules synchronization and ordinality? Hi, I have finally gained a tiny bit of control (and maybe even some competency) in using the DROOLs language operators ‘no-loop’ and ‘lock-on-active’ as a basis for controlling rule set firing behavior in response to Fact mutation events (during consequence processing). I now want to (competently!) use DROOLs language tactics that give me ever finer grained control over managing rule set firing behavior on Fact mutation events. Specifically, I want to be able to implement some form of ‘Guarded entry/block’ controls. E.g. let’s say I have a Fact (InsertedFactPOJO) that I insert into the KS and want to have its ‘fireAllRules()’ AgendaSet(s) renedered in exact incremental ordinal stages and in perfect isolation. To do this, I am testing the inclusion of a ‘countdownLatch’ Semaphore reference as a Fact member (initialized to N=`total rule count` value). I then use this to ‘Guard’ individual rule entry, by generating an explicit predicate participant (InsertedFactPOJO(countdownLatch == i) ) @ each ith Rule producedby my template. Is this approach a valid/sound/complete way to implement ‘Guarded entry/block’ controls in DROOLs? Is there a better way? As always, my sincerest gratitude to this community for its generosity (and its genius). Ben packagecom.ms.fast.triclear.eligibility.rules.drools_community.questions.posted; importcom.ms.fast.triclear.eligibility.InsertedFactPOJO; //fact:(backed by Class 'InsertedFactPOJO' has //- 'countdownLatch' (Semaphore) member //- 'aList' (List)member rule"RULE_ALL_RULES_HAVE_FIRED_ONCE_ORDINALLY" when fact:InsertedFactPOJO() InsertedFactPOJO(countdownLatch == 0) then System.out.format("\tALL RULES have fired *EXACTLY* once, *EXACTLY* ordinally. "+ " fact.countdownLatch=%d \n\t fact.aList=%s\n\n", fact.countdownLatch, fact.aList.toString()); end rule"RULE_3" when fact:InsertedFactPOJO() InsertedFactPOJO(countdownLatch == 3) //bunch of other L-Value PREDICATES then System.out.format("\t %20.20s"+ " \t(DROOLS agenda: consequence fired for L-value predicate match @RULE="+ "3"+" -- fact.countDownLatch=%d)\n", "Rule 3",fact.countdownLatch); modify(fact) { countdownLatch = fact.countdownLatch - 1, aList.add("Rule 3 pattern-match event added to POJO 'aList' field"); } end rule"RULE_2" when fact:InsertedFactPOJO() InsertedFactPOJO(countdownLatch == 2) //bunch of other L-Value PREDICATES then System.out.format("\t %20.20s"+ " \t(DROOLS agenda: consequence fired for L-value predicate match @RULE="+ "2"+" -- fact.countDownLatch=%d)\n", "Rule 2",fact.countdownLatch); modify(fact) { countdownLatch = fact.countdownLatch - 1, aList.add("Rule 2 pattern-match event added to POJO 'aList' field"); } end rule"RULE_1" when fact:InsertedFactPOJO() InsertedFactPOJO(countdownLatch == 1) //bunch of other L-Value PREDICATES then System.out.format("\t %20.20s"+ " \t(DROOLS agenda: consequence fired for L-value predicate match @RULE="+ "1"+" -- fact.countDownLatch=%d)\n", "Rule 1",fact.countdownLatch); modify(fact) { countdownLatch = fact.countdownLatch - 1, aList.add("Rule 1 pattern-match event added to POJO 'aList' field"); } end Ben D Cotton III Morgan Stanley & Co. OTC Derivatives Clearing Technology 1221 AOTA Rockefeller Ctr - Flr 27 New York, NY 10020 (212)762.9094 ben.cot...@ms.com NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or views contained herein are not intended to be, and do not constitute, advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer Protection Act. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately. Mistransmission is not intended to waive confidentiality or privilege. Morgan Stanley reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers If you cannot acce
Re: [rules-users] Inserting Different Objects Of Same Class !
Are the values in the list ever tested? (With rules conditionally firing if the contents of a list changes.) In the rules you've provided so far they are not. If this is the case then there's no need to match them in the conditions and the use of globals is just fine. The only reason to match a list in the rule conditions is if changing the list could result in that rule firing. From: abhinay_agarwal To: rules-users@lists.jboss.org Sent: Tuesday, November 27, 2012 4:36 AM Subject: Re: [rules-users] Inserting Different Objects Of Same Class ! I was initially using two lists making them global, and it was working for me, but then i read "Globals are not designed to share data between rules and they should never be used for that purpose. Rules always reason and react to the working memory state, so if you want to pass data from rule to rule, assert the data as facts into the working memory." So, thought might be somewhere, an issue can arise and changed the global facts. Thanks, AA -- View this message in context: http://drools.46999.n3.nabble.com/Inserting-Different-Objects-Of-Same-Class-tp4020971p4020981.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Best practice to use heap memory effectively
Can't you sum up counts from multiple sessions? Remove the count from the session before you dispose and keep that total count around until the end of the day. Unless there's something complex you need to do with all of the Alarm facts at the end of the 24 hour period there's no need to keep them around. From: mohan To: rules-users@lists.jboss.org Sent: Thursday, November 1, 2012 3:42 PM Subject: Re: [rules-users] Best practice to use heap memory effectively Hi Greg, yes that's the way i'm doing right now. To keep this count hope we need to maintain single session. So we can’t dispose session and by the time will we end up with memory exhaust? Thanks a lot. -- View this message in context: http://drools.46999.n3.nabble.com/Best-practice-to-use-heap-memory-effectively-tp4020194p4020659.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Best practice to use heap memory effectively
Why not just maintain a counter object in working memory? Just increment it whenever an alarm fact is inserted. Reset or retract it at the end of the day. From: mohan To: rules-users@lists.jboss.org Sent: Thursday, November 1, 2012 3:15 PM Subject: Re: [rules-users] Best practice to use heap memory effectively Let's assume we need to calculate number of Alarm facts/events inserted into WM over particular day. We will keep on adding facts throughout the day. If this count greater than threshold let’s notify somebody. Also we will retract facts/events which are older than 24 hours. Can we handle this situation without single static StatefulKnowledgeSession? Simply can we count number of facts/events in a WM in a particular time using multiple session? So I can call session.dispose() after each insertion. -- View this message in context: http://drools.46999.n3.nabble.com/Best-practice-to-use-heap-memory-effectively-tp4020194p4020656.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Field value is different when and then section, very strange. Is it mvel vs java issue
You can stop the recursive firing by 1) having conditions in the rules that stop recursion, (similar to a stop condition in a for loop) and 2) using update or modify to tell the rules engine that the properties have changed. From: kina06 To: rules-users@lists.jboss.org Sent: Tuesday, October 30, 2012 11:39 AM Subject: Re: [rules-users] Field value is different when and then section, very strange. Is it mvel vs java issue Yes I tried account : Account(accountStatus == "NEW") In above posts it's mentioned that I have to use modify or update, when use that it fires rules recursively without stopping. Will it possible to test my code, I can provide the Account class code as well it's just two fields in it. -- View this message in context: http://drools.46999.n3.nabble.com/Field-value-is-different-when-and-then-section-very-strange-Is-it-mvel-vs-java-issue-tp4020550p4020581.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Field value is different when and then section, very strange. Is it mvel vs java issue
This is a list for support of the drools product, but there is some expectation that you will figure out some basic functionality by reading the docs and putting some thought into it. :) In general, though, the "next rule" is whatever rule matches the objects currently in working memory. If you don't want a given rule to fire you should make sure that the objects altered no longer match it after they are changed. In your original example the Account object matched in Rule1 has no conditions on it at all, meaning any Account in working memory will be matched, so it's no wonder that it's being matched repeatedly. Also, I'm puzzled by your calls to StringUtils.equals() in the rule conditions. Did you not try this? account : Account(accountStatus == "NEW") Again, in the docs, this is the recommended way to test object properties. From: kina06 To: rules-users@lists.jboss.org Sent: Tuesday, October 30, 2012 10:12 AM Subject: Re: [rules-users] Field value is different when and then section, very strange. Is it mvel vs java issue This looks like such a basic functionality and I'm not getting any help. I can't seem to understand why update function keep calling the function, is there no way to let drools know that I modifed an object values so it gives me the updated object in next rule. Please help, this is such a basic step without which I cna't proceed any further. -- View this message in context: http://drools.46999.n3.nabble.com/Field-value-is-different-when-and-then-section-very-strange-Is-it-mvel-vs-java-issue-tp4020550p4020578.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] refactoring "complex" conditon to use "in" operator
Also, I tried putting an underscore in front of the variable name, like in your code. Still no problem with Dools 5.4. (Project attached.) From: Greg Barton To: Rules Users List Sent: Friday, October 26, 2012 1:34 PM Subject: Re: [rules-users] refactoring "complex" conditon to use "in" operator I couldn't reproduce with Drools 5.4. If you can recreate the problem with the version of drools you're using on a test project like the one attached submit a JIRA. From: "Cotton, Ben" To: Rules Users List Sent: Friday, October 26, 2012 1:07 PM Subject: Re: [rules-users] refactoring "complex" conditon to use "in" operator No, that’s not it. Using “1.0” causes the exact same syntax error. From:rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Greg Barton Sent: Friday, October 26, 2012 2:03 PM To: Rules Users List Subject: Re: [rules-users] refactoring "complex" conditon to use "in" operator Maybe because the 1.0 is in single quotes, and not double quotes, like the others? From:"Cotton, Ben" To: Rules Users List Sent: Friday, October 26, 2012 12:15 PM Subject: [rules-users] refactoring "complex" conditon to use "in" operator Hi, The following rule is working well. rule"foo" when Message(_initialStubRate == "1.0") || Message(_initialStubRate == "2.0") || ( Message(_initialStubRate >= "4.0") && Message(_initialStubRate <= "44.0") ) || Message(_initialStubRate == "52.0") then System.out.println("foo"); End To make this logic more amenable to being generically rendered via .DRT template, I want to simplify this rule . Consider the following re-factoring. rule"bar" when Message(_initialStubRate in( '1.0',"2.0", "4.0","5.0","6.0","7.0","8.0","9.0","10.0", "11.0", "12.0","13.0", "14.0","15.0","16.0","17.0","18.0","19.0","20.0", "21.0", "22.0","23.0", "24.0","25.0","26.0","27.0","28.0","29.0","30.0", "31.0", "32.0","33.0", "34.0","35.0","36.0","37.0","38.0","39.0","40.0", "41.0", "42.0","43.0", "44.0", "52.0") ) then System.out.println("bar"); end This re-facotred rule produces a syntax error in Eclipse’s .DRL view. BuildError: Unable to Analyse Expression_initialStubRate == "1.0" || _initialStubRate == "2.0" || _initialStubRate == "4.0" || _initialStubRate == "5.0" || _initialStubRate == "6.0" || _initialStubRate == "7.0" || _initialStubRate == "8.0" || _initialStubRate == "9.0" || _initialStubRate == "10.0" || _initialStubRate == "11.0" || _initialStubRate == "12.0" || _initialStubRate == "13.0" || _initialStubRate == "14.0" || _initialStubRate == "15.0" || _initialStubRate == "16.0" || _initialStubRate == "17.0" || _initialStubRate == "18.0" || _initialStubRate == "19.0" || _initialStubRate == "20.0" || _initialStubRate == "21.0" || _initialStubRate == "22.0" || _initialStubRate == "23.0" || _initialStubRate == "24.0" || _initialStubRate == "25.0" || _initialStubRate == "26.0" || _initialStubRate == "27.0" || _initialStubRate == "28.0" || _initialStubRate == "29.0" || _initialStubRate == "30.0" || _initialStubRate == "31.0" || _initialStubRate == "32.0" || _initialStubRate == "33.0" || _initialStubRate == "34.0" || _initialStubRate == "35.0" || _initialStubRate == "36.0" || _initialStubRate == "37.0" || _initialStubRate == "38.0" || _initialStubRate == "39.0" || _initialStubRate == "40.0" || _initialStubRate == "41.0" || _initialStubRate == "42.0" || _initialStubRate == "43.0" || _initialStubRate == "44.0" || _initialStubRate == "52.0": [Error: no such identifier: _initialStubRate] [Near : {
Re: [rules-users] refactoring "complex" conditon to use "in" operator
I couldn't reproduce with Drools 5.4. If you can recreate the problem with the version of drools you're using on a test project like the one attached submit a JIRA. From: "Cotton, Ben" To: Rules Users List Sent: Friday, October 26, 2012 1:07 PM Subject: Re: [rules-users] refactoring "complex" conditon to use "in" operator No, that’s not it. Using “1.0” causes the exact same syntax error. From:rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Greg Barton Sent: Friday, October 26, 2012 2:03 PM To: Rules Users List Subject: Re: [rules-users] refactoring "complex" conditon to use "in" operator Maybe because the 1.0 is in single quotes, and not double quotes, like the others? From:"Cotton, Ben" To: Rules Users List Sent: Friday, October 26, 2012 12:15 PM Subject: [rules-users] refactoring "complex" conditon to use "in" operator Hi, The following rule is working well. rule"foo" when Message(_initialStubRate == "1.0") || Message(_initialStubRate == "2.0") || ( Message(_initialStubRate >= "4.0") && Message(_initialStubRate <= "44.0") ) || Message(_initialStubRate == "52.0") then System.out.println("foo"); End To make this logic more amenable to being generically rendered via .DRT template, I want to simplify this rule . Consider the following re-factoring. rule"bar" when Message(_initialStubRate in( '1.0',"2.0", "4.0","5.0","6.0","7.0","8.0","9.0","10.0", "11.0", "12.0","13.0", "14.0","15.0","16.0","17.0","18.0","19.0","20.0", "21.0", "22.0","23.0", "24.0","25.0","26.0","27.0","28.0","29.0","30.0", "31.0", "32.0","33.0", "34.0","35.0","36.0","37.0","38.0","39.0","40.0", "41.0", "42.0","43.0", "44.0", "52.0") ) then System.out.println("bar"); end This re-facotred rule produces a syntax error in Eclipse’s .DRL view. BuildError: Unable to Analyse Expression_initialStubRate == "1.0" || _initialStubRate == "2.0" || _initialStubRate == "4.0" || _initialStubRate == "5.0" || _initialStubRate == "6.0" || _initialStubRate == "7.0" || _initialStubRate == "8.0" || _initialStubRate == "9.0" || _initialStubRate == "10.0" || _initialStubRate == "11.0" || _initialStubRate == "12.0" || _initialStubRate == "13.0" || _initialStubRate == "14.0" || _initialStubRate == "15.0" || _initialStubRate == "16.0" || _initialStubRate == "17.0" || _initialStubRate == "18.0" || _initialStubRate == "19.0" || _initialStubRate == "20.0" || _initialStubRate == "21.0" || _initialStubRate == "22.0" || _initialStubRate == "23.0" || _initialStubRate == "24.0" || _initialStubRate == "25.0" || _initialStubRate == "26.0" || _initialStubRate == "27.0" || _initialStubRate == "28.0" || _initialStubRate == "29.0" || _initialStubRate == "30.0" || _initialStubRate == "31.0" || _initialStubRate == "32.0" || _initialStubRate == "33.0" || _initialStubRate == "34.0" || _initialStubRate == "35.0" || _initialStubRate == "36.0" || _initialStubRate == "37.0" || _initialStubRate == "38.0" || _initialStubRate == "39.0" || _initialStubRate == "40.0" || _initialStubRate == "41.0" || _initialStubRate == "42.0" || _initialStubRate == "43.0" || _initialStubRate == "44.0" || _initialStubRate == "52.0": [Error: no such identifier: _initialStubRate] [Near : {... _initialStubRate == "1.0" || _ }] ^ [Line: 1, Column: 1] What could be wrong? Ben D Cotton III Morgan Stanley & Co. OTC Derivatives Clearing Technology 1221 AOTA Rockefeller Ctr - Flr 27 New York, NY 10020 (212)762.9094 ben.cot...@ms.com NOTICE: Morgan Stanley is not a
Re: [rules-users] refactoring "complex" conditon to use "in" operator
Maybe because the 1.0 is in single quotes, and not double quotes, like the others? From: "Cotton, Ben" To: Rules Users List Sent: Friday, October 26, 2012 12:15 PM Subject: [rules-users] refactoring "complex" conditon to use "in" operator Hi, The following rule is working well. rule"foo" when Message(_initialStubRate == "1.0") || Message(_initialStubRate == "2.0") || ( Message(_initialStubRate >= "4.0") && Message(_initialStubRate <= "44.0") ) || Message(_initialStubRate == "52.0") then System.out.println("foo"); End To make this logic more amenable to being generically rendered via .DRT template, I want to simplify this rule . Consider the following re-factoring. rule"bar" when Message(_initialStubRate in( '1.0',"2.0", "4.0","5.0","6.0","7.0","8.0","9.0","10.0", "11.0", "12.0","13.0", "14.0","15.0","16.0","17.0","18.0","19.0","20.0", "21.0", "22.0","23.0", "24.0","25.0","26.0","27.0","28.0","29.0","30.0", "31.0", "32.0","33.0", "34.0","35.0","36.0","37.0","38.0","39.0","40.0", "41.0", "42.0","43.0", "44.0", "52.0") ) then System.out.println("bar"); end This re-facotred rule produces a syntax error in Eclipse’s .DRL view. BuildError: Unable to Analyse Expression_initialStubRate == "1.0" || _initialStubRate == "2.0" || _initialStubRate == "4.0" || _initialStubRate == "5.0" || _initialStubRate == "6.0" || _initialStubRate == "7.0" || _initialStubRate == "8.0" || _initialStubRate == "9.0" || _initialStubRate == "10.0" || _initialStubRate == "11.0" || _initialStubRate == "12.0" || _initialStubRate == "13.0" || _initialStubRate == "14.0" || _initialStubRate == "15.0" || _initialStubRate == "16.0" || _initialStubRate == "17.0" || _initialStubRate == "18.0" || _initialStubRate == "19.0" || _initialStubRate == "20.0" || _initialStubRate == "21.0" || _initialStubRate == "22.0" || _initialStubRate == "23.0" || _initialStubRate == "24.0" || _initialStubRate == "25.0" || _initialStubRate == "26.0" || _initialStubRate == "27.0" || _initialStubRate == "28.0" || _initialStubRate == "29.0" || _initialStubRate == "30.0" || _initialStubRate == "31.0" || _initialStubRate == "32.0" || _initialStubRate == "33.0" || _initialStubRate == "34.0" || _initialStubRate == "35.0" || _initialStubRate == "36.0" || _initialStubRate == "37.0" || _initialStubRate == "38.0" || _initialStubRate == "39.0" || _initialStubRate == "40.0" || _initialStubRate == "41.0" || _initialStubRate == "42.0" || _initialStubRate == "43.0" || _initialStubRate == "44.0" || _initialStubRate == "52.0": [Error: no such identifier: _initialStubRate] [Near : {... _initialStubRate == "1.0" || _ }] ^ [Line: 1, Column: 1] What could be wrong? Ben D Cotton III Morgan Stanley & Co. OTC Derivatives Clearing Technology 1221 AOTA Rockefeller Ctr - Flr 27 New York, NY 10020 (212)762.9094 ben.cot...@ms.com NOTICE: Morgan Stanley is not acting as a municipal advisor and the opinions or views contained herein are not intended to be, and do not constitute, advice within the meaning of Section 975 of the Dodd-Frank Wall Street Reform and Consumer Protection Act. If you have received this communication in error, please destroy all electronic and paper copies and notify the sender immediately. Mistransmission is not intended to waive confidentiality or privilege. Morgan Stanley reserves the right, to the extent permitted under applicable law, to monitor electronic communications. This message is subject to terms available at the following link: http://www.morganstanley.com/disclaimers If you cannot access these links, please notify us by reply message and we will send the contents to you. By messaging with Morgan Stanley you consent to the foregoing. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to execute a rule only when a fact is retracted
Along the same lines, have a boolean attribute called "markedForDeletion" on the fact. Set it to true and match rules off of that, with a low priority rule that retracts it when all others are done. And if you can't modify the original fact class, like Wolfie says below, insert a control fact that points back to the original, and have rules match off of that: class RetractionHandler { public OriginalFactClass theDoomedFact; } From: Wolfgang Laun To: Rules Users List Sent: Wednesday, October 17, 2012 12:09 PM Subject: Re: [rules-users] How to execute a rule only when a fact is retracted Insert a fact that says "retracted" and write a rule matching that. Or, even simpler, execute whatever is required together with the retraction of that fact. -W On 17/10/2012, dme1 wrote: > Hi, > > How can I ensure that a rule is executed only when a fact is retracted. If > I > implement the rule using a "not" condition it will execute even when the > object was never inserted into the working memory. Is there a way to > implement the rule such that it will not execute when a fact is never > inserted into the working memory, but executes only when the fact is > retracted from the working memory. > > Thanks, > dme > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/How-to-execute-a-rule-only-when-a-fact-is-retracted-tp4020338.html > Sent from the Drools: User forum mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] rule infinitely loops, appears to be depending on naming on variable
You could implement a custom bit set with internal loops that are apt to be unrolled by the jit.From: Mark Proctor To: Rules Users List Sent: Friday, October 5, 2012 7:17 PM Subject: Re: [rules-users] rule infinitely loops, appears to be depending on naming on variable There is a class called BitSet, which grows the number of bits.http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/6-b14/java/util/BitSet.javaThis uses an array of longs instead. But i'm really reluctant to use this, because it adds overhead to our currently very lightweight operation, it has to create a for loop:public boolean intersects(BitSet set) {for (int i = Math.min(wordsInUse, set.wordsInUse) - 1; i >= 0; i--) { if ((words[i] & set.words[i]) != 0) {return true; } } return false;}But we can investigate and see if it adds any noticeable performance. In the meantime the kbuilder should probably throw an exception.MarkOn 5 Oct 2012, at 21:44, Davide Sottarawrote:At the moment, @propertyReactive uses a bit mask internally... and I believethat is limited to 64 bits, which corresponds to 64 fields, less than whatyou have. I'm not 100% sure since I didn't check, but I have the feeling that it mayexplain what is going on here..You have something like 160 fields, which is 128+32.. adding or removing onemight indeed make a difference!This may indeed be a (known?) bug or limitation of the current impl, MarioFusco will be able to provide more insight..You can easily work around the problem, at least for now, by preventing theloop with updatedArBankruptcyChapterPopulated != "No"A side question would be: do you really need all those fields in the sameclass? Wouldn't it be more reasonable to split it them in multiple beans,rather than a single generic "Facts" class? I'm not familiarwith the domain, but the properties seem very hetherogeneous...Also in terms of efficiency and memory consumption, would an averageinstance of yours have most of those fields populated?BestDavide--View this message in context: http://drools.46999.n3.nabble.com/rule-infinitely-loops-appears-to-be-depending-on-naming-on-variable-tp4020158p4020159.htmlSent from the Drools: User forum mailing list archive at Nabble.com.___rules-users mailing listrules-users@lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-users___rules-users mailing listrules-users@lists.jboss.orghttps://lists.jboss.org/mailman/listinfo/rules-users___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Avoid caching method results within non fact objects
The alternative you're attempting using "from" is potentially less efficient than the first one you tried. :) Can you alter the CurrentFact objects to hold current and previous state? That way you avoid the matching step altogether. rule "Interesting Event" when $currentFact: CurrentFact(state=="somethingNew", previousState=="somethingOld") then //do something //update currentFact.previousState to reflect the state of the newFact end - Original Message - From: rogelio_sevilla1 To: rules-users@lists.jboss.org Cc: Sent: Thursday, August 2, 2012 7:19 PM Subject: [rules-users] Avoid caching method results within non fact objects Good day everyone, I'm having a problem here and I'm not sure if I'm using the right approach. Currently I have a couple of rules where I inject A LOT of objects as facts. These objects change their states quite commonly and I have to make decisions when the previous state has a particular value comparing it to the current state. Something like this (just an example, sorry if there are typos) rule "Interesting Event" when $currentFact: CurrentFact(state=="somethingNew") $previousFact: PreviousFact($currentFact.id == id && state=="somethingOld") then //do something //update previousFact to reflect the state of the newFact end The problem that I had with this is that I had SOOO much facts within the rules session (thousands of objects with a lot of data that I need within the session too) that the fireAllRules method started to take too much time to complete. So, what I did is to store the previous facts of the objects within a Wrapper class that contains a hashmap with all of these states. Something like: PreviousStateHolder{ private static HashMap previousFacts; public void insertPreviousState(){ ... } public boolean containsPreviousState(CurrentState currentState){ ... } public boolean deletePreviousState(){ ... } .. other management methods } And my new rules look like rule "Interesting Event" when $currentFact: CurrentFact(state=="somethingNew") $previousFact: PreviousFact(state=="somethingOld") from PreviousStateHolder.retrievePreviousState($currentFact) then //do something //update previousFact to reflect the state of the newFact end The problem is that drools caches the result returned by the retrievePreviousState() method, so, it does not matter if the PreviousStateHolder member changes; drools always caches the result. I have tried to put my invocations within eval() but I still get the same problem (cached results). I know they are being cached because I put a breakpoint within the methods, and the first time the fireAllRules gets executed, they get hit. But then, the consequence of these rules keep getting executed even if the retrievePreviousState() does not reflect the value needed to do so. Am I doing something wrong?? Is there another approach that does not involve inserting all of these states as facts within my session?? Thanks a lot in advance -- View this message in context: http://drools.46999.n3.nabble.com/Avoid-caching-method-results-within-non-fact-objects-tp4019005.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Query for a fact, and concurrent rule execution
Indeed! And there's no reason you couldn't do the procedure below with multiple concurrent stateful sessions. In fact, this might be the best way, as when the support facts change you could create new sessions and not disrupt the service. (And if the support facts are immutable and not changed by the rules you should share them between sessions in the same JVM, saving memory and DB load overhead.) --- On Wed, 5/2/12, Wolfgang Laun wrote: > From: Wolfgang Laun > Subject: Re: [rules-users] Query for a fact, and concurrent rule execution > To: "Rules Users List" > Date: Wednesday, May 2, 2012, 11:09 AM > Loading a stateless knowledge session > with ~10k facts and the one (or > few) transaction fact(s) for a single transaction isn't > economic. > > I'd benchmark the costs for inserting the transaction > fact(s) into a > statefeul session, run fireAllRules(), returning the result > and > removing the debris in a thread. This should give you a > good > indication how many of these you can do per second, and the > potential > delay for concurrent requests when transactions are done in > turn. > > -W > > > On 02/05/2012, gpa...@tsys.com > > wrote: > > I would suggest making your service stateless and run > the service in > > multiple JVMs to alleviate performance concerns. You > will be able to scale > > and also not have to worry about cramming everything > into a > > StatefulKnowledgeSession and worry abt thead-safety. > > > > > > > > From: Stephen Lomax > > To: Rules Users List , > > Date: 05/02/2012 04:28 AM > > Subject: Re: [rules-users] > Query for a fact, and concurrent rule > > execution > > Sent by: rules-users-boun...@lists.jboss.org > > > > > > > > Hi Mike, > > > > Many thanks for that..we had previously thought of > serialising to file but > > thought the purpose of the StatefulKnowledgeSession was > to keep it live in > > memory continuously, rather than instantiating a new > session with each web > > service call. > > > > > > My concern is that if we instantiate a new session with > each web service > > call the memory required will increase massively (if we > have many > > concurrent requests). Is there a way of serving > multiple concurrent > > requests against the same session to remove that > concern. > > > > Many thanks for your help with this..it is very much > appreciated. > > > > Ste > > > > > > . > > On 2 May 2012, at 12:08, Michael Anstis wrote: > > > > That's a possibility, but it'd depend on your rules. > > > > As a thought, you could serialise the initialised > > StatelessKnowledgeSession into a byte[] (cached at > application scope) and > > deserialise with each web-service call. > > > > I would wait to see if Mark Proctor, Edson Tirelli or > community members > > have other thoughts on use of a single > StatefulKnowledgeSession. > > > > IIRC it is meant to be thread-safe but think people > have reported problems > > in the past. Recently: > > http://lists.jboss.org/pipermail/rules-dev/2012-February/003857.html > > > > With kind regards, > > > > Mike > > > > On 2 May 2012 11:58, Stephen Lomax > wrote: > > Hi Mike, > > > > Each quote does not enrich the session, we were > actively looking to remove > > the quote at the end of the session to prevent it > growing as we were just > > comparing the quote to the core product attribute > facts. > > > > What is the performance hit in launching a Stateful > knowledge session with > > say 10,000 facts, would it make the web service call > slow? > > > > Thanks very much for the help on the query also…we > will look into that. > > > > Kind Regards > > > > Ste > > > > On 2 May 2012, at 11:31, Michael Anstis wrote: > > > > Does each quote validation exercise enrich the > StatefulKnowledgeSession > > with other facts that could influence validation of > other quotes? > > > > If not probably using a StatefulKnowledgeSession per > HTTP request might be > > more simple (with the KnowledgeBase as an application > scoped variable). > > > > Regarding retrieval of results, there are a couple of > options that spring > > to mind:- > > Look at using a Global to collate results. > > Look at using a Query ( > > http://stackoverflow.com/questions/5872215/how-do-i-add-facts-to-working-memory-at-runtime-in-the-drools-drl-and-retrieve-t > > ) > > With kind regards, > > > > Mike > > > > On 2 May 2012 10:39, stelomax > wrote: > > Hi, > > > > Please bear with me, I am relatively new to the world > of Drools and have a > > question. I am hoping it will be a simple issue. > > > > First let me frame my planned implementation at a high > level. I am hoping > > to use Drools as a real time service enabled quote > validation tool. > > > > Facts representing products and attributes will be > loaded into a stateful > > knowledge session upon boot (using a piece of Java that > loads these as > > facts > > from our product DB). > > > > The front-end application will allow users to build up > quotes consisting > > of > > quote lines th
Re: [rules-users] Rule to load facts with pagination
I agree with Wolfgang that we need more information, but here's two general pieces of advice: 1) If the object loading involves little or no business logic then do it from java. (i.e. it's "load 1 objects and go") 2) It's usually more efficient to dispose of a session than to remove all objects from a session's working memory and reuse it. So if that fits your needs it's the best route. And if objects can be arbitrarily divided up in that way the problem is highly parallel, and you can take advantage of that by running the sessions in multiple threads/hosts. --- On Mon, 4/30/12, Wolfgang Laun wrote: > From: Wolfgang Laun > Subject: Re: [rules-users] Rule to load facts with pagination > To: "Rules Users List" > Date: Monday, April 30, 2012, 2:44 PM > Chances are high that you aren't > asking the right question but based > on the meagre information you provide I can't even propose a > better > question. > > Consider not only loading but also unloading. > > Does the logic for loading the next bunch of facts warrant > rules? > > -W > > > On 30/04/2012, mariofox > wrote: > > Hi. > > > > I'm running drools in a project with millions of facts > to process. My > > memory > > doesn't allow me to load all of my facts, so I have to > load N objects at > > once, then start over with next N objects, and so on. > > > > Is it a good idea to let Drools to manage Pagination? I > mean, create rules > > in Drools with the purpose of loading facts?, or should > I have to do this > > by > > executing a Drools session from java in a loop?. My > main goal is > > performance. > > > > Thanks! > > > > -- > > View this message in context: > > http://drools.46999.n3.nabble.com/Rule-to-load-facts-with-pagination-tp3951591.html > > Sent from the Drools: User forum mailing list archive > at Nabble.com. > > ___ > > rules-users mailing list > > rules-users@lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/rules-users > > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Performace Issues drools
You can simplify the last condition to: not LabTest(testId == $test.testId) I think it's faster, too. --- On Mon, 4/23/12, Welsh, Armand wrote: > From: Welsh, Armand > Subject: Re: [rules-users] Performace Issues drools > To: "'Rules Users List'" > Date: Monday, April 23, 2012, 11:13 AM > I don't know your data model, but I > believe, what you may be looking for is; > > CONDITION: > $pt: Patient ( ) > $test : LabTest( ) from $pt.labTests > not (exists (LabTest (testId == > $test.testId))) > CONSEQUENCE > Insert($test); > > > If I am recalling this correctly, line2 does not inject > anything into working memory yet, and the only reference in > memory to the collection of tests for the patent is > $test. Whereas Line 3 uses the Rete indexed items that > were inserted into working memory, so what you are > effectively doing, is blocking the fact from being inserted > twice, because one it is inserted, it is indexed, and > associated with the rules where it is uses, and since this > rule states it must not exist, this rule cannot fire again, > since it can only be activated when there is no matching > labTest. > > However, the test should not be inserted more than once, > because it should only fire for changes, not the whole list > every time. To trigger a change on the original > version of the rule, you would have to change the Patient > record to trigger a reactivation of the rule. > > In this modified version of the rule, any change to LabTest > or Patient would trigger a reactivation of the rule, so the > original version may be the better rule, since it involves > less work to evaluate the activation triggers (only > slightly, but less is less). > > -Original Message- > From: rules-users-boun...@lists.jboss.org > [mailto:rules-users-boun...@lists.jboss.org] > On Behalf Of Pedro Loaiza > Sent: Monday, April 23, 2012 4:59 AM > To: Rules Users List > Cc: rules-users@lists.jboss.org > Subject: Re: [rules-users] Performace Issues drools > > I want implement this. How would you control the > insertion rule in order to avoid having it insert duplicates > or re-fire? > > Thanks > > On Apr 19, 2012, at 10:56 AM, "Welsh, Armand" > wrote: > > > This may no longer be the case, but my understanding is > that when you use from to query data from a member list of > another object in working memory, that those members are not > indexed by Rete. > > > > I think every time the rule evaluates, it has to > iterate through the entire member list (collection) to find > the matching facts that are extracted for additional > evaluation. > > > > With that said, if you have one rule that extracts the > facts, and inserts them into working memory, they will be > indexed and now many operations on the fact type will be > pre-computed at the time of insert, improving performance > dramatically. I don't know if this makes sense, but > consider the following: > > > > > > CONDITION: > > $pt: Patient ( ) > > LabTest( ) from $pt.labTests > > $numTests: Number ( ) from accumulate > ( LabTest($type: type == "lab"), count($type) ) > > > > Drools first collects all the Patient facts and for > each Patient it extracts the collections of tests. Now > the collection of patients are already known by Rete, so > this has been pre-computed at time of fact insert. > > Next, for each Patient fact, drools extracts the > collection of LabTests performed. These are not indexed by > Rete to they are not actually in working memory. Each > time this rule is evaluated, the collection of LabTests must > be generated. > > Next the accumulate evaluates the LabTest facts to find > those that have a getType() == "lab". Since the facts > do not exist in working memory, accumulate iterates all the > LabTest fact and extracts just the ones where getType == > "lab". If the rule file 10 times, that's 10 iterations > of the collection. > > > > If you break this into two rules: > > > > CONDITION: > > $pt: Patient ( ) > > $test : LabTest( ) from $pt.labTests > > CONSEQUENCE > > Insert($test); > > > > CONDITION: > > $numTests: Number ( ) from accumulate > ( LabTest($type: type == "lab"), count($type) ) > > > > > > In this scenario, Drools only extracts the LabTest > facts once, and inserts them in working memory, so that when > the 2nd rule is evaluated, it is already known which LabTest > facts are in memory that exist, and the iteration only > happened once, at insert time, instead at every rule > evaluation. > > > > My understanding may be obsolete, and inaccurate as it > applies to Drools 5.4, but this is the type of coding > changes I have made in the past to improve > performance. The key is knowing how to control the > insertion rule, so it does not insert duplicates, or refire > unexpectedly. > > > > Care must be taken to ensure you are properly binding > your facts when you do this though... But the most speed > benefit in drools comes from using the rete engine to avoid > m
Re: [rules-users] Having problems with traits in 5.4.0beta2
It's not, but can easily be. I just tried that, though, and the same exception happened. DRL attached. It's an old attempt to update the classic monkeys and bananas example to make it a bit more interesting: wandering monkeys, stacking blocks, a bit of world physics, stuff like that. I haven't touched it for several years and wanted to update it with new drools features for a presentation I'm doing on Tuesday. I was able to use the new parser features to eliminate a ton of evals, and would like to put traits and propSpecific features in. And just to confuse things a bit I have a question about propSpecific. :) Is it possible to annotate a method to indicate that it changes properties on a different object type other than itself? Take the "monkey_finds_block" rule as an example. The Monkey.setHolding() method modifies the thing that's being held. It would be great if I could annotate Monkey.setHolding() to indicate that it not only modifies Monkey.holding, but also Entity.location and Entity.holds. --- On Sun, 3/11/12, Davide Sottara wrote: > From: Davide Sottara > Subject: Re: [rules-users] Having problems with traits in 5.4.0beta2 > To: rules-users@lists.jboss.org > Date: Sunday, March 11, 2012, 11:58 AM > Is HungryMoneky an interface you have > outside the DRL? > Can you send me the full DRL anyway? > Thanks > Davide > > -- > View this message in context: > http://drools.46999.n3.nabble.com/rules-users-Having-problems-with-traits-in-5-4-0beta2-tp3816181p3816923.html > Sent from the Drools: User forum mailing list archive at > Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > MonkeysAndBananas.drl Description: Binary data ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Having problems with traits in 5.4.0beta2
When I try that declaration syntax I get the following exception loading the code: Exception in thread "main" java.lang.NullPointerException at org.drools.common.AbstractRuleBase.addPackages(AbstractRuleBase.java:488) at org.drools.reteoo.ReteooRuleBase.addPackages(ReteooRuleBase.java:469) at org.drools.reteoo.ReteooRuleBase.addPackage(ReteooRuleBase.java:476) at org.gregcode.mnb.Main.main(Main.java:36) This is with the released 5.4.0beta2 --- On Sun, 3/11/12, Davide Sottara wrote: > From: Davide Sottara > Subject: Re: [rules-users] Having problems with traits in 5.4.0beta2 > To: rules-users@lists.jboss.org > Date: Sunday, March 11, 2012, 5:00 AM > Hi Greg > we changed the way traits are declared. Now you have to do: > > declare trait HungryMonkey > > end > > We'll stress this change in the documentation of the next > release. > > Sorry but the code is still very experimental and subject to > changes... > but I do really appreciate the fact that this functionality > is being used > and tested. > Please let me know any further problem or suggestions you > may have. > > Thanks > Davide > dso...@gmail.com > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/rules-users-Having-problems-with-traits-in-5-4-0beta2-tp3816181p3816434.html > Sent from the Drools: User forum mailing list archive at > Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Having problems with traits in 5.4.0beta2
I'm trying out the traits feature and I'm having some problems. I'm preparing simple Monkeys and Bananas example with existing classes that I want to add traits, but when I try adding a trait (either declared in DRL or as a static interface) I'm getting an exception thrown from the call to don(). Here's the code: declare HungryMonkey @format(trait) end rule "foo" when monkey : Monkey( ) then HungryMonkey hm = don(monkey, HungryMonkey.class); end And the exception thrown: Exception in thread "main" Exception executing consequence for rule "foo" in org.gregcode.mnb: org.drools.RuntimeDroolsException: Field/method 'attachment' not found for class 'org.gregcode.mnb.MonkeyWrapper' at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:39) at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1101) at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:1029) at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1251) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:709) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:673) at org.gregcode.mnb.Main.main(Main.java:49) Caused by: org.drools.RuntimeDroolsException: Field/method 'attachment' not found for class 'org.gregcode.mnb.MonkeyWrapper' at org.drools.base.ClassFieldAccessorFactory.getClassFieldWriter(ClassFieldAccessorFactory.java:199) at org.drools.base.ClassFieldAccessorCache$CacheEntry.getWriteAccessor(ClassFieldAccessorCache.java:187) at org.drools.base.ClassFieldAccessorCache.getWriteAcessor(ClassFieldAccessorCache.java:116) at org.drools.base.ClassFieldAccessorStore.wire(ClassFieldAccessorStore.java:424) at org.drools.base.ClassFieldAccessorStore.getAccessor(ClassFieldAccessorStore.java:216) at org.drools.factmodel.traits.TraitFactory.buildWrapperClassDefinition(TraitFactory.java:340) at org.drools.factmodel.traits.TraitFactory.getCoreWrapper(TraitFactory.java:310) at org.drools.base.DefaultKnowledgeHelper.don(DefaultKnowledgeHelper.java:493) at org.drools.base.DefaultKnowledgeHelper.don(DefaultKnowledgeHelper.java:522) at org.gregcode.mnb.Rule_foo_3c2199da53c4480ea0ec7b3d1c4781b5.defaultConsequence(Rule_foo_3c2199da53c4480ea0ec7b3d1c4781b5.java:7) at org.gregcode.mnb.Rule_foo_3c2199da53c4480ea0ec7b3d1c4781b5DefaultConsequenceInvokerGenerated.evaluate(Unknown Source) at org.gregcode.mnb.Rule_foo_3c2199da53c4480ea0ec7b3d1c4781b5DefaultConsequenceInvoker.evaluate(Unknown Source) at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:1091) "MonkeyWrapper" is not in my code, so I'm assuming it's generated. I also tried creating a HungryMonkey and HungryMonkeyImpl interface/class pair like the Scholar and ScholarImpl from the traits example, but the same exception happened. Any clues? ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] setting different value in consequence ( RHS part) based on a conditional check
Nonsense. Rules engines can solve many problems much better than a monotonic programming. The primary area where this is the case are the "watch for given conditions, then act" problems: monitoring, command and control, models, and simulations. Rule engines are particularly well suited for tackling those problems, as with the "just do it in java" approach you usually end up first implementing a rules engine (badly) and getting stuck twiddling with your engine when you could be solving the problem at hand. The business rules application of rules engines was just a way to get the technology adopted, but it is by no means the only use of the technology. --- On Mon, 2/6/12, Welsh, Armand wrote: From: Welsh, Armand Subject: Re: [rules-users] setting different value in consequence ( RHS part) based on a conditional check To: "Rules Users List" Date: Monday, February 6, 2012, 6:45 PM As I suggested, if you wish to put conditional logic in the RHS of a rule, you would use a function. I didn’t provide an example using the function, because it did not appear to warrant the need for one, and because I consider this to be a very simplified version of the actual rule. Again, the decision on how to solve the challenge is up to the developer. Rules engines are not really designed to solve programmer’s problems, they are designed to solve business problems. And the use of functions to apply business logic obfuscates the code, making it less readable by a business analyst, and complicates the development of the code. Placing the decision logic in the LHS keeps the rules simple, and thus more maintainable by a business analyst. If only developers will ever look at the code, then I would question the use of drools at all, since many of the challenges we solve with drools can be coded more efficiently in straight JAVA code. But again, the decision is always on the developers. From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wolfgang Laun Sent: Thursday, January 26, 2012 10:52 AM To: Rules Users List Subject: Re: [rules-users] setting different value in consequence ( RHS part) based on a conditional check Oh my, aren't we a wee bit too dogmatic? I've certainly been known as being a stickler to style and best practice and what not, but in this particular case I'd use a single rule and offload the earth-shaking decision between 'Y' and 'N' into a function: rule x when samplefact1( $status: status, state == "CA" ) then fact0.setField1( yn( $status) ); end Cheers -W On 26 January 2012 18:25, Welsh, Armand wrote: You cannot, under normal circumstances, place conditional login in the RHS. This is by design. Any conditional logic belongs in the LHS. If you need to perform conditional logic in the RHS, this is usually an indicator that they rule is not written correctly. Now, with that said, there are times when you specifically want to put a decision component in the RHS. I would do this using a function. In your case, it really would make sense to use two rules, to represent your one case, like this: Rule 1 when samplefact1( status == "active", state == "CA" ) then Response fact0= new Response(); fact0.setField1( "Y" ); fact0.setName( "something " ); insert(fact0 ); end Rule 2 when samplefact1( status != "active", state == "CA" ) then Response fact0= new Response(); fact0.setField1( "N" ); fact0.setName( "something " ); insert(fact0 ); end These two rules are mutually exclusive, only one will fire, and you get the result you want. It's really about changing the way you think about decision factors. You can also achieve the same result like this: Rule 1 when samplefact1(state == "CA" ) then Response fact0= new Response(); fact0.setName( "something " ); insert(fact0 ); end Rule 2a when samplefact1( status == "active", state == "CA" ) $resp : Response ( field1 != "Y") Then modify( $resp ) { setField1( "Y" ) };end Rule 2b when samplefact1( status != "active", state == "CA" ) $resp : Response ( field1 == "Y") then modify( $resp ) { setField1( "N" ) }; end In this scenario, you are changing from hard data mapping to an event oriented rule. Rule1 creates the basic Response fact, and Rules 2a&2b enrich the response fact based on conditions that may arise throughout the processing of the rules, independent of the initial creation step. Just whenever you have a response fact that is not Y, set it to Y, and of course the inverse rule... This requires more processing for the rules, but in a large rules
Re: [rules-users] Why isn't my rule firing??
This is by design. Unless you modify an object and inform the inference engine of the change, rule conditions will not be re-evaluated. If you want the rule to re-fire you must tell the engine to reconsider the old NotificationEvents via update() or modify(). A rule like this would do it every time a new MyBean is detected: rule "TouchAllNotificationEvents" dialect "mvel" when MyBean() $ne : NotificationEvent() then update($ne); end --- On Wed, 1/18/12, dunnlow wrote: > From: dunnlow > Subject: [rules-users] Why isn't my rule firing?? > To: rules-users@lists.jboss.org > Date: Wednesday, January 18, 2012, 1:47 PM > First, my intent: > > 1) insert a pojo into a stateful session > 2) based upon that pojo's attributes, create and > insert a new fact > (different type) > 3) retract the initial pojo, but keep the newly > created fact in memory for > some period of time > > After some helpful insight from the forum, I thought I > could knock this out. > > However, I'm stuck and I've boiled down to what I imagine > is a > misunderstanding that I have. I have the code and > rules below. > > With each fact that I insert, I expected > 1) to see the number of facts grow (the list of > facts printed line 16 does > grow with each call). This works > 2) to see the NotificationEvent added only once to > working memory (the > facts printed shows only one NotificationEvent and then a > new MyBean for > each one I insert). So, I think this works also. > 3) BUT, each time I call fireAllRules(), I expect > the "foundNE" rule to be > triggered and to see "Found A notification event" > printed. However, this is > only printed once - after my first insert. Also, I see that > 0 rules get > fired (line 13) after the first MyBean insert. > > SO, if I see a NotificationEvent in the list of facts in > line 17, why isn't > my foundNE rule printing out the message each time I insert > a new MyBean and > call fireallrules?? > > FYI, my future plan is to have a rule with low salience > that retracts the > MyBeans just inserted and have my foundNE rule retract any > NotificationEvents that are at least 10 mins old. (so > that the > NotificationEvents will grow but not MyBeans) . > > Here is my test code (please excuse typos - there are none > in my code): > > Thanks very much for any insight. > -J > > ===test.java === > > 1 KnowledgeBase kbase = readKnowledgeBaseFromFile(); > 2 StatefulKnowledegeSession ksession = > kbase.newStatefulKnowledgeSession(): > 3 KnowledgeRuntimeLogger logger = > KnowledgeRuntimeLoggerFactory.newFileLogger(ksession,"testlog"); > > 4 for (int x=0;x<10;x++){ > 5 myBean mb = new MyBean(); > 6 mb.setName("me"); > 7 mb.setHeadline("my_head"); > 8 mb.setTag("tagline"); > 9 > 10 List cmds = new > ArrayList(); > 11 FactHandle fh = (FactHandle) > ksession.insert(seb); > 12 int rf = ksession.fireAllRules(); > 13 System.out.println(rf+"rules fired"); > 14 > 15 Collection c = > ksession.getFactHandles(); > 16 for (FactHandle f:c) { > 17 > System.out.println(" now: "+f.toString()); > 18 } > 19 > 20 Thread.sleep(5000); > 21 } > > === test.drl > import com.me.MyBean > import java.util.Calendar > > declare NotificationEvent > name: String > headline: String > tagline: String > dts: Long > end > > rule "foundNE" > dialect "mvel" > when > $ne : > NotificationEvent() > then > > System.out.println("Found a Notification Event"); > end > > rule "NotTemplate_1" > dialect "mvel" > when > $myb : MyBean(name > matches "me", headline matches "my_head") > not ($ne : > NotificationEvent(name matches $myb.name, > headline=$myb.headline) > then > NotificationEvent > fact0 = new NotificationEvent(); > > fact0.setName($myb.name); > > fact0.setHeadline($myb.headline); > insert(fact0); > > System.out.println("Adding a notification event"); > end > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Why-isn-t-my-rule-firing-tp3670261p3670261.html > Sent from the Drools: User forum mailing list archive at > Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] StatefulKnowledgeSession and multi-threaded processing
Common sense doesn't become common until it's communicated. :) --- On Tue, 12/20/11, Salaboy wrote: > From: Salaboy > Subject: Re: [rules-users] StatefulKnowledgeSession and multi-threaded > processing > To: "Rules Users List" > Cc: "Rules Users List" > Date: Tuesday, December 20, 2011, 7:56 PM > Sure, but its common sense and find > the right tool for each particular problem. In my > perspective he did that perfectly. > > - CTO @ http://www.plugtree.com > - MyJourney @ http://salaboy.wordpress.com > - Co-Founder @ http://www.jbug.com.ar > - Mauricio "Salaboy" Salatino - > > On 20/12/2011, at 22:52, Greg Barton > wrote: > > > Absolutely. Anyone who wants to build a high > performance rules system should watch it. > > > > --- On Tue, 12/20/11, Mauricio Salatino > wrote: > > > >> From: Mauricio Salatino > >> Subject: Re: [rules-users] > StatefulKnowledgeSession and multi-threaded processing > >> To: "Rules Users List" > >> Date: Tuesday, December 20, 2011, 11:50 AM > >> That's not me.. his name is Alexandre > >> Porcelli.. he is also a > >> community member.. really good presentation > >> > >> On Tue, Dec 20, 2011 at 2:46 PM, lhorton > >> wrote: > >>> You might like to view this video, posted by > Mauricio > >> (Salaboy) this year, > >>> from their Drools workshop in Argentina. > It's about > >> a real (production) > >>> implementation of a very high volume, high > performance > >> Drools-based system: > >>> > >>> http://vimeo.com/27209589 http://vimeo.com/27209589 > >>> > >>> -- > >>> View this message in context: > >>> http://drools.46999.n3.nabble.com/StatefulKnowledgeSession-and-multi-threaded-processing-tp3599689p3601845.html > >>> Sent from the Drools: User forum mailing list > archive > >> at Nabble.com. > >>> > ___ > >>> rules-users mailing list > >>> rules-users@lists.jboss.org > >>> https://lists.jboss.org/mailman/listinfo/rules-users > >> > >> > >> > >> -- > >> - CTO @ http://www.plugtree.com > >> - MyJourney @ http://salaboy.wordpress.com > >> - Co-Founder @ http://www.jugargentina.org > >> - Co-Founder @ http://www.jbug.com.ar > >> > >> - Salatino "Salaboy" Mauricio - > >> > >> ___ > >> rules-users mailing list > >> rules-users@lists.jboss.org > >> https://lists.jboss.org/mailman/listinfo/rules-users > >> > > > > ___ > > rules-users mailing list > > rules-users@lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/rules-users > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] StatefulKnowledgeSession and multi-threaded processing
Absolutely. Anyone who wants to build a high performance rules system should watch it. --- On Tue, 12/20/11, Mauricio Salatino wrote: > From: Mauricio Salatino > Subject: Re: [rules-users] StatefulKnowledgeSession and multi-threaded > processing > To: "Rules Users List" > Date: Tuesday, December 20, 2011, 11:50 AM > That's not me.. his name is Alexandre > Porcelli.. he is also a > community member.. really good presentation > > On Tue, Dec 20, 2011 at 2:46 PM, lhorton > wrote: > > You might like to view this video, posted by Mauricio > (Salaboy) this year, > > from their Drools workshop in Argentina. It's about > a real (production) > > implementation of a very high volume, high performance > Drools-based system: > > > > http://vimeo.com/27209589 http://vimeo.com/27209589 > > > > -- > > View this message in context: > > http://drools.46999.n3.nabble.com/StatefulKnowledgeSession-and-multi-threaded-processing-tp3599689p3601845.html > > Sent from the Drools: User forum mailing list archive > at Nabble.com. > > ___ > > rules-users mailing list > > rules-users@lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/rules-users > > > > -- > - CTO @ http://www.plugtree.com > - MyJourney @ http://salaboy.wordpress.com > - Co-Founder @ http://www.jugargentina.org > - Co-Founder @ http://www.jbug.com.ar > > - Salatino "Salaboy" Mauricio - > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Problem evaluating with Enum
If the attribute IPhoneSentences.Sentence.descriptor is a Collection then this makes perfect sense. The elements are instances of ETimeConstraint (what your second rule tests for) not instances of the enum class definition ETimeConstraint. (what your first rule tests for...maybe...) However, I'm wondering why the first version of the "My Test" rule compiles at all. It doesn't when I try it. --- On Tue, 9/13/11, Hezi Stern wrote: From: Hezi Stern Subject: [rules-users] Problem evaluating with Enum To: rules-users@lists.jboss.org Date: Tuesday, September 13, 2011, 3:54 PM I have encountered the following problem using enums in drools. I have an enum defined called ETimeConstraint, something of the sort: public enum ETimeConstraint { NO_CONSTRAINT, TODAY,TOMORROW,;} Now I wish to filter sentences which reside in the working memory based on a time constraint which is of this enum type.I created the following test rule rule "My Test" when $sentences: ArrayList() from collect (IPhoneSentences.Sentence( descriptor contains ETimeConstraint )) then //somethingend this does not work meaning no sentence are selected although I know that there are sentences in the working memory. but when I add ETimeConstraint.name it does: rule "My Test" when $sentences: ArrayList() from collect (IPhoneSentences.Sentence( descriptor contains ETimeConstraint.name )) then //somethingend I can stick to this workaround but it becomes very problematic to work this way. Furthermore once I wish to define a variable for example defining $timeConstraint : rule "My Test" when $cm: Condition( $timeConstraint: contextIntention, ) $sentences: ArrayList() from collect (IPhoneSentences.Sentence( descriptor contains $timeConstraint )) then //somethingend this will not work because I can’t put $timeConstraint.name any suggestions? I am running:- Drools 5.2.0- Eclipse Helios - JBoss 5.1.0 ThanksHezi -Inline Attachment Follows- ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Condition syntax to access Map
Ah, other engines don't do nested accessors because they're wimps. WIMPS! :) --- On Fri, 7/29/11, Mark Proctor wrote: From: Mark Proctor Subject: Re: [rules-users] Condition syntax to access Map To: rules-users@lists.jboss.org Date: Friday, July 29, 2011, 8:52 AM On 29/07/2011 14:28, Edson Tirelli wrote: Yes, that is exactly what I think. Pattern matching constraints are like query parameters. They need to exist and evaluate to true in order to match. So, for this to match: a.b.c == null a needs to exist and be non-null, b needs to exist and be non-null, c needs to exist and be null. So it is not just NP safe navigation... it is an existence test at the same time. So for maps a[x].b[y].c[z] == null The keys x, y and z need to exist, and c[z] must have a value of null. That is what the expression above is asking for, in my understanding. This presents no loss of completeness to the language, as you can still test non-existence of keys if that is what you want, but the most common case you are looking for the opposite and it becomes much simpler to write rules that way. > So, a builder option to turn this on is allright with me. We can probably do that and have a configuration option to turn this feature on/off. I'm strongly against configuration options in this case, we decide on one way and stick with it. We already have too many configurations and a casual person looking at the code could introduce a bug as they weren't aware of what configuratino was on for null safety. I think part of the problem here is we are mixing domains, between script evaluation and relational constraints. There is a reason why other rule engines don't do nested accessors :) (ignoring the technical issues too). Mark Mark Edson 2011/7/29 Mark Proctor Lets forget that these are nested accessors and the problems they bring. Lets look at what they would be if they were real relations: On 29/07/2011 08:55, Wolfgang Laun wrote: Whoa! See below... 2011/7/28 Edson Tirelli I think we need to differentiate paradigms here. When using rules, contrary to imperative code, what we are doing is pattern matching. X( a.b.c == ) In the above case, we are looking for Xs that make that whole constraint true (i.e. match). If a or b are null, the whole expression will be false, does not matter the value of c or the value it is being compared against. (Edson: Only if you define it so. The logical implication of c being null in an absent a.b (i.e., a.b==null) could very well be that "a.b.c does not exist", and you can't claim that a.b.c exists if a.b. doesn't! Is there no house at some address? (city.street[name].house[number] == null) # true => no such house $c : City() $s : Street( city == $c, street = "name" ) House( number == null) The above is identical logic to the more convenient form of nested accessors, it's the proper relational form. In this case if there was no Street, it wouldn't match. This test data with false when null: Vienna/TirelliStrasse/42 returns "false", hence there is such a house. But we don't have a Tirelli Street in Vienna (yet)! Confer this to Perl's ! exists $city{-streets}{"Tirelli"}[42] )
Re: [rules-users] Condition syntax to access Map
+1 Naw +billion --- On Thu, 7/28/11, Edson Tirelli wrote: From: Edson Tirelli Subject: Re: [rules-users] Condition syntax to access Map To: "Rules Users List" Date: Thursday, July 28, 2011, 1:13 PM All, I think we need to differentiate paradigms here. When using rules, contrary to imperative code, what we are doing is pattern matching. X( a.b.c == ) In the above case, we are looking for Xs that make that whole constraint true (i.e. match). If a or b are null, the whole expression will be false, does not matter the value of c or the value it is being compared against. Raising a null pointer exception, IMO, brings no advantage at all to the table... on the contrary, makes writing rules more difficult. Another example we had in the past: class Circle implements Shapeclass Square implements Shape rule Xwhen Circle() from $shapes ... In the above example, $shapes is a list and the rule is clearly looking for Circles. If there are Squares in there, they will just not match. Raising a ClassCastException like it would happen in an imperative language brings no advantage to the table, IMO. So, IMO, all property navigation should be null pointer safe in the LHS of the rules. This is not what happens today, but I think it should be fixed. Edson 2011/7/28 Vincent LEGENDRE Hi all, I agree with W. : NPE should be the default, and "null" cases behaviour should be planned by programmers. But I am not sure about using a new operator in rules (and do the update in Guvnor ...). Why not using some drools annotations on the getter specifying the behaviour of an eval on a null value returned by this getter ? And may be these annotation could be added to an existing POJO via the declared type syntax (just like event role in fusion) ? Vincent. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com -Inline Attachment Follows- ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] One rule calling another rule
Rules do not "call" other rules. A rule can change the value of an object in working memory, and if another rule is triggered by that change (it's conditions are matched) then that other rule could fire. This is done without calling the subsequent rule directly. You do need to notify the rule engine that the object has changed, though, and that's done in Drools using the update or modify statements in the action portion of the rule. http://docs.jboss.org/drools/release/5.2.0.Final/drools-expert-docs/html_single/index.html#d0e5906 --- On Sat, 7/9/11, Roger Smith wrote: From: Roger Smith Subject: [rules-users] One rule calling another rule To: "Rules Users List" Date: Saturday, July 9, 2011, 12:27 AM I am involved in a project in which one rule needs to call another re-usable rule. Have anyone had experience using Drools to support such cascaded rules? If yes, any pointers as to how to do it? Roger -Inline Attachment Follows- ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] drools dynamic LHS
This design would get my vote, especially if the rules for each state diverge even slightly. The thing is, this kind of divergence can become a nightmare over time if you design too tightly to any initial requirements. The initial divergence always increases. :) One main selling point for rule based systems is that they're supposed to scale to higher complexities. They can if your design allows for it. Also, there's no reason that several states couldn't share the "facts per state" rules if their rules were identical. --- On Tue, 5/24/11, Ansgar Konermann wrote: > From: Ansgar Konermann > Subject: Re: [rules-users] drools dynamic LHS > To: rules-users@lists.jboss.org > Date: Tuesday, May 24, 2011, 6:28 PM > Am 25.05.2011 00:34, schrieb > marunam: > > What I was thinking was, creating fact object > dynamically with its > > attributes being loaded from some properties file > dynamically?? > > > > Any other solution/suggestions? > Create pre-compiled rule packages: one for each state and > one for the > generic rules, and merge the latter with one of the "facts > per state" > when preparing the knowledge base. > > Works well for our use case (multiple customers), should do > equally well > for a number of states. > > Best regards > > Ansgar > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] drools dynamic LHS
WHat you're describing is a rule base, which is what writing drl (or using guvnor) is for in the first place. :) --- On Tue, 5/24/11, marunam wrote: > From: marunam > Subject: Re: [rules-users] drools dynamic LHS > To: rules-users@lists.jboss.org > Date: Tuesday, May 24, 2011, 2:17 PM > I understand that fact could store > the values but my question more towards > how to design this for dynamic number of facts. Let's say, > if the business > want to modify the rules with more fact values, I want to > be able to happen > this dynamically rather than changing the code for fact > values and adding it > there. > > I was thinking more toward having a property > file(database??) and program > reads those dynamic values and prepares fact model before > running the rules > > Thoughts?? > > Thanks > > -- > View this message in context: > http://drools.46999.n3.nabble.com/drools-dynamic-LHS-tp2980536p2981145.html > Sent from the Drools: User forum mailing list archive at > Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Business Logic in Java
Use eval() to call the java logic, but realize that by doing what you describe you're subverting the need to use a rule engine in the first place. --- On Tue, 5/24/11, sdinoo wrote: > From: sdinoo > Subject: [rules-users] Business Logic in Java > To: rules-users@lists.jboss.org > Date: Tuesday, May 24, 2011, 5:33 AM > I have a claim object that I want to > subject to a Rule > there is a Java class that contains the complex business > logic > > Rule Class DurBusinessRules has the following method > public DurRuleResponse executeHardCodedTDAlertRule(DurClaim > incomingClaim) > > DurRuleResponse is an response object that contains the > contributing claims > > I want to be able to send just the incoming claim to the > Rule > and in the rule I want to print just the values from the > DurRuleResponse > object > > something like > > when > executeHardCodedRule(incoming claim) > then > print each contributing claim from the DurRuleResponse > end > > Can someone help? > > > > -- > View this message in context: > http://drools.46999.n3.nabble.com/Business-Logic-in-Java-tp2979079p2979079.html > Sent from the Drools: User forum mailing list archive at > Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] The update function inside a rule
Upgrade to 5.2M1 and the CPU overuse problem goes away. --- On Wed, 3/30/11, marc wrote: > From: marc > Subject: Re: [rules-users] The update function inside a rule > To: rules-users@lists.jboss.org > Date: Wednesday, March 30, 2011, 5:47 AM > I was using only one fireAllRules() > after insert(message) and not > fireUntilHalt(). But is should be enough : as the rule > change & update the > fact, the rule is applied again (10 seconds later, and not > 1second). > > With fireUntilHalt() the rule work fine (and without > timer)... but it burns > the CPU (the java process reach 50% on a bi-proc) while a > simple call to > fireAllRues() after the timer update use nothing... This > doesn't make sense > to me because the drools engine is only notified of a fact > modification only > 1 time per second (the timer update), so it should only > fire all rules a > this moment and that all (just like a fireAllRules() after > the > update(SimpleClock) does), so why does it takes so much CPU > ? I can post the > code but I should open a other thread because it not the > same "problem" ? > > About adding log to trace the values of endDate, the traces > show correct > values. But it doesn't trace the value viewed by the drools > engine itself > wich could be different (just as if I don't do an update() > after a > modification) > > Marc > > > -- > View this message in context: > http://drools-java-rules-engine.46999.n3.nabble.com/The-update-function-inside-a-rule-tp2747484p2753098.html > Sent from the Drools - User mailing list archive at > Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] accumulate min over java.util.Date
Which is why I prefaced with "if it can work that way..." A JIRA can be for feature requests, and that's what this would be. Whether just adding a Comparable based accumulate function is the solution, or making accumulate generic like "from" is now, a JIRA does not have to specify the solution, just the request. GreG On Mar 25, 2011, at 4:22, Wolfgang Laun wrote: > Now don't be hasty with a JIRA. Using Comparable for the arguments of the min > and max accumulate functions will give you a result that is -- Comparable. So: > > $min: Comparable() from accumulate( Schedule( $d: date ), min( $d ) ) > > OK, this will give you the minimum data, bound to $min, although it won't let > you write any constraint for the "Comparable" result fact. But, what's worse, > it will not let you write > > $min: Number( intValue > 100 ) from accumulate( X( $y: y ), min( $y ) ) > > any more (unless I'm very much mistaken). > > -W > > > > On 25 March 2011 03:56, Greg Barton wrote: > Well, if it can work that way it should. I'd say open a JIRA and request > that feature. It works with the "principle of least confusion." :) > > --- On Thu, 3/24/11, jkrupka wrote: > > > From: jkrupka > > Subject: Re: [rules-users] accumulate min over java.util.Date > > To: rules-users@lists.jboss.org > > Date: Thursday, March 24, 2011, 8:26 PM > > Yea the docs weren't really clear > > about it, so I just thought it would work > > for anything that implemented Comparable =) > > > > Yep, used the long from getTime() - not the prettiest way > > of doing it, but > > it works great. > > > > Thanks! > > > > -- > > View this message in context: > > http://drools-java-rules-engine.46999.n3.nabble.com/accumulate-min-over-java-util-Date-tp2726081p2728477.html > > Sent from the Drools - User mailing list archive at > > Nabble.com. > > ___ > > rules-users mailing list > > rules-users@lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/rules-users > > > > > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] accumulate min over java.util.Date
Well, if it can work that way it should. I'd say open a JIRA and request that feature. It works with the "principle of least confusion." :) --- On Thu, 3/24/11, jkrupka wrote: > From: jkrupka > Subject: Re: [rules-users] accumulate min over java.util.Date > To: rules-users@lists.jboss.org > Date: Thursday, March 24, 2011, 8:26 PM > Yea the docs weren't really clear > about it, so I just thought it would work > for anything that implemented Comparable =) > > Yep, used the long from getTime() - not the prettiest way > of doing it, but > it works great. > > Thanks! > > -- > View this message in context: > http://drools-java-rules-engine.46999.n3.nabble.com/accumulate-min-over-java-util-Date-tp2726081p2728477.html > Sent from the Drools - User mailing list archive at > Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] accumulate min over java.util.Date
That's because a java.util.Date is not a java.lang.Number. :) You can get the long value behind the Date by calling Date.getTime(), though. Try that. --- On Thu, 3/24/11, jkrupka wrote: > From: jkrupka > Subject: [rules-users] accumulate min over java.util.Date > To: rules-users@lists.jboss.org > Date: Thursday, March 24, 2011, 12:07 PM > Should I be able to do an accumulate > min over java.util.Date objects? Like > this: > $minDate : Date() from accumulate(MyFact ($startDate : > startDate), > > min($startDate)) > > I would have thought so, but when I try it, I'm getting: > > Caused by: java.lang.ClassCastException: java.util.Date > cannot be cast to > java.lang.Number > at > org.drools.base.accumulators.MinAccumulateFunction.accumulate(MinAccumulateFunction.java:76) > > > > If it should work, then it's possible I'm doing something > else wrong, but > everything looks correct to me. I can always work > around it by getting the > milliseconds from the Date object and doing the min over > that... it's just > not as clean looking. > > -- > View this message in context: > http://drools-java-rules-engine.46999.n3.nabble.com/accumulate-min-over-java-util-Date-tp2726081p2726081.html > Sent from the Drools - User mailing list archive at > Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Starting engine using fireUntilHalt and inserting no facts results in 50% CPU usage
Confirmed using the standalone test project from a previous thread using 5.2.0.M1. (attached) --- On Fri, 3/18/11, lexsoto wrote: > From: lexsoto > Subject: Re: [rules-users] Starting engine using fireUntilHalt and inserting > no facts results in 50% CPU usage > To: rules-users@lists.jboss.org > Date: Friday, March 18, 2011, 9:37 AM > My bad, the EAR packaging was wrong > causing version 5.1.1 to be the one being > deployed (due to other modules included in the EAR). > > > 5.2.0.M1 does indeed fix the high CPU usage. > > > -- > View this message in context: > http://drools-java-rules-engine.46999.n3.nabble.com/Starting-engine-using-fireUntilHalt-and-inserting-no-facts-results-in-50-CPU-usage-tp1760370p2698129.html > Sent from the Drools - User mailing list archive at > Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > DroolsBoxes.tar.gz Description: GNU Zip compressed data ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Basic doubt regarding Drools Fusion - @expires
Yes, but I just fired up a small project using it and it used 100% of CPU. If you build the attached project you'll see the tests run just fine. (They use fireAllRules.) If you launch from the commandline, ("java -jar target/DroolsBoxes-1.0.jar") which uses fireUntilHalt, the rules fire (and complete) just fine, but it continues to use 100% of a cpu core indefinitely. This is with 5.1.1. If I change the drools version to 5.2.0-SNAPSHOT it compiles but the tests won't run. They all fail with the following exception: java.lang.NoSuchMethodError: org.drools.spi.DeclarationScopeResolver.([Ljava/util/Map;Ljava/util/Stack;)V at org.drools.rule.builder.RuleBuildContext.(RuleBuildContext.java:72) at org.drools.compiler.PackageBuilder.addRule(PackageBuilder.java:1198) at org.drools.compiler.PackageBuilder.addPackage(PackageBuilder.java:629) at org.drools.compiler.PackageBuilder.addPackageFromDrl(PackageBuilder.java:278) at org.drools.compiler.PackageBuilder.addKnowledgeResource(PackageBuilder.java:451) at org.drools.builder.impl.KnowledgeBuilderImpl.add(KnowledgeBuilderImpl.java:28) at com.sample.DroolsTest.readKnowledgeBase(DroolsTest.java:75) at com.sample.DroolsTest.go(DroolsTest.java:31) at com.sample.BoxTest.test0(BoxTest.java:21) --- On Thu, 3/17/11, Edson Tirelli wrote: From: Edson Tirelli Subject: Re: [rules-users] Basic doubt regarding Drools Fusion - @expires To: "Rules Users List" Date: Thursday, March 17, 2011, 10:47 AM To be honest, I believe so, but didn't profiled it extensively. I used fireUntilHalt() in my Webinar yesterday on a live demo and it worked nicely. Edson 2011/3/17 Greg Barton Has the performance problem with fireUntilHalt been fixed in 5.2? --- On Thu, 3/17/11, Makewise - Vitor Rui Mendonça wrote: From: Makewise - Vitor Rui Mendonça Subject: Re: [rules-users] Basic doubt regarding Drools Fusion - @expires To: "'Rules Users List'" Date: Thursday, March 17, 2011, 7:01 AM Hi Thomas, thanks for the info! I googled it quite a bit and I think it’s a path to be explored, albeit I’ve saw several messages on the mailing list regarding performance issues when using fireUntilHalt. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com -Inline Attachment Follows- ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users DroolsBoxes.tar.gz Description: GNU Zip compressed data ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Basic doubt regarding Drools Fusion - @expires
Has the performance problem with fireUntilHalt been fixed in 5.2? --- On Thu, 3/17/11, Makewise - Vitor Rui Mendonça wrote: From: Makewise - Vitor Rui Mendonça Subject: Re: [rules-users] Basic doubt regarding Drools Fusion - @expires To: "'Rules Users List'" Date: Thursday, March 17, 2011, 7:01 AM #yiv2042545743 P.yiv2042545743c1e0f729-dcb6-480b-8dd2-365933e094eb { MARGIN:0cm 0cm 0pt;} #yiv2042545743 LI.yiv2042545743c1e0f729-dcb6-480b-8dd2-365933e094eb { MARGIN:0cm 0cm 0pt;} #yiv2042545743 DIV.yiv2042545743c1e0f729-dcb6-480b-8dd2-365933e094eb { MARGIN:0cm 0cm 0pt;} #yiv2042545743 TABLE.yiv2042545743c1e0f729-dcb6-480b-8dd2-365933e094ebTable { MARGIN:0cm 0cm 0pt;} #yiv2042545743 DIV.yiv2042545743Section1 { } Hi Thomas, thanks for the info! I googled it quite a bit and I think it’s a path to be explored, albeit I’ve saw several messages on the mailing list regarding performance issues when using fireUntilHalt. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Open file leak in Drools Compiler
Yes, but it's not a full blown leak. Wrapping stream use in a try/finally block is best. Feel free and open a JIRA to fix it. There may be other instances. --- On Wed, 3/16/11, Chris Selwyn wrote: > From: Chris Selwyn > Subject: Re: [rules-users] Open file leak in Drools Compiler > To: "Rules Users List" > Cc: "Greg Barton" > Date: Wednesday, March 16, 2011, 12:18 PM > Isn't it regarded as bad practice to > rely on the finalize() method > called by the garbage collector to release such resources? > > Chris > > On 16/03/2011 17:04, Greg Barton wrote: > > Only if garbage collection never runs. Then > you'd already be in trouble. :) > > > > --- On Wed, 3/16/11, Chris Selwyn > wrote: > > > >> From: Chris Selwyn > >> Subject: [rules-users] Open file leak in Drools > Compiler > >> To: "Drools users" > >> Date: Wednesday, March 16, 2011, 11:49 AM > >> I am running Drools (actually JBoss > >> Rules 5.1.0 ) in Glassfish. > >> > >> My deployable is an EJB that uses a > >> StatelessKnowledgeSession to run > >> some rules that I get from a KnowledgeAgent that > has a > >> Changeset with a > >> .drl in it. > >> Therefore, I have placed the drools compiler into > the > >> deployable and it > >> all appears to work. > >> > >> Glassfish has a clever little mechanism that, when > you > >> unload a > >> deployable that had some open streams, it tells > you all > >> about it (and > >> kindly closes them). > >> > >> Glassfish is reporting that InputStreams are being > left > >> open that were > >> opened in the isPackage() method of > >> > org.drools.commons.jci.compilers.EclipseJavaCompiler. > >> That method has the following code in it:- > >> > >> > > >> final InputStream is = > >> > pClassLoader.getResourceAsStream(ClassUtils.convertClassToResourcePath(pClazzName)); > >> > > >> if (is != null) { > >> > > >> return false; > >> > > >> } > >> > >> So, when "is" is not null (i.e. open), it is > forgotten > >> about and not closed. > >> > >> Isn't this a potential file handle leak? > >> > >> Chris Selwyn > >> > >> ___ > >> rules-users mailing list > >> rules-users@lists.jboss.org > >> https://lists.jboss.org/mailman/listinfo/rules-users > >> > > > > > > > > ___ > > rules-users mailing list > > rules-users@lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/rules-users > > > > > > - > > No virus found in this message. > > Checked by AVG - www.avg.com > > Version: 10.0.1204 / Virus Database: 1498/3509 - > Release Date: 03/15/11 > > > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Open file leak in Drools Compiler
Only if garbage collection never runs. Then you'd already be in trouble. :) --- On Wed, 3/16/11, Chris Selwyn wrote: > From: Chris Selwyn > Subject: [rules-users] Open file leak in Drools Compiler > To: "Drools users" > Date: Wednesday, March 16, 2011, 11:49 AM > I am running Drools (actually JBoss > Rules 5.1.0 ) in Glassfish. > > My deployable is an EJB that uses a > StatelessKnowledgeSession to run > some rules that I get from a KnowledgeAgent that has a > Changeset with a > .drl in it. > Therefore, I have placed the drools compiler into the > deployable and it > all appears to work. > > Glassfish has a clever little mechanism that, when you > unload a > deployable that had some open streams, it tells you all > about it (and > kindly closes them). > > Glassfish is reporting that InputStreams are being left > open that were > opened in the isPackage() method of > org.drools.commons.jci.compilers.EclipseJavaCompiler. > That method has the following code in it:- > > > final InputStream is = > pClassLoader.getResourceAsStream(ClassUtils.convertClassToResourcePath(pClazzName)); > > if (is != null) { > > return false; > > } > > So, when "is" is not null (i.e. open), it is forgotten > about and not closed. > > Isn't this a potential file handle leak? > > Chris Selwyn > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] alert via email
You want the java mail API: http://www.oracle.com/technetwork/java/javamail/index.html --- On Tue, 3/15/11, Esteban Aliverti wrote: From: Esteban Aliverti Subject: Re: [rules-users] alert via email To: "Rules Users List" Date: Tuesday, March 15, 2011, 7:42 AM AFAIK Drools doesn't provides out-of-the-box support for this. But because in the THEN part of your rules you can write Java code, you can implement this in any way you want. Best Regards, Esteban Aliverti - Developer @ http://www.plugtree.com - Blog @ http://ilesteban.wordpress.com 2011/3/15 kedar vyawahare Hi all, I want to send an alert via e-mail through my .drl (rule) file. Does Drool engine support for sending the emails. Thanks in Advance. Kedar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -Inline Attachment Follows- ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Misunderstanding salience?
"Control facts" is a term for objects in working memory that are not directly derived from outside data, or used as output. As their name implies, they're used to explicitly control flow of the rules. --- On Wed, 3/9/11, Peter Ashford wrote: From: Peter Ashford Subject: Re: [rules-users] Misunderstanding salience? To: "Rules Users List" Date: Wednesday, March 9, 2011, 2:54 PM Working with Zombies? No... although some of our clients A wrinkle we have is that sometimes an exception case should terminate the decision. Usually that’s an emergency case and it will be something like “this patient needs to be admitted to hospital immediately”. In other cases, we want to provide some advice which a clinician may or may not choose to heed. It sounds to me that the insertLogical mechanism might well work for those latter cases (was this what you were referring to when you talked about ‘control facts’?) In the other case – an emergency when you need to give one element of critical advice then quit – is there an option to terminate the rules immediately and return the current result? Peter From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Swindells, Thomas Sent: Wednesday, 9 March 2011 10:23 p.m. To: Rules Users List Subject: Re: [rules-users] Misunderstanding salience? I don’t think you even need it that complicated.Just have your constraints in the form Patient(advice == null, ...) This assumes you only give the patient one advice at a time – if not control facts would have to be the way to go. You also need to make sure you actually tell the rule engine you have modified the patient when you set their advice – you need to wrap the call with a modify(p) {...}. Hope you get your zombies under control soon, Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Michael Anstis Sent: 09 March 2011 07:58 To: Rules Users List Subject: Re: [rules-users] Misunderstanding salience? You had me fooled Peter, I thought you worked in a zombie related field ;-) Control Facts can also be used, which I think David eluded to with his use of "null advice", such that:-rule "General brain eating advice" when p : Patient(eatsBrains == true) not Diagnosis( patient == $p ) then p.setAdvice("Stop eating brains, or at least, try to cut down"); insertLogical( new Diagnosis( $p ) ); end rule "Zombie exception to brain eating advice" salience -50 when p : Patient(eatsBrains == true, isZombie == true) not Diagnosis( patient == $p ) then p.setAdvice("Evidence suggests that the undead cannot contract Kuru or that the effects are irellevant given the " + "patient's current zombified state.\nSuggest euthenasing patient lest he/she eat your (or someone " + "else's) brains"); insertLogical( new Diagnosis( $p ) ); end As David states, more specific rules should have higher salience than the more general that should have lower. Salience controls conflict resolution, which is the order in which activations on the agenda are evaluated, it does not control which rules are evaluated - which happens as facts are inserted into working memory and not when fireAllRules( ) invoked. With kind regards, Mike2011/3/9 Peter Ashford Thanks for the ideas, David. What I ultimately want to achieve is to have the individual rules independent of each other to the maximal degree to which that is possible. That’s why I didn’ t want to have isZombie==false in the general rule – I wanted the general case to be unaware of the exceptions. The field in which I’m working is clinical decision support where there might be a number of exceptions and corner cases. I’d like to be able to express the core logic without reference to the corner cases and then deal with the exceptions separately. I think your idea of using salience but only adding advice if it hasn’t already been given fits the bill – that way the general case can be simple and not have to explicitly exclude all the exception cases. Thanks very much for the feedback – it’s really valuable to get an idea about what options are available and what’s considered best practice. Cheers! Peter. From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of David Faulkner Sent: Wednesday, 9 March 2011 4:51 p.m. To: Rules Users List Subject: Re: [rules-users] Misunderstanding salience? Peter, The EXACT way to accomplish the functionality that you are looking for is “activation-group”; if two rules are in the same activation group, only one of them will fire. Note that the rule with HIGHER salience will fire first; to accomplish what you are looking for you’d have to give the except
Re: [rules-users] Best approach for handling parallel requests for a stateful rules session
They submit the commands to an execution queue, and they're executed in the order received in a thread safe manner. And note there's an asyncFireAllRules() method, so you can time when rules fire. As for whether objects are fed into working memory while rules are firing, I'm not sure, but that would be easy to test. (Just create rules that cause an infinite loop with low salience, start them up, and try to insert more data that trigger rules of a higher salience.) Or maybe a dev will reply with a conclusive answer. :) --- On Tue, 3/8/11, jkrupka wrote: > From: jkrupka > Subject: Re: [rules-users] Best approach for handling parallel requests for a > stateful rules session > To: rules-users@lists.jboss.org > Date: Tuesday, March 8, 2011, 12:42 PM > Took a look... thanks. I'm not > sure that they will help me though - do the > async methods actually look to see if fireAllRules is > already running > somewhere else and synchronize the calls? Or do they just > wrap a Callable > around it so that if your rules take a long time to run you > can do something > else while they run? > > -- > View this message in context: > http://drools-java-rules-engine.46999.n3.nabble.com/Best-approach-for-handling-parallel-requests-for-a-stateful-rules-session-tp2651617p2652011.html > Sent from the Drools - User mailing list archive at > Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Best approach for handling parallel requests for a stateful rules session
Take a look at the org.drools.StatefulSession.async*() methods. I've used them in a multithreaded context before. --- On Tue, 3/8/11, jkrupka wrote: > From: jkrupka > Subject: [rules-users] Best approach for handling parallel requests for a > stateful rules session > To: rules-users@lists.jboss.org > Date: Tuesday, March 8, 2011, 11:10 AM > We've been over multiple ways of > handling multiple parallel requests for a > stateful rules session and I want to make sure the approach > we have settled > on makes sense. > > We will be getting multiple requests at a time to run some > score calculation > rules for various products. In the past we used > stateless rules sessions to > do this and it worked fine. In the newer version of > our application we are > using significantly more data to do our calculation and are > pretty sure > stateful is the way to go. That being said, can we > use the same session in > multiple threads? Based on our understanding, a > session isn't inherently > thread safe, so we are thinking we will need to do one of > two things: > > 1. Synchronize all updates to facts and the calling of > fireAllRules so that > only one thread is doing this at a time. Is this the > best (or only safe) > approach in this situation? Since all fact updates > and rules running in > done in one thread, when is throughput a concern (obviously > depends on > hardware, # of rules, # of facts, etc)? > 2. Ensure that only one thread updates the facts related to > a given product > at a time. Multiple threads could still call > fireAllRules at the same time, > but after the rules finish, the calling class would grab > the facts that > would have been updated for just the product that it's > interested in. That > way, it doesn't matter if the rules were technically > matched in a different > thread, as long as I'm grabbing just the data I'm > interested in. Is this a > safe approach? Does it end up offering more > throughput capability than > approach #1? > > Josh > > -- > View this message in context: > http://drools-java-rules-engine.46999.n3.nabble.com/Best-approach-for-handling-parallel-requests-for-a-stateful-rules-session-tp2651617p2651617.html > Sent from the Drools - User mailing list archive at > Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Object updated as rules are running
See this section: http://downloads.jboss.com/drools/docs/5.1.1.34858.FINAL/drools-expert/html_single/index.html#d0e5118 And subsection 4.8.4.2 --- On Fri, 2/25/11, Wolfgang Laun wrote: From: Wolfgang Laun Subject: Re: [rules-users] Object updated as rules are running To: "Rules Users List" Date: Friday, February 25, 2011, 11:26 AM Here's one way: rule "example" when $fact: Type( someField != 42 ) then modify( $fact ){ setSomeField( 42 ) } end Did you read any of the Drools Expert documentation? The necessity of informing the inference engine about changes of fact objects is indeed discussed, and all three techniques of doing that are covered. -W 2011/2/25 Jon Gil Can you please provide the syntax or point me in the direction of an example? 2011/2/25 Greg Barton It's done in the rule action of the first rule. If you don't inform the engine that the object has updated the second rule can't know about it. --- On Fri, 2/25/11, Jon Gil wrote: From: Jon Gil Subject: Re: [rules-users] Object updated as rules are running To: "Rules Users List" Date: Friday, February 25, 2011, 10:14 AM How do we do that? Since we are using the rules server, all we are doing is calling with an HTTP call with the object and the rules flow we want to call. We then receive back the results as the HTTP response. 2011/2/25 Greg Barton Did you notify the engine that your data has been updated? http://downloads.jboss.com/drools/docs/5.1.1.34858.FINAL/drools-expert/html_single/index.html#d0e1436 See section 3.3.3.1.3 --- On Fri, 2/25/11, Jon Gil wrote: From: Jon Gil Subject: [rules-users] Object updated as rules are running To: rules-users@lists.jboss.org Date: Friday, February 25, 2011, 9:16 AM Hi, I have a very simple rules flow that I am getting odd results from. For now, our project is planning on using spreadsheets and a drools server. The test project we are working on accepts a movie name from an external source and creates a Movie object that is passed to the rules. The first rule looks at the movieName attribute and assigns it a movieStar using the Movie objects setMovieStar call. We have printLn statements before and after this action to confirm that it does in fact work. The second rule, where things go wrong, checks the MovieStar attribute, but no matter what we've just set it to, it always uses the value ("NoStarYet") that was originally created when we create the Movie object in our Java code in the condition of our second rule. We've tried using the getMovieStar call in the condition, but it has been throwing errors when we startup the Drools Server. When we retreive the Movie object from the resultSet, the movieStar attribute is set correclty, but we can't get our flow to go as expected. This really seems like a simple issue, but we've had no luck with it. Any thoughts? Does the rules engine use the getter methods for conditions or does it use the values from the entityXML we pass in? Is there a way to make the engine update the object between running each rule? Any help is appreciated greatly. -Inline Attachment Follows- ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -Inline Attachment Follows- ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -Inline Attachment Follows- ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Object updated as rules are running
It's done in the rule action of the first rule. If you don't inform the engine that the object has updated the second rule can't know about it. --- On Fri, 2/25/11, Jon Gil wrote: From: Jon Gil Subject: Re: [rules-users] Object updated as rules are running To: "Rules Users List" Date: Friday, February 25, 2011, 10:14 AM How do we do that? Since we are using the rules server, all we are doing is calling with an HTTP call with the object and the rules flow we want to call. We then receive back the results as the HTTP response. 2011/2/25 Greg Barton Did you notify the engine that your data has been updated? http://downloads.jboss.com/drools/docs/5.1.1.34858.FINAL/drools-expert/html_single/index.html#d0e1436 See section 3.3.3.1.3 --- On Fri, 2/25/11, Jon Gil wrote: From: Jon Gil Subject: [rules-users] Object updated as rules are running To: rules-users@lists.jboss.org Date: Friday, February 25, 2011, 9:16 AM Hi, I have a very simple rules flow that I am getting odd results from. For now, our project is planning on using spreadsheets and a drools server. The test project we are working on accepts a movie name from an external source and creates a Movie object that is passed to the rules. The first rule looks at the movieName attribute and assigns it a movieStar using the Movie objects setMovieStar call. We have printLn statements before and after this action to confirm that it does in fact work. The second rule, where things go wrong, checks the MovieStar attribute, but no matter what we've just set it to, it always uses the value ("NoStarYet") that was originally created when we create the Movie object in our Java code in the condition of our second rule. We've tried using the getMovieStar call in the condition, but it has been throwing errors when we startup the Drools Server. When we retreive the Movie object from the resultSet, the movieStar attribute is set correclty, but we can't get our flow to go as expected. This really seems like a simple issue, but we've had no luck with it. Any thoughts? Does the rules engine use the getter methods for conditions or does it use the values from the entityXML we pass in? Is there a way to make the engine update the object between running each rule? Any help is appreciated greatly. -Inline Attachment Follows- ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -Inline Attachment Follows- ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Object updated as rules are running
Did you notify the engine that your data has been updated? http://downloads.jboss.com/drools/docs/5.1.1.34858.FINAL/drools-expert/html_single/index.html#d0e1436 See section 3.3.3.1.3 --- On Fri, 2/25/11, Jon Gil wrote: From: Jon Gil Subject: [rules-users] Object updated as rules are running To: rules-users@lists.jboss.org Date: Friday, February 25, 2011, 9:16 AM Hi, I have a very simple rules flow that I am getting odd results from. For now, our project is planning on using spreadsheets and a drools server. The test project we are working on accepts a movie name from an external source and creates a Movie object that is passed to the rules. The first rule looks at the movieName attribute and assigns it a movieStar using the Movie objects setMovieStar call. We have printLn statements before and after this action to confirm that it does in fact work. The second rule, where things go wrong, checks the MovieStar attribute, but no matter what we've just set it to, it always uses the value ("NoStarYet") that was originally created when we create the Movie object in our Java code in the condition of our second rule. We've tried using the getMovieStar call in the condition, but it has been throwing errors when we startup the Drools Server. When we retreive the Movie object from the resultSet, the movieStar attribute is set correclty, but we can't get our flow to go as expected. This really seems like a simple issue, but we've had no luck with it. Any thoughts? Does the rules engine use the getter methods for conditions or does it use the values from the entityXML we pass in? Is there a way to make the engine update the object between running each rule? Any help is appreciated greatly. -Inline Attachment Follows- ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] unsolved myth regarding transitive closure using insertlogical...
Implementations of equals() and hashCode() should always agree: http://www.javapractices.com/topic/TopicAction.do?Id=28 --- On Tue, 2/22/11, Simon Chen wrote: > From: Simon Chen > Subject: Re: [rules-users] unsolved myth regarding transitive closure using > insertlogical... > To: "Rules Users List" > Date: Tuesday, February 22, 2011, 2:24 PM > On Sun, Feb 20, 2011 at 10:11 PM, > Mark Proctor > wrote: > > On 21/02/2011 03:03, Simon Chen wrote: > >> On Sun, Feb 20, 2011 at 8:20 PM, Ansgar Konermann > >> > wrote: > >>> On 19.02.2011 16:01, Simon Chen wrote: > The example you gave seems to be the > one-hop case. For the two-hop > case, we need something like this > > when > edge(a, b), reach(b, c), not > exists reach(a, c) > then > insertLogical( reach(a,c) ) > > So, where do you put your logical around? > It should include both > edge(a,b) and reach(b,c), right? > > Another thought, can we have something > like > testExistsAndInsertLogical() to replace > insertLogical()? But this may > be buggy, as the conditions are all met, > so the rule actually fired... > > >>> Hi, > >>> > >>> from my experience, insertLogical does exactly > what > >>> testExistsAndInsertLogical would suggest. If > the same object is already > >>> in the working memory, it keeps this object > and does not insert another > >>> instance. This behaviour is not stated > explicitly in the documentation, > >>> but I did a learning test a few weeks ago and > IIRC it clearly showed > >>> this behaviour (at least for 5.0.1). -- I > consider this behaviour a > >>> feature and would like it to be kept this > way. > >> I am using Drools 5.1.1, and I don't think > insertLogical prevents > >> duplicates automatically. This also boils down to > the question of how > >> Drools decides whether two objects are indeed the > same. For strings > >> and integers, it is straightforward, but not much > so for complex > >> objects. Is there a way to pass in a comparison > function? > > InsertLogical operates on equality mode, that is > determined by the > > pojo's equals() method implementation. If an object > already exists that > > is equal, it will use that and the justification > counter for that > > existing object is increased. > > Mark, > > I did a bit debugging using the drools source code, which > is neatly > written btw. I now know what caused my problem. When > logically > inserting an object, the current implementation would > compare the > object with saved EqualityKeys in the > TruthMaintenanceSystem. The > comparison is done through hashCode(), not equals(). So, a > duplicate > (by value) object can be inserted, because the hashcode is > different. > > I am not sure if this is a design decision, but I would > rather using > equals() here. I overrode the hashCode() implementation of > my objects, > and it is working now... > > Thanks. > -Simon > > > > > Mark > >>> With this, all which is necessary to implement > transitive closure is to > >>> remove the contradicting part of the > precondition to avoid oscillation. > >>> If it turns out that insertLogical does not > perform a "does fact already > >>> exist" check and thus might potentially insert > duplicates, put exists( ) > >>> around the two preconditions and also use > "exists( reach(x,y) )" to > >>> check whether y is reachable from x. > >> I don't quite follow. Can you elaborate with an > actual rule? > >> > >> Thanks! > >> -Simon > >> > >>> Kind regards > >>> > >>> Ansgar > >>> > ___ > >>> rules-users mailing list > >>> rules-users@lists.jboss.org > >>> https://lists.jboss.org/mailman/listinfo/rules-users > >>> > >> ___ > >> rules-users mailing list > >> rules-users@lists.jboss.org > >> https://lists.jboss.org/mailman/listinfo/rules-users > >> > >> > > > > > > ___ > > rules-users mailing list > > rules-users@lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/rules-users > > > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] hardcore masterclass (west london)
I'd be interested in listening in if you can webcast it. GreG On Feb 12, 2011, at 10:27, Mauricio Salatino wrote: > I'm really interested in that kind of courses, but I'm pretty far away. Can I > help you creating material and content for those courses? In that way we can > share the meetups knowledge in different places. > > Greetings. > > > On Sat, Feb 12, 2011 at 12:56 PM, Mark Proctor wrote: > I was just wondering if anyone was interested in learning hard core rule > engine theory, with the aim of helping you to develop some core engine > features and be involved in the next generation Drools engine. If this > interests anyone let me know and I can organise some meetups, probably > based in West London (Chiswick). > > Mark > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > > > -- > - CTO @ http://www.plugtree.com > - MyJourney @ http://salaboy.wordpress.com > - Co-Founder @ http://www.jbug.com.ar > > - Salatino "Salaboy" Mauricio - > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Writing a pattern in which each event constraint depends on the previous event
Yes, the accumulate function itself should maintain the sort internally. @OlliSee : See the thread titled "How to write a rule that fires when it matches against specific facts in working memory." --- On Sun, 1/30/11, Wolfgang Laun wrote: From: Wolfgang Laun Subject: Re: [rules-users] Writing a pattern in which each event constraint depends on the previous event To: "Rules Users List" Date: Sunday, January 30, 2011, 10:25 AM On 30 January 2011 12:55, OlliSee wrote: @Wolfgang: I guess you are referring to the list I use. Of course I expect them to be ordered by timestamp. You sure do, but the question is whether you get them in this order during processing by accumulate. There is no documentation that accumulate passes through a set of selected facts in the order they were inserted. It could just as well be the (random) order of some hash key, or reverse, or whatever. -W -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Writing-a-pattern-in-which-each-event-constraint-depends-on-the-previous-event-tp2370165p2383235.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -Inline Attachment Follows- ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Writing a pattern in which each event constraint depends on the previous event
See the current discussion of accumulate functions. That should satisfy your need. GreG On Jan 29, 2011, at 10:18, OlliSee wrote: > > Hello everyone. > > Lets say we have StockTicks... > Is it possible to detect a monotonically decreasing StockTick stream over a > window? > > If I knew the number of events I want to check on, I'd do it this way > > $a : StockTick() over window:time(20s) > $b : StockTick(this after $a, price < $a.price) over window:time(20s) > ... > > But I don't know for how long the StockTick prices continue to decrease.. > I imagine doing something like that > > $list : List(size > 0) from collect(StockTick() over window:time(20s)) > forall($a : StockTick() from $list >$b : StockTick(this after $a, price < $a.price from $list > ) > > That results in a nice exception. > Any idea how to do this work? And more efficiently than my approach? > > Thanks > Oliver > > > > Exception in thread "Thread-1" java.lang.ClassCastException: > org.drools.common.DefaultFactHandle cannot be cast to > org.drools.common.EventFactHandle >at > org.drools.base.evaluators.AfterEvaluatorDefinition$AfterEvaluator.evaluateCachedLeft(AfterEvaluatorDefinition.java:336) >at > org.drools.rule.VariableRestriction.isAllowedCachedLeft(VariableRestriction.java:110) >at > org.drools.rule.VariableConstraint.isAllowedCachedLeft(VariableConstraint.java:115) >at > org.drools.common.DoubleBetaConstraints.isAllowedCachedLeft(DoubleBetaConstraints.java:166) >at > org.drools.reteoo.FromNode.checkConstraintsAndPropagate(FromNode.java:274) >at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:138) >at > org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:220) >at > org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:81) >at > org.drools.reteoo.FromNode.checkConstraintsAndPropagate(FromNode.java:279) >at org.drools.reteoo.FromNode.assertLeftTuple(FromNode.java:138) >at > org.drools.reteoo.CompositeLeftTupleSinkAdapter.doPropagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:220) >at > org.drools.reteoo.CompositeLeftTupleSinkAdapter.propagateAssertLeftTuple(CompositeLeftTupleSinkAdapter.java:81) >at > org.drools.reteoo.AccumulateNode.evaluateResultConstraints(AccumulateNode.java:662) >at org.drools.reteoo.AccumulateNode.assertObject(AccumulateNode.java:270) >at > org.drools.reteoo.CompositeObjectSinkAdapter.doPropagateAssertObject(CompositeObjectSinkAdapter.java:450) >at > org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject(CompositeObjectSinkAdapter.java:378) >at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:190) >at org.drools.reteoo.EntryPointNode.assertObject(EntryPointNode.java:145) >at > org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1187) >at > org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:1089) >at > org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:893) >at > org.drools.impl.StatefulKnowledgeSessionImpl.insert(StatefulKnowledgeSessionImpl.java:238) > > -- > View this message in context: > http://drools-java-rules-engine.46999.n3.nabble.com/Writing-a-pattern-in-which-each-event-constraint-depends-on-the-previous-event-tp2370165p2370165.html > Sent from the Drools - User mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Question about Drools accessing a global HashMap and comparing it to an object value
Not a bug in drools, but a bug in my brain. :) The first term in a condition element must come from the object, and objCode was bound in the previous object. I didn't test that rule before posting, so my bad. GreG On Jan 27, 2011, at 15:15, mviens wrote: > > Hi Greg, > > Thank you for the reply. I converted the rules back to being processed in > singular mode versus through an ArrayList as you recommended. I am curious > about the reason though -- is it a performance issue or does it just make it > more difficult to work with within the rule? > > I tried your recommendation of the rule, but it caused an error: > > rule "Check for valid code" >when >obj : MyObj(objState : state, objCode : code) >codes : State2Code(state == objState && objCode not memberOf codes) >then >obj.addError("Code is not valid for the State"); > end > > BuildError: Unable to create Field Extractor for 'objCode' of > '[ClassObjectType class=com.abc.xyz.StateFips]' in rule 'Check for valid > Code' > > > When I changed the rule to this, the error is gone and it worked just fine. > > rule "Check for valid code" >when >obj : MyObj(objState : state, objCode : code) >codes : State2Code(state == objState && codes not contains objCode) >then >obj.addError("Code is not valid for the State"); > end > > Do you have any thoughts on why the first rule does not work but the second > one does? Is it a bug? The only difference between the rule I have and the > one you suggested was using a comma versus ==. I tried with the comma, but > the error remained. I am using Drools 5.1.1. > > Mike V. > -- > View this message in context: > http://drools-java-rules-engine.46999.n3.nabble.com/Question-about-Drools-accessing-a-global-HashMap-and-comparing-it-to-an-object-value-tp2334346p2364040.html > Sent from the Drools - User mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Question about Drools accessing a global HashMap and comparing it to an object value
You really shouldn't be matching an entire collection of objects like that. Think of each rule as capturing one "example" of an object in a given state, and doing something when that object is found. So think of your first rule like this: rule "Check for null State" when obj : MyObj(state == null || state == "") then obj.addError("State must have a value"); end Where all MyObj instances are inserted into working memory. If you also insert all entries in the state2CodeMap into working memory, that rule becomes equally simple. Let's say a State2Code object has String state and ArrayList> codes properties, then the rule would look like this: rule "Check for valid code" when obj : MyObj(objState : state, objCode : code) codes : State2Code(state == objState, objCode not memberOf codes) then obj.addError("Code is not valid for the State"); end Make sense? --- On Tue, 1/25/11, mviens wrote: > From: mviens > Subject: [rules-users] Question about Drools accessing a global HashMap and > comparing it to an object value > To: rules-users@lists.jboss.org > Date: Tuesday, January 25, 2011, 3:37 PM > > MyObj is a Java object that contains: > > String state; > String code; > public void addError(String message); > > myObjList is an ArrayList containing from 2 to > 20,000 objects > > state2CodeMap is a HashMap ArrayList> containing an entry > for each US state. The associated ArrayList contains a > minimum of 1 entry, > up to 200 entries. > > I need to create a rule that checks all of the MyObj > objects in myObjList, > gets the appropriate ArrayList from state2CodeMap based on > myObj.state and > then if myObj.code not memberOf $codeList, run the "then" > portion of the > rule. > > I have created about 60 fairly simple rules, that are > working just fine, but > this one is a little too complex for me to userstand how to > write it in > Drools. Looking at this page ( > http://blog.athico.com/2007/06/chained-from-accumulate-collect.html > http://blog.athico.com/2007/06/chained-from-accumulate-collect.html > ), I can > see that nested "from" seems to be supported, but the page > seems to be for > Drools 4. Plus, I have had to teach myself Drools in the > past week. I could > really use some help with this. Any assistance is greatly > appreciated! > > Mike V. > > global List myObjList; > global HashMap state2CodeMap; > > # this rule is working just fine! > rule "Check for null State" > when > $objs : > ArrayList() from collect(MyObj(state == null || state == > "") from myObjList) > then > for (MyObj myObj > : (ArrayList)$objs) > { > > myObj.addError("State must have a value"); > } > end > > # I really have no idea how to write this > rule > rule "Check for valid code" > when > $objs : > ArrayList() from collect(MyObj()) > then > for (MyObj myObj > : (ArrayList)$objs) > { > > myObj.addError("Code is not valid for the State"); > } > end > > -- > View this message in context: > http://drools-java-rules-engine.46999.n3.nabble.com/Question-about-Drools-accessing-a-global-HashMap-and-comparing-it-to-an-object-value-tp2334346p2334346.html > Sent from the Drools - User mailing list archive at > Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Why Using "from" Always Return A New Fact?
When you say "owning 100% of the language syntax" does that include the RHS? Just curious. GreG On Jan 19, 2011, at 22:04, Edson Tirelli wrote: > As of Drools 5.1.1, drools looks at the expression in "from" as a > black box. Every time it is executed, drools creates a new fact handle > to wrap the result(s). Since the lock and no-loop features are based > on the fact handles, the sometimes undesired interaction occurs. We > may be able to improve this in drools 6, when we will have the engine > owning 100% of the language syntax, that will enable us to run better > expression analisys than we can do today. > > Edson > > Em quarta-feira, 19 de janeiro de 2011, > hyjshanghai escreveu: >> >> You explanation is very reasonable: >> the engine assumes anything within $p may be changed by modify($p), although >> $p.address is not changed actually. >> >> However, I tried these rules myself and both rules were fired. Why? >> According to the document, only one of the rules should fire; the other's >> activation should be cancelled because the engine assumes $p has changed, >> which may mismatch the other rule, right?. >> >> The following are the output and my rules. The only difference between my >> rules and the document's is that my rules don't belong to any >> ruleflow-group. >> >> Program Output of Inserting a "new Person()" and Firing All Rules. >> BEGIN >> Rule 'Apply discount' fired. Person: Person{name[Tom], >> address[Address{state[NC], city[Raleigh]}], region[null], discount[0.9]} >> Rule 'Assign to sales region 1' fired. Person: Person{name[Tom], >> address[Address{state[NC], city[Raleigh]}], region[sales region 1], >> discount[0.9]} >> Program Output of Inserting a "new Person()" and Firing All Rules. >> END >> >> The Rules I Tested. BEGIN >> package hello.rules >> import java.util.* >> import java.math.* >> import hello.model.Address; >> import hello.model.Person; >> >> rule "Assign to sales region 1" >> lock-on-active true >> when >>$p : Person() >>$a : Address( state=="NC") from $p.address >> then >>modify ($p) { setRegion("sales region 1") } >>System.out.println("Rule 'Assign to sales region 1' fired. Person: >> "+$p); >> end >> >> rule "Apply discount" >> lock-on-active true >> when >>$p : Person() >>$a : Address( city=="Raleigh") from $p.address >> then >>modify ($p) { setDiscount((float)0.9) } >>System.out.println("Rule 'Apply discount' fired. Person: "+$p); >> end >> The Rules I Tested. END >> >> The Person and Address. BEGIN >> public class Person >> { >>private String name; >>private Address address; >>private String region; >>private float discount; >>public String getRegion() { >>return region; >>} >>public void setRegion(String region) { >>this.region = region; >>} >>public float getDiscount() { >>return discount; >>} >>public void setDiscount(float discount) { >>this.discount = discount; >>} >> >>public String getName() { >>return name; >>} >>public void setName(String name) { >>this.name = name; >>} >>public Address getAddress() { >>return address; >>} >>public void setAddress(Address address) { >>this.address = address; >>} >>@Override >>public String toString() >>{ >>return String.format("Person{name[%s], address[%s], region[%s], >> discount[%s]}", >>name, address.toString(), region, discount); >>} >> } >> >> public class Address >> { >>private String state; >>private String city; >>public String getState() { >>return state; >>} >>public void setState(String state) { >>this.state = state; >>} >>public String getCity() { >>return city; >>} >>public void setCity(String city) { >>this.city = city; >>} >> >>@Override >>public String toString() >>{ >>return String.format("Address{state[%s], city[%s]}", state, city); >>} >> } >> The Person and Address END >> -- >> View this message in context: >> http://drools-java-rules-engine.46999.n3.nabble.com/Why-Using-from-Always-Return-A-New-Fact-tp2286393p2292029.html >> Sent from the Drools - User mailing list archive at Nabble.com. >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> > > -- > Edson Tirelli > JBoss Drools Core Development > JBoss by Red Hat @ www.jboss.com > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Salience
Another way is to keep bugging Mark and Edson to put in an else clause. :P GreG On Jan 19, 2011, at 12:56, Wolfgang Laun wrote: > Either you define a rule covering all "else" cases, which, in your > case, could be > > rule "#catch-all" > when > $i : Item( type != 1 && != 2 ) > then > retract ($i) > // do something... > end > > or you do rely on salience, which, in this case is not quite so "bad > practice". > > It depends: if the "catch all" is there to detect unexpected data, > it's ok; if it is there just to cover several cases the programmer is > too lazy to code in the ordinary way, then it might be considered "bad > practice". > > -W > > > > On 19 January 2011 19:17, huionn wrote: >> >> If I have a rule like below: >> >> rule "#1" >> when >> $i : Item(type == 1) >> then >> retract ($i) >> // do something... >> end >> >> rule "#2" >> when >> $i : Item(type == 2) >> then >> retract ($i) >> // do something... >> end >> >> // to handle other type of Item >> rule "#catch-all" >> salience -10 >> when >> $i : Item() >> then >> retract ($i) >> // do something... >> end >> >> As it is known, reliance on salience is bad practice and its order is not >> guaranteed (as shown in Sudoku example). >> >> My question is: what is the simple and good practice to emulate "else" (rule >> "#catch-all") without reliance on salience? It seems ruleflow is not >> applicable here as well. >> >> >> Thanks and best regards. >> -- >> View this message in context: >> http://drools-java-rules-engine.46999.n3.nabble.com/Salience-tp2289179p2289179.html >> Sent from the Drools - User mailing list archive at Nabble.com. >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Different rule fires when debugging vs running after upgrading to 5.1.1
You've already pointed to it yourself. Rules execution should be thought of in the same way you approach concurrent programming. Execution can (and should) be able to happen in any order possible. Only the current logical state of working memory should influence the next step in execution, with a bit of arbitrary choice thrown in. (The last step in conflict resolution between rules is "pick one...") GreG On Jan 19, 2011, at 14:16, "H.C." wrote: > > I certainly do appreciate the help and fully understand no one here will be > able to give me a concrete solution without a test case. I was just hoping > that describing the behavior would jog something in someone's head which > would lead to a pointed question that may help steer me in the right > direction of searching for the cause. > -- > View this message in context: > http://drools-java-rules-engine.46999.n3.nabble.com/Different-rule-fires-when-debugging-vs-running-after-upgrading-to-5-1-1-tp2283993p2290099.html > Sent from the Drools - User mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] how do you select from a global List in decisiontable
Using globals in rule conditions is generally a bad idea. This is because changes to the globals are not tracked automatically so rule firing is 1) not responsive to data changes, and 2) somewhat random when change happens. Basically, avoid it. GreG On Jan 13, 2011, at 15:56, Gregory Mace wrote: > Here is a simple example where 'otherPersonList' is a global java.util.List: > > RuleTable Are friends having fun > CONDITION CONDITION > ACTION > person: Person, op: Person from otherPersonList > person.getRelationShip(op)op.getActivity() > System.out.println("$param"); > FRIENDPLAYING > Your friend is having fun > ENEMY WORKING > Not your friend and not having fun > > which produces the following drl output: > > #From row number: 31 > rule "Friends are having fun_31" > > when > person: Person, op : Person from > otherPersonList(person.getRelationShip(op) == "FRIEND", op.getActivity() == > "PLAYING") > then > System.out.println("Your friend is having fun "); > end > > #From row number: 32 > rule "Friends are having fun_32" > > when > person: Person, op : Person from > otherPersonList(person.getRelationShip(op) == "ENEMY", op.getActivity() == > "WORKING") > then > System.out.println("Not your friend and not having fun"); > end > > shouldn't the 'from' be after the statement like this:? > > person: Person, op : Person(person.getRelationShip(op) == "ENEMY", > op.getActivity() == "WORKING") from otherPersonList > > Thx > > On Jan 13, 2011, at 11:47 AM, Wolfgang Laun wrote: > >> I think I understand your question, but I'm not sure how to answer it. ;-) >> >> What, exactly, are you trying to do? "Pulling" from a list means what? >> >> -W >> >> >> On 13 January 2011 20:34, Gregory Mace wrote: >> I believe I have the list set up correctly as a variable, but I am not sure >> how to set up a condition that pulls from a global list. Any examples? >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Swing GUI & Drools
If the business logic is this simple then no, drools is not a good fit because business rules are not necessary. The only thing that would make it necessary is if you had business users writing rules, but as far as I know drools 2.5 doesn't have much in the way of modern rules management. (unlike the 5.x series) --- On Wed, 1/5/11, albertkao wrote: > From: albertkao > Subject: [rules-users] Swing GUI & Drools > To: rules-users@lists.jboss.org > Date: Wednesday, January 5, 2011, 5:51 PM > > I want to find out whether Swing GUI, Drools 2.5 (the only > version approved > by my company) & JDK 1.6.20 are a good fit for my > application. > i.e. whether my application is complex enough to use > Drools. > If Drools should be used, please give some hints how to > implement with > Drools 2.5. > The business logic is: > if (Entity = Corporation) { > Switch (Account type) { > 1: the Entity dropdown box > field should be greyed out; the In > checkbox should be enabled. > 2: the Entity dropdown box > field should be greyed out; the Out field > should be selected. > 3: the Entity dropdown box > field show all the available values; > 4: the Entity dropdown box > field show value1, value2 only. > } else { > // ... > } > > > -- > View this message in context: > http://drools-java-rules-engine.46999.n3.nabble.com/Swing-GUI-Drools-tp2202386p2202386.html > Sent from the Drools - User mailing list archive at > Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools-Spring Config for Knowledge Agent
Also, sometimes emails I send to the list are delayed as much as 12 hours. Maybe it's because I post from a yahoo account and the spam filter pushes back. Could be that as well. GreG On Dec 29, 2010, at 0:18, Mark Proctor wrote: > On 29/12/2010 06:10, KR - wrote: >> >> few posts mine and my team members are pending for quite a long time. Why? > You have to subscribe and post using the email address you subscribed with. > If you post with an unsubscribed email address it has to go through > moderation due to spam control. But we get so much spam the moderation > list is just ignored, as it's not practical to sift through the emails to > figure out what is and what isn't spam. > > Mark >> >> >> On Wed, Dec 29, 2010 at 11:09 AM, Mark Proctor wrote: >> On 28/12/2010 12:40, krkaleraj wrote: >> > Turner, >> > >> > Unfortunately if you post anything which is hard truth that will not be >> > published here. Advantage of moderation hehehe >> There is no moderation for this list, hard truths are visible to all. >> >> Feel free to apologise anytime. >> >> Mark >> >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> >> >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools-Spring Config for Knowledge Agent
There is no moderation system on this list. I've been posting here for quite a while and have seen no evidence of of one. And if there were I'm sure I would have pissed off someone enough to trip it by now. :) GreG On Dec 28, 2010, at 6:40, krkaleraj wrote: > > Turner, > > Unfortunately if you post anything which is hard truth that will not be > published here. Advantage of moderation hehehe > -- > View this message in context: > http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Spring-Config-for-Knowledge-Agent-tp1634280p2156513.html > Sent from the Drools - User mailing list archive at Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Too many ACTIVATION "candidates"
One way of detecting cartesian products is to model the LHS as a graph, with object patterns being nodes, and conditions that compare two objects being an edge. If the LHS graph has unconnected subgraphs then it contains a cartesian product. You can make this more sophisticated by excluding classes that you know have few instances in working memory, like control objects. GreG On Dec 23, 2010, at 3:37, "Swindells, Thomas" wrote: >>> I'd say that this rule should actually be written as 16 rules - one for >>> each of the or'd together GoodsItems conditions, each of these rules would >>> only depend on a single Fact and you won't get into this problem. >> >> True. This rule can be re-written as a series of 5 rules that do not >> exhibit the explosion of activation candidates. I have done so and >> everything worked fine. >> >>> >>> Who controls the custom interface? If you can control then the simplest >>> solution is to prevent them doing or's of conditions (though perhaps this >>> may not fly with your customers). Alternatively have the interface output >>> an intermediate form which you can then control the compilation of. >> >> The custom interface, you may think of it as a simplified Guvnor, is under >> my total control as I've implemented it. >> The problem is, that the user can use it to write these kinds of rules. >> In theory, rule rewriting could be possible, but I'm not sure I can detect >> these kinds of dependencies for any kind of rule that may be written. > > No, I think they should be rewritten as a series of 16 rules (one for each > '||'. > You could remove the option from the user of being able to 'or' together > conditions and require each thing to be written as separate rules. This > should reduce the Cartesian products for the majority of cases (although > creative users could still possibly write statements like (fact1 != > "thiswillneverhappen" && fact2 != "thiswillneverhappen2"...)/ > >> It there is a way that these kinds of cartesian product of activation >> candidates can be estimated before hand (either by analyzing the rule or >> by some other means), it would be great. >> Any ideas are welcomed. > It depends on how accurate you want it. > Simplist option is to restrict the number of facts that a rule can match > against (if they can only match against 3 facts the Cartesian product > probably isn't too bad). > Slightly more complicated you can assume the worst case scenario that every > value of each fact type is included and multiple the count of each included > fact together, if it exceeds a configured limit you decide that potentially > the rule is too complicated. > Getting much more complicated is to perform a much more accurate estimation > of each fact based upon the constraints. You could either do this in code > (perhaps a db query or some other way to apply the constraint). > Another way to do this would be to decompose the rules so that you accumulate > the result of each fact constraint first, check whether too many facts have > been included and then use a from for each accumulation at the end (or > something like that anyway). > > Thomas > > > ** > This message is confidential and intended only for the addressee. If you have > received this message in error, please immediately notify the > postmas...@nds.com and delete it from your system as well as any copies. The > content of e-mails as well as traffic data may be monitored by NDS for > employment and security purposes. To protect the environment please do not > print this e-mail unless necessary. > > NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 > 4EX, United Kingdom. A company registered in England and Wales. Registered > no. 3080780. VAT no. GB 603 8808 40-00 > ** > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Multiple bindings with the same type
Still won't work, and it's worse than you think. The main problem is that drools (and any rules engine) will match on all possible combinations of objects in working memory that match the right hand side of the rule. So let's say you insert two lists, call them A and B. Your rule will fire four times on AxB, BxA, AxA, and BxB. You have to make sure you don't match the same object twice, and even then you must have an explicit test for ordering. For this reason it's best to match on a custom object (not just java.util.ArrayList) that contains data you can test for ordering. GreG On Dec 8, 2010, at 14:19, Gabor Szokoli wrote: > Hi, > > 2010/12/8 Robert Miyashiro : >> Is there some kind of evaluation mode or setting that will make >> Drools pay attention to the order in which objects are inserted into the >> session? > > Not that I know of, but here's a way to externally supply the pairs of > objects to fire on: > > rule > when >$list1 : ArrayList() >$list2 : ArrayList() >Pair(first==$list1, second==$list2) > then > > If you find yourself reasoning about the order and timing of insertion > events, you may want to look into drools fusion instead. > > > Gabor > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] new to Drools: modeling issues
+1 GreG On Dec 6, 2010, at 5:03, "Swindells, Thomas" wrote: > In my experience no-loop is pretty much worthless as it only prevents the > most trivial type of loops (a rule reactivating itself). It provides no help > for the most common type of loop where multiple rules modify the same object > and reactivate each other. > > > > From: rules-users-boun...@lists.jboss.org > [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Michael Anstis > Sent: 06 December 2010 10:54 > To: Rules Users List > Subject: Re: [rules-users] new to Drools: modeling issues > > > > Glad you're reading the documents - you'd be surprised how many people asking > questions do not! > > You can put off DSL until you're happy your rules are working, off course - > in fact, IMO, it's easier to "debug" rules without the additional abstraction. > > You're first rule looks better - although I'd still be inclined to look at > no-loop rather than the check yourself (what if you need the new value to be > dynamic; i.e. not just statically "value"? Your rules would become > cumbersome). > > The second rule does not associate StringHolder to any particular Child > instance (although easily added); so you'd get the cross-product of > StringHolders and Child facts; not I suspect what you'd want. > > Cheers, > > Mike > > On 6 December 2010 10:36, Gabor Szokoli wrote: > > Thanks for the instant response! > > 2010/12/6 Michael Anstis : > > > The drools-expert documentation would be a good starting point; otherwise > > Wikipedia has a good overview of the RETE algorithm (all be it Drools has > > its own extensions). > > I'm reading the documentation thoroughly of course, but it seems to be > centered about using the system and writing rules. Which is how it > should be, don't get me wrong :-) > I'm just hoping for some spoilers like "Section X will detail how java > object are mapped to WMEs." > > > > Regarding your specifics; you could look into using a DSL for the domain > > experts rather than pure DRL. Also, the no-loop attribute could\should help > > with your looping fear (have a look in the documentation). > > Can I put off the DSL part for later, and consider it just an extra > layer of rule file parsing for now? > Do I lose the graphical on-line editor features of Guvnor (which I > admittedly have not looked into yet, just salivated over some > screenshots.) if I make a DSL? > > > > A rather disturbing example you choose to show in your email; I think I > > prefer the "Cheese" centric types in the documentation :) > > Other than the attention-whoring double take in nomenclature, does > that rule pattern look OK? > > I'll stick with cheese in the future :-) > > > Thanks Again! > > > Gabor Szokoli > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > > > > > ** > This message is confidential and intended only for the addressee. If you have > received this message in error, please immediately notify the > postmas...@nds.com and delete it from your system as well as any copies. The > content of e-mails as well as traffic data may be monitored by NDS for > employment and security purposes. To protect the environment please do not > print this e-mail unless necessary. > > NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 > 4EX, United Kingdom. A company registered in England and Wales. Registered > no. 3080780. VAT no. GB 603 8808 40-00 > ** > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Rules in App Server Error
My, aren't we snippy? OK, well if you read this then note that those rules shouldn't work in any environment for the reason previously stated. (Use of an undeclared variable in the RHS.) If they are working then something odd is going on, and since you say they are then...something odd is going on. BTW, the error you're getting now is an mvel error: http://mvel.codehaus.org/Strong+Typing+Mode Since you're currently getting it for "$severity" and not just "severity" even though the former does not currently appear in your rule...well that's the odd bit I mentioned before. Somewhere $severity (along with $weight, $factor, and $tempScore) is being declared, but it's not in the text of the rule as you've provided it. GreG On Dec 3, 2010, at 19:07, "John McKim" wrote: First off, yes, I am an expert Java programmer, not just a Drools expert - yet. If you took the time to read the post, you would have found that the answer that was provided to me “DIDN’T WORK”. Never mind, I’ll figure it out myself. Goodby! From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Greg Barton Sent: Friday, December 03, 2010 7:26 PM To: Rules Users List Subject: Re: [rules-users] Rules in App Server Error You made the same error in three other places. Fix them. Are you familiar with the java language? GreG On Dec 3, 2010, at 15:15, "John McKim" wrote:Thanks for the reply Mauricio. I tried what you said using this modified rule: rule "medicalHistoryBleedingRiskFactors.gastritis rule"salience 20 when # find patients who indicated that they have MedicalHistoryBleedingRiskFactors: gastritis $patient : Patient(medicalHistoryBleedingRiskFactors.gastritis > 0) then String severity = $patient.medicalHistoryBleedingRiskFactors.gastritis; $weight = 5; $factor = .1; $tempScore = $factor; $tempScore = $tempScore * $weight; $tempScore = $tempScore * $severity; # Now add this risk score to the accumlated risk score $patient.score = $patient.score + $tempScore; $patient.problem = new String("MedicalHistoryBleedingRiskFactors.gastritis");end But I got this exception in the client (I am using 5.1.1 by the way): Exception in thread "Thread-4" java.lang.RuntimeException: Unable to build expression for 'consequence': [Error: Failed to compile: 1 compilation error(s): - (1,9) unqualified type in strict mode for: $severity][Near : {... Unknown }] ^[Line: 1, Column: 0] ' String severity = $patient.medicalHistoryBleedingRiskFactors.gastritis; $weight = 5; $factor = .1; $tempScore = $factor; $tempScore = $tempScore * $weight; $tempScore = $tempScore * $severity; // Now add this risk score to the accumlated risk score $patient.score = $patient.score + $tempScore; $patient.problem = new String("MedicalHistoryBleedingRiskFactors.gastritis");' : [Rule name='medicalHistoryBleedingRiskFactors.gastritis rule'] at com.kai.framework.plugins.ruleengine.LocalRuleEnginePlugin.createLevel1KnowledgeBase(LocalRuleEnginePlugin.java:107) at com.kai.framework.plugins.ruleengine.LocalRuleEnginePlugin.access$100(LocalRuleEnginePlugin.java:22) at com.kai.framework.plugins.ruleengine.LocalRuleEnginePlugin$InitializeRuleEngine.run(LocalRuleEnginePlugin.java:192) When I took out the String severity and used just $severity: it works fine. Just on the App server does it fail. From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Mauricio Salatino Sent: Friday, December 03, 2010 3:36 PM To: Rules Users List Subject: Re: [rules-users] Rules in App Server Error that's weird.. you are using a varible that you never define in the Right Hand Side. $severity was never defined. In the RHS remember that you can write pure java. So if you want a variable called severity you should declare it as: String severity = $patient.medicalHistoryBleedingRiskFactors.gastritis; Greetings. 2010/12/3 John McKim I'm having a problem that I can't seem to figure out. I have rules that run in a client program with no problem - about 125 rules in all. When I try to run these same rules in an App Server (GlassFish) I get several rules (about 5) that have an error on initialization. Here is the error message followed by the rule. *** SEVERE: java.lang.RuntimeException: Unable to build expression for 'consequence': [Error: not a statement, or badly formed structure] [Near : {... $severity; }] ^ [Line: 1, Column: 233] ' $severity = $patient.medicalHistoryBleedingRiskFactors.gastritis;
Re: [rules-users] Rules in App Server Error
You made the same error in three other places. Fix them. Are you familiar with the java language? GreG On Dec 3, 2010, at 15:15, "John McKim" wrote: > Thanks for the reply Mauricio. I tried what you said using this modified > rule: > > > > rule "medicalHistoryBleedingRiskFactors.gastritis rule" > > salience 20 > > when > > # find patients who indicated that they have > MedicalHistoryBleedingRiskFactors: gastritis > > $patient : Patient(medicalHistoryBleedingRiskFactors.gastritis > 0) > > then > > String severity = > $patient.medicalHistoryBleedingRiskFactors.gastritis; > > $weight = 5; > > $factor = .1; > > $tempScore = $factor; > > $tempScore = $tempScore * $weight; > > $tempScore = $tempScore * $severity; > > # Now add this risk score to the accumlated risk score > > $patient.score = $patient.score + $tempScore; > > $patient.problem = new > String("MedicalHistoryBleedingRiskFactors.gastritis"); > > end > > > > But I got this exception in the client (I am using 5.1.1 by the way): > > > > Exception in thread "Thread-4" java.lang.RuntimeException: Unable to build > expression for 'consequence': [Error: Failed to compile: 1 compilation > error(s): > > - (1,9) unqualified type in strict mode for: $severity] > > [Near : {... Unknown }] > > ^ > > [Line: 1, Column: 0] 'String severity = > $patient.medicalHistoryBleedingRiskFactors.gastritis; > > $weight = 5; > > $factor = .1; > > $tempScore = $factor; > > $tempScore = $tempScore * $weight; > > $tempScore = $tempScore * $severity; > > // Now add this risk score to the accumlated risk score > > $patient.score = $patient.score + $tempScore; > > $patient.problem = new > String("MedicalHistoryBleedingRiskFactors.gastritis"); > > ' : [Rule name='medicalHistoryBleedingRiskFactors.gastritis rule'] > > > > at > com.kai.framework.plugins.ruleengine.LocalRuleEnginePlugin.createLevel1KnowledgeBase(LocalRuleEnginePlugin.java:107) > > at > com.kai.framework.plugins.ruleengine.LocalRuleEnginePlugin.access$100(LocalRuleEnginePlugin.java:22) > > at > com.kai.framework.plugins.ruleengine.LocalRuleEnginePlugin$InitializeRuleEngine.run(LocalRuleEnginePlugin.java:192) > > > > When I took out the String severity and used just $severity: it works fine. > Just on the App server does it fail. > > > > From: rules-users-boun...@lists.jboss.org > [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Mauricio Salatino > Sent: Friday, December 03, 2010 3:36 PM > To: Rules Users List > Subject: Re: [rules-users] Rules in App Server Error > > > > that's weird.. you are using a varible that you never define in the Right > Hand Side. > $severity was never defined. In the RHS remember that you can write pure > java. So if you want a variable called severity you should declare it as: > String severity = $patient. > > medicalHistoryBleedingRiskFactors.gastritis; > > Greetings. > > > > 2010/12/3 John McKim > > I'm having a problem that I can't seem to figure out. I have rules that run > in a client program with no problem - about 125 rules in all. When I try to > run these same rules in an App Server (GlassFish) I get several rules (about > 5) that have an error on initialization. Here is the error message followed > by the rule. > > *** > SEVERE: java.lang.RuntimeException: Unable to build expression for > 'consequence': [Error: not a statement, or badly formed structure] > [Near : {... $severity; >}] > ^ > [Line: 1, Column: 233] '$severity = > $patient.medicalHistoryBleedingRiskFactors.gastritis; > $weight = 5; > $factor = .1; > $tempScore = $factor; > $tempScore = $tempScore * $weight; > $tempScore = $tempScore * $severity; > // Now add this risk score to the accumlated risk score > $patient.score = $patient.score + $tempScore; > $patient.problem = new > String("MedicalHistoryBleedingRiskFactors.gastritis"); > ' : [Rule name='medicalHistoryBleedingRiskFactors.gastritis rule'] > ** > rule "medicalHistoryBleedingRiskFactors.gastritis rule" > salience 20 > when > # find patients who indicated that they have > MedicalHistoryBleedingRiskFactors: gastritis > $patient : Patient(medicalHistoryBleedingRiskFactors.gastritis > 0) > then > $severity = $patient.medicalHistoryBleedingRiskFactors.gastritis; > $weight = 5; > $factor = .1; > $tempScore = $factor; > $tempScore = $tempScore * $weight; > $tempScore = $tempScore * $severity; > # Now add this risk score to the accumlated risk score >
Re: [rules-users] Drools logging to console.
You're just commenting out the references to the loggere, but not the construction. (if the line breaks are the same in your original code as they are below.) GreG On Nov 28, 2010, at 6:54, Nadav Hashimshony wrote: > my drools application write debug and info message to the console. > > i currently do the follwoing > > in the main thread i i have: > > private static KnowledgeBase m_droolsKbase= createKnowledgeBase(); > > private static KnowledgeBase createKnowledgeBase() > { > ResourceFactory.getResourceChangeNotifierService().start(); > ResourceFactory.getResourceChangeScannerService().start(); > > > Properties droolsConf = new Properties(); > droolsConf.setProperty("drools.dialect.java.compiler", > "JANINO"); > KnowledgeBuilderConfiguration config = > KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(droolsConf, null); > KnowledgeBuilder builder = > KnowledgeBuilderFactory.newKnowledgeBuilder(config); > > builder.add(ResourceFactory.newFileResource(m_properties.getProperty("drools.pkg")), > ResourceType.PKG); > > if (builder.hasErrors()) > { > throw new > RuntimeException(builder.getErrors().toString()); > } > > KnowledgeBase knowledgeBase = > KnowledgeBaseFactory.newKnowledgeBase(); > > knowledgeBase.addKnowledgePackages(builder.getKnowledgePackages()); > > m_droolsKagent= > KnowledgeAgentFactory.newKnowledgeAgent("DroolsAgent",knowledgeBase); > > m_droolsKagent.applyChangeSet(ResourceFactory.newFileResource(m_properties.getProperty("drools.pkg.xml"))); > return m_droolsKagent.getKnowledgeBase(); > } > > > each worker thread does the following: > > StatefulKnowledgeSession droolsSession = > m_droolsKagent.getKnowledgeBase().newStatefulKnowledgeSession(); > //KnowledgeRuntimeLogger logger = > KnowledgeRuntimeLoggerFactory.newConsoleLogger(droolsSession); > //KnowledgeRuntimeLogger logger = > KnowledgeRuntimeLoggerFactory.newFileLogger(droolsSession, > "var/log/ctch/ctDefender/ctDefenderDrools.log"); > . > . > . > > > Even if the logger lines are commented i still get log prints to console > (STDOUT) > > how can i control them? stop them? > > Thanks. > Nadav. > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] StatefulKnowledgeSession.startProcess not thread-safe ?
org.drools.StatefulSession has the async* methods, which are thread safe. I'm not sure if org.drools.runtime.StatefulKnowledgeSession.execute(Command command) uses them behind the scenes, though. --- On Fri, 11/26/10, Wolfgang Laun wrote: From: Wolfgang Laun Subject: Re: [rules-users] StatefulKnowledgeSession.startProcess not thread-safe ? To: "Rules Users List" Date: Friday, November 26, 2010, 9:33 AM 2010/11/26 Esteban Aliverti Are you using the same session? Sessions are not thread-safe in drools. Sessions not thread-safe? So how do I run x.fireUntilHalt() in one session and do insert() in other threads? Do I have to synchronize this myself? -W Best, Esteban Aliverti - Developer @ http://www.plugtree.com - Blog @ http://ilesteban.wordpress.com On Fri, Nov 26, 2010 at 12:12 PM, OptimusPrime wrote: Hello, I wrote a micro benchmark in order to test the performance of Drools Flow 5.1.0 in single and multi-threaded environments. And I noticed that, when 2 threads call startProcess() at the same time (Intel Core 2 Duo CPU), the returned process instance IDs are the same. I checked the code and it seems there is no locking mechanism in the org.drools.process.instance.impl.DefaultProcessInstanceManager class for the id creation. Is this a bug or am I missing something ? Thanks -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/StatefulKnowledgeSession-startProcess-not-thread-safe-tp1973203p1973203.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -Inline Attachment Follows- ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Replacement for eval
You're missing the agenda. http://en.wikipedia.org/wiki/Rete_algorithm#Conflict_resolution In the rete algorithm the agenda is a list of activated rules who's actions are eligible to fire. The "first" one on the list is selected, it's action is fired, and the agenda might change as a result. "First" is in quotes because the agenda list is sorted by conflict resolution rules. One of those rules drools uses is specificity, which means that rules with more specific patterns (i.e. ones that select for a more specific set of working memory objects) are selected before less specific ones. You can't get any less specific than selecting nothing, so the empty LHS rule is selected last... --- On Tue, 11/16/10, Nirmal Fernando wrote: From: Nirmal Fernando Subject: Re: [rules-users] Replacement for eval To: "Rules Users List" Date: Tuesday, November 16, 2010, 10:32 PM Thanks for the replies! I observed that the action of a rule not get executed straight after that rule activated. Say my rules are following: rule "Hello World" when then System.out.println( "hello world" ); end rule "GoodBye" when Message( status == Message.GOODBYE, myMessage : message ) then System.out.println("good bye"); end If I have set up my Message class such that it will fire the "GoodBye" rule, my output is: good bye hello world What I wanna know whether this is the expected behaviour? (Since normally I expect the action of that particular rule to be executed straight after it's fired.) Am I missing something here? Thanks. 2010/11/16 Greg Barton If you use bean property conventions for naming your methods you can use a regular condition element. for instance, you could rename emptyMessageFinder() to isMessageFound() or getMessageFound() and your condition would look like this: when m : Message(messageFound == true)then...end And when you do this the rete is used, birds sing in the trees, and world peace will be declared. GreG On Nov 16, 2010, at 5:37, Nirmal Fernando wrote: Hi, I have two questions. 1) Is there any other way/method in Drools to test the truth value of a condition other than "eval"? In almost all rules of my application needs to test conditions, and it takes ages to run using "eval". 2) Say I have a java method which returns a boolean, and I have used it within an "eval" function. (eg: eval(message.emptyMessageFinder()) ) This "emptyMessageFinder()" method will return a "boolean" if there's an empty message. This function is containing many loops and recursive operations. Will I get a performance improvement if I alternate the above such that the "emptyMessageFinder()" method sets a boolean attribute (anyEmptyMessage) in the Message class to true and false, and I'm using following in my drl. when m: Message() m.emptyMessageFinder() eval(m.anyEmptyMessage) //can I use eval here?? .. If someone can answer these questions it would be a great help! Thank you in advance! -- Best Regards, Nirmal C.S.Nirmal J. Fernando Department of Computer Science & Engineering, Faculty of Engineering, University of Moratuwa, Sri Lanka. Blog: http://nirmalfdo.blogspot.com/ ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Best Regards, Nirmal C.S.Nirmal J. Fernando Department of Computer Science & Engineering, Faculty of Engineering, University of Moratuwa, Sri Lanka. Blog: http://nirmalfdo.blogspot.com/ -Inline Attachment Follows- ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Replacement for eval
If you use bean property conventions for naming your methods you can use a regular condition element. for instance, you could rename emptyMessageFinder() to isMessageFound() or getMessageFound() and your condition would look like this: when m : Message(messageFound == true) then ... end And when you do this the rete is used, birds sing in the trees, and world peace will be declared. GreG On Nov 16, 2010, at 5:37, Nirmal Fernando wrote: Hi, I have two questions. 1) Is there any other way/method in Drools to test the truth value of a condition other than "eval"? In almost all rules of my application needs to test conditions, and it takes ages to run using "eval". 2) Say I have a java method which returns a boolean, and I have used it within an "eval" function. (eg: eval(message.emptyMessageFinder()) ) This "emptyMessageFinder()" method will return a "boolean" if there's an empty message. This function is containing many loops and recursive operations. Will I get a performance improvement if I alternate the above such that the "emptyMessageFinder()" method sets a boolean attribute (anyEmptyMessage) in the Message class to true and false, and I'm using following in my drl. when m: Message() m.emptyMessageFinder() eval(m.anyEmptyMessage) //can I use eval here?? .. If someone can answer these questions it would be a great help! Thank you in advance! -- Best Regards, Nirmal C.S.Nirmal J. Fernando Department of Computer Science & Engineering, Faculty of Engineering, University of Moratuwa, Sri Lanka. Blog: http://nirmalfdo.blogspot.com/ ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Rules selection logic
Also, the use of doubles in an == test is problematic. Not that it would cause this particular problem, but it will cause others. GreG On Nov 13, 2010, at 11:52, Wolfgang Laun wrote: Are you using the latest (5.1.1) release? Is the duplicated rule in another DRL file and does it have exactly the same name? If so, it simply overwrites the first rule. If it's different, please create a JIRA with a minimized example reproducing the error. -W On 13 November 2010 14:12, balagh wrote: Hi, Below is the DRl used. When i have two different rules with the same below DRL, only one rule is getting executed. I could find that in my logs. If i change the line to Ransome(amr <= 10) in any one of the rule, both of them are getting executed. I am having the rules in db and the execution trace log will have the rules no which gets executed Rule "rule -1" when loose : Loose() ransome : Ransome(amt == 6.15) from loose.getRansomeArray(0) util : Util() then util.doIt(loose, "Hello"); end Thanks, Bala -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Rules-selection-logic-tp1894132p1894257.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] check if a
$value : Value( $value : value, // other restrictions ) $object : MyObject( $value not memberOf valueList ) GreG On Nov 1, 2010, at 9:55, Tina Vießmann wrote: Is it possible to write the following conditions without using eval? $object : MyObject ( $valueList : valueList ) // of type List $ value : Value ( // other restrictions && eval( !($valueList.contains($value)) ) ) Thank you :) Tina ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Declaring events programmatically
http://downloads.jboss.com/drools/docs/5.1.1.34858.FINAL/drools-fusion/html/ch02.html#d0e241 Use type declaration and @role(event) --- On Tue, 10/26/10, Samuli Saarinen wrote: > From: Samuli Saarinen > Subject: [rules-users] Declaring events programmatically > To: "Rules Users List" > Date: Tuesday, October 26, 2010, 1:42 AM > Hello, > > I'm looking for a way to declare facts as events using an > API. Would > anyone happen to know if such an API exists in drools? > > Cheers, > > Samuli > > -- > Remion Oy > Etävalvontajärjestelmät liiketoiminnan > Samuli Saarinen > tehostamiseen > gsm +358 (0)50 3560075 > fax +358 (0)3 2125064 > www.remion.com > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Starting engine using fireUntilHalt and inserting no facts results in 50% CPU usage
The problem is the race condition fix introduced in rev 30163. The missedNotifyAll flag is set to true immediately which causes the busy loop. missedNotifyAll is initialized to false, but is immediately set to true because notifyHalt() is called in AbstractWorkingMemory.queueWorkingMemoryAction() via ReteooRuleBase.newStatefulSession(). Anyway, I'll move discussions of possible solutions over to the dev list, (crossposting now) or a JIRA if you'd prefer that. --- On Mon, 10/25/10, Greg Barton wrote: > From: Greg Barton > Subject: Re: [rules-users] Starting engine using fireUntilHalt and inserting > no facts results in 50% CPU usage > To: "Rules Users List" > Date: Monday, October 25, 2010, 3:18 PM > I was going to look at this at some > point. I guess that point will be tonight. :) > > GreG > > On Oct 25, 2010, at 15:02, Edson Tirelli > wrote: > > No worries, it is a good starting point anyway. > Hopefully someone > can continue from there or I will eventually fix it. Just a > lot of > stuff in my plate already that have priority over this. > > Edson > > 2010/10/25 mardo : > Unfortunately no, I just had a look how it was implemented > (like > http://tutorials.jenkov.com/java-concurrency/thread-signaling.html#missedsig > nals) -> missed signals and noticed that it somehow > didn't work as intended. > > But no idea how to directly correct it, sorry. > > -Original Message- > From: rules-users-boun...@lists.jboss.org > [mailto:rules-users-boun...@lists.jboss.org] > On Behalf Of Edson Tirelli > Sent: Montag, 25. Oktober 2010 21:30 > To: Rules Users List > Subject: Re: [rules-users] Starting engine using > fireUntilHalt and inserting > no facts results in 50% CPU usage > > Do you have a solution/patch for it? > > Edson > > 2010/10/25 mardo : > Luckily just stumbled upon this mail... > > You can take a look at > > http://drools-java-rules-engine.46999.n3.nabble.com/fireUntilHalt-and-OSGi-C > PU-load-td1022352.html > > where I already provided a minimal example (don't know if > it covers all > cases) and tracked it down to missedNotifyAll in > DefaultAgenda > > cheers > > > > -Original Message- > From: rules-users-boun...@lists.jboss.org > [mailto:rules-users-boun...@lists.jboss.org] > On Behalf Of Edson Tirelli > Sent: Montag, 25. Oktober 2010 21:17 > To: Rules Users List > Subject: Re: [rules-users] Starting engine using > fireUntilHalt and > inserting > no facts results in 50% CPU usage > > This is clearly a regression as Drools should be not be > using busy > waits in fireUntilHalt(). It should use monitors and locks > as it was > doing before. > > Can anyone open a JIRA? also, if anyone would be willing > to take > investigate and fix this one, it would really help. > Otherwise, I will > add it to my queue. > > Thanks, > > Edson > > 2010/10/25 Norman C : > > > Note that the 100% CPU issue with fireUntiHalt is only with > the 5.1 > version of > Drools. In 5.0.x, CPU is close to 0% when there are > no rules to fire. I > saw > this when I was testing upgrading to 5.1. > > Norman > > > > - Original Message > From: jschmied > To: rules-users@lists.jboss.org > Sent: Sun, October 24, 2010 4:06:02 AM > Subject: Re: [rules-users] Starting engine using > fireUntilHalt and > inserting no > facts results in 50% CPU usage > > > Hi! > > fireUntilHalt uses one processor with 100%. You have a > dualcore, so it's > 50%. It's by design like this. > > You can: > - Call fireAllRules after every insert if you have no > ruleflow. > > - Use fireAllRules in a loop with a small sleep and check > for the end of > the > ruleflow in the loop: > > while (prc.getState() == ProcessInstance.STATE_ACTIVE) { > Threads.sleep(20); > ksession.fireAllRules(); > } > > with both methods you get a low cpu load. > > bye > > juergen > -- > View this message in context: > > > http://drools-java-rules-engine.46999.n3.nabble.com/Starting-engine-using-fi > > reUntilHalt-and-inserting-no-facts-results-in-50-CPU-usage-tp1760370p1761821 > .html > > Sent from the Drools - User mailing list archive at > Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > > > > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman
Re: [rules-users] Starting engine using fireUntilHalt and inserting no facts results in 50% CPU usage
I was going to look at this at some point. I guess that point will be tonight. :) GreG On Oct 25, 2010, at 15:02, Edson Tirelli wrote: No worries, it is a good starting point anyway. Hopefully someone can continue from there or I will eventually fix it. Just a lot of stuff in my plate already that have priority over this. Edson 2010/10/25 mardo : Unfortunately no, I just had a look how it was implemented (like http://tutorials.jenkov.com/java-concurrency/thread-signaling.html#missedsig nals) -> missed signals and noticed that it somehow didn't work as intended. But no idea how to directly correct it, sorry. -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Edson Tirelli Sent: Montag, 25. Oktober 2010 21:30 To: Rules Users List Subject: Re: [rules-users] Starting engine using fireUntilHalt and inserting no facts results in 50% CPU usage Do you have a solution/patch for it? Edson 2010/10/25 mardo : Luckily just stumbled upon this mail... You can take a look at http://drools-java-rules-engine.46999.n3.nabble.com/fireUntilHalt-and-OSGi-C PU-load-td1022352.html where I already provided a minimal example (don't know if it covers all cases) and tracked it down to missedNotifyAll in DefaultAgenda cheers -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Edson Tirelli Sent: Montag, 25. Oktober 2010 21:17 To: Rules Users List Subject: Re: [rules-users] Starting engine using fireUntilHalt and inserting no facts results in 50% CPU usage This is clearly a regression as Drools should be not be using busy waits in fireUntilHalt(). It should use monitors and locks as it was doing before. Can anyone open a JIRA? also, if anyone would be willing to take investigate and fix this one, it would really help. Otherwise, I will add it to my queue. Thanks, Edson 2010/10/25 Norman C : Note that the 100% CPU issue with fireUntiHalt is only with the 5.1 version of Drools. In 5.0.x, CPU is close to 0% when there are no rules to fire. I saw this when I was testing upgrading to 5.1. Norman - Original Message From: jschmied To: rules-users@lists.jboss.org Sent: Sun, October 24, 2010 4:06:02 AM Subject: Re: [rules-users] Starting engine using fireUntilHalt and inserting no facts results in 50% CPU usage Hi! fireUntilHalt uses one processor with 100%. You have a dualcore, so it's 50%. It's by design like this. You can: - Call fireAllRules after every insert if you have no ruleflow. - Use fireAllRules in a loop with a small sleep and check for the end of the ruleflow in the loop: while (prc.getState() == ProcessInstance.STATE_ACTIVE) { Threads.sleep(20); ksession.fireAllRules(); } with both methods you get a low cpu load. bye juergen -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Starting-engine-using-fi reUntilHalt-and-inserting-no-facts-results-in-50-CPU-usage-tp1760370p1761821 .html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Stateless K-Session but no Sequential Mode
The stateless session is just a convenience wrapper around the stateful session. GreG On Oct 20, 2010, at 6:52, "Swindells, Thomas" wrote: That is enough reason in itself - why go to the bother of having to do inserts, fire all rules and dispose separately when stateless sessions do that all for you - as the javadoc says: "StatelessKnowledgeSession provides a convenience API, wrapping StatefulKnowledgeSession. It avoids the need to call dispose()." -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Wolfgang Laun Sent: 20 October 2010 12:34 To: Rules Users List Subject: Re: [rules-users] Stateless K-Session but no Sequential Mode If I understand this correctly, there isn't much point in having a non-sequential-mode stateless session. If I want a one-shot execution, I can call inserts, fireAllRules and dispose() just as well in a stateful session. Possibly this is due to past development. Thanks! -W On 20 October 2010 09:13, Swindells, Thomas wrote: I've not used it but from what I understand: Sequential mode: 1. Insert facts 2. Create activations. 3. Fire all activations. 4. Done. None Sequential (Standard) mode: 1. Insert facts. 2. Create initial activations. 3. Pop and fire highest salience activation. 4. Update activations (if update, retract etc was performed). 5. If there are more activations goto 3. 6. Done. They key difference is that in the standard mode rule consequences can activate and deactivate activations as they update the working memory. Thomas -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users- boun...@lists.jboss.org] On Behalf Of Wolfgang Laun Sent: 19 October 2010 22:34 To: Rules Users List Subject: Re: [rules-users] Stateless K-Session but no Sequential Mode Indeed I have, and I've read it down to the last paragraph: "Sequential mode can only be used with a Stateless Session and is off by default. To turn it on, either call..." This tells me about a StatelessKnowledgeSession WITH sequential mode. So, what if I create a StatelessKnowledgeSession from a KnowledgeBase, but do not turn sequential mode on? Best -W 2010/10/19 Michael Anstis : No doubt I'm missing the point but have you seen "3.3.7.1. Sequential Mode" in Expert's documentation? On 19 October 2010 21:27, Wolfgang Laun wrote: As I understand the Expert documentation, Sequential Mode has to be turned on, even with a Stateless Knowledge Session to achieve all the shortcuts and speed-ups. What the documentation does not tell me (or I haven't seen it) is the difference of a Stateless Knowledge Session with and without Sequential Mode. Cheers Wolfgang ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.com and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 *
Re: [rules-users] Pattern aggregation
It would be nice if we had an example of some rules. That way we can rule out obvious performance killers like cartesian products and multiple "from" clauses in one rule. GreG On Oct 18, 2010, at 5:19, Tim 4076 wrote: Hi, I'm trying to use drools to do grouping of data according to patterns defined in my rules, but I'm having issues creating something that works in a reasonable amount of time (seconds). I've tried all sorts of permutations without much luck and would like to hear how others would do the same thing. To give an example: I've got a big batch of transaction records and I want to aggregate all the records where the consumer id and product category are the same and the purchases were made within an hour of each other. The fact that its matching the same values between facts, rather than against constants seems to scupper it somewhat. I would go down the ETL route, but the idea is for non-techies to define their own aggregations using rules. -Cheers. Tim ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Check if fact is subset of items in the rule
Try the custom operator Wolfgang suggested. Then rete will be used. --- On Mon, 10/11/10, kpandey wrote: > From: kpandey > Subject: Re: [rules-users] Check if fact is subset of items in the rule > To: rules-users@lists.jboss.org > Date: Monday, October 11, 2010, 8:23 PM > > I got it to work using eval like so > > when > ... > eval($mycontext.isNotSubset("STRING1", > "STRING2","STRING3", "STRING4")) > > I have the logic in isNotSubset method in context class to > check if the set > the context is subset of array passed in the call to the > method. > > This works but I believe this can't make use of the rete > optimization ? > > > Thanks > Kumar > > -- > View this message in context: > http://drools-java-rules-engine.46999.n3.nabble.com/Check-if-fact-is-subset-of-items-in-the-rule-tp1680013p1684551.html > Sent from the Drools - User mailing list archive at > Nabble.com. > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] fireUntilHalt and timing of rule activations
The entire purpose of fireUntilHalt is to do exactly the opposite of what you describe. :) Is there any compelling reason you're using it as opposed to just calling fireAllRules? GreG On Oct 5, 2010, at 16:34, Norman C wrote: Thanks for the suggestions. They all look like good ways to handle the situation I described. However, they require modifying all of the rules to check for the latch object and its state, which I would prefer not to do and doesn't seem like would be necessary. It seems to me that this is something that Drools can handle internally without the rules having to be written this way. Since the rules engine processes rules in a single thread, it's a concurrency issue. fireUntilHalt should be blocked when a fact is inserted/updated/retracted, until all activations as a result of that change in working memory are completed. Thoughts? Norman From: Wolfgang Laun To: Rules Users List Sent: Sun, October 3, 2010 10:51:08 PM Subject: Re: [rules-users] fireUntilHalt and timing of rule activations 2010/10/4 Greg Barton If you don't have some way of associating the data with a particular Latch it's easy to get overlap when processing datasets. In general you need some way to group the data together. You can avoid a back reference to the Latch by having a Set of some sort in the Latch to which you add all data in the batch. Which burdens all inserts and retracts to be accompanied by correpsonding updates of the Set/Map. If you use a Set backed by an IdentityHashMap the overhead is pretty small, and rules look like this: rule "CountAs" dialect "java" salience -1 when l : Latch() a : A( this memberOf l.dataSet ) then retract(a); l.incACount(); System.out.println("Found an A in " + l); end See attached project. THough I like the cleverness of using the "data in matched objects alters rule properties" trick, you could have just as easily had a "Latch(value == true)" conditional, and that would be more clear, It was meant to emphasize the role of Latch.value as an enabler for the rule in contrast to a regular constraint being part of the application logic. YMMV ;-) IMO. I'm curious to see of the enabled trick would perform better, though. Whichever way, there is a considerable burden associated with writing the rules and, possibly, inserts and retracts. I wonder what the benefits of having the session run all the time are as opposed to simply let it fire until it stops; then do the inserts and then fireUntilHalt again? If there is, I'd opt for the addition of an atomic insertAll(Object... objects) and then none of this hocus-pocus would be necessary. -W GreG --- On Sun, 10/3/10, Wolfgang Laun wrote: From: Wolfgang Laun Subject: Re: [rules-users] fireUntilHalt and timing of rule activations To: "Rules Users List" Date: Sunday, October 3, 2010, 4:23 AM There is another way of associating a Latch object with rules, without having to store a reference to a Latch in objects: rule "CountAs" enabled ( $v ) when Latch( $v : value ) X( ... ) then ... end At the beginning, insert Latch( false ), which blocks all rules with this construction, or modify the Latch object to false before inserting more facts. Then, insert the facts, and, at the end, modify Latch to true. Latch latch = new Latch( true ); FactHandle fh = kSession.insert( latch ); kSession.fireAllRules(); latch.setValue( false ); kSession.update( fh, latch ); Of course, you can use multiple Latch objects, adding a name field with a specific value, so that a latch applies to a subset of rules only: rule "CountAs" enabled ( $v ) when Latch( name == "CountAs", $v : value ) ... But be aware that changes to Latch objects will retrigger rules that have fired previously; so with this approach you'll have to make sure to retract facts when they have been processed. -W 2010/10/3 Greg Barton Nope, you're not missing anything. What you need is a control object of some sort thst's inserted after all of the "real" data is inserted. (See attached project for an example.) Rules will look like this, if the control object is called BatchLatch and data objects A: rule "CountAs" dialect "java" salience -1 when l : Latch() a : A( latch == l ) then retract(a); l.incACount(); System.out.println("Found an A in " + bl); end Note that the A object being processed is tied back to the latch. This is so multiple latches can be processed simultaneously and their processing won't be intermingled. This is necessary because there
Re: [rules-users] fireUntilHalt and timing of rule activations
If you don't have some way of associating the data with a particular Latch it's easy to get overlap when processing datasets. In general you need some way to group the data together. You can avoid a back reference to the Latch by having a Set of some sort in the Latch to which you add all data in the batch. If you use a Set backed by an IdentityHashMap the overhead is pretty small, and rules look like this: rule "CountAs" dialect "java" salience -1 when l : Latch() a : A( this memberOf l.dataSet ) then retract(a); l.incACount(); System.out.println("Found an A in " + l); end See attached project. THough I like the cleverness of using the "data in matched objects alters rule properties" trick, you could have just as easily had a "Latch(value == true)" conditional, and that would be more clear, IMO. I'm curious to see of the enabled trick would perform better, though. GreG --- On Sun, 10/3/10, Wolfgang Laun wrote: From: Wolfgang Laun Subject: Re: [rules-users] fireUntilHalt and timing of rule activations To: "Rules Users List" Date: Sunday, October 3, 2010, 4:23 AM There is another way of associating a Latch object with rules, without having to store a reference to a Latch in objects: rule "CountAs" enabled ( $v ) when Latch( $v : value ) X( ... ) then ... end At the beginning, insert Latch( false ), which blocks all rules with this construction, or modify the Latch object to false before inserting more facts. Then, insert the facts, and, at the end, modify Latch to true. Latch latch = new Latch( true ); FactHandle fh = kSession.insert( latch ); kSession.fireAllRules(); latch.setValue( false ); kSession.update( fh, latch ); Of course, you can use multiple Latch objects, adding a name field with a specific value, so that a latch applies to a subset of rules only: rule "CountAs" enabled ( $v ) when Latch( name == "CountAs", $v : value ) ... But be aware that changes to Latch objects will retrigger rules that have fired previously; so with this approach you'll have to make sure to retract facts when they have been processed. -W 2010/10/3 Greg Barton Nope, you're not missing anything. What you need is a control object of some sort thst's inserted after all of the "real" data is inserted. (See attached project for an example.) Rules will look like this, if the control object is called BatchLatch and data objects A: rule "CountAs" dialect "java" salience -1 when l : Latch() a : A( latch == l ) then retract(a); l.incACount(); System.out.println("Found an A in " + bl); end Note that the A object being processed is tied back to the latch. This is so multiple latches can be processed simultaneously and their processing won't be intermingled. This is necessary because there's no guarantee that two Latch objects aren't in working memory at once. (Though you could create a rule that enforces this.) GreG --- On Sat, 10/2/10, Norman C wrote: > From: Norman C > Subject: [rules-users] fireUntilHalt and timing of rule activations > To: rules-users@lists.jboss.org > Date: Saturday, October 2, 2010, 10:22 AM > Hi All, > > In my app, I have a separate thread calling fireUntilHalt() > continuously. I > have quite a few rules, and I am using salience extensively > to control the order > > in which rules are executed. What I have seen (by adding > an event listener) is > that as a new fact is inserted, various rules are > activated. Often, the > fireUntilHalt will start executing fireNextItem in > DefaultAgenda before all of > the activations are complete. So if the rule with the > highest salience > value hasn't been activated at this point, then the first > rule to be fired isn't > > the correct one. > > This can be worked around by waiting for insert to return > and then calling > fireAllRules(). But it seems like the session should > block fireUntilHalt from > trying to execute activated rules until all activations are > complete. Or am I > missing something here? > > thanks, > Norman > > > > > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://
Re: [rules-users] fireUntilHalt and timing of rule activations
Nope, you're not missing anything. What you need is a control object of some sort thst's inserted after all of the "real" data is inserted. (See attached project for an example.) Rules will look like this, if the control object is called BatchLatch and data objects A: rule "CountAs" dialect "java" salience -1 when l : Latch() a : A( latch == l ) then retract(a); l.incACount(); System.out.println("Found an A in " + bl); end Note that the A object being processed is tied back to the latch. This is so multiple latches can be processed simultaneously and their processing won't be intermingled. This is necessary because there's no guarantee that two Latch objects aren't in working memory at once. (Though you could create a rule that enforces this.) GreG --- On Sat, 10/2/10, Norman C wrote: > From: Norman C > Subject: [rules-users] fireUntilHalt and timing of rule activations > To: rules-users@lists.jboss.org > Date: Saturday, October 2, 2010, 10:22 AM > Hi All, > > In my app, I have a separate thread calling fireUntilHalt() > continuously. I > have quite a few rules, and I am using salience extensively > to control the order > > in which rules are executed. What I have seen (by adding > an event listener) is > that as a new fact is inserted, various rules are > activated. Often, the > fireUntilHalt will start executing fireNextItem in > DefaultAgenda before all of > the activations are complete. So if the rule with the > highest salience > value hasn't been activated at this point, then the first > rule to be fired isn't > > the correct one. > > This can be worked around by waiting for insert to return > and then calling > fireAllRules(). But it seems like the session should > block fireUntilHalt from > trying to execute activated rules until all activations are > complete. Or am I > missing something here? > > thanks, > Norman > > > > > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > DroolsContinuousBatch.tar.gz Description: GNU Zip compressed data ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Multi threaded rule engine question.
I wouldn't reuse a stateless session. You could reuse a stateful session and clean up between runs, but session creation is not that expensive. (and easily less expensive than cleanup of a stateful session, mattering on the complexity of your rules) GreG On Sep 27, 2010, at 8:39, Nadav Hashimshony wrote: My rule engine server is multi threaded. in the server main i build a knowledgebase: KnowledgeBuilderConfiguration config = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(droolsConf, null); KnowledgeBuilder builder = KnowledgeBuilderFactory.newKnowledgeBuilder(config); builder.add(ResourceFactory.newFileResource("path to drools pkg", ResourceType.PKG); KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(); knowledgeBase.addKnowledgePackages(builder.getKnowledgePackages()); i have 10 threads that have the following code: thread run method: as long as a Vector has data do: 1. StatelessKnowledgeSession droolsSession= m_droolsKagent.getKnowledgeBase().newStatelessKnowledgeSession(); 2. get data object from a vector 3. create fact model from data 4. droolsSession.insert(facts); 5. droolsSession.fireAllRules(); 6. do stuff with the response 7.droosSession.dispose 8.get next object from vector. Questions: 1. should i create each time the droolsSession? or can i resuse the same one, meaning can i create it in the Thread's constractor? Thanks Nadav. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] LHS compare two lists
Also, you can avoid duplicate AcquiredCertification errors and o(n^2) run time by making all Lists into Sets. GreG On Sep 19, 2010, at 15:57, Esteban Aliverti wrote: > You can avoid the eval setting the size restriction inside the list: > > List(size == $certifications.size) from collect... > > Best, > >> El sep 19, 2010 12:29 p.m., "Wolfgang Laun" >> escribió: >> >> The idea of the rule given below is to collect a List >> from a certain User that's contained in the Position object's list of >> requiredCertifications, and then to compare the sizes. Equality means that >> User meets all requirements. >> >> rule "meets requirements" >> dialect "mvel" >> when >> Position( $certifications: requiredCertifications ) >> User( $name: name, $profile: profile ) >> $got: List() from collect ( AcquiredCertification( certification >> memberOf $certifications ) from $profile.userCertifications ) >> eval($certifications.size == $got.size ) >> then >> System.out.println( "Hire " + $name ); >> end >> >> -W >> >> >> On 19 September 2010 01:26, lnguyen wrote: >> > >> > >> > Hi, >> > >> > I'm trying to determ... >> >> >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Hold the Beans!
As opposed to data wrapped in a Fact? I suppose you could use java.util.Map instead of Fact and write rules around that. Or you could use a strongly typed POJO, which drools is optimized for. For translating the xml use something like JAXB or XStream. (I'm preferring XStream these days.) --- On Fri, 9/10/10, Donald Winston wrote: From: Donald Winston Subject: Re: [rules-users] Hold the Beans! To: "Rules Users List" Date: Friday, September 10, 2010, 9:06 PM So unlike Jess, Drools can or cannot use asserted facts from a data structure and can only use data wrapped in a bean? /* Assert ordered or unordered facts from the session's document. A deftemplate with matching * id and slots for each "fact" element should already exist for unordered facts.*/ public void assertDocument(Document document, Rete engine) throws JessException { Iterator facts = (document.getRootElement().getChildren("fact")).iterator();while (facts.hasNext() == true) { Element factElement = (Element)facts.next();String id = factElement.getAttributeValue("id");Fact fact = new Fact(id, engine); Iterator slots = (factElement.getChildren("slot")).iterator(); while (slots.hasNext() == true) { Element slotElement = (Element)slots.next();String name = slotElement.getAttributeValue("name");String type = slotElement.getAttributeValue("type");if (slotElement.getChildren("value").size() == 1) { String value = slotElement.getChild("value").getText(); fact.setSlotValue(name, getValue(type, value)); } else { ValueVector valueVector = new ValueVector(); Iterator values = (slotElement.getChildren("value")).iterator(); while (values.hasNext() == true) { String value = ((Element)values.next()).getText(); valueVector.add(getValue(type, value)); } fact.setSlotValue(name, new Value(valueVector, RU.LIST)); } } //while slots engine.assertFact(fact);} //while facts } /* * Output the fact base to the response output stream. * Intended for debugging. Override to do your own processing. */ public String processResults(HttpServletRequest request, HttpServletResponse response, Rete engine) throws IOException { PrintWriter writer = response.getWriter(); writer.println("Jess Results"); writer.println("PrettyPrint listFacts()"); writer.println("");Iterator facts = engine.listFacts(); while (facts.hasNext() == true) { Fact fact = (Fact)facts.next(); writer.println(new PrettyPrinter(fact)); } writer.println(""); writer.println(""); return null;} private Value getValue(String type, String value) throws JessException {if ("STRING".equals(type) == true) return new Value(value, RU.STRING); else if ("INTEGER".equals(type) == true)return new Value(Integer.parseInt(value), RU.INTEGER); else if ("FLOAT".equals(type) == true) return new Value(Float.parseFloat(value), RU.FLOAT);else if ("SYMBOL".equals(type) == true) return new Value(value, RU.SYMBOL); else if ("LONG".equals(type) == true) return new Value(Long.parseLong(value), RU.LONG); else return new Value(value, RU.ANY);}On Sep 10, 2010, at 11:18 AM, Wolfgang Laun wrote: So everthing is String or list of String? (What if your data contains numbers, where you'd like to use > in patterns?) Is there a stable relationship between key/slot and its type, i.e., scalar String or list of String? You realize that a record of untyped fields (slots) is fundamentally different from an approach where data is bound to be stored in (necessarily) strongly typed fields of an object. There's no difficulty with writing similar code for storing values from a Map into an object of some class, but class fields must have fixed types. -W 2010/9/10 Donald Winston This is what I'm doing: /* Assert unordered facts from the request parameter map. A deftemplate with matching id and * slots should alread
Re: [rules-users] Loading facts and memory size limits
Do you have rules which relate two arbitrary customers together? If the answer is no (and even a limited yes) then the problem can process customers in parallel. That means you can break the processing down into smaller chunks and you don't need all customers in memory at once. GreG On Sep 9, 2010, at 3:27, bellios wrote: In my application I would to model the Customers-Sales domain and I thought that drools could help me to express a set of rules to capture (or execute on-demand) some "special" customers (e.g. take the customers which not have/have bought some products of category X in the last 6 months). To do this i'm loading the last 6 months sales into WM, afterwards on demand i execute the rules. This process fails due the memory requirements. I thought that Drools would use an hibernate/JPA/ or an incremental mechanisms to load and process the facts. @Swindells, Thomas: Do you think that it's the right approach? @Michael Anstis-2: I will try to study in deep the event processing\CEP\streaming methods. -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Loading-facts-and-memory-size-limits-tp1440236p1444747.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Loading facts and memory size limits
Considering that just an Object array of 10 million Objects consumes 115MB of memory, I think loading 1 billion facts will be stretching the limits of the VM all by itself. (and that's java.lang.Object with no fields...) GreG On Sep 8, 2010, at 10:31, bellios wrote: Hi all, i have read the Documentation and the Drools book. I am developping an application but i don't understand in my case how i can loading a 1,000,000,000 facts (approx). At present I load all facts into a StatefulKnowledgeSession with a for- cycle and I insert them into ksession ("ksession.insert(customer);") The problem is the out of memory exception due the high memory requirements of facts. How i can resolve it? There is another approach to facts loading into session? Can i integrate the loading with JPA/Hibernate frameworks? Thanks in advance for any suggestion, David -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Loading-facts-and-memory-size-limits-tp1440236p1440236.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] copyright violation issue on Drools
This is not the appropriate forum for copyrighgt issues. GreG On Aug 31, 2010, at 9:40, 山本 裕介 wrote: Hi, There's a copyright violation issue on Drools 5.1 release. Please remove the changes listed in the following issue. https://jira.jboss.org/browse/JBRULES-2660 Thanks, Yusuke ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Caching results in temperory variables
You must either update an existing working memory object or insert a new working memory object with the results. That's how rules communicate with each other. GreG On Aug 12, 2010, at 10:31 AM, Manav wrote: Hi, I am using the version 5.x of drools and i have a scenario where i want to hold the result of a test in one rule to a temperory variable . This result will then be used in another rule that will be fired later in the sequence . For ex : salience 100 when User (language.keySet contains "Japanese", $j_score : language["Japanese"]) then // do something end salience 50 when User (language.keySet contains "French", $f_score : language["French"]) then // do something end salience 25 when eval (($j_score + $f_score) > 4) then // update the same to db end Is this possible in Drools 5.x ? Regards, Manav ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] functions inside fact type declaration?
+1 on the full constructor. GreG On Aug 9, 2010, at 3:58 PM, Edson Tirelli wrote: I thought about adding that, but I feel like we would just be reimplementing java, in this case. So, if you need anything else other than simple java beans, you should implement it as a java class. Regarding the constructor, I might still add a constructor that receives all fields as parameters, just to reduce verbosity when using the java dialect, but if you are using mvel dialect, you can use "with": rule ... when ... then with( person = new Person() ) { name = "Bob", age = 35 } insert( person ); end Edson 2010/8/9 Tina Vießmann Hi, is it possible to define a function/constructor inside a fact type declaration? If yes, how can it be done? Thank you :) Tina ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss by Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Problem with DRL language/ XLS decision tables.
Considering that googling on "rule latch" will return this thread on gmane as the 2nd link, you might find research difficult. :) I think Tom coined that term in this context, but it fits. The basic idea is that you use an object as an indicator of what processing has happened, and whether or not rules should fire. class RuleLatch { public final String name; public final DataObject dataObject; public RuleLatch(String name, DataObject dataObject) { this.name = name; this.dataObject = dataObject; } } when data: DataObject(...selection conditions for data...) level1Latch: RuleLatch(name == "level1Foo", dataObejct == data) level2Latch: RuleLatch(name == "level2Bar", dataObject == data) then ...if this rule wants to cancel all subsequent "level1Foo" it retracts level1Latch... ...if this rule wants to cancel all subsequent "level2Bar" it retractslevel2Latch... end An alternative, more efficient, but not as OO happy way, is to put the control information into the DataObject itself. Drools does a lot of optimization on the == tests with hashing, but if speed is a priority it might not be enough. So... class DataObject { public boolean level1Foo = true; public boolean level2Bar = true; } when data: DataObject(level1Foo == true, level2Bar == true, ...selection conditions for data... ) then ...if this rule wants to cancel all subsequent "level1Foo" it updates level1Foo = false... ...if this rule wants to cancel all subsequent "level2Bar" it updates level2Bar = false... end --- On Thu, 7/22/10, tom ska wrote: From: tom ska Subject: Re: [rules-users] Problem with DRL language/ XLS decision tables. To: "Rules Users List" Date: Thursday, July 22, 2010, 11:50 AM Thanks for reacting ;) I did some simulations, and after them, I want of course to parallelize this process of processing 2 billions facts. But as far as I wrote, Drools engine, can't do this. And I have to create threads manually in application (with pool of sessions). Am I right? Tuning number of data sounds fine to me, so I will try method with "rule latch" too (but I have to read about this, because, I don't know what is it, and I don't want to waste your time ;) But still I don't know how to use StatefulSessions to do this... Summarising, there are 3 methods to do, what I want to do (apart of a scalability problem - yet ;) 1.)with StatelessSession for one fact at time and "activation group" 2.)"rule latch" - I have to read more about it 3.)with a pool of StatefulSessions that I reuse - but I still don't know how to do it using StatefulSessions Really thanks for help ;) P.S. I use Drools 5 :) ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -Inline Attachment Follows- ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Problem with DRL language/ XLS decision tables.
You could always have a pool of StatefulSessions that you reuse. (This would allow you to run concurrently in multiple threads as well.) As long as these billions of facts don't need to interact that'll work fine. However I'd suggest that you try the "rule latch" method that Thomas suggested. That way you could tune the number of data objects you insert into a single pooled session, instead of inserting one at a time. And I'm guessing that, no matter how efficient you get, throwing 2 billion in memory at once won't scale. :) --- On Thu, 7/22/10, tom ska wrote: From: tom ska Subject: Re: [rules-users] Problem with DRL language/ XLS decision tables. To: "Rules Users List" Date: Thursday, July 22, 2010, 9:17 AM Hi, thanks for so quick answer. I think, that using StatelessSession could be a solution, but as I understood, I have to insert only one fact to the facts base. But, I have about 2 billions of facts that I want to process with Drools, and execution time, is for me really important. A think, that inserting one fact at time means for me additional time to initialise engine (when adding a new fact, and removing old one). Am I right? Thanks :) 2010/7/22 Pavel Tavoda Don't know details of your problem but it's typical situation where you can use StatelessSession, insert one fact at time and use activation-group. Pavel 2010/7/22 tom ska : > Hello, > I have a problem with defining rules. I insert many, many objects (facts) to > ksession object (StatefulKnowledgeSession). I want to fire rules for all of > them(facts), but I want to fire only one rule from all rules for each one > fact(not always this same rule is fired, because I use salience). > activation-group is not appropriate, because it works only with one object > (fact) - rest is not processed by engine. > Second question is: how can I stop processing rules, bot only for one fact, > not for all of them. > > Thanks, > tom. > > P.S. forgive me my English... :) > P.S.2 Firstly I want to do this in DRL, then, I'll try with XLS, and write > post if I would find problems... > > > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -Inline Attachment Follows- ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Error while executing business Rule
Yoda? You is that? GreG On Jul 15, 2010, at 9:53, Puneet duggal wrote: > but after that error my rules on none of the screens work why so > > On 7/15/10, Swindells, Thomas wrote: > Your rules are probably written wrong, or your application, or you have a > dodgy computer, or you have a race condition, or it is doing exactly what it > should be doing and your expectations are wrong. > > There’s also possibly a small chance that there is a bug in drools but with > absolutely no information about what the problem is or what you are doing I’d > be inclined to check all the other options first. > > > > From: rules-users-boun...@lists.jboss.org > [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Puneet duggal > Sent: 15 July 2010 14:42 > To: Rules Users List > Subject: [rules-users] Error while executing business Rule > > > > Hi friends, > > > > Some times i gets the error while executing rules so after that > > Rules accross entire screen stops working .. > > So can anyone tell me what can be the cause > > why it becomes unstable after that. > > > > Thanks > > Puneet > > > > ** > This message is confidential and intended only for the addressee. If you have > received this message in error, please immediately notify the > postmas...@nds.com and delete it from your system as well as any copies. The > content of e-mails as well as traffic data may be monitored by NDS for > employment and security purposes. To protect the environment please do not > print this e-mail unless necessary. > > NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 > 4EX, United Kingdom. A company registered in England and Wales. Registered > no. 3080780. VAT no. GB 603 8808 40-00 > ** > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Improving Drools Memory Performance
For #2 try a custom operator for "connects". GreG On Jul 12, 2010, at 12:56 AM, Jevon Wright wrote: Hi Wolfgang and Mark, Thank you for your replies! You were correct: my eval() functions could generally be rewritten into Drools directly. I had one function "connectsDetail" that was constraining unidirectional edges, and could be rewritten from: detail : DetailWire ( ) eval ( functions.connectsDetail(detail, source, target) ) to: detail : DetailWire ( from == source, to == target ) Another function, "connects", was constraining bidirectional edges, and could be rewritten from: sync : SyncWire( ) eval ( functions.connects(sync, source, target) ) to: sync : SyncWire( (from == source && to == target) || (from == target && to == source) ) Finally, the "veto" function could be rewritten from: detail : DetailWire ( ) eval ( handler.veto(detail) ) to: detail : DetailWire ( overridden == false ) I took each of these three changes, and evaluated them separately [1]. I found that: 1. Inlining 'connectsDetail' made a huge difference - 10-30% faster execution and 50-60% less allocated heap. 2. Inlining 'connects' made very little difference - 10-30% faster execution, but 0-20% more allocated heap. 3. Inlining 'veto' made no difference - no significant change in execution speed or allocated heap. I think I understand why inlining 'connects' would improve heap usage - because the rules essentially have more conditionals? I also understand why 'veto' made no difference - for most of my test models, "overridden" was never true, so adding this conditional was not making the cross product set any smaller. Finally, I also tested simply joining all of the rules together into one file. This happily made no difference at all (although made it more difficult to edit). So I think I can safely conclude that eval() should be used as little as possible - however, this means that the final rules are made more complicated and less human-readable, so a DSL may be best for my common rule patterns in the future. Thanks again! Jevon [1]: http://www.jevon.org/wiki/Improving_Drools_Memory_Performance On Sat, Jul 10, 2010 at 12:28 AM, Wolfgang Laun wrote: On 9 July 2010 14:14, Mark Proctor wrote: You have many objects there that are not constrained; I have an inkling that the functions.*() are hiding just these contraints, It's certainly the wrong way, starting with oodles of node pairs, just to pick out connected ones by fishing for the connecting edge. And this is worsened by trying to find two such pairs which meet at some DomainSource Guesswork, hopefully educated ;-) -W if there are multiple versions of those objects you are going to get massive amounts of cross products. Think in terms of SQL, each pattern you add is like an SQL join. Mark On 09/07/2010 09:20, Jevon Wright wrote: Hi everyone, I am working on what appears to be a fairly complex rule base based on EMF. The rules aren't operating over a huge number of facts (less than 10,000 EObjects) and there aren't too many rules (less than 300), but I am having a problem with running out of Java heap space (set at ~400 MB). Through investigation, I came to the conclusion that this is due to the design of the rules, rather than the number of facts. The engine uses less memory inserting many facts that use simple rules, compared with inserting few facts that use many rules. Can anybody suggest some tips for reducing heap memory usage in Drools? I don't have a time constraint, only a heap/memory constraint. A sample rule in my project looks like this: rule "Create QueryParameter for target container of DetailWire" when container : Frame( ) schema : DomainSchema ( ) domainSource : DomainSource ( ) instance : DomainIterator( ) selectEdge : SelectEdge ( eval ( functions.connectsSelect(selectEdge, instance, domainSource )) ) schemaEdge : SchemaEdge ( eval ( functions.connectsSchema(schemaEdge, domainSource, schema )) ) source : VisibleThing ( eContainer == container ) target : Frame ( ) instanceSet : SetWire ( eval(functions.connectsSet(instanceSet, instance, source )) ) detail : DetailWire ( ) eval ( functions.connectsDetail(detail, source, target )) pk : DomainAttribute ( eContainer == schema, primaryKey == true ) not ( queryPk : QueryParameter ( eContainer == target, name == pk.name ) ) eval ( handler.veto( detail )) then QueryParameter qp = handler.generatedQueryParameter(detail, target); handler.setName(qp, pk.getName()); queue.add(qp, drools); // wraps insert(...) end I try to order the select statements in an order that will reduce the size of the cross-product (in theory), but I also try and keep the rules fairly human readable. I try to avoid comparison operators like < and>. Analysing a heap dump shows that most of the memory is being used in StatefulSession.nodeMemories> PrimitiveLongMap. I am using
Re: [rules-users] Problem Setting globals in drools session
Let's keep this on the list. Also, since your reply text is at the end of the email I'll repaste it below: --- On Tue, 7/6/10, djerir smail <1983dje...@gmail.com> wrote: > > Thank you for your > response,my application is deployed in Mobicents slee AS, I > think it uses multiple classloaders .how can I fix that > please > > I've never used Mobicents before so I don't have the first clue, but a quick google on "mobicents classloader" returns this as the first result: http://markmail.org/message/z3sy5gtaghxc3366 >From that link: "Working with classpaths/URLs would result the same class to >be loaded in multiple classloaders, and then you would have linkage errors >when passing from one component to other..." Sounds familiar. :) There >should be some solution in Mobicents for passing objects between components >such that they share a common class. --- On Tue, 7/6/10, djerir smail <1983dje...@gmail.com> wrote: > From: djerir smail <1983dje...@gmail.com> > Subject: Re: [rules-users] Problem Setting globals in drools session > To: "Greg Barton" > Date: Tuesday, July 6, 2010, 2:25 PM > Greg Barton a écrit : > > Does your application use multiple classloaders? It's > possible for two instances with the same class definition to > not have "equal" classes if the class is loaded twice from > different classloaders. > > > > --- On Mon, 7/5/10, djerir smail <1983dje...@gmail.com> > wrote: > > > > > >> From: djerir smail <1983dje...@gmail.com> > >> Subject: [rules-users] Problem Setting globals in > drools session > >> To: "Rules Users List" > >> Date: Monday, July 5, 2010, 2:38 PM > >> Hello everybody, > >> > >> When I try to sett my globals I get this > error > >> > >> 2010-07-05 21:26:04,531 ERROR [STDERR] > >> java.lang.RuntimeException: Illegal class for > global. Expected > >> [ulb.mfe.srabre.ra.BREINTERFACE], found > [ulb.mfe.srabre.ra.BREINTERFACE]. > >> > >> Can anyone explain to me what does this error mean > please > >> . > >> > >> MY DRL FILE > >> > >> package ulb.mfe.srabre.rule > >> > >> import ulb.mfe.srabre.ra.BREINTERFACE; > >> import ulb.mfe.srabre.ra.DROOLSSLEEAgent; > >> > >> global ulb.mfe.srabre.ra.BREINTERFACE > BRERAInterface; > >> global ulb.mfe.srabre.ra.DROOLSSLEEAgent > DROOLSSLEEAgent; > >> > >> rule "MaxBtsAlarmrule" > >> dialect "mvel" > >> > >> when > >> > >> $B : BREINTERFACE() > >> then > >> System.out.println(" HELLO > "); > >> end > >> > >> > >> > >> > >> my code > >> > >> > >> public void Insert(Object fact) { > >> try{ > KnowledgeSessionConfiguration > >> sessConfig = > KnowledgeBaseFactory.newKnowledgeSessionConfiguration(); > >> > sessConfig.setOption(ClockTypeOption.get("pseudo")); > >> > StatefulKnowledgeSession > >> session = > knowledgeBase.newStatefulKnowledgeSession(); > >> > session.setGlobal("BRERAInterface", this.breinter); > >> > session.setGlobal("DROOLSSLEEAgent", this.droolssleeAgent); > >> > session.insert(this.breinter); > >> > System.out.println("Fact is now > >> inserted"); > >> > session.fireAllRules(); > >> } catch (Throwable t) { > >> > logger.info("sml couldn't set > >> up a session"); > >> > t.printStackTrace(); > >> } > >> } > >> ___ > >> rules-users mailing list > >> rules-users@lists.jboss.org > >> https://lists.jboss.org/mailman/listinfo/rules-users > >> > >> > > > > > > Thank you for your > response,my application is deployed in Mobicents slee AS, I > think it uses multiple classloaders .how can I fix that > please > > > > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] rules-users Digest, Vol 44, Issue 15
I think isolating it in a test case is the best way. Like Edson said, this is a simple use case, proven trouble free many times over by many drools users. Isolating the test case will either show you where the funky behavior is happening on your side, or provide a comprehensible regression test for the drools devs to use. GreG On Jul 6, 2010, at 12:34 PM, "Axelrod, Nelson" wrote: Hi Greg, I've tried to adjust/increase the JVMP heap memory but that does not help solve this problem. I've set the VM option -XX:+HeapDumpOnOutOfMemoryError. No heap dump files are generated, so I assume that is not the problem either. I can isolate this problem within a test case and add a bug report to Drools JIRA. Any other ideas as to how else this could occur, or how to troubleshoot this further? It is really disconcerting. Thanks, Nelson -- Message: 3 Date: Tue, 6 Jul 2010 09:05:16 -0700 (PDT) From: Greg Barton Subject: Re: [rules-users] How is this possible? To: Rules Users List Cc: "Richter, Alexander" , "" Message-ID: <376326.67572...@web81506.mail.mud.yahoo.com> Content-Type: text/plain; charset="utf-8" Does the amount of heap allocated affect it? I'm wondering if there's a hidden OutOfMemoryError happening. (Which, if you're catching Throwable anywhere, is a possibility. Use the HeapDumpOnOutOfMemoryError VM flag to diagnose this.) And this should be easy to reproduce in your unit tests: just insert many unrelated objects into working memory during the test. In fact you could construct tests thst show the same code succeeding without the excess objects then failing with them. That would be essential if you think this is a core drools problem and want it fixed. GreG ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How is this possible?
Does the amount of heap allocated affect it? I'm wondering if there's a hidden OutOfMemoryError happening. (Which, if you're catching Throwable anywhere, is a possibility. Use the HeapDumpOnOutOfMemoryError VM flag to diagnose this.) And this should be easy to reproduce in your unit tests: just insert many unrelated objects into working memory during the test. In fact you could construct tests thst show the same code succeeding without the excess objects then failing with them. That would be essential if you think this is a core drools problem and want it fixed. GreG On Jul 6, 2010, at 10:28 AM, "Axelrod, Nelson" wrote: Hi, We’re having some troubling problems that can be best explained by the following two rules. Based on the facts inserted into the stateful knowledge session, we expected both rules to fire for an Hmm Hit to TIGR00549, but only the “Test” rule fires. Can anyone explain how this could possibly occur? There are no other rules added to the knowledge base. This was tested using Drools 5.0 on Windows XP and Linux environments. rule "HMM Hit" when hit : HmmHit( aboveTrustedHit == true ) p : FeatureProperty( id == hit.hitId ) f : Feature ( featureId == hit.queryId, properties not contains p ) then if (hit.getHitId().equals("TIGR00549")) { System.err.println("HMM Hit rule: " + hit.getHitId() + " " + hit.getQueryId()); } end rule "Test" when hit : HmmHit( aboveTrustedHit == true, hitId == "TIGR00549") p : FeatureProperty( id == hit.hitId ) f : Feature ( featureId == hit.queryId, properties not contains p ) then System.err.println("Test rule: " + hit.getHitId() + " " + hit.getQueryId()); end Notably, this error is dependent on the amount and/or order of facts loaded into the knowledge session although we’re talking < 20k facts total. We have repeatedly found problems when running system-level tests of our production rules that do not appear when we run our unit tests, with issues such as this one that only show up after loading some number of facts that are unrelated to the particular fact in question. It’s difficult to debug because we can see that fact handles that satisfy the when conditions are in the knowledge session (i.e. the same facts that fulfill the Test rule), but we do not have any obvious way to debug why the expected HMM Hit rule does not fire. Nelson ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Problem Setting globals in drools session
Having it twice in the classpath would make no diffence (at least with the default java classloader) as only the first one in the path is used. Having multiple copies of a class in the classpath is generally not a good idea because it leads to confusion, but it would not cause this behavior. (multiple classloaders would, though) GreG On Jul 6, 2010, at 2:33 AM, "PAYET, Manuel" wrote: Looks like you have twice in your classpath the class ulb.mfe.srabre.ra.BREINTERFACE :) If I were you, I'd check that... -Message d'origine- De : rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] De la part de djerir smail Envoyé : lundi 5 juillet 2010 21:39 À : Rules Users List Objet : [rules-users] Problem Setting globals in drools session Hello everybody, When I try to sett my globals I get this error 2010-07-05 21:26:04,531 ERROR [STDERR] java.lang.RuntimeException: Illegal class for global. Expected [ulb.mfe.srabre.ra.BREINTERFACE], found [ulb.mfe.srabre.ra.BREINTERFACE]. Can anyone explain to me what does this error mean please . MY DRL FILE package ulb.mfe.srabre.rule import ulb.mfe.srabre.ra.BREINTERFACE; import ulb.mfe.srabre.ra.DROOLSSLEEAgent; global ulb.mfe.srabre.ra.BREINTERFACE BRERAInterface; global ulb.mfe.srabre.ra.DROOLSSLEEAgent DROOLSSLEEAgent; rule "MaxBtsAlarmrule" dialect "mvel" when $B : BREINTERFACE() then System.out.println(" HELLO "); end my code public void Insert(Object fact) { try{ KnowledgeSessionConfiguration sessConfig = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(); sessConfig.setOption(ClockTypeOption.get("pseudo")); StatefulKnowledgeSession session = knowledgeBase.newStatefulKnowledgeSession(); session.setGlobal("BRERAInterface", this.breinter); session.setGlobal("DROOLSSLEEAgent", this.droolssleeAgent); session.insert(this.breinter); System.out.println("Fact is now inserted"); session.fireAllRules(); } catch (Throwable t) { logger.info("sml couldn't set up a session"); t.printStackTrace(); } } ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Problem Setting globals in drools session
Does your application use multiple classloaders? It's possible for two instances with the same class definition to not have "equal" classes if the class is loaded twice from different classloaders. --- On Mon, 7/5/10, djerir smail <1983dje...@gmail.com> wrote: > From: djerir smail <1983dje...@gmail.com> > Subject: [rules-users] Problem Setting globals in drools session > To: "Rules Users List" > Date: Monday, July 5, 2010, 2:38 PM > Hello everybody, > > When I try to sett my globals I get this error > > 2010-07-05 21:26:04,531 ERROR [STDERR] > java.lang.RuntimeException: > Illegal class for global. Expected > [ulb.mfe.srabre.ra.BREINTERFACE], > found [ulb.mfe.srabre.ra.BREINTERFACE]. > > Can anyone explain to me what does this error mean please > . > > MY DRL FILE > > package ulb.mfe.srabre.rule > > import ulb.mfe.srabre.ra.BREINTERFACE; > import ulb.mfe.srabre.ra.DROOLSSLEEAgent; > > global ulb.mfe.srabre.ra.BREINTERFACE BRERAInterface; > global ulb.mfe.srabre.ra.DROOLSSLEEAgent DROOLSSLEEAgent; > > rule "MaxBtsAlarmrule" > dialect "mvel" > > when > > $B : BREINTERFACE() > then > System.out.println(" HELLO "); > end > > > > > my code > > > public void Insert(Object fact) { > try{ > KnowledgeSessionConfiguration > sessConfig = > KnowledgeBaseFactory.newKnowledgeSessionConfiguration(); > > sessConfig.setOption(ClockTypeOption.get("pseudo")); > StatefulKnowledgeSession > session = > knowledgeBase.newStatefulKnowledgeSession(); > > session.setGlobal("BRERAInterface", this.breinter); > > session.setGlobal("DROOLSSLEEAgent", this.droolssleeAgent); > session.insert(this.breinter); > System.out.println("Fact is now > inserted"); > session.fireAllRules(); > } catch (Throwable t) { > logger.info("sml couldn't set > up a session"); > t.printStackTrace(); > } > } > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Arden Syntax support in Drools / Guvnor?
The first one has a full grammar for parsing Arden syntax, which would be a good starting point for producing an Arden->drools compiler. Also, you could compile MLMs into java classes using the project as is and use the results of their processing in drools rules. It might be worth it to get IEEExplore access (I don't have it myself) to read that paper. The abstract describes translating Arden syntax to CLIPS (another rules based system like drools) so it should be easy to adapt what they did to drools. (You might try contacting the author directly.) --- On Sat, 7/3/10, Harry Simons wrote: > From: Harry Simons > Subject: Re: [rules-users] Arden Syntax support in Drools / Guvnor? > To: "Rules Users List" > Date: Saturday, July 3, 2010, 12:33 AM > I did run into the first one. But > thinking that Drools/Guvnor may nor > may not be able to edit the bytecode, I thought may be it's > better to > ask on the Drools forum. > > The second one... the paper... I'm not so sure from its > title and > abstract if it would help me. (Unfortunately, I don't also > have > IEEExplore access!) > > Basically, I'm looking for a way to *import* Arden MLMs > into > Drools/Guvnor, and then be able to modify them through a > GUI, much like > I would rules natively done in Drools/Guvnor. > > Thanks though, I will still check out the bytecode compiler > sometime. > > On 07/03/2010 10:15 AM, Greg Barton wrote: > > Have you seen this... > > > > http://github.com/dgrunwald/arden2bytecode > > > > ...and this? > > > > http://ieeexplore.ieee.org/Xplore/login.jsp?url=http%3A%2F%2Fieeexplore.ieee.org%2Fiel5%2F4548614%2F4548615%2F04548695.pdf%3Farnumber%3D4548695&authDecision=-203 > > > > --- On Fri, 7/2/10, HarrySimons > wrote: > > > > > >> From: HarrySimons > >> Subject: Re: [rules-users] Arden Syntax support in > Drools / Guvnor? > >> To: rules-users@lists.jboss.org > >> Date: Friday, July 2, 2010, 11:11 PM > >> > >> > >> Mark Proctor wrote: > >> > >>> On 02/07/2010 07:37, > HarrySimons > >>> > >> wrote: > >> > >>>> Hi, > >>>> > >>>> Wanted to know whether or not the > Drools/Guvnor > >>>> > >> combo supports the Arden > >> > >>>> Syntax for knowledge coding... used in > Medical > >>>> > >> Logic Modules (or, MLMs) > >> > >>>> and > >>>> clinical decision support systems such as > EGADSS. > >>>> > >>>> If no, then are there any external tools > / > >>>> > >> utilities that would allow > >> > >>>> importing of Arden Syntax into Drools / > Guvnor? > >>>> > >>> There is nothing for this at the moment, > sounds like a > >>> > >> good sub project > >> > >>> if you have time? :) > >>> > >>> Mark > >>> > >>> > >> Hey Mark - > >> First off, appreciate your prompt response. > >> Wish I had the time and, more importantly, the > brains to do > >> it! :-( > >> I guess, I'll have to wait then.. but hopefully > not > >> forever... for a more > >> qualified and braver comrade in our community... > to take > >> this project up. > >> > >> I do think that such a tool, if one were to exist, > would > >> greatly popularize > >> Drools in the clinical decision support systems > >> community... as the tons and > >> tons of legacy MLMs (Medical Logic Modules) coded > in the > >> past two decades > >> for use in CDSSs would instantly become available > for use > >> in the JBoss > >> world! > >> > >> Many thanks, once again... > >> > >> -- > >> View this message in context: > >> http://drools-java-rules-engine.46999.n3.nabble.com/Arden-Syntax-support-in-Drools-Guvnor-tp937924p940130.html > >> Sent from the Drools - User mailing list archive > at > >> Nabble.com. > >> ___ > >> rules-users mailing list > >> rules-users@lists.jboss.org > >> https://lists.jboss.org/mailman/listinfo/rules-users > >> > >> > > > > > > > > ___ > > rules-users mailing list > > rules-users@lists.jboss.org > > https://lists.jboss.org/mailman/listinfo/rules-users > > > > > ___ > rules-users mailing list > rules-users@lists.jboss.org > https://lists.jboss.org/mailman/listinfo/rules-users > ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users