Re: [rules-users] Problem with modify sentence
Hi Luis, The whole error message is the following: BuildError: Unable to build expression for 'consequence': Failed to compile: 1 compilation error(s): - (1,16) unqualified type in strict mode for: - 'modify ( rules ) { allowedGuesses -= 1 } System.out.println( Write a Letter:); br = new BufferedReader( new InputStreamReader( System.in ) ); l = br.readLine().toUpperCase(); System.out.println( l ); System.out.println( guess.guessedWord); guess.sayOneLetter(l); System.out.println( guess.guessedWord); System.out.println( guess.letters); 'hangman.drlHangman/src/main/rulesline 44Drools Error The rule code: rule Letter ruleflow-group Letter no-loop when rules : GameRules( allowedGuesses 0 ) guess : GuessedWord() then modify ( rules ) { allowedGuesses -= 1 } System.out.println( Write a Letter:); br = new BufferedReader( new InputStreamReader( System.in ) ); l = br.readLine().toUpperCase(); System.out.println( l ); System.out.println( guess.guessedWord); guess.sayOneLetter(l); System.out.println( guess.guessedWord); System.out.println( guess.letters); end Thank you, Kevin Luis Silva escribió: Hi Kevin, What is the error that you are getting? On Fri, Jun 5, 2009 at 2:47 AM, Kevin Alonso kalo...@vicomtech.org mailto:kalo...@vicomtech.org wrote: Hi all, I get a compilation error in a then part of the rule with the next sentence: modify ( rules ) { allowedGuesses -= 1 } This problem has appeared after update from 5.0 CR1 to Drools 5.0 final version. Is it a bug? Thank you, Kevin. ___ rules-users mailing list rules-users@lists.jboss.org mailto:rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Luis Enrique Silva Valdivieso Cel. 00 51 1 991546707 Casa 00 51 1 4476616 ___ 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] Rules storage in a database
Hello, we have stored rules in a database, and require to migrate the rules from say a development database to a test database, and further to a production database and use Guvnor for analysts to view current rules in the production database. Has anyone attempted this, and is there an appropriate deployment scenario for this? Has anyone attempted a similar deployment scenario? We have found that the tables that get created are not always the same - we have had 4 tables created in one environment, and 8 in another; what drives the table creation? Any documentation we can refer to? Would appreciate pointers. Krishna ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] ResourceChangeNotifier and subscribeResourceChangeListener()
Hi, maybe this helps: http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/html_single/index.html#d0e1123 Resource scanning is not on by default, it's a service and must be started, and the same is true for notification. Both can be done via the ResourceFactory. Have a look at Example 3.19. Starting the Scanning and Notification Services Cheers, Jarek Andrew Nguyen wrote: I am using Guvnor and have configured a change-set.xml to look towards http:///LATEST. I would like to add a listener to ResourceChangeNotifier that will respond to detected changes. I implemented the ResourceChangeListener interface and have added it via the subscribeResourceChangeListener() but my resourcesChanged() function never seems to be called. I'm wondering if my assumption and usage of everything is correct... Thanks, Andrew ___ 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] OR operator affects how many times Rule's action is executed
More simple example: package continuated_rules dialect mvel rule fire_twice no-loop true when eval(true) or eval(true) then System.out.println(word); end output is: word word why does it happens ? -- View this message in context: http://www.nabble.com/OR-operator-affects-how-many-times-Rule%27s-action-is-executed-tp23910106p23923259.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
RE: [rules-users] OR operator affects how many times Rule's actionis executed
I believe the answer is that Drools implements sub-rule compilation for rules containing or. So in essence your rulebase contains the following once compiled:- rule fire_twice_a no-loop true when eval(true) then System.out.println(word); end rule fire_twice_b no-loop true when eval(true) then System.out.println(word); end -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of sergey.olifirenko Sent: 08 June 2009 13:39 To: rules-users@lists.jboss.org Subject: Re: [rules-users] OR operator affects how many times Rule's actionis executed More simple example: package continuated_rules dialect mvel rule fire_twice no-loop true when eval(true) or eval(true) then System.out.println(word); end output is: word word why does it happens ? -- View this message in context: http://www.nabble.com/OR-operator-affects-how-many-times-Rule%27s-action -is-executed-tp23910106p23923259.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] Timestamp for processing Historical Data
Hi, I had a chance to go through the fusion sample. I tried the same example with another logfile as input Input: 1000 critical Symantec 5000 critical Symantec 6000 critical Symantec Here I set the timestamp as ( some date in the past + first column of the input). * Following is the simple DRL which has the rule to count number of OMTicket using sliding window. package* org.drools.examples.broker; * import* org.drools.examples.broker.model.OMTicket; * dialect* mvel * declare* OMTicket @role( event ) @timestamp (timestamp) @expires (1h) * end* * rule* Count over last 5 seconds * salience* 10 * no-loop* *true when * Number( $count : intValue ) *from* *accumulate* ( OMTicket($severity:severity) over window:time(5s) *from* entry-point OM stream, count() ) * then* System.out.println(Number of Critical Tickets over last 5 seconds : + $count); *end* Here, I just read and insert facts as events with no scheduling. But the ouput varies for each invocation and it is also not as expected. Am I missing any configuration here? ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Re: Timestamp for processing Historical Data
I can't say for sure that the results are right or wrong, because when time is involved, a lot of things must be taken in consideration. So, assuming you are using the fusion example as is, with the only difference that you are using your input/rules, meaning specifically that you are using the event feeder, knowledge base configured to stream mode and real time session clock, it is necessary to check what is discrepant between the results. Please note that since the engine is running in near-realtime as well as event feeders are running in near-realtime, you might have interferences from threads and processes running in the same machine. In other words, for your 3 inputs bellow and a time-window of 5 seconds, I would not be surprised if sometimes events 1 and 3 are reported in the same window and sometimes they don't since each one of them sit at one of the edges of the window. I would be concerned if events 2 and 3 are not in the same window and unless your machine is swapping or heavily loaded, events 1 and 2 should also be reported in the same window. If you want to test the actual algorithm with extreme precision, the only way I know is using the PSEUDO_CLOCK, so that the application can completely control the time flow with discrete advances. If the above is not what you are seeing, please give more details. Thank you, Edson 2009/6/8 PriyaSha nash.8...@gmail.com Hi, I had a chance to go through the fusion sample. I tried the same example with another logfile as input Input: 1000 critical Symantec 5000 critical Symantec 6000 critical Symantec Here I set the timestamp as ( some date in the past + first column of the input). * Following is the simple DRL which has the rule to count number of OMTicket using sliding window. package * org.drools.examples.broker; * import * org.drools.examples.broker.model.OMTicket; * dialect * mvel * declare * OMTicket @role( event ) @timestamp (timestamp) @expires (1h) * end * * rule * Count over last 5 seconds* salience * 10* no-loop * *true when * Number( $count : intValue ) *from* *accumulate* ( OMTicket($severity:severity) over window:time(5s) *from* entry-point OM stream, count() )* then * System.out.println( Number of Critical Tickets over last 5 seconds : + $count); *end* Here, I just read and insert facts as events with no scheduling. But the ouput varies for each invocation and it is also not as expected. Am I missing any configuration here? -- Edson Tirelli JBoss Drools Core Development JBoss, a division of Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] OR operator affects how many times Rule's actionis executed
Correct. This is explained in the manual. All production rules rete-based engines work like this, executing the rule consequence once for each logical branch. []s Edson 2009/6/8 Anstis, Michael (M.) manst...@ford.com I believe the answer is that Drools implements sub-rule compilation for rules containing or. So in essence your rulebase contains the following once compiled:- rule fire_twice_a no-loop true when eval(true) then System.out.println(word); end rule fire_twice_b no-loop true when eval(true) then System.out.println(word); end -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of sergey.olifirenko Sent: 08 June 2009 13:39 To: rules-users@lists.jboss.org Subject: Re: [rules-users] OR operator affects how many times Rule's actionis executed More simple example: package continuated_rules dialect mvel rule fire_twice no-loop true when eval(true) or eval(true) then System.out.println(word); end output is: word word why does it happens ? -- View this message in context: http://www.nabble.com/OR-operator-affects-how-many-times-Rule%27s-action -is-executed-tp23910106p23923259.htmlhttp://www.nabble.com/OR-operator-affects-how-many-times-Rule%27s-action%0A-is-executed-tp23910106p23923259.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, a division of Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Templates / Generated rules debugging
Hi, Can some of your share your technique for debugging/troubleshooting rules: Here is the situation: - I have a web application that uses rules at specific points. - I use templates and decision tables so the actual rules are compiled by my application using a spread sheet compiler. - Since this is a web application, I cannot debug the rules in Eclipse (unless I am missing something) I must not be the only one asking this question but I cannot find answers in the archives. Thanks, André Malenfant ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Strange situation when defining arrays in Drools 5
Last friday, I had the next situation. In drools 4.0.7 I had the expression: new double[]{-1, 1} And it worked. But in Drools 5.0 I had to erase the blank space (before 1 and after ,), because I was getting a warning message, during knowledge base building : line 29:114 extraneous input '1' expecting RIGHT_CURLY and an exception, during rule execution : org.drools.runtime.rule.ConsequenceException: java.lang.IndexOutOfBoundsException So the working expression for Drool 5.0 was: new double[]{-1,1} -- Luis Enrique Silva Valdivieso ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Templates / Generated rules debugging
- Since this is a web application, I cannot debug the rules in Eclipse (unless I am missing something) You are missing something. :-) That's possible. However we have found regular debuggers not to helpful. Have a look at the WorkingMemoryLoggers, they can give you a detailed insight of what's going on inside Drools, ie. * Facts inserted, changed, retracted * Activations * Rules fired 4.0.7: http://downloads.jboss.com/drools/docs/4.0.7.19894.GA/apidocs/org/drools/audit/WorkingMemoryFileLogger.html (The Drools Eclipse Plugin can be used to view these logs). To be useful, this requires a usable toString, we have created those using apache commmons-lang. Happy hunting! -- Ingomar Am 08.06.2009 um 17:46 schrieb Malenfant, Andre: Hi, Can some of your share your technique for debugging/troubleshooting rules: Here is the situation: - I have a web application that uses rules at specific points. - I use templates and decision tables so the actual rules are compiled by my application using a spread sheet compiler. - Since this is a web application, I cannot debug the rules in Eclipse (unless I am missing something) I must not be the only one asking this question but I cannot find answers in the archives. Thanks, André Malenfant ___ 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] Templates / Generated rules debugging
Is it possible to see the generated Java code for the rules? -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Ingomar Otter Sent: Monday, June 08, 2009 12:00 PM To: Rules Users List Subject: Re: [rules-users] Templates / Generated rules debugging - Since this is a web application, I cannot debug the rules in Eclipse (unless I am missing something) You are missing something. :-) That's possible. However we have found regular debuggers not to helpful. Have a look at the WorkingMemoryLoggers, they can give you a detailed insight of what's going on inside Drools, ie. * Facts inserted, changed, retracted * Activations * Rules fired 4.0.7: http://downloads.jboss.com/drools/docs/4.0.7.19894.GA/apidocs/org/drools/audit/WorkingMemoryFileLogger.html (The Drools Eclipse Plugin can be used to view these logs). To be useful, this requires a usable toString, we have created those using apache commmons-lang. Happy hunting! -- Ingomar Am 08.06.2009 um 17:46 schrieb Malenfant, Andre: Hi, Can some of your share your technique for debugging/troubleshooting rules: Here is the situation: - I have a web application that uses rules at specific points. - I use templates and decision tables so the actual rules are compiled by my application using a spread sheet compiler. - Since this is a web application, I cannot debug the rules in Eclipse (unless I am missing something) I must not be the only one asking this question but I cannot find answers in the archives. Thanks, André Malenfant ___ 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] Templates / Generated rules debugging
Yes, check this out: http://blog.athico.com/2008/02/looking-under-drools-skirt.html Am 08.06.2009 um 18:34 schrieb Malenfant, Andre: Is it possible to see the generated Java code for the rules? -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org ] On Behalf Of Ingomar Otter Sent: Monday, June 08, 2009 12:00 PM To: Rules Users List Subject: Re: [rules-users] Templates / Generated rules debugging - Since this is a web application, I cannot debug the rules in Eclipse (unless I am missing something) You are missing something. :-) That's possible. However we have found regular debuggers not to helpful. Have a look at the WorkingMemoryLoggers, they can give you a detailed insight of what's going on inside Drools, ie. * Facts inserted, changed, retracted * Activations * Rules fired 4.0.7: http://downloads.jboss.com/drools/docs/4.0.7.19894.GA/apidocs/org/drools/audit/WorkingMemoryFileLogger.html (The Drools Eclipse Plugin can be used to view these logs). To be useful, this requires a usable toString, we have created those using apache commmons-lang. Happy hunting! -- Ingomar Am 08.06.2009 um 17:46 schrieb Malenfant, Andre: Hi, Can some of your share your technique for debugging/troubleshooting rules: Here is the situation: - I have a web application that uses rules at specific points. - I use templates and decision tables so the actual rules are compiled by my application using a spread sheet compiler. - Since this is a web application, I cannot debug the rules in Eclipse (unless I am missing something) I must not be the only one asking this question but I cannot find answers in the archives. Thanks, André Malenfant ___ 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] Templates / Generated rules debugging
Yes, check the PackageBuilderConfiguration class for the method setDumpDir(). Please note that drools generates and compile files in memory, so after you stop debugging, remember to turn this option off again to not consume unnecessary IO time. Also, the java code is usually not much helpful. Best to use the loggers as suggested by Ingomar. []s Edson 2009/6/8 Malenfant, Andre andre.malenf...@cgi.com Is it possible to see the generated Java code for the rules? -Original Message- From: rules-users-boun...@lists.jboss.org [mailto: rules-users-boun...@lists.jboss.org] On Behalf Of Ingomar Otter Sent: Monday, June 08, 2009 12:00 PM To: Rules Users List Subject: Re: [rules-users] Templates / Generated rules debugging - Since this is a web application, I cannot debug the rules in Eclipse (unless I am missing something) You are missing something. :-) That's possible. However we have found regular debuggers not to helpful. Have a look at the WorkingMemoryLoggers, they can give you a detailed insight of what's going on inside Drools, ie. * Facts inserted, changed, retracted * Activations * Rules fired 4.0.7: http://downloads.jboss.com/drools/docs/4.0.7.19894.GA/apidocs/org/drools/audit/WorkingMemoryFileLogger.html (The Drools Eclipse Plugin can be used to view these logs). To be useful, this requires a usable toString, we have created those using apache commmons-lang. Happy hunting! -- Ingomar Am 08.06.2009 um 17:46 schrieb Malenfant, Andre: Hi, Can some of your share your technique for debugging/troubleshooting rules: Here is the situation: - I have a web application that uses rules at specific points. - I use templates and decision tables so the actual rules are compiled by my application using a spread sheet compiler. - Since this is a web application, I cannot debug the rules in Eclipse (unless I am missing something) I must not be the only one asking this question but I cannot find answers in the archives. Thanks, André Malenfant ___ 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 -- Edson Tirelli JBoss Drools Core Development JBoss, a division of Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
RE: [rules-users] Templates / Generated rules debugging
Perfect! B.T.W. I realized I can debug if I have drools sources and add a breakpoint at a strategic spot... Thanks -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Ingomar Otter Sent: Monday, June 08, 2009 12:47 PM To: Rules Users List Subject: Re: [rules-users] Templates / Generated rules debugging Yes, check this out: http://blog.athico.com/2008/02/looking-under-drools-skirt.html Am 08.06.2009 um 18:34 schrieb Malenfant, Andre: Is it possible to see the generated Java code for the rules? -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org ] On Behalf Of Ingomar Otter Sent: Monday, June 08, 2009 12:00 PM To: Rules Users List Subject: Re: [rules-users] Templates / Generated rules debugging - Since this is a web application, I cannot debug the rules in Eclipse (unless I am missing something) You are missing something. :-) That's possible. However we have found regular debuggers not to helpful. Have a look at the WorkingMemoryLoggers, they can give you a detailed insight of what's going on inside Drools, ie. * Facts inserted, changed, retracted * Activations * Rules fired 4.0.7: http://downloads.jboss.com/drools/docs/4.0.7.19894.GA/apidocs/org/drools/audit/WorkingMemoryFileLogger.html (The Drools Eclipse Plugin can be used to view these logs). To be useful, this requires a usable toString, we have created those using apache commmons-lang. Happy hunting! -- Ingomar Am 08.06.2009 um 17:46 schrieb Malenfant, Andre: Hi, Can some of your share your technique for debugging/troubleshooting rules: Here is the situation: - I have a web application that uses rules at specific points. - I use templates and decision tables so the actual rules are compiled by my application using a spread sheet compiler. - Since this is a web application, I cannot debug the rules in Eclipse (unless I am missing something) I must not be the only one asking this question but I cannot find answers in the archives. Thanks, André Malenfant ___ 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] Weighted rules / scoring
Hi, Don't think I intended to create a new instance, just modify the one matched in the rule. The following seems to have got it working. rule Myscoreincreaserule dialect mvel when a : Applicant( name == chris ) then a.setScore( a.score + 2 ); end Thanks for pointing me in the right direction. Greg Barton wrote: 1) Where is the variable score initialized? If it's not a global the rule wouldn't compile. 2) Is your intent to create a new Applicant instance, or modify the one matched in the rule? (Or maybe you want to gather the score from the matched instance and put it (+2) into a new instance? --- On Sun, 6/7/09, Chris Strachan chris.st...@googlemail.com wrote: From: Chris Strachan chris.st...@googlemail.com Subject: [rules-users] Weighted rules / scoring To: rules-users@lists.jboss.org Date: Sunday, June 7, 2009, 1:11 PM Hi, I want to be able to use drools / guvnor brms to store weighted rules (scoring), however I can't seem to find a way to do this. I attempted the following, rule Myscoreincreaserule dialect mvel when Applicant( name == chris ) then Applicant fact0 = new Applicant(); fact0.setScore( score + 2 ); insert(fact0 ); end drools didn't seem to like the way I did this. Perhaps this isn't permitted, in effect I am trying to do - score = score + 2. Upon validation I get the following error. [Myscoreincreaserule] Unable to build expression for 'consequence': Failed to compile: 1 compilation error(s): - (1,3) unqualified type in strict mode for: age ' Applicant fact0 = new Applicant(); fact0.setScore( score + 2 ); insert(fact0 ); ' Any ideas on how I should be approaching this? Thanks, -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
Re: [rules-users] Weighted rules / scoring
I think your issue is resolved Chris, but just curious would putting the rule like below make it more efficient? rule Myscoreincreaserule dialect mvel when a : Applicant( name == chris,$score:score ) then a.setScore( $score + 2 ); end --Sarish Shoot for the moon. Even if you miss it you will land among the stars. - Les Brown On Mon, Jun 8, 2009 at 11:06 AM, Chris Strachan chris.st...@googlemail.comwrote: Hi, Don't think I intended to create a new instance, just modify the one matched in the rule. The following seems to have got it working. rule Myscoreincreaserule dialect mvel when a : Applicant( name == chris ) then a.setScore( a.score + 2 ); end Thanks for pointing me in the right direction. Greg Barton wrote: 1) Where is the variable score initialized? If it's not a global the rule wouldn't compile. 2) Is your intent to create a new Applicant instance, or modify the one matched in the rule? (Or maybe you want to gather the score from the matched instance and put it (+2) into a new instance? --- On Sun, 6/7/09, Chris Strachan chris.st...@googlemail.com wrote: From: Chris Strachan chris.st...@googlemail.com Subject: [rules-users] Weighted rules / scoring To: rules-users@lists.jboss.org Date: Sunday, June 7, 2009, 1:11 PM Hi, I want to be able to use drools / guvnor brms to store weighted rules (scoring), however I can't seem to find a way to do this. I attempted the following, rule Myscoreincreaserule dialect mvel when Applicant( name == chris ) then Applicant fact0 = new Applicant(); fact0.setScore( score + 2 ); insert(fact0 ); end drools didn't seem to like the way I did this. Perhaps this isn't permitted, in effect I am trying to do - score = score + 2. Upon validation I get the following error. [Myscoreincreaserule] Unable to build expression for 'consequence': Failed to compile: 1 compilation error(s): - (1,3) unqualified type in strict mode for: age ' Applicant fact0 = new Applicant(); fact0.setScore( score + 2 ); insert(fact0 ); ' Any ideas on how I should be approaching this? Thanks, -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 ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
RE: [rules-users] Timer does not return!
Thanks for the sample code Kris. It seems that the problem is not with the Timer itself, but with WorkItemHadler ! (Complete code - extended version of your code - is attached). Adding a Log work item between START and the first Action breaks the code. If I remove the Log item, the flow works as expected. Here is the code that runs in executeWorkItem: logger.info(=== message from flow === + workItem.getParameter(Message)); manager.completeWorkItem(workItem.getId(), null); logger.info(Work item completed!); the 2nd log message is not displayed! Any ideas what am I doing wrong? Second issue: The process does not end! - I took Kris's code and ran it. Even after the work flow completed, the process was still alive! (End Node's Terminate Property *is* set to true). Thanks Ajay -Original Message- From: Kris Verlaenen [mailto:kris.verlae...@cs.kuleuven.be] Sent: Friday, June 05, 2009 5:08 PM To: Rules Users List; Gautam, Ajay, GBM Cc: rules-users@lists.jboss.org Subject: Re: [rules-users] Timer does not return! It's difficult to figure out what's going on without looking at the process itself, but your code seems to be fine. If you run the engine in reactive mode (using fireUntilHalt), it should automatically fire the action associated with the timer once it goes off. Note that, if you are not running in reactive mode, the timer is also triggered (it doesn't just run through), but it'll wait to execute the associated action until fireAllRules is called. For example, this simple process is a timer followed by an action writing out when the timer is being triggered. ?xml version=1.0 encoding=UTF-8? process xmlns=http://drools.org/drools-5.0/process; xmlns:xs=http://www.w3.org/2001/XMLSchema-instance; xs:schemaLocation=http://drools.org/drools-5.0/process drools-processes-5.0.xsd type=RuleFlow name=ruleflow id=com.sample.ruleflow package-name=com.sample header /header nodes start id=1 name=Start x=16 y=16 width=80 height=40 / timerNode id=4 name=Timer x=128 y=16 width=80 height=40 delay=2000 / actionNode id=2 name=Action x=240 y=16 width=80 height=40 action type=expression dialect=mvel System.out.println(Executing);/action /actionNode end id=3 name=End x=352 y=16 width=80 height=40 / /nodes connections connection from=1 to=4 / connection from=4 to=2 / connection from=2 to=3 / /connections /process By using the following code, the action is written out immediately when the timer triggers (after 2 seconds): public static final void main(String[] args) { try { // load up the knowledge base KnowledgeBase kbase = readKnowledgeBase(); final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); new Thread(new Runnable() { public void run() { ksession.fireUntilHalt(); } }).start(); // start a new process instance ksession.startProcess(com.sample.ruleflow); } catch (Throwable t) { t.printStackTrace(); } } The following code doesn't use reactive mode, so the action associated with the timer is only triggered during the next fireAllRules (after 4 seconds). public static final void main(String[] args) { try { // load up the knowledge base KnowledgeBase kbase = readKnowledgeBase(); final StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); // start a new process instance ksession.startProcess(com.sample.ruleflow); Thread.sleep(4000); ksession.fireAllRules(); } catch (Throwable t) { t.printStackTrace(); } } Hope this clears up the situation a little more. If you still have problems integrating timers in your process, could you send a standalone example (containing both the process xml and the Java code)? Thx, Kris Quoting ajay.gau...@rbs.com: I have a timer in my code that does not return. It just hangs the process (with no CPU activity). Any idea what may be causing this? The timer delay is 2000 ms. Based on the docs, here are code snippets: ... ksession = kbase.newStatefulKnowledgeSession(); new Thread(new Runnable() { public void run() { ksession.fireUntilHalt(); } }).start(); final RFQRequest req = createRequest(); parameters.put(rfqIn, req); ksession.setGlobal(reqTag, req.getTag()); ksession.startProcess(com.rbs.gbm.pm.RFQ-WorkFlow, parameters); If I remove the fireUntilHalt thread, the timer is not triggered at all. The flow just passes through it lilke its not even there. Any help / info / pointers will be appreciated. Thanks Ajay *Please note that my email address may have changed. For all future correspondence, please use this address* This message (including any attachments) is confidential and/or privileged. It is to be used by
[rules-users] Globals in ruleflow
I am experimenting with rule flows and I get the following error: Unexpected global [myglobal] When calling setGlobal on the session. This code works without the workflow (globals declared in the drl) but fails when I include the rule flow. I declared the same globals in the rule flow in the header section. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Weighted rules / scoring
Don't forget that if you want other rules to react to the changed score you must call update() on the altered object: rule Myscoreincreaserule dialect mvel when a : Applicant( name == chris) then a.setScore( a.score + 2 ); update( a ); end --- On Mon, 6/8/09, Chris Strachan chris.st...@googlemail.com wrote: From: Chris Strachan chris.st...@googlemail.com Subject: Re: [rules-users] Weighted rules / scoring To: Rules Users List rules-users@lists.jboss.org Date: Monday, June 8, 2009, 1:06 PM Hi, Don't think I intended to create a new instance, just modify the one matched in the rule. The following seems to have got it working. rule Myscoreincreaserule dialect mvel when a : Applicant( name == chris ) then a.setScore( a.score + 2 ); end Thanks for pointing me in the right direction. Greg Barton wrote: 1) Where is the variable score initialized? If it's not a global the rule wouldn't compile. 2) Is your intent to create a new Applicant instance, or modify the one matched in the rule? (Or maybe you want to gather the score from the matched instance and put it (+2) into a new instance? --- On Sun, 6/7/09, Chris Strachan chris.st...@googlemail.com wrote: From: Chris Strachan chris.st...@googlemail.com Subject: [rules-users] Weighted rules / scoring To: rules-users@lists.jboss.org Date: Sunday, June 7, 2009, 1:11 PM Hi, I want to be able to use drools / guvnor brms to store weighted rules (scoring), however I can't seem to find a way to do this. I attempted the following, rule Myscoreincreaserule dialect mvel when Applicant( name == chris ) then Applicant fact0 = new Applicant(); fact0.setScore( score + 2 ); insert(fact0 ); end drools didn't seem to like the way I did this. Perhaps this isn't permitted, in effect I am trying to do - score = score + 2. Upon validation I get the following error. [Myscoreincreaserule] Unable to build expression for 'consequence': Failed to compile: 1 compilation error(s): - (1,3) unqualified type in strict mode for: age ' Applicant fact0 = new Applicant(); fact0.setScore( score + 2 ); insert(fact0 ); ' Any ideas on how I should be approaching this? Thanks, -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 ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users