Re: [rules-users] Validation flow - defer expression evaluation
putting $var: user.?manager.name to avoid nullpointer in the business rule defeats the purpose of a sanity check upfront, as execution should fail if the relation is empty. Nullpointers are not an elegant way to fail, and the stack trace gives no clue in which rule the error occurred. I was thinking of starting a seperate session to run validation. This is cumbersome however, en I would like to find a way to solve this problem with a process(rule) flow. I guess it's about rule activation occuring. Is there a way to activate the business rules only when validation rules have passed? I will try starting a subprocess, and see if this activates the business rules at the appropriate time in the flow. Any suggestions to avoid this trial and error approach are most welcome. -- View this message in context: http://drools.46999.n3.nabble.com/Validation-flow-defer-expression-evaluation-tp3447883p3450736.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] Rule, import with wildcards and variable / patternBinding
Hello, Yesterday I wanted to upgrade my drools version to 5.3 (from 5.1). I got the exception java.lang.NoClassDefFoundError: de/pelle7/testpackage/event/myEvent (wrong name: de/pelle7/testpackage/event/MyEvent) while adding my resources. I removed the import wildcards and the error disappeard. Finally I found the problem: I used the patternBinding 'myEvent' and there is a class called 'MyEvent' and I used an wildcard import where the class 'MyEvent' is located. Example code: package de.pelle7.testrules.impl.drools import de.pelle7.testpackage.event.* rule Test rule 1 dialect java salience 50 when myEvent : MyEvent( ) myEvent2 : MyEvent( data == myEvent.data ) -- here the Exception is thrown then System.err.println(Output); end My solution is that I replaced all my pattern bindings with the suffix '$' which is more convenient. Perhaps it would be nice to produce an rule-compilation error. with a line notice. Regard, Per Sterner ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] 5.3.0.Final resource change scanner bug
This has been already reported: https://bugzilla.redhat.com/show_bug.cgi?id=741219 https://bugzilla.redhat.com/show_bug.cgi?id=741287 This happens for Guvnor's PKG, XLS, DRF and I guess CSV too. You'll find test cases there. Jiri Svitak On 10/25/2011 12:07 AM, Michael Anstis wrote: Thanks Lisa, I appreciate it is a pain for you but your help is much appreciated. sent on the move On 24 Oct 2011 23:03, lhorton lhor...@abclegal.com mailto:lhor...@abclegal.com wrote: Yes, all compile ok without change set (our tests compile the rules in code, but our server compiles using knowledge agent). I had to roll everything back to 5.2 for our developers, but I'll find some time tomorrow to try things out with 5.3 again. I'll see if I can narrow it down to specific file(s) that fail compilation. -- View this message in context: http://drools.46999.n3.nabble.com/5-3-0-Final-resource-change-scanner-bug-tp3449420p3449655.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org mailto: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] Validation flow - defer expression evaluation
Hi, I have added a subprocess to the flow, but the exception still occurs: Caused by: [Error: null pointer or function not found: getName] [Near : {... manager.getName().equals(tes }] Would anyone have suggestions or know about best practices for handling this kind of scenario? Thanks -- View this message in context: http://drools.46999.n3.nabble.com/Validation-flow-defer-expression-evaluation-tp3447883p3450960.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
Re: [rules-users] Why this rule fires immediately ?
Hi W et al., I came up with a following solution. One reason why I came up with this kind of solution is that it is not firing every time when there comes a temperature reading (ZZZBean) in the system (working memory). Would you comment if this solution is viable and if there are any pitfalls ? It seems to work all right, though. Rules involved: TemperatureOver30_settracker Update_tracker_count TemperatureOver30_setalarm TemperatureOver40_setalarm TemprOver30_launch TemprOver40_launch Kill_tracker The tracker is set when get a temperature reading 30 (TemperatureOver30_settracker). Every subsequent reading is added to tracker's internal list and retracted from working memory (update_tracker_count). Alarm30 is set if average reading from tracker's list is in range 30 and 40. Also tracker is retracted (TemperatureOver30_setalarm). Alarm40 is set if average reading from tracker's list is over 40. Also tracker is retracted (TemperatureOver40_setalarm). Intelligent action is launched if Alarm30 is detected, alarm is rectracted (TemprOver30_launch). Another kind of intelligent action is launched if alarm40 is detected, alarm is retracted (TemprOver40_launch). Tracker is retracted if there are over a number of readings (here 10) in tracker's internal list (Kill_tracker), which infers that the average temperature is 30. Sensor readings and tracker are declared as events, alarms are facts. The saliences are not final, I would like to get comments on that too. rule TemperatureOver30_settracker dialect mvel no-loop true salience 150 when $tsb : ZZZBean(temperature 30 40) not TOver30Tracker(profileID == $tsb.profileID) then TOver30Tracker $tracker = new TOver30Tracker(); $tracker.profileID = $tsb.profileID; $tracker.level = 1; retract($tsb); $tracker.sensorBean = $tsb; $tracker.addSensorBean($tsb); insert($tracker); end rule Update_tracker_count dialect mvel no-loop true salience 100 when $tracker : TOver30Tracker() $tsb : ZZZBean(profileID == $tracker.profileID, this after $tracker) then drools.retract($tsb); $tracker.addSensorBean($tsb); $tracker.count = $tracker.count + 1; drools.update($tracker); end rule TemperatureOver30_setalarm dialect mvel no-loop true salience 50 when $tracker : TOver30Tracker(count == 5, $prof : profileID) $avg : Number(floatValue 30 40) from accumulate( ZZZBean( $tempr : temperature, profileID == $prof) over window:length( 5 ) from $tracker.beanList, average( $tempr ) ) then retract($tracker); TOver30Alarm $alarm = new TOver30Alarm(); $alarm.profileID = $prof; $alarm.sensorBean = $tracker.sensorBean; $alarm.sensorBean.temperature = $avg; insert($alarm); end rule TemperatureOver40_setalarm dialect mvel no-loop true salience 50 when $tracker : TOver30Tracker(count == 5, $prof : profileID) $avg : Number(floatValue 40) from accumulate( ZZZBean( $tempr : temperature, profileID == $prof) over window:length( 5 ) from $tracker.beanList, average( $tempr ) ) then retract($tracker); TOver40Alarm $alarm = new TOver40Alarm(); $alarm.profileID = $prof; $alarm.sensorBean = $tracker.sensorBean; insert($alarm); end rule TemprOver30_launch dialect mvel no-loop true when $alarm : TOver30Alarm($prof : profileID) then retract($alarm); // Intelligent action goes here end rule TemprOver40_launch dialect mvel no-loop true when $alarm : TOver40Alarm($prof : profileID) then retract($alarm); // Intelligent action goes here end rule Kill_tracker dialect mvel no-loop true salience 999 when $tracker : TOver30Tracker(count 10) then retract($tracker); end Best Regards, Esko - Esko Hujanen www.ebsolut.fi -- View this message in context: http://drools.46999.n3.nabble.com/Why-this-rule-fires-immediately-tp3430427p3451005.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] [planner][5.3.0.Final] Benchmark
I'm trying to upgrade from drools 5.2.0 to 5.3.0 and having some difficulties with the planner benchmark. I'd like to make a set of move factories common to all local search solvers, by adding them to inheritedSolverBenchmark block. But it seems that the localSearch environment always requires a selector, so I can't specify the localSearch environment for the solverBenchmark's without providing a selector. Here's a piece of code that gives runtime error: http://paste.ubuntu.com/718806/ The error is: Exception in thread main java.lang.IllegalArgumentException: A selector requires configuration, for example a moveFactoryClass. --- Note --- If I understood correcly, the following configuration from examination examples: examinationStepLimitSolverBenchmarkConfig.xml contains a bug, because it specifies a maximum step count for a general solver termination maximumStepCount70/maximumStepCount /termination This gave the following exception: Exception in thread main java.lang.UnsupportedOperationException: StepCountTermination can only be used for phase termination. Thanks, ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Rule, import with wildcards and variable / patternBinding
Per, This looks like a bug. Can you please open a JIRA for it with the information on this e-mail? Thank you, Edson 2011/10/25 Per Sterner pelle...@yahoo.de Hello, Yesterday I wanted to upgrade my drools version to 5.3 (from 5.1). I got the exception java.lang.NoClassDefFoundError: de/pelle7/testpackage/event/myEvent (wrong name: de/pelle7/testpackage/event/MyEvent) while adding my resources. I removed the import wildcards and the error disappeard. Finally I found the problem: I used the patternBinding 'myEvent' and there is a class called 'MyEvent' and I used an wildcard import where the class 'MyEvent' is located. Example code: package de.pelle7.testrules.impl.drools import de.pelle7.testpackage.event.* rule Test rule 1 dialect java salience 50 when myEvent : MyEvent( ) myEvent2 : MyEvent( data == myEvent.data ) -- here the Exception is thrown then System.err.println(Output); end My solution is that I replaced all my pattern bindings with the suffix '$' which is more convenient. Perhaps it would be nice to produce an rule-compilation error. with a line notice. Regard, Per Sterner ___ 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
Re: [rules-users] WorkingMemoryLogger + statelessSessions = memory leak?
Anybody? From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Swindells, Thomas Sent: 21 October 2011 14:49 To: Rules Users List (rules-users@lists.jboss.org) Subject: [rules-users] WorkingMemoryLogger + statelessSessions = memory leak? Hi everyone, I believe that there is a memory leak when using WorkingMemoryLoggers with statelessSessions. This was raised against 5.1.1 but I think it will still exist in the latest as well. Our code basically has the following pattern: KnowledgeBase kb ==; while(nextEvent()) { StatelessKnowledgeSession session = kb.newStatelessKnowledgeSession(); auditor = new WorkingMemoryInMemoryLogger(session); session.execute(getEvent()); dumpAuditLog(auditor); session = null; //no dispose it's stateless } We were getting Out of Memory Exception on site and the stack dump showed a high number of MemoryLoggers on the heap. Having a look at the code I think the problem is in the WorkingMemoryLogger constructor: } else if (session instanceof StatelessKnowledgeSessionImpl) { ((StatelessKnowledgeSessionImpl) session).workingMemoryEventSupport.addEventListener( this ); ((StatelessKnowledgeSessionImpl) session).agendaEventSupport.addEventListener( this ); ((StatelessKnowledgeSessionImpl) session).ruleFlowEventSupport.addEventListener( this ); ((StatelessKnowledgeSessionImpl) session).getRuleBase().addEventListener( this ); } The last statement gets the knowledge base and attaches the event listener to it. As far as I can see there is no way to dispose of the WorkingMemoryLogger and you don't dispose stateless sessions (and it doesn't know about the listener anyway). This means that even after the session is gone the rule base still has a reference to the logger. The work around is to make the logger a singleton and clear it in each loop rather than creating a new one each time, however this obviously doesn't scale to multiple threads. Have I missed some fundamental in the api or should I raise a Jira for this? 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.commailto: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] [drools planner 5.3.0 Final] cached planning values
I get the following exception when i try to solve and don't know if i didn't set something properly on my side or if there is a bug in the planner. After debugging, seems like cachedPlanningValues in PlanningValueCreator is being created as an empty collection and when PlanningValueWalker gets cachedPlanningValues's iterator and tries to iterate through it then it gets a NoSuchElementException. I am a little confused as to when the extractPlanningValues method is called in PlanningValueSelector to get a collection of planned values a null is begin passed in instead of a planning entity which is responsible for the empty cachedPlanningValues collection. Any help on this issue will be much appreciated. java.util.NoSuchElementException at java.util.AbstractList$SimpleListIterator.next(AbstractList.java:61) at org.drools.planner.core.heuristic.selector.variable.PlanningValueWalker.initWalk(PlanningValueWalker.java:90) at org.drools.planner.core.heuristic.selector.variable.PlanningVariableWalker.initWalk(PlanningVariableWalker.java:104) at org.drools.planner.core.constructionheuristic.greedyFit.decider.DefaultGreedyDecider.decideNextStep(DefaultGreedyDecider.java:58) at org.drools.planner.core.constructionheuristic.greedyFit.DefaultGreedyFitSolverPhase.solve(DefaultGreedyFitSolverPhase.java:62) at org.drools.planner.core.solver.DefaultSolver.runSolverPhases(DefaultSolver.java:166) at org.drools.planner.core.solver.DefaultSolver.solve(DefaultSolver.java:138) -- View this message in context: http://drools.46999.n3.nabble.com/drools-planner-5-3-0-Final-cached-planning-values-tp3452270p3452270.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] Drools 5.3.0 Dependencies
Hi, I was using drools 5.2.0 in my grails 2.0.0.M2 application. I use Drools expert to execute a .drl file I have. The three dependencies that I have set up for this to work was: runtime 'org.drools:drools-core:5.2.0.Final' runtime 'org.drools:drools-compiler:5.2.0.Final' runtime 'com.sun.xml.bind:jaxb-xjc:2.2.4' However when I switched to drools 5.3.0. The rules are not getting executed or there are some problems. There is no stacktrace or log. I have no idea what is going on. My guess is that some of the dependency jars or classes are missing. Any insight into this? Thanks, Abdul -- View this message in context: http://drools.46999.n3.nabble.com/Drools-5-3-0-Dependencies-tp3452346p3452346.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
Re: [rules-users] Drools 5.3.0 Dependencies
I assume you replaced both drools-core and drools-compiler with those for 5.3? Furthermore, you should endeavour to use knowledge-api which contains the public API. Can you isolate the rules from grail, to understand if it is an integration issue too? On 25 October 2011 20:04, arrehman arrehma...@yahoo.com wrote: Hi, I was using drools 5.2.0 in my grails 2.0.0.M2 application. I use Drools expert to execute a .drl file I have. The three dependencies that I have set up for this to work was: runtime 'org.drools:drools-core:5.2.0.Final' runtime 'org.drools:drools-compiler:5.2.0.Final' runtime 'com.sun.xml.bind:jaxb-xjc:2.2.4' However when I switched to drools 5.3.0. The rules are not getting executed or there are some problems. There is no stacktrace or log. I have no idea what is going on. My guess is that some of the dependency jars or classes are missing. Any insight into this? Thanks, Abdul -- View this message in context: http://drools.46999.n3.nabble.com/Drools-5-3-0-Dependencies-tp3452346p3452346.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] Drools 5.3.0 Dependencies
Hi manstis, I will look into incorporating knowledge-api jar and try. Thanks. Anywhere these dependencies are documented clearly? The issue is clearly drools related, i have isolated this already in another git branch meant only for drools upgrade. Abdul -- View this message in context: http://drools.46999.n3.nabble.com/Drools-5-3-0-Dependencies-tp3452346p3452428.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
Re: [rules-users] Drools 5.3.0 Dependencies
I have included knowledge-api.jar thats not working -- View this message in context: http://drools.46999.n3.nabble.com/Drools-5-3-0-Dependencies-tp3452346p3452445.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
Re: [rules-users] Drools 5.3.0 Dependencies
Yes locally in machine just to make sure i have only drools upgrade happening. My issues are because of this upgrade guaranteed. The error message drools is giving me is misleading: service.RulesService Error executing drools rules Unexpected global [dateService] No stacktrace, nothing :o Abdul -- View this message in context: http://drools.46999.n3.nabble.com/Drools-5-3-0-Dependencies-tp3452346p3452592.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
Re: [rules-users] Drools 5.3.0 Dependencies
I think you are going to need to provide some code and rule definitions to help solve your problem. sent on the move On 25 Oct 2011 21:22, arrehman arrehma...@yahoo.com wrote: Yes locally in machine just to make sure i have only drools upgrade happening. My issues are because of this upgrade guaranteed. The error message drools is giving me is misleading: service.RulesService Error executing drools rules Unexpected global [dateService] No stacktrace, nothing :o Abdul -- View this message in context: http://drools.46999.n3.nabble.com/Drools-5-3-0-Dependencies-tp3452346p3452592.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] Advice on varying rule behavior based on object tested?
Each item I am testing MAY have overridden the default thresholds or disable the rule entirely. I would prefer to have this data related to the item I am testing rather than have each rule manage customized behavior for thousands of different types of objects. The object could have a map of rule thresholds it overrides, but for simplicity I assume there is a method to return the current threshold for the current object. is there a better way to perform this kind of logic? Example of my current code: declare TestedEntity temp : Double end declare AlertThreshold maxAllowed : Double end rule Check temperature when $entity : TestedEntity( ) // would prefer to use drools.getRule().getName() on next line AlertThreshold($entity.temp maxAllowed) from $entity.getAlertThresholdForRule(Check temperature) then // raise alert end I dislike hard-coding the rule name as it leads to copy paste errors. I can't insert thresholds easily unless I define different ones for each rule and I want to be able to fall back to defaults easily. This is a type of problem I have come up against several times now so I feel like others must have dealt with it before. The idea of writing copies of rules tailored to each Entity appeals less than a generalized way of doing this. By doing this I want to contain complexity. Dozens of slightly different implementations of the same rule would be much harder to test and support. I am dealing with hundreds of thousands of facts today and will need to scale to millions before I can deploy fully. But with that large number I need to have ways to manage exceptions to the general case just to keep complexity manageable. Thanks, Zack -- View this message in context: http://drools.46999.n3.nabble.com/Advice-on-varying-rule-behavior-based-on-object-tested-tp3452814p3452814.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
Re: [rules-users] Advice on varying rule behavior based on object tested?
Zack, The use of rule names as part of your logic (LHS) is a bad practice (as you noticed already) for many reasons. I discussed this yesterday during my presentation at the Rules Fest... I will make the presentation available later this week. I think the problem is that you are mixing data driven constraints with rule explicit constraints. There are several ways of improving your rules depending on your goals. For instance, if your AlertThreshold is supposed to constrain your instance, then it should know which attribute should be tested. Using a strategy pattern (or simply method overload if you prefer), you could have the method testing your instance directly: $entity : TestedEntity( ) AlertThreshold( entity == $entity, isOverThreshold( $entity ) ) Another way is to have an ENUM for the type of threshold you are dealing with. This will avoid arbitrarily creating dependencies between facts and rules. $entity : TestedEntity( ) AlertThreshold( entity == $entity, type == ThresholdType.TEMPERATURE, maxThreshold $entity.temp ) My .02c. Hope it helps, Edson 2011/10/25 zstlaw zstla...@akamai.com Each item I am testing MAY have overridden the default thresholds or disable the rule entirely. I would prefer to have this data related to the item I am testing rather than have each rule manage customized behavior for thousands of different types of objects. The object could have a map of rule thresholds it overrides, but for simplicity I assume there is a method to return the current threshold for the current object. is there a better way to perform this kind of logic? Example of my current code: declare TestedEntity temp : Double end declare AlertThreshold maxAllowed : Double end rule Check temperature when $entity : TestedEntity( ) // would prefer to use drools.getRule().getName() on next line AlertThreshold($entity.temp maxAllowed) from $entity.getAlertThresholdForRule(Check temperature) then // raise alert end I dislike hard-coding the rule name as it leads to copy paste errors. I can't insert thresholds easily unless I define different ones for each rule and I want to be able to fall back to defaults easily. This is a type of problem I have come up against several times now so I feel like others must have dealt with it before. The idea of writing copies of rules tailored to each Entity appeals less than a generalized way of doing this. By doing this I want to contain complexity. Dozens of slightly different implementations of the same rule would be much harder to test and support. I am dealing with hundreds of thousands of facts today and will need to scale to millions before I can deploy fully. But with that large number I need to have ways to manage exceptions to the general case just to keep complexity manageable. Thanks, Zack -- View this message in context: http://drools.46999.n3.nabble.com/Advice-on-varying-rule-behavior-based-on-object-tested-tp3452814p3452814.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 -- 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