Re: [rules-users] Drools 4 poor performance scaling?
Ron, Can you send me your project in zip, i'd be interesting to see this. Mark Ron Kneusel wrote: I am testing Drools 4 for our application and while sequential mode is very fast I get very poor scaling when I increase the number of facts for stateful or stateless sessions. I want to make sure I'm not doing something foolish before deciding on whether or not to use Drools because from what I am reading online it should be fast with the number of facts I have. The scenario: I have 1000 rules in a DRL file. They are all of the form: rule rule when Data(type == 0, value> 0.185264); Data(type == 3, value < 0.198202); then insert(new AlarmRaised(0)); warnings.setAlarm(0, true); end where the ranges checked on the values and the types are randomly generated. Then, I create a Stateful session and run in a loop timing how long it takes the engine to fire all rules as the number of inserted facts increases: // Run for(j=0; j < 100; j+=5) { if (j==0) { nfacts = 1; } else { nfacts = j; } System.out.println(nfacts + ":"); // Get a working memory StatefulSession wm = ruleBase.newStatefulSession(); // Global - output warnings = new Alarm(); wm.setGlobal("warnings", warnings); // Add facts st = (new Date()).getTime(); for(i=0; i < nfacts; i++) { wm.insert(new Data(rand.nextInt(4), rand.nextDouble()-0.5)); } en = (new Date()).getTime(); System.out.println("facts = " + (en-st)); // Now run the rules st = (new Date()).getTime(); wm.fireAllRules(); en = (new Date()).getTime(); System.out.println("rules = " + (en-st)); // Clean up wm.dispose(); System.out.println("\n"); } This code is based on the HelloWorldExample.java code from the manual and the setup for the rule base is the same as in the manual. As the number of facts increases runtime increases dramatically: facts -- runtime (ms) 10 -- 168 20 -- 166 30 -- 344 40 -- 587 50 -- 1215 60 -- 1931 70 -- 2262 80 -- 3000 90 -- 4754 with a maximum memory use of about 428 MB RAM. By contrast, if I use sequential stateless sessions, everything runs in about 1-5 ms. Is there something in my set up that would cause this, or is this how one would expect Drools to scale? I read about people using thousands of facts so I suspect I'm setting something up incorrectly. Any help appreciated! Ron _ The other season of giving begins 6/24/08. Check out the i’m Talkathon. http://www.imtalkathon.com?source=TXT_EML_WLH_SeasonOfGiving ___ 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] Drools 4 poor performance scaling?
I am testing Drools 4 for our application and while sequential mode is very fast I get very poor scaling when I increase the number of facts for stateful or stateless sessions. I want to make sure I'm not doing something foolish before deciding on whether or not to use Drools because from what I am reading online it should be fast with the number of facts I have. The scenario: I have 1000 rules in a DRL file. They are all of the form: rule rule when Data(type == 0, value> 0.185264); Data(type == 3, value < 0.198202); then insert(new AlarmRaised(0)); warnings.setAlarm(0, true); end where the ranges checked on the values and the types are randomly generated. Then, I create a Stateful session and run in a loop timing how long it takes the engine to fire all rules as the number of inserted facts increases: // Run for(j=0; j < 100; j+=5) { if (j==0) { nfacts = 1; } else { nfacts = j; } System.out.println(nfacts + ":"); // Get a working memory StatefulSession wm = ruleBase.newStatefulSession(); // Global - output warnings = new Alarm(); wm.setGlobal("warnings", warnings); // Add facts st = (new Date()).getTime(); for(i=0; i < nfacts; i++) { wm.insert(new Data(rand.nextInt(4), rand.nextDouble()-0.5)); } en = (new Date()).getTime(); System.out.println("facts = " + (en-st)); // Now run the rules st = (new Date()).getTime(); wm.fireAllRules(); en = (new Date()).getTime(); System.out.println("rules = " + (en-st)); // Clean up wm.dispose(); System.out.println("\n"); } This code is based on the HelloWorldExample.java code from the manual and the setup for the rule base is the same as in the manual. As the number of facts increases runtime increases dramatically: facts -- runtime (ms) 10 -- 168 20 -- 166 30 -- 344 40 -- 587 50 -- 1215 60 -- 1931 70 -- 2262 80 -- 3000 90 -- 4754 with a maximum memory use of about 428 MB RAM. By contrast, if I use sequential stateless sessions, everything runs in about 1-5 ms. Is there something in my set up that would cause this, or is this how one would expect Drools to scale? I read about people using thousands of facts so I suspect I'm setting something up incorrectly. Any help appreciated! Ron _ The other season of giving begins 6/24/08. Check out the i’m Talkathon. http://www.imtalkathon.com?source=TXT_EML_WLH_SeasonOfGiving ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
RE: [rules-users] QueryResult.getFactHandles bug?
Looks like there's a JIRA for this now. Some feedback would have been nice, however. http://jira.jboss.com/jira/browse/JBRULES-1649 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Fenderbosch, Eric Sent: Monday, June 16, 2008 11:00 AM To: Rules Users List Subject: RE: [rules-users] QueryResult.getFactHandles bug? Any feedback on this? Just curious, we've worked around it, but I'd like to know if my assumption was wrong or if this is an actual problem. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Fenderbosch, Eric Sent: Monday, June 09, 2008 11:39 AM To: rules-users@lists.jboss.org Subject: [rules-users] QueryResult.getFactHandles bug? I didn't find a JIRA for this and I'm pretty sure my test is valid. QueryResult.getFactHandles() seems to be only returning [fid:-1:X:null] I'm using 4.0.7. Here's my test case: public void testQueryResults() throws Exception { StatefulSession workingMemory = DroolsUtil.getWorkingMemory(); TestFact testFact = new TestFact(); String id = "1234"; testFact.setId(id); FactHandle testHandle = workingMemory.insert(testFact); System.out.println(testHandle); Object[] args = {id}; int resultCount = 0; int factCount = 0; int handleCount = 0; Object fact = null; FactHandle handle = null; // query getTestFact(String _id) // TestFact(id == _id) // end QueryResults queryResults = workingMemory.getQueryResults("getTestFact", args); Iterator iterator = queryResults.iterator(); while (iterator.hasNext()) { resultCount++; QueryResult result = iterator.next(); FactHandle[] handles = result.getFactHandles(); for (FactHandle h : handles) { handleCount++; handle = h; } for (int i = 0; i < result.size(); i++) { factCount++; fact = result.get(i); } } System.out.println(handle); assertTrue(resultCount == 1); assertTrue(factCount == 1); assertTrue(testFact == fact); assertTrue(handleCount == 1); // this fails assertTrue(testHandle == handle); } TestFact is very simple, using id in hashCode and equals. Am I using getFactHandles correctly? Thanks. ___ 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] Stateless session and rule flows
Somewhat better than my reply, now where was that stone I crawled from under? ;-) -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kris Verlaenen Sent: 26 June 2008 15:49 To: Rules Users List Subject: Re: [rules-users] Stateless session and rule flows Use a rule (probably without conditions and high salience) to start your ruleflow: rule "Start Process" salience 10 when then drools.getWorkingMemory().startProcess("yourName"); end Kris - Original Message - From: "Yoni Mazar" <[EMAIL PROTECTED]> To: Sent: Thursday, June 26, 2008 4:30 PM Subject: [rules-users] Stateless session and rule flows > > Hi Guys, > > We are trying to work with drools with stateless session (Sequential) and > to > apply rule flows. > > we use the following code: > > //define diagnosis and patient here > ... > > StatelessSession session = ruleBase.newStatelessSession(); > //Here we would like to use: session.startProcess("ruleflow id") but this > is > a method which belongs to > //StatefullSession only. > session.execute(new Object[] {diagnosis, patient}); > > How can we do that in steteless mode? > > Thanks, > > Yoni > -- > View this message in context: > http://www.nabble.com/Stateless-session-and-rule-flows-tp17863849p17863849.h tml > 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 smime.p7s Description: S/MIME cryptographic signature ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
RE: [rules-users] Stateless session and rule flows
Hi, I believe Stateless session is only a wrapper around a stateful session, so you're only gaining convenience by using a Stateless one. Why not write your own wrapper that allows for the execution of a rule flow too? Cheers, Mike -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Yoni Mazar Sent: 26 June 2008 15:31 To: rules-users@lists.jboss.org Subject: [rules-users] Stateless session and rule flows Hi Guys, We are trying to work with drools with stateless session (Sequential) and to apply rule flows. we use the following code: //define diagnosis and patient here ... StatelessSession session = ruleBase.newStatelessSession(); //Here we would like to use: session.startProcess("ruleflow id") but this is a method which belongs to //StatefullSession only. session.execute(new Object[] {diagnosis, patient}); How can we do that in steteless mode? Thanks, Yoni -- View this message in context: http://www.nabble.com/Stateless-session-and-rule-flows-tp17863849p17863849.h tml 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 smime.p7s Description: S/MIME cryptographic signature ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Stateless session and rule flows
Use a rule (probably without conditions and high salience) to start your ruleflow: rule "Start Process" salience 10 when then drools.getWorkingMemory().startProcess("yourName"); end Kris - Original Message - From: "Yoni Mazar" <[EMAIL PROTECTED]> To: Sent: Thursday, June 26, 2008 4:30 PM Subject: [rules-users] Stateless session and rule flows Hi Guys, We are trying to work with drools with stateless session (Sequential) and to apply rule flows. we use the following code: //define diagnosis and patient here ... StatelessSession session = ruleBase.newStatelessSession(); //Here we would like to use: session.startProcess("ruleflow id") but this is a method which belongs to //StatefullSession only. session.execute(new Object[] {diagnosis, patient}); How can we do that in steteless mode? Thanks, Yoni -- View this message in context: http://www.nabble.com/Stateless-session-and-rule-flows-tp17863849p17863849.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] Package parameters
Hi, I don't think Drools supports this directly, but would this not be as accomplishable with DSL? Your Drools rule could then be written something like this (bare in mind I'm no DSL expert):- DSL: [when]There is a hemoglobin lab result with=LabResult(type==hemoglobin) [when]- a value less than {v}=value<{v} Rule: There is a hemoglobin lab result with - a value less than 42 With kind regards, Mike -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Yoni Mazar Sent: 26 June 2008 15:29 To: rules-users@lists.jboss.org Subject: [rules-users] Package parameters Hi all, We are at the begining of a new clinical decision-support project. We are considering using a BRMS to manage and execute our business logic. As part of our research, we evaluated JRules and Drools. JRules has a nice feature that we could not find in Drools. We'd like to know if we are misunderstanding something, or maybe this feature is missing. In JRules, one can define a ruleset (corresponds to a package) with parameters. Each parameter has a datatype (a class), a direction (in/out/inout), and an alias. Then, within the rules, the user can refer to the parameter alias. For example, a user can define a ruleset with the following parameters: *class=LabResult, direction=in, alias=hemoglobin *class=LabResult, direction=in, alias=creatinin Then, within a rule, one can write: when hemoglobin.value<10 and creatinin.value>34 then... Now, the application retrieves the patient data accordingle (hemoglobin and creatinine data separetly) and sets the ruleset parameters: ruleset.parameters.add("hemoglobin",hemoglobinFact) ruleset.parameters.add("creatinin",creatininFact) This approach simplifies the rule authoring process significantly! Writing this logic in Drools will be: package cdss import LabResult; rule when LabResult(type=hemoglobin && value <10) LabResult(type=creatinin&& value <34) then... workingMemory.Assert(hemoglobinFact); workingMemory.Assert(creatininFact); Does someone has an idea how to bridge this gap using Drools? Im not sure if using parameters JRule complies with JSR94 specification. Thanks, Yoni -- View this message in context: http://www.nabble.com/Package-parameters-tp17979190p17979190.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 smime.p7s Description: S/MIME cryptographic signature ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Data Enumerations in Drools using Eclipse IDE
Hi Guys, According to what I understood from the manual, it is possible to create data enumerations ONLY when using the BRMS and not when using the Eclipse IDE. Is that correct? If so, are there any plans to add this functionality to the Eclipse IDE in the near future? Thanks, Yoni -- View this message in context: http://www.nabble.com/Data-Enumerations-in-Drools-using-Eclipse-IDE-tp17864475p17864475.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] Stateless session and rule flows
Hi Guys, We are trying to work with drools with stateless session (Sequential) and to apply rule flows. we use the following code: //define diagnosis and patient here ... StatelessSession session = ruleBase.newStatelessSession(); //Here we would like to use: session.startProcess("ruleflow id") but this is a method which belongs to //StatefullSession only. session.execute(new Object[] {diagnosis, patient}); How can we do that in steteless mode? Thanks, Yoni -- View this message in context: http://www.nabble.com/Stateless-session-and-rule-flows-tp17863849p17863849.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] Package parameters
Hi all, We are at the begining of a new clinical decision-support project. We are considering using a BRMS to manage and execute our business logic. As part of our research, we evaluated JRules and Drools. JRules has a nice feature that we could not find in Drools. We'd like to know if we are misunderstanding something, or maybe this feature is missing. In JRules, one can define a ruleset (corresponds to a package) with parameters. Each parameter has a datatype (a class), a direction (in/out/inout), and an alias. Then, within the rules, the user can refer to the parameter alias. For example, a user can define a ruleset with the following parameters: *class=LabResult, direction=in, alias=hemoglobin *class=LabResult, direction=in, alias=creatinin Then, within a rule, one can write: when hemoglobin.value<10 and creatinin.value>34 then... Now, the application retrieves the patient data accordingle (hemoglobin and creatinine data separetly) and sets the ruleset parameters: ruleset.parameters.add("hemoglobin",hemoglobinFact) ruleset.parameters.add("creatinin",creatininFact) This approach simplifies the rule authoring process significantly! Writing this logic in Drools will be: package cdss import LabResult; rule when LabResult(type=hemoglobin && value <10) LabResult(type=creatinin&& value <34) then... workingMemory.Assert(hemoglobinFact); workingMemory.Assert(creatininFact); Does someone has an idea how to bridge this gap using Drools? Im not sure if using parameters JRule complies with JSR94 specification. Thanks, Yoni -- View this message in context: http://www.nabble.com/Package-parameters-tp17979190p17979190.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] Eclipse plugin error: DRL-files in multiple folders?
The IDE allows you to define shared definitions (e.g. functions and imports) in a file with extension .package (instead of the normal .drl). This .package file should be in the same directory as the rules that use it, the IDE is not capable of searching other folders at this point. Kris - Original Message - From: "Tobias Abstreiter" <[EMAIL PROTECTED]> To: Sent: Tuesday, June 24, 2008 6:41 PM Subject: [rules-users] Eclipse plugin error: DRL-files in multiple folders? Hi! I have a problem using the drools Eclipse plugin 4.0.7 (with Drools 4.0.7). In our project rules are located in different folders. One of it is called "global" (containing many functions, imports, ...) whereon most of the rules in the other folders depend. The package name is identical. Running the application works fine but the Eclipse plugin reports many "... cannot be resolved"-errors when I convert the Eclipse Java project into a Drools project. I believe that the plugin has problems to find all rule files. Is that possible? Is there a way to tell the plugin to look in multiple rule-folders? Thanks in advance, Tobias __ MicroNova electronic GmbH Tobias Abstreiter Telekommunikation & Netzmanagment Unterfeldring 17 D-85256 Vierkirchen Tel.: +49 (08139) 93 00-42 Fax.: +49 (08139) 93 00-80 eMail: [EMAIL PROTECTED] Web: http://www.micronova.de Geschäftsführer: Josef W. Karl - Sitz der Gesellschaft: Jetzendorf Registergericht: Ingolstadt - HRB-Nr.: 181 373 __ ___ 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] DSL debugging?
Are you loading your DSL rules using PackageBuilder.addPackageFromDrl(Reader source, Reader dsl) ? Kris - Original Message - From: "Barry Kaplan" <[EMAIL PROTECTED]> To: Sent: Tuesday, June 24, 2008 7:33 PM Subject: [rules-users] DSL debugging? I have a very simple DSL snippet: PPositionQuantityAllocatedToLegs {position} {rulePriority}= Integer(intValue < {position}.quantity) from accumulate( StrategyLeg(priority > {rulePriority}, instrument == {position}.instrument, longShort == {position}.longShort, legQuantity : quantity) legsQuantity(legQuantity) ) In the IDE it seems to expand correctly without errors. However, at runtime I get the below error. How does one decipher such a message? Caused by: org.drools.rule.InvalidRulePackage: [20,0]: unknown:20:0 mismatched token: [EMAIL PROTECTED],506:513='expander',<7>,20:0]; at org.drools.rule.Package.checkValidity(Package.java:424) at org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:394) at com.sig.buyingpower.DroolsOptionStrategyBuyingPowerPositionAggregator.loadRules(DroolsOptionStrategyBuyingPowerPositionAggregator.java:91) at com.sig.buyingpower.DroolsOptionStrategyBuyingPowerPositionAggregator.(DroolsOptionStrategyBuyingPowerPositionAggregator.java:117) -- View this message in context: http://www.nabble.com/DSL-debugging--tp18095970p18095970.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] Problems with drools-4.0.7 examples
FYI, cleaning and rebuilding the project solved the problem for me. So, here are the steps I took, for future reference: 1. Imported the drools-examples project 2. Removed the drools-compiler and drools-core from the project build path 3. Right-clicked the project and selected convert to drools 4. Selected Project > Clean On Tue, Jun 24, 2008 at 12:56 PM, Stephen Schaub <[EMAIL PROTECTED]> wrote: > Thanks for the tip, Mark. I did what you suggested, and got the > necessary libraries added to the project build configuration. > > I can run the HelloWorldExample, and there are no compile errors for > any of the .java project files. However, there are still lots of > errors reported for the .drl files. When I open the HelloWorld.drl > file and attempt to click the Rete Tree tab at the bottom of the > editor, I get the message: > > Rete Tree Build Error! > Reason: > Unable to parse rules to show RETE view! > > Am I missing something? > > Stephen > > On Tue, Jun 24, 2008 at 10:18 AM, Mark Proctor <[EMAIL PROTECTED]> wrote: >> it seems an incorrect .project was committed, it's easy to fix. Just remove >> anything from the project dependencies and then right click and select >> "convert to drools" >> >> Should do the job. >> >> Mark >> Stephen Schaub wrote: >>> >>> I am new to Drools. >>> >>> I downloaded the drools-4.0.7 examples from >>> >>> >>> http://download.jboss.org/drools/release/4.0.7.19894.GA/drools-4.0.7-examples.zip >>> >>> I have Eclipse 3.3 with the GEF dependency, and installed the Drools >>> plugins. I then imported the drools examples into a clean Eclipse >>> workspace. I'm getting many errors reported in the Eclipse Problems >>> view on the .drl files. >>> >>> I attempted to run the HelloWorldExample, and got a runtime error. I >>> checked the build path of the project, and it references >>> drools-compiler and drools-core projects, neither of which are in my >>> workspace. I manually removed these, and added the dependencies >>> mentioned in the Drools README_DEPENDENCIES.txt. >>> >>> I looked around for info on setting up the drools examples, and didn't >>> find any. I would appreciate a pointer... >>> >>> >> >> ___ >> rules-users mailing list >> rules-users@lists.jboss.org >> https://lists.jboss.org/mailman/listinfo/rules-users >> > > > > -- > Stephen Schaub > -- Stephen Schaub ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users