Re: [rules-users] Drools Workflow functionality related doubt.
Hi, Hi! I will answer what I can here below inline: I want to use Drool Workflow in one of my project. I have some doubts about functionalities proovided by the Drools Workflow, as can they fullfill my requirements. 1. Is there support for multiple roles in a workflow? Do you mean human tasks in a rules flow? 2. Does it checks for sufficient user rights to execute workflow actions? Not sure what you mean here? Do you want to check some user before each rules flow step attempts to fire it's rules? 3. Can Drools Workflow steps can access and update the related content objects and maintain version history? Yes, it is all in a repo with versioning, history, etc. 4. Is their support for Database updates and interfacing with RDBMS possible? Yes, http://www.jboss.com/products/platforms/brms/testedconfigurations/ 5. Ability to generate conditional alerts and notifications. Of course, this is Java remember! 6. Intefacing with other systems possible and Workflow engine can be driven programmatically. Yes, there is an API, see examples provided in code base or look closer at this mailinglist. Regards, erics ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Using multiple threads for parallel rule flow execution
Hi *, I need to speed up the total processing time needed for the execution of a rule flow which consists of multiple rule flow groups (e. g. A, B and C). I'm thinking about to parallelize the execution of A and B. +-- A -- + Start -- split + +-- join -- C -- End +-- B -- + Is it possible to split a flow in multiple parallel execution paths (with AND), execute them with real parallelism in their own threads and join them together at the end? Or is everything in the drools flow some sort of pseudo-parallelism so that I would have to implement this by hand? Cheers, Tobias signature.asc Description: OpenPGP digital signature ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Using multiple threads for parallel rule flow execution
Tobias, I believe that this is more than a flow question. The answer depends on another question: what is taking too much time to execute? The evaluation of the rules in A and B (LHS) or the actual consequence execution of rules in A and B (RHS)? If it is LHS of the rules that is taking too long to execute, then you may try enabling the engine multi-thread evaluation option. If it is the consequence, unfortunately, the engine by itself can not solve the problem, because it does not know when/how the consequence code of your rules affect each other. This way, the engine executes all consequences in sequence, one after the other. If it is the later, one possible solution is to make your consequences trigger an asynchronous action instead of executing all the code in the same engine thread, when you know your code is independent among rules. We are working on enabling multiple agendas and different ways to execute consequences in the engine, but no idea at this moment when it will be ready. Edson 2009/8/13 Tobias Buchloh t.buch...@gmx.net Hi *, I need to speed up the total processing time needed for the execution of a rule flow which consists of multiple rule flow groups (e. g. A, B and C). I'm thinking about to parallelize the execution of A and B. +-- A -- + Start -- split + +-- join -- C -- End +-- B -- + Is it possible to split a flow in multiple parallel execution paths (with AND), execute them with real parallelism in their own threads and join them together at the end? Or is everything in the drools flow some sort of pseudo-parallelism so that I would have to implement this by hand? Cheers, Tobias ___ 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] How to create nested rules in Drool Guvnor
You can do this using the extends keyword in your rule. Rule shopping cart total exceeds 4000, give 50% discount when condition then action end Rule if order between 6 to 9 pm give additional discount of 20 % extends shopping cart total exceeds 4000, give 50% discount when condition then action end You can also disable the first rule and just use extends to limit the amount of duplicate conditions in your rules. Note extends basically copies the conditions from the first rule to what is being extended, but I believe it will do what you are trying to do. Michael Rhoden VP - IT Development Franklin American Mortgage Company Direct: 615-778-1117 Fax: 615-778-2766 Email: mrho...@franklinamerican.com - Original Message - From: Pardeep Ruhil pardeep.ru...@lntinfotech.com To: rules-users@lists.jboss.org Sent: Wednesday, August 12, 2009 2:44:38 PM GMT -06:00 US/Canada Central Subject: [rules-users] How to create nested rules in Drool Guvnor Hi, Thanks for replying. I have a scenario like Rule shopping cart total exceeds 4000, give 50% discount when condition then action call Ruleif order is between 6 to 9 pm, give additional discount of 20 % end Rule if order between 6 to 9 pm give additional discount of 20 % when condition then action end .. Also i have a query like, Can we make rule like this Rule shopping cart total exceeds 4000 give 50% discount when condition then action Rule if order between 6 to 9 pm give additional discount of 20 % when condition then action end end Can we make rules like above? Thanks Regards Pardeep Ruhil This email may contain confidential or privileged information for the intended recipient(s). If you are not the intended recipient, please do not use or disseminate the information, notify the sender and delete it from your system. 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
Re: [rules-users] How to create nested rules in Drool Guvnor
Hi Pardeep, you cannot nest rules. You can solve the situation with 2 rules like: rule big amount discount when Basket( total 4000 ) discount: Discount() then discount.percentage = discount.percentage + 20; end rule preferred time discount when Clock( 6 time 9 ) discount: Discount() then discount.percentage = discount.percentage + 20; end Please note that I did not use correct Drools language notation, it is just the example how to solve your problem. -- View this message in context: http://www.nabble.com/How-to-create-nested-rules-in-Drool-Guvnor-tp24943230p24954552.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] Why is a flat object recommended?
Mark Proctor wrote: We can exploit cartesian products and indexing for == constraints. If its a nested model we have to iterate over all possible instances. The other problem is if the nested model changes the engine has no idea this has happened, which if you are not careful can lead to data integrity issues. I think that plain flat model is too limited for real life. In fact in most situations you just cannot avoid nesting. For example when I try to search for cars with 4 cylinder engine the best approach I found is: rule get 4 cylinder cars when Car ( $e: engine != null ) // car without engine? where are we? :) Engine ( cylinderCount == 4 ) from $e then System.out.println(Found 4 cylinder car.); end This should be quite effective. I doubt that the following solution with cartesian product has the same complexity: rule get 4 cylinder cars when $e: Engine ( cylinderCount == 4 ) Car ( engine == $e ) then System.out.println(Found 4 cylinder car.); end Using approach Car ( engine.cylinderCount == 4 ) tends to raise NullPointerException and I had problems with assigning the cylinderCount to variable so this was not a way to go for me. But this is not much a problem for me as I am a programmer and I can understand the rule language and data structures. But when business users are to edit rules (using Guvnor as the tool of choice) we come to troubles. I think that guided editor for rules does not allow from. More importantly - can you create such a structure for a test scenario? I failed. :( -- View this message in context: http://www.nabble.com/Why-is-a-flat--object-recommended--tp15567690p24954944.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] Type declaration in DSL
hi all, can any one help me how can convert drl to dsl for drools,let say for the following code what will be the dsl, rule 'Rank accomodation name' salience 90 when $accBase: AccomodationBase() not AccomodationBase( eval( $accBase instanceof AccomodationRank) ) $accRank: AccomodationRank( level == $accBase.level, description == $accBase.description ) then $accRank.setScore($accRank.getScore()+1); end thanks Chandana Pingle wrote: hi all, I have recently started using Drools 5.0 .I have a difficulty in writing the expressions in DSL file.i have my .dslr file written like this when not PricingResult() productType : ProductType() customer : Party() then create a PricingResult set productType set customer now, i am able to fire the rule successfully,with the following in .dslr file with rule language mappings set to pricingResult.setProductType(productType); pricingResult.setCustomer(customer); where productType and customer are set using CommandFactory.insert() but i want to remove the below 2 lines from .dslr file and expand them in .dsl file productType : ProductType() customer : Party() how do i declare these types in DSL? Any help would be great. Thanks chandana ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://www.nabble.com/Type-declaration-in-DSL-tp24838670p24955318.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] Why is a flat object recommended?
Java pojo's nested fields is just a weak way to represent relations between objects. If you want to exploit those properly in a rule engine, best to use real relations. Mark Libor Nenadál wrote: Mark Proctor wrote: We can exploit cartesian products and indexing for == constraints. If its a nested model we have to iterate over all possible instances. The other problem is if the nested model changes the engine has no idea this has happened, which if you are not careful can lead to data integrity issues. I think that plain flat model is too limited for real life. In fact in most situations you just cannot avoid nesting. For example when I try to search for cars with 4 cylinder engine the best approach I found is: rule get 4 cylinder cars when Car ( $e: engine != null ) // car without engine? where are we? :) Engine ( cylinderCount == 4 ) from $e then System.out.println(Found 4 cylinder car.); end This should be quite effective. I doubt that the following solution with cartesian product has the same complexity: rule get 4 cylinder cars when $e: Engine ( cylinderCount == 4 ) Car ( engine == $e ) then System.out.println(Found 4 cylinder car.); end Using approach Car ( engine.cylinderCount == 4 ) tends to raise NullPointerException and I had problems with assigning the cylinderCount to variable so this was not a way to go for me. But this is not much a problem for me as I am a programmer and I can understand the rule language and data structures. But when business users are to edit rules (using Guvnor as the tool of choice) we come to troubles. I think that guided editor for rules does not allow from. More importantly - can you create such a structure for a test scenario? I failed. :( ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] how to convert drl to dsl
hi all, can any one help me how can convert drl to dsl for drools,let say for the following code what will be the dsl, rule 'Rank accomodation name' salience 90 when $accBase: AccomodationBase() not AccomodationBase( eval( $accBase instanceof AccomodationRank) ) $accRank: AccomodationRank( level == $accBase.level, description == $accBase.description ) then $accRank.setScore($accRank.getScore()+1); end thanks -- View this message in context: http://www.nabble.com/how-to-convert-drl-to-dsl-tp24955345p24955345.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] OSGI, classloading, and imports in KnowledgeBuilder
lasse.wallen...@apcc.com wrote: Ok, I finally got it running. I had missed an import in the excel sheet so I had a dependency on another bundle. Cool! All this debugging has made me understand (and appreciate) the solution sketched earlier by Faron Dutton more clearly. However it still seems a bit involved when just a few decisiontables is needed - don't you think? I think that under OSGi in gereral, the classloader becomes much more important. Luckily drools is prepared for that, but it still pushes OSGi a fair bit - with us witnessing the fallout. Basically you need a classloader which can access you classes _and_ all drools internals. Probably we could combine them somehow. Thought, googled :) http://www.osgi.org/blog/2008/08/classy-solutions-to-tricky-proxies.html I'm not too content with my setup as well, maybe you can sketch yours as it's running now? I'm gonna the try above solution, maybe we can establish some best practise. Cheers, Simon ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Problem with JPA session persistence in Drools Flow (5.0.1)
Thanks Kris Will download from the below link and check. Quick question, do you know when the official 5.1 release will be available ? Kris Verlaenen wrote: The fix for this issue has been added to trunk about a month ago already I think, have you already tried with the 5.1.0 SNAPSHOT release? Does this solve your issue? You can get the snapshot at https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/ Kris Quoting SBalakrishnan sanjay.balakrish...@fnis.com: Looks like I am running into the same/similar issue while recreating from a session_id. Exception pasted below. Any idea whether it will be addressed in the coming release ? Thanks in advance.. /**/ Hibernate: select sessioninf0_.id as id0_0_, sessioninf0_.dirty as dirty0_0_, sessioninf0_.lastModificationDate as lastModi3_0_0_, sessioninf0_.rulesByteArray as rulesByt4_0_0_, sessioninf0_.startDate as startDate0_0_ from SessionInfo sessioninf0_ where sessioninf0_.id=? java.lang.RuntimeException: Unable to load session snapshot at org.drools.persistence.session.JPASessionMarshallingHelper.loadSnapshot(JPASessionMarshallingHelper.java:112) at org.drools.persistence.session.JPASessionMarshallingHelper.init(JPASessionMarshallingHelper.java:46) at org.drools.persistence.session.SingleSessionCommandService.init(SingleSessionCommandService.java:171) at org.drools.persistence.jpa.impl.JPAKnowledgeServiceProviderImpl.loadStatefulKnowledgeSession(JPAKnowledgeServiceProviderImpl.java:75) at org.drools.persistence.jpa.JPAKnowledgeService.loadStatefulKnowledgeSession(JPAKnowledgeService.java:102) at org.drools.examples.process.order.OrderExample.createWorkingMemory(OrderExample.java:257) at org.drools.examples.process.order.OrderExample.init(OrderExample.java:99) at org.drools.examples.process.order.OrderExample.main(OrderExample.java:80) Caused by: java.lang.NullPointerException at org.drools.marshalling.impl.InputMarshaller.readLeftTuple(InputMarshaller.java:496) at org.drools.marshalling.impl.InputMarshaller.readLeftTuples(InputMarshaller.java:426) at org.drools.marshalling.impl.InputMarshaller.readFactHandles(InputMarshaller.java:349) at org.drools.marshalling.impl.InputMarshaller.readSession(InputMarshaller.java:207) at org.drools.marshalling.impl.DefaultMarshaller.unmarshall(DefaultMarshaller.java:75) at org.drools.persistence.session.JPASessionMarshallingHelper.loadSnapshot(JPASessionMarshallingHelper.java:104) /**/ Mauricio Salatino wrote: Ok, I will try to take a look at it.. this week.. I will let you know if I can fix it 2009/7/28 DroolsUser rafiuddin...@gmail.com: Mark / salaboy, I am also facing same problem while recreate the session from database. Can you advice any alternative, so that I can go forward till the next release. Moreover when is the new release is ... Do new release will targeting this kind problem? Please suggest any alternative to recreate the session from db. Thanks in advance.. gairey wrote: Mark, Done: https://jira.jboss.org/jira/browse/JBRULES-2199 - thanks for the quick response. Regards, Alan Mark Proctor Sent by: rules-users-boun...@lists.jboss.org 08/07/2009 13:49 Please respond to Rules Users List To Rules Users List cc Subject Re: [rules-users] Problem with JPA session persistence in Drools Flow (5.0.1) Can you open a JIRA for this, and we'll make sure it's done in the next few weeks: https://jira.jboss.org/jira/browse/JBRULES thanks Mark alan.gai...@tessella.com wrote: I'm currently using Drools Flow with JPA session persistence enabled as described in section 5.1 of the User Guide. As a process executes, session information is saved to the H2 database correctly. The problem comes if a process only executes part way through, and I then try to finish the process by recreating a session using the code: // recreate the session from database using the sessionId ksession = JPAKnowledgeService.loadStatefulKnowledgeSession( sessionId, kbase, null, env ); This gives me a NullPointerException. Having looked into the Drools Flow source code, I think the problem is in the class drools-persistence-jpa\src\main\java\org\drools\persistence\session\SingleSessionCommandService.java. The 4th constructor of this class is called as part of the loading of a knowledge session from the H2 database; this in turn leads to the afterCompletion method of the inner class SynchronizationImpl being called. The final two lines of this method are: ((JPAProcessInstanceManager) ((ReteooWorkingMemory) session).getProcessInstanceManager()).clearProcessInstances(); ((JPAWorkItemManager) ((ReteooWorkingMemory) session).getWorkItemManager()).clearWorkItems();
Re: [rules-users] Conversion from Normal Decision Tables to Web-Based Tables and vice-versa
Have you made any progress on this migration. I am currently estimating the migration path for our Excel based rules to web based decision tables. Can you describe the steps you were required to take? Anyone else, please feel free to comment on your Excel to Web Decision Table migrations. Thanks Barry Vikrant Yagnick wrote: Hi All, I am wondering if anyone has had a requirement where they would need to convert their normal decision tables into web-based decision tables(or vice-versa). If someone has already done this, can they share either some code or pointers to how this can be done? (I guess it will involving parsing the Excel and creating the XML for the decision table). Will this be a useful feature to have? Cheers, Vikrant MASTEK LTD. Mastek is in NASSCOM's 'India Top 20' Software Service Exporters List. In the US, we're called MAJESCOMASTEK ~~ Opinions expressed in this e-mail are those of the individual and not that of Mastek Limited, unless specifically indicated to that effect. Mastek Limited does not accept any responsibility or liability for it. This e-mail and attachments (if any) transmitted with it are confidential and/or privileged and solely for the use of the intended person or entity to which it is addressed. Any review, re-transmission, dissemination or other use of or taking of any action in reliance upon this information by persons or entities other than the intended recipient is prohibited. This e-mail and its attachments have been scanned for the presence of computer viruses. It is the responsibility of the recipient to run the virus check on e-mails and attachments before opening them. If you have received this e-mail in error, kindly delete this e-mail from desktop and server. ~~ ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://www.nabble.com/Conversion-from-Normal-Decision-Tables-to-Web-Based-Tables-and-vice-versa-tp22098053p24958056.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] Drools and Clojure
Greg Barton schrieb: There's no reason why a rete based system couldn't use maps as first class objects, but Drools is heavily oriented towards POJOS. Using eval in the way you have is pretty much the way to go. Thanks for confirming that. For now I know that I am doing it right by using eval and that this means that rules for typical Clojure objects will not benefit from some of the optimizations Drools usually can apply. Maybe it will change in the future. As long as type information is accessible (both for first class types and their members) you should be able to have the left hand side of a rule (the conditions) be as it is now. I think that if Maps become 1st class objects there could be a different Syntax, without using eval. If you lobby the devs hard enough and get others on your side you may be able to convince them to go in that direction, but I doubt it would be possible before version 6 or so, if that early. (And I'm not even sure it's possible.) At this point it is mostly interesting for me to get Drools working with Clojure together and concentrate on correctness. The goal is that users of my lib can use do all typical things people do with Drools without writing Java code. Everything, including the rules, would be written in Clojure. But of course it would be very interesting if the devs could indeed have Clojure in mind. I don't know how reusable the existing code is, for using Maps without the need for eval and with having the respective performance advantages. I understand that the looup of the value for a given key can not be optimized away. On my hardware get() is limited to only 1000 calls per msec and core. Reading a field from a POJO is faster. If I understand it correctly then the problem with eval is that it needs to be executed each time, and no clever caching can be done. So, eliminating that by having Maps being 1st class is what sounds interesting. When I refer to Maps and Clojure, then I talk about Maps having only very few key/value pairs, just like POJOs, and being immutable. This immutability may even be very helpful for optimization. It is guaranteed that a given object will never change. I hope the devs will find it okay if I make some concrete suggestions in the coming weeks. Sunny greetings, André -- Lisp is not dead. It’s just the URL that has changed: http://clojure.org/ ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools and Clojure
I was wrong. :). See Mark's later email. GreG On Aug 13, 2009, at 17:25, André Thieme address.good.until.2009.dec...@justmail.de wrote: Greg Barton schrieb: There's no reason why a rete based system couldn't use maps as first class objects, but Drools is heavily oriented towards POJOS. Using eval in the way you have is pretty much the way to go. Thanks for confirming that. For now I know that I am doing it right by using eval and that this means that rules for typical Clojure objects will not benefit from some of the optimizations Drools usually can apply. Maybe it will change in the future. As long as type information is accessible (both for first class types and their members) you should be able to have the left hand side of a rule (the conditions) be as it is now. I think that if Maps become 1st class objects there could be a different Syntax, without using eval. If you lobby the devs hard enough and get others on your side you may be able to convince them to go in that direction, but I doubt it would be possible before version 6 or so, if that early. (And I'm not even sure it's possible.) At this point it is mostly interesting for me to get Drools working with Clojure together and concentrate on correctness. The goal is that users of my lib can use do all typical things people do with Drools without writing Java code. Everything, including the rules, would be written in Clojure. But of course it would be very interesting if the devs could indeed have Clojure in mind. I don't know how reusable the existing code is, for using Maps without the need for eval and with having the respective performance advantages. I understand that the looup of the value for a given key can not be optimized away. On my hardware get() is limited to only 1000 calls per msec and core. Reading a field from a POJO is faster. If I understand it correctly then the problem with eval is that it needs to be executed each time, and no clever caching can be done. So, eliminating that by having Maps being 1st class is what sounds interesting. When I refer to Maps and Clojure, then I talk about Maps having only very few key/value pairs, just like POJOs, and being immutable. This immutability may even be very helpful for optimization. It is guaranteed that a given object will never change. I hope the devs will find it okay if I make some concrete suggestions in the coming weeks. Sunny greetings, André -- Lisp is not dead. It’s just the URL that has changed: http://clojure.org/ ___ 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 and Clojure
Mark Proctor schrieb: Map( this['c'] == 206 ) That should work, we do support MVEL syntax for maps and arrays - we just don't suppor method calls, yet. Hello Mark. I just tested it and it indeed works for me. Although as I understand it, this will be compiled into an expression using eval (or it will even be only interpreted). So, if that is true it can't bring any performance advantage. The syntax is nothing I worry about. In Clojure, which is a Lisp, I have macros and can remove any obstacles in the syntax I like. It is trivial to develop new domain specific languages for rules. So, my rule syntax for Clojure will look very lispy, and each user is free to change and extend it. I will also allow the RHS to be written in Clojure code, no Java needed. But back to your example: I noticed something very interesting: when I use the MVEL dialect for the Map lookup, then I get no NPE anymore when I check in a Map which does *not* have the key I test for. So, now I have two versions of my rule: package droolsandclojure; import java.util.Map; rule Clojure test 1 when m:Map() eval((Integer)m.get(c) == 206) then System.out.println(Match: + m); end and package droolsandclojure; import java.util.Map; rule Clojure MVEL test 2 dialect mvel when m:Map( this[c] == 206 ) then System.out.println(Match: + m); end Only one of these two rules is used, not both at the same time. When I use rule 1 then I can not insert Maps into my session which do not have a key c. If I try it and run my code I get a NPE. When I use rule 2, the MVEL version, this is different. Now I can insert any Maps and will not get an exception. The rule will simply just not execute the RHS. How can rule 1 be changed so that it will not put a constraint on the objects which are allowed to go into the session without throwing a NPE? And another interesting thing I noticed: to both rules I added the line global String s; and in the LHS's of both rules I removed the c and put s at its place. Then the first thing I did after creating a session was to (.setGlobal session s c) The rule 1 accepted this change. I can use s instead of c. But there is still the limitation that I can only insert Maps into the session which do have the String c as key. Otherwise: NPE. The rule 2 (mvel) however does not accept s as a placeholder. I get: Exception executing predicate this[s] == 206 [Thrown class org.drools.RuntimeDroolsException] Any ideas how to get rid of the NPE? -- Lisp is not dead. It’s just the URL that has changed: http://clojure.org/ ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools and Clojure
With what have you been wrong Greg? I understood Marks reply in such a way that the mvel dialect allows to use Maps without eval. But this is just syntactic sugar. When compiled or interpreted (I don't know which of those Drools will do with mvel rules), this will get replaced with an eval under the hood. So, that means that still the optimizations can't be applied. Maybe the mvel rule is only interpreted, which would make it even slower. For me it does not matter much which syntax will be my target. My Clojure lib will allow to write down rules in s-expression syntax, and it will compile them (compilation is also available at runtime) into any syntax Drools accepts. Currently my target is the default syntax - that means I will produce strings that access Maps with eval. IF the mvel syntax will result in more performant code because it makes Drools handle it better without using eval under the hood, then sure, I can also compile into mvel syntax. Although with that I still have the little problem to have globals in place of literals for Map lookups (see my other mail). Greg Barton schrieb: I was wrong. :). See Mark's later email. GreG On Aug 13, 2009, at 17:25, André Thieme address.good.until.2009.dec...@justmail.de wrote: Greg Barton schrieb: There's no reason why a rete based system couldn't use maps as first class objects, but Drools is heavily oriented towards POJOS. Using eval in the way you have is pretty much the way to go. Thanks for confirming that. For now I know that I am doing it right by using eval and that this means that rules for typical Clojure objects will not benefit from some of the optimizations Drools usually can apply. Maybe it will change in the future. As long as type information is accessible (both for first class types and their members) you should be able to have the left hand side of a rule (the conditions) be as it is now. I think that if Maps become 1st class objects there could be a different Syntax, without using eval. If you lobby the devs hard enough and get others on your side you may be able to convince them to go in that direction, but I doubt it would be possible before version 6 or so, if that early. (And I'm not even sure it's possible.) At this point it is mostly interesting for me to get Drools working with Clojure together and concentrate on correctness. The goal is that users of my lib can use do all typical things people do with Drools without writing Java code. Everything, including the rules, would be written in Clojure. But of course it would be very interesting if the devs could indeed have Clojure in mind. I don't know how reusable the existing code is, for using Maps without the need for eval and with having the respective performance advantages. I understand that the looup of the value for a given key can not be optimized away. On my hardware get() is limited to only 1000 calls per msec and core. Reading a field from a POJO is faster. If I understand it correctly then the problem with eval is that it needs to be executed each time, and no clever caching can be done. So, eliminating that by having Maps being 1st class is what sounds interesting. When I refer to Maps and Clojure, then I talk about Maps having only very few key/value pairs, just like POJOs, and being immutable. This immutability may even be very helpful for optimization. It is guaranteed that a given object will never change. I hope the devs will find it okay if I make some concrete suggestions in the coming weeks. Sunny greetings, André -- Lisp is not dead. It’s just the URL that has changed: http://clojure.org/ ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] how to convert drl to dsl
We use a SQL like statements for our dsl. For example: DRL FORM: rule 'Rank accomodation name' salience 90 when $accBase: AccomodationBase() not AccomodationBase( eval( $accBase instanceof AccomodationRank) ) $accRank: AccomodationRank( level == $accBase.level, description == $accBase.description ) then $accRank.setScore($accRank.getScore()+1);end DSL FORM: when Select [AccomodationBase] Not [AccomodationBase] is kind of [AccomodationRank] Select [AccomodationRank] where [level] = [AccomodationBase][level] and [description] = [AccomodationBase][description] then Update [AccomodationRank] set [score] = [score] + 1 end On Thu, Aug 13, 2009 at 11:09 AM, drools d.devend...@yahoo.com wrote: hi all, can any one help me how can convert drl to dsl for drools,let say for the following code what will be the dsl, rule 'Rank accomodation name' salience 90 when $accBase: AccomodationBase() not AccomodationBase( eval( $accBase instanceof AccomodationRank) ) $accRank: AccomodationRank( level == $accBase.level, description == $accBase.description ) then $accRank.setScore($accRank.getScore()+1); end thanks -- View this message in context: http://www.nabble.com/how-to-convert-drl-to-dsl-tp24955345p24955345.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 -- 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
Re: [rules-users] OSGI, classloading, and imports in KnowledgeBuilder
We'd really like to improve out OSGi friendlyness. From getting Drools to work perfectly as an OSGi service, to getting our build system to publish all the necessary bundles. But we need people in the commnity to help us, you know where to find us if you want to help out, as we have so much other core stuff to do :) http://wwws.jboss.org/drools/irc.html Mark Simon Thum wrote: lasse.wallen...@apcc.com wrote: Ok, I finally got it running. I had missed an import in the excel sheet so I had a dependency on another bundle. Cool! All this debugging has made me understand (and appreciate) the solution sketched earlier by Faron Dutton more clearly. However it still seems a bit involved when just a few decisiontables is needed - don't you think? I think that under OSGi in gereral, the classloader becomes much more important. Luckily drools is prepared for that, but it still pushes OSGi a fair bit - with us witnessing the fallout. Basically you need a classloader which can access you classes _and_ all drools internals. Probably we could combine them somehow. Thought, googled :) http://www.osgi.org/blog/2008/08/classy-solutions-to-tricky-proxies.html I'm not too content with my setup as well, maybe you can sketch yours as it's running now? I'm gonna the try above solution, maybe we can establish some best practise. Cheers, Simon ___ 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 and Clojure
André Thieme wrote: Mark Proctor schrieb: Map( this['c'] == 206 ) That should work, we do support MVEL syntax for maps and arrays - we just don't suppor method calls, yet. Hello Mark. I just tested it and it indeed works for me. Although as I understand it, this will be compiled into an expression using eval (or it will even be only interpreted). So, if that is true it can't bring any performance advantage. yes, no performance benefit. As this form of use is a return value really, it should be possible to index (if we assume that nest objects do not change). Although it's a fair bit of work to do this, but interesting work - if anyone wants to help out :) The syntax is nothing I worry about. In Clojure, which is a Lisp, I have macros and can remove any obstacles in the syntax I like. It is trivial to develop new domain specific languages for rules. So, my rule syntax for Clojure will look very lispy, and each user is free to change and extend it. I will also allow the RHS to be written in Clojure code, no Java needed. Btw if you are doing lispy stuff: http://blog.athico.com/2008/02/drools-clips.html http://blog.athico.com/2008/06/drools-clips-progress.html But back to your example: I noticed something very interesting: when I use the MVEL dialect for the Map lookup, then I get no NPE anymore when I check in a Map which does *not* have the key I test for. So, now I have two versions of my rule: package droolsandclojure; import java.util.Map; rule Clojure test 1 when m:Map() eval((Integer)m.get(c) == 206) then System.out.println(Match: + m); end and package droolsandclojure; import java.util.Map; rule Clojure MVEL test 2 dialect mvel when m:Map( this[c] == 206 ) then System.out.println(Match: + m); end Only one of these two rules is used, not both at the same time. When I use rule 1 then I can not insert Maps into my session which do not have a key c. If I try it and run my code I get a NPE. When I use rule 2, the MVEL version, this is different. Now I can insert any Maps and will not get an exception. The rule will simply just not execute the RHS. How can rule 1 be changed so that it will not put a constraint on the objects which are allowed to go into the session without throwing a NPE? see Null-Safe Bean Navigation http://mvel.codehaus.org/MVEL+2.0+Property+Navigation And another interesting thing I noticed: to both rules I added the line global String s; and in the LHS's of both rules I removed the c and put s at its place. Then the first thing I did after creating a session was to (.setGlobal session s c) The rule 1 accepted this change. I can use s instead of c. But there is still the limitation that I can only insert Maps into the session which do have the String c as key. Otherwise: NPE. The rule 2 (mvel) however does not accept s as a placeholder. I get: Exception executing predicate this[s] == 206 [Thrown class org.drools.RuntimeDroolsException] Any ideas how to get rid of the NPE? We'll have to look into this, probably a bug. Mark ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] how to convert drl to dsl
thanks Isilva, i will try by using this lsilva wrote: We use a SQL like statements for our dsl. For example: DRL FORM: rule 'Rank accomodation name' salience 90 when $accBase: AccomodationBase() not AccomodationBase( eval( $accBase instanceof AccomodationRank) ) $accRank: AccomodationRank( level == $accBase.level, description == $accBase.description ) then $accRank.setScore($accRank.getScore()+1);end DSL FORM: when Select [AccomodationBase] Not [AccomodationBase] is kind of [AccomodationRank] Select [AccomodationRank] where [level] = [AccomodationBase][level] and [description] = [AccomodationBase][description] then Update [AccomodationRank] set [score] = [score] + 1 end On Thu, Aug 13, 2009 at 11:09 AM, drools d.devend...@yahoo.com wrote: hi all, can any one help me how can convert drl to dsl for drools,let say for the following code what will be the dsl, rule 'Rank accomodation name' salience 90 when $accBase: AccomodationBase() not AccomodationBase( eval( $accBase instanceof AccomodationRank) ) $accRank: AccomodationRank( level == $accBase.level, description == $accBase.description ) then $accRank.setScore($accRank.getScore()+1); end thanks -- View this message in context: http://www.nabble.com/how-to-convert-drl-to-dsl-tp24955345p24955345.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 -- 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 -- View this message in context: http://www.nabble.com/how-to-convert-drl-to-dsl-tp24955345p24964587.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] Drools and Clojure
Well, you never know it performs until you try. :) See attached project. $ java -jar target/DroolsMapTest-1.0.jar eval.drl {bar=0} {foo=100} Time: 6607ms $ java -jar target/DroolsMapTest-1.0.jar mvel.drl {bar=0} {foo=100} Time: 13077ms So eval ended up being 2x as fast, at least for this micro benchmark. I guess the fact that the this['foo'] expressions are not indexed, plus the fact that they're interpreted mvel, doubles up. Stick with the eval. --- On Thu, 8/13/09, André Thieme address.good.until.2009.dec...@justmail.de wrote: From: André Thieme address.good.until.2009.dec...@justmail.de Subject: Re: [rules-users] Drools and Clojure To: Rules Users List rules-users@lists.jboss.org Date: Thursday, August 13, 2009, 6:29 PM With what have you been wrong Greg? I understood Marks reply in such a way that the mvel dialect allows to use Maps without eval. But this is just syntactic sugar. When compiled or interpreted (I don't know which of those Drools will do with mvel rules), this will get replaced with an eval under the hood. So, that means that still the optimizations can't be applied. Maybe the mvel rule is only interpreted, which would make it even slower. For me it does not matter much which syntax will be my target. My Clojure lib will allow to write down rules in s-expression syntax, and it will compile them (compilation is also available at runtime) into any syntax Drools accepts. Currently my target is the default syntax - that means I will produce strings that access Maps with eval. IF the mvel syntax will result in more performant code because it makes Drools handle it better without using eval under the hood, then sure, I can also compile into mvel syntax. Although with that I still have the little problem to have globals in place of literals for Map lookups (see my other mail). Greg Barton schrieb: I was wrong. :). See Mark's later email. GreG On Aug 13, 2009, at 17:25, André Thieme address.good.until.2009.dec...@justmail.de wrote: Greg Barton schrieb: There's no reason why a rete based system couldn't use maps as first class objects, but Drools is heavily oriented towards POJOS. Using eval in the way you have is pretty much the way to go. Thanks for confirming that. For now I know that I am doing it right by using eval and that this means that rules for typical Clojure objects will not benefit from some of the optimizations Drools usually can apply. Maybe it will change in the future. As long as type information is accessible (both for first class types and their members) you should be able to have the left hand side of a rule (the conditions) be as it is now. I think that if Maps become 1st class objects there could be a different Syntax, without using eval. If you lobby the devs hard enough and get others on your side you may be able to convince them to go in that direction, but I doubt it would be possible before version 6 or so, if that early. (And I'm not even sure it's possible.) At this point it is mostly interesting for me to get Drools working with Clojure together and concentrate on correctness. The goal is that users of my lib can use do all typical things people do with Drools without writing Java code. Everything, including the rules, would be written in Clojure. But of course it would be very interesting if the devs could indeed have Clojure in mind. I don't know how reusable the existing code is, for using Maps without the need for eval and with having the respective performance advantages. I understand that the looup of the value for a given key can not be optimized away. On my hardware get() is limited to only 1000 calls per msec and core. Reading a field from a POJO is faster. If I understand it correctly then the problem with eval is that it needs to be executed each time, and no clever caching can be done. So, eliminating that by having Maps being 1st class is what sounds interesting. When I refer to Maps and Clojure, then I talk about Maps having only very few key/value pairs, just like POJOs, and being immutable. This immutability may even be very helpful for optimization. It is guaranteed that a given object will never change. I hope the devs will find it okay if I make some concrete suggestions in the coming weeks. Sunny greetings, André -- Lisp is not dead. It’s just the URL that has changed: http://clojure.org/ ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users DroolsMap.tar.gz Description: GNU Zip compressed data ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users