[rules-users] can drools support complex rules
Hi, I recently came across Drools. I gone through the documentation and the examples provide are quite simple. I want to know if it can be really applied to complex real world problems. Take for example, If a customer login within 5 minutes from two different locations, mark the user invalid. How can I write the above rule in drools? I have the data when the user last logged in and the data of current login. You can say two objects. May be my understanding is wrong but looks like based on rule I have to pass all the required data. How can then at real time new rules can be added? For example, If the customer location is not on a list of valid locations, mark the user invalid. For the above rule I need to pass a list of valid locations as well. Now how about Customer login from more than 5 locations in the last one month? Thanks Mr. Bhangale Bhushan Associate Manager Kale Consultants Ltd. mailto:bhushan_bhang...@kaleconsultants.com bhushan_bhang...@kaleconsultants.com tel: http://www.plaxo.com/click_to_call?lang=ensrc=jj_signatureTo=%2B91+%280%2 9206+608+3777email=bhushan_bhang...@kaleconsultants.com +91 (0)206 608 3777 http://www.kaleconsultants.com http://www.kaleconsultants.com Disclaimer: This email (including any attachments) is intended for the sole use of the recipient/s and may contain material that is CONFIDENTIAL. Any unauthorized disclosure / copying / distribution or forwarding of this message or part is STRICTLY PROHIBITED. If you have erroneously received this message, please delete it immediately and notify the sender. No liability is assumed for any errors and/or omissions in the contents of this message. Information in this message that does not relate to the official business of this Company shall be understood as neither given nor endorsed by it. If verification is required please request a hard-copy version. To know more about Kale Consultants, visit www.kaleconsultants.com -=-=-=-=-=-=-=-=-=- ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] can drools support complex rules
Drools is very well equipped for handling large fact collections. As to the examples you cite, #1 and #2 are simple, as you apparently know. As for #3, check the documentation on the collect and accumulate patterns, which should satisfy you that it can be implemented without undue strain. (To wit: accumulate over logins, later (now-1month), of that customer, maintaining a Set of locations, which must be size()5 at the end. As simple as that.) Also, keep in mind that you have Java as a fallback; so if some problem cannot be implemented easily by pattern matching, you can alway resort to procedural code. -W 2009/5/19 Bhushan Bhangale bhushan_bhang...@kaleconsultants.com Hi, I recently came across Drools. I gone through the documentation and the examples provide are quite simple. I want to know if it can be really applied to complex real world problems. Take for example, If a customer login within 5 minutes from two different locations, mark the user invalid. How can I write the above rule in drools? I have the data when the user last logged in and the data of current login. You can say two objects. May be my understanding is wrong but looks like based on rule I have to pass all the required data. How can then at real time new rules can be added? For example, If the customer location is not on a list of valid locations, mark the user invalid. For the above rule I need to pass a list of valid locations as well. Now how about “Customer login from more than 5 locations in the last one month”? Thanks *Mr. Bhangale Bhushan* *Associate Manager* *Kale Consultants Ltd.* bhushan_bhang...@kaleconsultants.com tel: +91 (0)206 608 3777http://www.plaxo.com/click_to_call?lang=ensrc=jj_signatureTo=%2B91+%280%29206+608+3777email=bhushan_bhang...@kaleconsultants.com http://www.kaleconsultants.com Disclaimer: This email (including any attachments) is intended for the sole use of the recipient/s and may contain material that is CONFIDENTIAL. Any unauthorized disclosure / copying / distribution or forwarding of this message or part is STRICTLY PROHIBITED. If you have erroneously received this message, please delete it immediately and notify the sender. No liability is assumed for any errors and/or omissions in the contents of this message. Information in this message that does not relate to the official business of this Company shall be understood as neither given nor endorsed by it. If verification is required please request a hard-copy version. To know more about Kale Consultants, visit www.kaleconsultants.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] can drools support complex rules
Your question is funny. First you ask if Drools is capable of managing complex rules and then you mention examples of extremely simple rules? :) Drools is FOL complete and so can represent any well formed First Order Logic expression. Anyway, I will use this message to advertise some of the temporal reasoning features that we have on Drools 5 for the benefit of anyone interested. There are several ways of authoring such rules, depending on how you model your problem domain. One possible way of doing them is: #1: rule If a customer login within 5 minutes from two different locations, mark the user invalid. when $l1 : CustomerLogin( ) $l2 : CustomerLogin( userId == l1.$id, location != $l1.id, timestamp after[0s, 5m] $l1.timestamp ) then // mark user as invalid end In the previous example I assumed both login objects would be in working memory, but you can easily query for the previous login in an external datasource, pulling the data from the previous login on-demand for the reasoning cycle. #2: rule If the customer location is not on a list of valid locations, mark the user invalid when $l : CustomerLogin( location not memberOf $validLocations ) then // mark the user invalid end In the above rule, I assume the valid locations list is a global list, but you can as easily model locations as being facts on your working memory or a service end point that you can call to validate the location. #3: rule “Customer login from more than 5 locations in the last one month” when $customer : Customer( $id : id ) $locations : Set( size 5 ) from accumulate( CustomerLogin( customerId == $id, $loc : location ) over window:time( 30d ), collectSet( $loc ) ) then // do something as the customer logged in from more than 5 locations in the last 30 days end In the previous rule I decided to use sliding windows, just to show how that feature can be used to simplify rules, but again, there are several ways of doing it. I strongly recommend you read Drools manual. http://www.jboss.org/drools/documentation.html Cheers, Edson 2009/5/19 Bhushan Bhangale bhushan_bhang...@kaleconsultants.com Hi, I recently came across Drools. I gone through the documentation and the examples provide are quite simple. I want to know if it can be really applied to complex real world problems. Take for example, If a customer login within 5 minutes from two different locations, mark the user invalid. How can I write the above rule in drools? I have the data when the user last logged in and the data of current login. You can say two objects. May be my understanding is wrong but looks like based on rule I have to pass all the required data. How can then at real time new rules can be added? For example, If the customer location is not on a list of valid locations, mark the user invalid. For the above rule I need to pass a list of valid locations as well. Now how about “Customer login from more than 5 locations in the last one month”? Thanks *Mr. Bhangale Bhushan* *Associate Manager* *Kale Consultants Ltd.* bhushan_bhang...@kaleconsultants.com tel: +91 (0)206 608 3777http://www.plaxo.com/click_to_call?lang=ensrc=jj_signatureTo=%2B91+%280%29206+608+3777email=bhushan_bhang...@kaleconsultants.com http://www.kaleconsultants.com Disclaimer: This email (including any attachments) is intended for the sole use of the recipient/s and may contain material that is CONFIDENTIAL. Any unauthorized disclosure / copying / distribution or forwarding of this message or part is STRICTLY PROHIBITED. If you have erroneously received this message, please delete it immediately and notify the sender. No liability is assumed for any errors and/or omissions in the contents of this message. Information in this message that does not relate to the official business of this Company shall be understood as neither given nor endorsed by it. If verification is required please request a hard-copy version. To know more about Kale Consultants, visit www.kaleconsultants.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, a division of Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Using joda-time in drools-fusion
Greg, Not possible to use jodatime at this moment, but I want to develop integration with it and/or JSR 310 for the coming versions. []s Edson 2009/5/19 Greg Barton greg_bar...@yahoo.com Is it possible to use the joda-time classes as timestamp and interval fields in drools-fusion? i.e. declare Foo @role( event ) @timestamp( startTime ) @duration( interval ) end ...where... import org.joda.time.DateTime; import org.joda.time.Interval; public interface Foo { public DateTime getStartTime(); public Interval getInterval(); } I tried it and it's not working, but I want to make sure it's possible before I dig in. There's a dependency in drools for joda-time and I'd like to use it if possible. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Edson Tirelli JBoss Drools Core Development JBoss, a division of Red Hat @ www.jboss.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to import DRL into Business Rule Assets section?
Hi Jon, You could use webdav to connect to Guvnor - http://blog.athico.com/2008/05/accessing-guvnor-as-filesystem-webdav.html. You should then see how Guvnor stores the 'business rules', I think it is an XML file. Then instead of generating DRL file you could generate this XML. You can then upload these files via webdav into Guvnor. Hope this helps. Regards, Michal On Tue, May 19, 2009 at 8:57 PM, Late Norther latenort...@gmail.com wrote: Hello, We are trying to develop a system based on Drools and want to have a repository based on JBoss and manage it from the Guvnor website. Now, we have a few questions: 1) Can we import DRL files into the Business rules section, so that later we can view/modify them using the graphical interface (text boxes, drop down menus, etc)? This will be very useful for production use. What we tried so far, imports them as text in the Technical rules section I have the identical question. I have created a utility which takes our own homegrown rules and converts them (hundreds of rules) into a DRL file. I too have been able to import them into Guvnor, but was hoping they could then be modified via the graphical editor instead of the technical rule editor. The rules are simple and do not contain anything that Guvnor's graphical editor does not support. I have a feeling this is an enhancement request, but just in case anyone knew of a workaround to change the type of rule from technical rule to business rule. Thanks, Jon ___ 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 import DRL into Business Rule Assets section?
2009/5/19 Michal Bali michalb...@gmail.com: Hi Jon, You could use webdav to connect to Guvnor - http://blog.athico.com/2008/05/accessing-guvnor-as-filesystem-webdav.html. You should then see how Guvnor stores the 'business rules', I think it is an XML file. Then instead of generating DRL file you could generate this XML. You can then upload these files via webdav into Guvnor. Hope this helps. Regards, Michal Michal, I can't thank you enough. This worked well. For others, here is a review of what I did. 1. Created a 'dummy' rule using the guided editor in my target package. 2. Used the blog URL above to mount the package webdav share 3. Downloaded the 'dummy' rule from the webdav share to act as a template 4. Updated my Perl import/export script to create .brl files instead of .drl files, using the template. 5. Copied the new .brl files created by my utility script to the webdav share. 6. Go back to Guvnor GWT and saw/confirmed my rules. The only snafu I found was that I am unable to populate a category as part of the import, but I can have my analysts do that by hand if needed. That apparently is not stored in the .brl, but rather somewhere else. I did confirm that I can update the category in the UI after the load. Again, Thank you. Jon ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
RE: [rules-users] can drools support complex rules
I only spent a day reading about Drools. The rules I presented looks simple but the idea was to know if the only solution is to extract all the required data and pass to the rules engine. Or the rules can be written in such a way that is can get the required data from the raw data. Your and Wolfgang example shows that rules can be written over raw data as well as rules can talk to database. I will go through the documentation to grasp the power of drools. Thanks Bhushan -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Edson Tirelli Sent: Tuesday, May 19, 2009 8:48 PM To: Rules Users List Subject: Re: [rules-users] can drools support complex rules Your question is funny. First you ask if Drools is capable of managing complex rules and then you mention examples of extremely simple rules? :) Drools is FOL complete and so can represent any well formed First Order Logic expression. Anyway, I will use this message to advertise some of the temporal reasoning features that we have on Drools 5 for the benefit of anyone interested. There are several ways of authoring such rules, depending on how you model your problem domain. One possible way of doing them is: #1: rule If a customer login within 5 minutes from two different locations, mark the user invalid. when $l1 : CustomerLogin( ) $l2 : CustomerLogin( userId == l1.$id, location != $l1.id, timestamp after[0s, 5m] $l1.timestamp ) then // mark user as invalid end In the previous example I assumed both login objects would be in working memory, but you can easily query for the previous login in an external datasource, pulling the data from the previous login on-demand for the reasoning cycle. #2: rule If the customer location is not on a list of valid locations, mark the user invalid when $l : CustomerLogin( location not memberOf $validLocations ) then // mark the user invalid end In the above rule, I assume the valid locations list is a global list, but you can as easily model locations as being facts on your working memory or a service end point that you can call to validate the location. #3: rule Customer login from more than 5 locations in the last one month when $customer : Customer( $id : id ) $locations : Set( size 5 ) from accumulate( CustomerLogin( customerId == $id, $loc : location ) over window:time( 30d ), collectSet( $loc ) ) then // do something as the customer logged in from more than 5 locations in the last 30 days end In the previous rule I decided to use sliding windows, just to show how that feature can be used to simplify rules, but again, there are several ways of doing it. I strongly recommend you read Drools manual. http://www.jboss.org/drools/documentation.html Cheers, Edson 2009/5/19 Bhushan Bhangale bhushan_bhang...@kaleconsultants.com Hi, I recently came across Drools. I gone through the documentation and the examples provide are quite simple. I want to know if it can be really applied to complex real world problems. Take for example, If a customer login within 5 minutes from two different locations, mark the user invalid. How can I write the above rule in drools? I have the data when the user last logged in and the data of current login. You can say two objects. May be my understanding is wrong but looks like based on rule I have to pass all the required data. How can then at real time new rules can be added? For example, If the customer location is not on a list of valid locations, mark the user invalid. For the above rule I need to pass a list of valid locations as well. Now how about Customer login from more than 5 locations in the last one month? Thanks Mr. Bhangale Bhushan Associate Manager Kale Consultants Ltd. mailto:bhushan_bhang...@kaleconsultants.com bhushan_bhang...@kaleconsultants.com tel: http://www.plaxo.com/click_to_call?lang=ensrc=jj_signatureTo=%2B91+%280%2 9206+608+3777email=bhushan_bhang...@kaleconsultants.com +91 (0)206 608 3777 http://www.kaleconsultants.com http://www.kaleconsultants.com Disclaimer: This email (including any attachments) is intended for the sole use of the recipient/s and may contain material that is CONFIDENTIAL. Any unauthorized disclosure / copying / distribution or forwarding of this message or part is STRICTLY PROHIBITED. If you have erroneously received this message, please delete it immediately and notify the sender. No liability is assumed for any errors and/or omissions in the contents of this message. Information in this message that does not relate to the official business of this Company shall be understood as neither given nor endorsed by it. If verification is required please request a hard-copy version. To know more about Kale Consultants, visit www.kaleconsultants.com --