[rules-users] Inconsistent behaviour of insertLogical in rules having from pattern
Hi all, It is 2 days I am fighting with a strange behaviour of insertLogical in rules having from pattern in conditions : it works the first time, and not after ... - Here is my use-case (simplified) : I have a class that represent a Flight. A Flight has a start/end datetime and is associated with a Airplane and a list of Crew : class Flight { String airplaneId; ListString crewIds; Date start; Date end; } I want to maintain an alert list that contains all overlaps for each airplane and each crew. So I have rules like: rule Overlap Airplane when $f1 : Flight($airplaneId : airplaneId) $f2 : Flight(this != $1, airplaneId == $airplaneId, ... and periods intersecting ... ) then insertLogical(new Alert(...)); end rule Overlap Crews when $f1 : Flight() $crew : String from $f1.getCrewIds() $f2 : Flight(this != $1, eval($f2.getCrewIds().contains($crew)) , ... and periods intersecting ... ) then insertLogical(new Alert(...)); end - Ok. So what I do to test all that stuff : - create a new session - add a first single Flight -- no alerts at all, normal - add a second Flight insersecting the first one with same airplane and same crews list -- 3 new alerts inserted (one for airplane, one for each crew) : normal - remove this second Flight -- the 3 preivous alerts are retracted : still ok - re-add this second Flight -- only the 'airplane' rule triggers, I only get one new alert insteads of the previous same 3 The alerts not inserted correspond to the rule having 'from' in it - To test that it is the source of the problem, I add a new explicit association object that I insert in WM : class CrewAffectation { String idCrew; String idFlight; } For each inserted Flight, I also insert corresponding new CrewAffectation objects. (in case of retract, I retract them of course). I change the last rule to something like : rule Overlap Crews when $f1 : Flight($id1 : id $f2 : Flight(this != $1, $id2 : id, ... and periods intersecting ... ) $crewAff1 : CrewAffectation($idCrew : idCrew, idFlight== $id1) $crewAff2 : CrewAffectation(idCrew == $idCrew, idFlight== $id2) then insertLogical(new Alert(...)); end And with this 'no-from' approach, everything is working as expected. - In addition, I suspect the truth maintenance system to have leaks, and notably in the source kBase. Why ? Because I was facing problems by reusing the same kBase to generate multiples kSessions : The first session created reacted well, while all the folowing not. And it was in fact the same problem as the one described here : usage of from and insertLogical in the same rule. The first created session adds and retract my 3 alerts, the second created session only adds the airplane alert. With using the explicit association object, I can reuse my kBase and everything is working well. - Does someone already faced the problem ? Does it looks like a real bug to dev team or am I doing something wrong (but as it work once, I guess it is a bug) ? Vincent ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Inconsistent behaviour of insertLogical in rules having from pattern
Forgot to say : using drools 5.6.FINAL - Mail original - De: Vincent LEGENDRE vincent.legen...@eurodecision.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Jeudi 28 Août 2014 15:28:49 Objet: [rules-users] Inconsistent behaviour of insertLogical in rules having from pattern Hi all, It is 2 days I am fighting with a strange behaviour of insertLogical in rules having from pattern in conditions : it works the first time, and not after ... - Here is my use-case (simplified) : I have a class that represent a Flight. A Flight has a start/end datetime and is associated with a Airplane and a list of Crew : class Flight { String airplaneId; ListString crewIds; Date start; Date end; } I want to maintain an alert list that contains all overlaps for each airplane and each crew. So I have rules like: rule Overlap Airplane when $f1 : Flight($airplaneId : airplaneId) $f2 : Flight(this != $1, airplaneId == $airplaneId, ... and periods intersecting ... ) then insertLogical(new Alert(...)); end rule Overlap Crews when $f1 : Flight() $crew : String from $f1.getCrewIds() $f2 : Flight(this != $1, eval($f2.getCrewIds().contains($crew)) , ... and periods intersecting ... ) then insertLogical(new Alert(...)); end - Ok. So what I do to test all that stuff : - create a new session - add a first single Flight -- no alerts at all, normal - add a second Flight insersecting the first one with same airplane and same crews list -- 3 new alerts inserted (one for airplane, one for each crew) : normal - remove this second Flight -- the 3 preivous alerts are retracted : still ok - re-add this second Flight -- only the 'airplane' rule triggers, I only get one new alert insteads of the previous same 3 The alerts not inserted correspond to the rule having 'from' in it - To test that it is the source of the problem, I add a new explicit association object that I insert in WM : class CrewAffectation { String idCrew; String idFlight; } For each inserted Flight, I also insert corresponding new CrewAffectation objects. (in case of retract, I retract them of course). I change the last rule to something like : rule Overlap Crews when $f1 : Flight($id1 : id $f2 : Flight(this != $1, $id2 : id, ... and periods intersecting ... ) $crewAff1 : CrewAffectation($idCrew : idCrew, idFlight== $id1) $crewAff2 : CrewAffectation(idCrew == $idCrew, idFlight== $id2) then insertLogical(new Alert(...)); end And with this 'no-from' approach, everything is working as expected. - In addition, I suspect the truth maintenance system to have leaks, and notably in the source kBase. Why ? Because I was facing problems by reusing the same kBase to generate multiples kSessions : The first session created reacted well, while all the folowing not. And it was in fact the same problem as the one described here : usage of from and insertLogical in the same rule. The first created session adds and retract my 3 alerts, the second created session only adds the airplane alert. With using the explicit association object, I can reuse my kBase and everything is working well. - Does someone already faced the problem ? Does it looks like a real bug to dev team or am I doing something wrong (but as it work once, I guess it is a bug) ? Vincent ___ 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] Rules storage without Guvnor?
Hi Guvnor implements a REST API that can be used to get a big DRL from ressources in a package. Most of time in my company's projects we used this API to get and store DRL files in a production environnement, with some dedicated code (no maven nor web in prod). It is almost as simple as copying files, the REST api is simple to use and works great, with all versions (did not test the 6.0, but I use almost the same code since guvnor 5.2). Guvnor only exists in the authoring environnement, and rules should be tested before being deployed (via DRL file copying on a NFS, but a BLOB would work too) in the real prod env, which has no Guvnor at all. We have specifc code to load rules into a new session and execute it on our data (loading new rules if he file has changed). This last point does not use latest drools spring integration (with agents etc etc) mainly because I had to do that kind of thing a long time ago when all that stuff did not exist and from there I go on with some code that I can easily change. But it is quite easy to do (not immediate neither) and you won't depend on some drools code that may change over versions if you want to inject some of your tricks in the middle of the process. In my opinion, Guvnor should be used if you need to make your business user to author rules by themselves. As far I understood from your other posts, you have a lot of old java code to port to new java/rules code, but nowhere you mention who will maintain this. If is it only dev guys, you certainly don't need gunvnor at all and deal directly with your favorite IDE and Git with normal source files (DRL, DSRL, XLS, or whatever, there are numbers of code samples in the doc that tells you how to feed a KB with file ressources). - Mail original - De: Horváth Péter Gergely h.pe...@mailbox.hu À: Rules Users List rules-users@lists.jboss.org Envoyé: Lundi 2 Juin 2014 17:21:11 Objet: Re: [rules-users] Rules storage without Guvnor? Hi Mark, Thank you for your help. Creating a custom build of Guvnor sounds to require quite some effort, I'm not sure whether we should go down that way. Unfortunately, I don't think we will have the option to use Maven based rule deployments at all. In Drools 6, KieScanner seems to be built around Maven; this doesn't suit environments where the application runs on servers without Maven (e.g. no Maven installed, no local Maven repository allowed, access to remote Maven repositories blocked by firewall.) Do you see any way for us to load rule files directly from the file system and still have the automatic change detection? For example, we could push rule files to NFS with CI and let the application detect and pick up changes... Thanks, Peter 2014-06-02 14:13 GMT+02:00 Mark Proctor mproc...@codehaus.org : On 2 Jun 2014, at 08:40, Péter Gergely, Horváth h.pe...@mailbox.hu wrote: blockquote Hello All, We are evaluating Drools for our use case and would have a question for storing rules files. We are in a relatively constrained environment, where getting Guvnor up and running does not seems to be a valid option. Since we would only need the core repository functionality so that we can separate rule deployment from application deployments (and none of the advanced features like online editing etc), I think it would make more sense to have a light-weight alternative for storing the rule files. In 6.0 our rules are stored in GIT, it doesn’t get much lighter than that Our UI is easily customisable if you know how, as it’s all modular, and everything is a plugin. So you can hide/disable the parts that you do not want available at run time, although at the moment that requires a rebuild. blockquote Being able to pick up rules from an NFS share of from a database CLOB field would be perfectly sufficient for us. I have worked with JBPM4 quite a lot, where the core engine contained support for versioned storage of the process definitions in the database itself [1]. /blockquote I don’t see how this would be better than GIT, and certainly a lot more complicated and heavier. blockquote Is there any similar feature in Drools, where the rules can be deployed to e.g. a database or any other repository solution, (without using Guvnor)? /blockquote No, I don’t see what value this would have (simply storing a clob). I could potentially see value in an indexed/exploded rules stored in a DB for refactoring, x-reference, analysis work. But this would be additional to the GIT storage, and not instead of. blockquote I haven't found too much details on this topic, but for me it seems that the only approach would be to have some custom logic, which programmatically checks for rule updates and re-creates the whole knowledgebase on any update. /blockquote You can use our Maven plugin for this with GIT. You can poll or add a GIT hook. You can look into hudson for automating this. JGIT doesn’t expose
Re: [rules-users] Abstraction between rules and data model?
I have personnaly 2 ways of getting as far as possible from refactor problems : - mostly use flat objets, ie some objets that are as DB tables (only simple POJO with foreign keys, no child objects). This way it is easy to get and store used objects (with SQL or JPA frameworks, which has some annotations to map fields with DB columns where you can set your business translations). And for writing rules, it could be simpler too (do the join by testing attributes, ie the attributes you want in this particular context ...) - use automatic translation from your old code, if it is possible it depends on the corresponding code complexity, but then you can handle most of rules automatically (so changes in data model can be handled massively). But I share Wolfgang's point of view when he says that building rules totally independant of underlying objects is not realistic. You will have refactor painful work if you start too soon on a not enough stable data model. So the real way to avoid too much refactor ... is to spend time at building a stable data model ... (considering that point, rules projects are not that different from standard java projects) ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools beginner - unable to resolve method using strict-mode
Define the type as a java class and the error should go away . - Mail original - De: Stefan Schuster stefan.m.schus...@gmail.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Jeudi 11 Avril 2013 10:38:01 Objet: Re: [rules-users] Drools beginner - unable to resolve method using strict-mode yes, the dialect is declared as mvel. The pong game is also part of the standard-examples that come with drools-experts. It's the same if I import this example unmodified. But as it runs, it seams to be only an issue with the eclipse plugin. Annoying, but no serious problem. thanks to all for your help! 2013/4/10 Davide Sottara dso...@gmail.com That rule style requires dialect mvel to be declared either at the rule level or globally in the DRL file, do you have that? Davide On 04/10/2013 08:41 AM, Vincent LEGENDRE wrote: blockquote I am not that drools eclipse plugin is able to see DRL types if they are defined in a separate DRL file. But if your app works well, it is only that. If the type is really missing, you should encounter errors at runtime (when feeding the knowledge base) De: Stefan Schuster stefan.m.schus...@gmail.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Mercredi 10 Avril 2013 16:44:50 Objet: Re: [rules-users] Drools beginner - unable to resolve method using strict-mode Thanks a lot for this hint, but unfortunately this wasn't the problem. Any other ideas? Thanks in advance Stefan ___ 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 /blockquote ___ 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 beginner - unable to resolve method using strict-mode
I am not that drools eclipse plugin is able to see DRL types if they are defined in a separate DRL file. But if your app works well, it is only that. If the type is really missing, you should encounter errors at runtime (when feeding the knowledge base) - Mail original - De: Stefan Schuster stefan.m.schus...@gmail.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Mercredi 10 Avril 2013 16:44:50 Objet: Re: [rules-users] Drools beginner - unable to resolve method using strict-mode Thanks a lot for this hint, but unfortunately this wasn't the problem. Any other ideas? Thanks in advance Stefan ___ 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] Abstracting Rules using extends
May be that the extends problem also comes from the fact that the rules are in separated files, and/or the order which they are given to the kbuilder (base rules must exists prior to rules exntending them). ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Is Drools suitable for preprocessing my Resource Allocation Problem
Hi Raphael, There are multiple concerns mixed here, I don't know if this post would benefit of being cutted in at least 2 : 1- How drools works : read about RETE algorithm (wikipedia is a good start) and about drools-expert (core module that contains the engine, first chapter of the doc explain various things about how it works, how you shoud use, and when you should use or not rules engines). 2- How to mix rules (written by business users I guess) with another optimisation module? For that point the solution will be some architectural design to be as much efficient as possible to stay within the 1 minute. It is highly dependant of what you are using in the optimisation module (especially the KPI form), and/or if you need to call the rules in the middle of solving of not. So, let's go with you case : I am currently playing with Drools, and trying to build rules in Java from my own Rule objects, with the help of the lang.api. So you have your own Rule list somewhere. You don't plan to use drools langage to define them ? What they look like ? (if you can share at least the structure) Actually, there is a optimization-team that already worked on that and came up with their own solution. They also evaluated Drool-planner for the planning part but went another direction for several reasons. This would be interresting to know these reasons. I am only working here into transforming the complex user-filled rules into forbid pairs as an input to the optimizer. I might use drools-planner for this. Don't use planner only to generate pairs. You don't need planner there, drools 'basic' will do the job . If you use planner, use it for you whole optim problem, and feed it with all yours complex user-filled rules. Using planner for that will let you write at most any kind of criteria/KPI or contraints. NoT a stream, but yes, this is a service that will stay up and act as a method : Return the list of forbids for a given list of activities and resources. If I have two rule A and B that may produce the same forbid pairs, I want to produce this pair only once. For that, I will use inference and produce a : insert(new Forbid(ressource, activity)) Then, in each rule, I will check that this forbid is not already present. If the problem is generating a Set of Forbid pairs, you should conlude your rules by adding in a Set (in a kind of response object), and not inserting at all (and remove you check in each rule, except If you use them for more than that). So my question is : Will Drools learn from preivous processings and learn that rule A matches more often than rule B ? And so will it promote A to be processed first ? Even if I flush the working memory between two calls ? Calling fireAllRules will fire all possible rules, whatever their execution order. It is not processed by rules, see RETE algo. Vincent ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Is Drools suitable for preprocessing my Resource Allocation Problem
Hi I did not get the use case here. When you write : The Problem : I have an optimisation engine that can allocate some activities to some resources, while optimizing some KPIs (Key Performance Indicator). The optimizer takes as input (among others) a list of forbiden allocations that should be generated based on some user-provided rules. to me you mean generating an allocation plan. drools-planner is for you, especially if your users want to define more complex rules. As soon as a pair of [Activity,Resource] matches one rule, it should be sent as output, and not tested again against other rules. Also, this is important to note that some rules will match very often, while overs will match very rarely (very specific cases). and here it sounds like a service that has a stream to consume ? then just write rules, put a session in a separate thread, and send him your stream as input. You can even use drools-fusion time operators. Performance constraints Here are some rough hints about the volumetry of the problem : * 1000 activities * 200 resources * 50 rules I need the forbidden allocations to be generated in under a minute. is it the due time for you plan ? or each minute, you need to check 1000a and 200r ? For example, I would not generate all possible allocations (200.000) and then try to apply each rule on it (50 rules x 200.000). not 20 obj, but 20 binary variables. Use local search (drools-planner) or other methods (depends on your KPIs). if stream processing, processing 200.000 objects with 50 rules within a minute is not so hard (depends on rules as W. said). Instead, I would try to match the resources and the activities separately on each rule (each side of the rule), and then assemble the couples that match at least one common rule. RETE will do that for you Also, I would add some counter on each rule that would auto increment upon each match, in order to apply first the rules that match often. If there is a session in a thread, ie maintaining its kownledge over time, RETE will do that for you, by propagating only the updates to the matching rules (forward chaining). If you speak about optimisation using local search, drools-planner will do that for you (by using the previous, may be with adding so custom moves generators). QuestionsIs the engine of Drools smart enought for that ? Or is he even smarter ? If the point is to process forbidden associations, yes, drools can be smarter than that. I whould even say that drools shoud be used only if you want to do to more than that. Do you have an example of Drools being used in a similar problem with success ? optim : drools-planner and its cloud balancing sample real-time stream : look at drools-fusion samples and also drools-expert doc (to get the basis of what rules can do) ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Newbie question - rule based technical drawing
Hi You should look at drools-planner and n-queens sample : http://docs.jboss.org/drools/release/5.5.0.Final/drools-planner-docs/html_single/#d0e914 - Mail original - De: Andreas Höhmann andreas.hoehm...@gmx.de À: rules-users@lists.jboss.org Envoyé: Samedi 8 Décembre 2012 19:04:19 Objet: Re: [rules-users] Newbie question - rule based technical drawing I wan't define the rules with drools to produce an technical drawing. - the electrical elements are placed in layers (i think this is already a rule). - the elements are connected with other elements (i want describe this also with rules) - the number of elements per layer may depend on the number of elements of an other layer (rules) - and so on Maybe this describes my problem a little bit better :) -- View this message in context: http://drools.46999.n3.nabble.com/Newbie-question-rule-based-technical-drawing-tp4021116p4021152.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] Cutom Attributes in Drools
It is not a myth ... but indeed, it's hard. Most of times, you have to find one guy at client's side who is ready to learn at least the main principles of expert-systems. For my experience, it works well enough (ie most of rules dev time is done by the BA) in about 1 proj out of 3. For the others, an IT guy is still needed to help the BA (which is something doable if you have enough rules to author). DSL are hard to set, and harder to maintain, especially while using guvnor (using DSL in a dsrl rule is fine, but dsrl rules for non-IT guys is a myth). Usually I try as much as I can to set a business-compliant POJO model (ie simple, almost flat, with fields named in a way they understand what is behind) and no DSL at all... For the rules' firing control, it is harder ... @dme1 : May be you can think on an agenda filter that looks for the rule's package ? Or use category rules, which is a rule binded to a category, which acts as a parent rule for all rules under this category (so all rules of the same category will have the same common first conditions, which can be the test of your control fact). But beware of that, there was a bug on sub-categories, or when a rule has more than one category (one the first category is taken if I remember well). A last thing could be to use verifier to ensure that all rules have a first condition that test the control fact . @GPatel : your approach sounds great. How much time did you spent to write such a Guvnor alternative ? - Mail original - De: gpa...@tsys.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Jeudi 13 Septembre 2012 18:47:52 Objet: Re: [rules-users] Cutom Attributes in Drools I would not store the result of the (missed) activation of a rule in a rule attribute, anyway. Can't you just use a dedicated fact(s) for that? I face a similar issue where the target audience are business users i.e users that dont really understanding or wish to get into logic. I am finding myself having to resort to all sorts of tricks (using categories/packages/standlone rule editor) to allow business users to easily specify which rules are for what purposes and when they should fire. I just cant rely on them using facts correctly to disable rules that should not fire. In fact, I am now down to using only the standalone editor and saving the rule xml in my tables (not guvnor) so that i have full control over itemized rule display, rule search, knowledgebase creation for different execution profiles, etc. Overall, I increasingly tend to think rules for business users is a myth. The business users wants rule-driven systems, yet they dont want to learn drools. And drools DSL just doesnt cut it. From: Davide Sottara dso...@gmail.com To: rules-users@lists.jboss.org, Date: 09/13/2012 01:57 AM Subject: Re: [rules-users] Cutom Attributes in Drools Sent by: rules-users-boun...@lists.jboss.org You can add any metadata using the format @name( value ) or @name( key=value ). You can then look them up using rule.getMetaData(). Please notice that there's a bug (solved by an open pull request) that does not let you write just @name. In order to use those attributes to control whether a rule fires or not, you can use the declarative agenda, i.e. add meta-rules to your knowledge base such as: rule Meta @activationListener('direct') when // assuming the attribute is @region( [value] ) $a : Activation( rule.metaData[ name ] != MyDesiredRegion, $objs : objects ) // any condition on the tuple here, if needed then drools.cancelActivation( $a ); end notice that you'll have to enable the corresponding option first: KnowledgeBaseConfiguration kconf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration(); kconf.setOption( DeclarativeAgendaOption.ENABLED ); KnowledgeBase kb = KnowledgeBaseFactory.newKnowledgeBase( kconf ); If you want to have rules override each other, watch out for an upcoming feature, Defeasible logic. I would not store the result of the (missed) activation of a rule in a rule attribute, anyway. Can't you just use a dedicated fact(s) for that? Best Davide -- View this message in context: http://drools.46999.n3.nabble.com/Cutom-Attributes-in-Drools-tp4019692p4019736.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 - The information contained in this communication (including any attachments hereto) is confidential and is intended solely for the personal and confidential use of the individual or entity to whom it is addressed. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this communication in error and that any review,
Re: [rules-users] Guvnor Declarative Model
It may be faster to get the drools source code and change the generation by yourself. And post the new code to Edson ... - Mail original - De: Jean-Paul Shemali jshem...@hotmail.com À: rules-users@lists.jboss.org Envoyé: Mardi 11 Septembre 2012 08:29:08 Objet: Re: [rules-users] Guvnor Declarative Model Exactly what I was thinking about, but I wanted to check first if I could reuse drools' bytecode generation instead of adding another thirdparty to the mix (one of my previous questions actually). I do want to avoid messing with custom classloaders as much as I can :-) From what I've seen, it doesn't seem to be easily reusable though Date: Mon, 10 Sep 2012 17:33:43 +0200 From: vincent.legen...@eurodecision.com To: rules-users@lists.jboss.org Subject: Re: [rules-users] Guvnor Declarative Model Ok, not simple indeed ... And why can't you generate a POJO instead of declarative fact ? De: Jean-Paul Shemali jshem...@hotmail.com À: rules-users@lists.jboss.org Envoyé: Lundi 10 Septembre 2012 10:06:43 Objet: Re: [rules-users] Guvnor Declarative Model Simply by not writing them in drools, but in another (proprietary) language, which in turn gets translated to drools at runtime. Of course there's nothing really simple about the translation and how the actual facts get generated Date: Sat, 8 Sep 2012 23:53:47 +0200 From: vincent.legen...@eurodecision.com To: rules-users@lists.jboss.org Subject: Re: [rules-users] Guvnor Declarative Model How can you declare your facts (or rules) if you don't know beforehand the structure of the POJO to use ? ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Guvnor Declarative Model
Ok, not simple indeed ... And why can't you generate a POJO instead of declarative fact ? - Mail original - De: Jean-Paul Shemali jshem...@hotmail.com À: rules-users@lists.jboss.org Envoyé: Lundi 10 Septembre 2012 10:06:43 Objet: Re: [rules-users] Guvnor Declarative Model Simply by not writing them in drools, but in another (proprietary) language, which in turn gets translated to drools at runtime. Of course there's nothing really simple about the translation and how the actual facts get generated Date: Sat, 8 Sep 2012 23:53:47 +0200 From: vincent.legen...@eurodecision.com To: rules-users@lists.jboss.org Subject: Re: [rules-users] Guvnor Declarative Model How can you declare your facts (or rules) if you don't know beforehand the structure of the POJO to use ? ___ 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] Guvnor Declarative Model
How can you declare your facts (or rules) if you don't know beforehand the structure of the POJO to use ? ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Guvnor Declarative Model
a workaround could be to use a java pojo, not a declared fact - Original Message - From: Edson Tirelli ed.tire...@gmail.com To: Rules Users List rules-users@lists.jboss.org Sent: Friday, September 7, 2012 3:43:04 PM Subject: Re: [rules-users] Guvnor Declarative Model Ouch, more than 255 fields? As of 5.4.x there is no workaround, the engine always tries to generate the constructor. Can you please open a JIRA and we will fix this for the next release? Thank you, Edson On Fri, Sep 7, 2012 at 9:05 AM, JP Chemali jshem...@hotmail.com wrote: Hi guys, I just stumbled into the same issue in 5.4.0.Final, I think this is caused by https://issues.jboss.org/browse/JBRULES-2652 When declaring a type, a constructor with all fields as parameters is generated automatically, but this causes in our case to hit a barrier of the Java language because the generated constructor has more than 255 parameters Anyone knows if this generation can be skipped (annotation or something else), maybe a safeguard not to generate the constructor when the limit is reached would be nice too? -- View this message in context: http://drools.46999.n3.nabble.com/Guvnor-Declarative-Model-tp4019419p4019637.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 ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Without salience
If it works with salience, why change ? And why is the order so important ? Still trying to get the first occurence of an event of a given type/value ? It remembers me some not-so-old post ... - Mail original - De: salt writemesaltwo...@gmail.com À: rules-users@lists.jboss.org Envoyé: Mardi 4 Septembre 2012 06:17:16 Objet: [rules-users] Without salience Hi All, For the below use case i have implemented the rule. Please suggest other way of doing without salience. scenario ITEMS AMOUNT OCCNO PASS 10 1 FAIL 10 2 PASS 15 3 PASS 25 4 rule HelloWorld_14 salience (65522- $list.indexOf( $transdet1 )) when $p1:Passes($list : transaction) $trans1:Transaction(items in (PASS)) from $list $p2:Passes() not(exists($transdet5:Transaction(items in (FAIL),value==$transdet1.getVaue(), occno$trans1.getOccno()) from $p2.transaction)) then System.out.println($trans1.getOccno()); end The above will return 3 4 (not 4,3) Kindly suggest other way of doing this without salience. Thanks Salt -- View this message in context: http://drools.46999.n3.nabble.com/Without-salience-tp4019565.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] ClassNotFoundException
Are you sure that this specific jar/class does not depends of other external (from java/drools point of view) classes ? Does it work if you download the generated DRL, and compile/run it outside Guvnor ? - Mail original - De: devan vanreenen devan.vanree...@gmail.com À: rules-users@lists.jboss.org Envoyé: Lundi 3 Septembre 2012 13:49:00 Objet: Re: [rules-users] ClassNotFoundException Thanks for the response Steve, the only imports I have are specifically for objects I use within my rules, I have removed all the imports for the problematic jar as well as any imports for objetcs not used in the rules and tried using the fully qualified names of the classes in the rules, still no luck. There are no issues with my other jars just a specific one, I deleted this jar and uploaded again. -- View this message in context: http://drools.46999.n3.nabble.com/ClassNotFoundException-tp4019536p4019541.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] Job Opportunity - Jboss, Drools, Java Architecht/Consultant
But it may be a horse anyway ... Let's say Anatolia is this list, and the horse the initial post. According to all the jobs available for that kind of profile around the world, it can be the first of a very long bunch of junk mails proposing a job that anyone here can find within a week ... - Mail original - De: Tom Eugelink t...@tbee.org À: rules-users@lists.jboss.org Envoyé: Jeudi 30 Août 2012 11:59:07 Objet: Re: [rules-users] Job Opportunity - Jboss, Drools, Java Architecht/Consultant Hey, I'm already impressed with myself that I knew MI is Michigan (I did use google to find out how that is spelled though, initially had a T in there). :-) Tom On 2012-08-30 11:53, Wolfgang Laun wrote: Well, it's certainly not Troy in Anatolia ;-) On 30/08/2012, Tom Eugelink t...@tbee.org wrote: I assume this is somewhere in the US? MI is Michigan, right? (There are non Americans on this list as well ;-) Tom ___ 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] rules not being reconsidered after modify
Hi, You must make a difference between facts and other objects (that you can get by bindings). facts are the objects inserted in the working memory. Only those objects can be matched directly in LHS. Other entities can be accessed by using attributes (of facts) bindings or from constructions to get objects from facts fields. And finally, only the facts can be modified/inserted/retracted, ie actions that trigger a RETE evaluation and thus new candidate rules to fire. Here, in your first rule, your LHS is matching facts and use a binding $krankheitsbild for a field of KrankheitsbildVonPatient fact. And you are modifying the binded attribute, which is not a fact. So it won't trigger RETE evaluation... To me, it should not compile, but apparently it does You can think about 2 corrections : 1 - make your $krankheitsbild objects real facts, ie insert them in the WM, and don't get them via attribute binding 2 - do the set on $krankheitsbild, then update your containing fact object ( with update($krankheitsbildVonPatient) ) here are the approximative form of the resulting rules for the 2 approaches : ---1--- I suppose that Krankheitsbild objects are inserted independently, and your model modified like that declare KrankheitsbildVonPatient patient : Patient end declare Krankheitsbild parent : KrankheitsbildVonPatient abdominaleAdipositas : boolean adipositasGrad : String risikoBegleiterkrankungGrad : int risikoMetabolischeKardiovaskulaereKomplikationen : String metabolischesSyndrom : boolean end so the rule should look like : rule when MessdatenVonPatient($patient : patient (getMessdaten().getBmi() = 18.5) (getMessdaten().getBmi() 25)) $krankheitsbildVonPatient : KrankheitsbildVonPatient(patient == $patient ) $krankheitsbild : Krankheitsbild ( parent == $krankheitsbildVonPatient ) then modify($krankheitsbild){setAdipositasGrad(Normalgewicht), setRisikoBegleiterkrankungGrad(1) } end ---2--- May be simpler, but beware of loops ... rule ... when MessdatenVonPatient($patient : patient (getMessdaten().getBmi() = 18.5) (getMessdaten().getBmi() 25)) $krankheitsbildVonPatient : KrankheitsbildVonPatient(patient == $patient $krankheitsbild : krankheitsbild) then $krankheitsbild.setAdipositasGrad(Normalgewicht); $krankheitsbild.setRisikoBegleiterkrankungGrad(1); update ( $krankheitsbildVonPatient ) ; end - Mail original - De: wichtl irr4e...@gmx.net À: rules-users@lists.jboss.org Envoyé: Jeudi 30 Août 2012 15:56:29 Objet: [rules-users] rules not being reconsidered after modify Hi, I'm new to using Drools and its probably just a problem with me understanding how this works, but I've tried everything i can think of, so I come to you in hope for some help! I have a set of rules which modify an object in the RHS and another set of Rules that should be fireing after the modification of the object. Rule modifying the Object: rule Wenn der BMI des Patienten = 18.5 und 25 ist, dann gehört der Patient der Kategorie 'Normalgewicht' an und hat ein 'durchschnittliches' Risiko für Begleiterkrankungen des Übergewichts when MessdatenVonPatient($patient : patient (getMessdaten().getBmi() = 18.5) (getMessdaten().getBmi() 25)) $krankheitsbildVonPatient : KrankheitsbildVonPatient(patient == $patient $krankheitsbild : krankheitsbild) then modify($krankheitsbild){setAdipositasGrad(Normalgewicht), setRisikoBegleiterkrankungGrad(1) } end Rule that should fire after the modification: rule Wenn Patient der Kategorie 'Normalgewicht' angehoert, dann werden folgende Maßnahmen vorgeschlagen when KrankheitsbildVonPatient($patient : patient, krankheitsbild.adipositasGrad == Normalgewicht) then System.out.println(Some Text); end Also I have encountered problems (application freezes) when trying to modify the $krankheitsbildVonPatient object in the RHS. And I still don't understand why it did freeze and why modifying $krankheitsbild does not. Heres my datamodel if needed: http://drools.46999.n3.nabble.com/file/n4019463/dataModel.drl dataModel.drl Best Regards, wichtl -- View this message in context: http://drools.46999.n3.nabble.com/rules-not-being-reconsidered-after-modify-tp4019463.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] Understanding Rules Firing Sequence
The learning is : for your case, where all your row in your table have an implicit priority and business logic, yes, don't hope that drools engine will guess that by itself. As far i understand, you expect the rules to trigger from top to bottom (or most specific to less), and stop when a rule has fired. Your problem is that you have a lot of rules with shared conditions which have different (and conflicting) actions. Using specificity strategy is a good idea (never tried, but it looks great), but that won't prevent other (less specific) rules to fired after the first specific rules has fired. In addition to specific strategy, you have to add a condition to test if your fees field is set or not. If you add a common column (you can hide it under guvnor) that test fees == null, then the first rule exec (so the most specific one) will set this field and prevent other rules to fire. So, please let drools manage the rules firing, but tune your rules/facts to fit your specific business logic, under drools (or any other expert-system) constraints. - Mail original - De: tanug tanu.gu...@rupeelog.com À: rules-users@lists.jboss.org Envoyé: Mardi 28 Août 2012 13:44:25 Objet: Re: [rules-users] Understanding Rules Firing Sequence Thanks everyone for your suggestions. so, basically, the learning is : I should not leave rule firing to Drools, and have a proper priority and exit condition. And, I cannot rely on specificity for rule selection (i was so hoping it would work) Thanks again, best regards Tanu -- View this message in context: http://drools.46999.n3.nabble.com/Understanding-Rules-Firing-Sequence-tp4019409p4019416.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] Timer Cron reevaluating same facts again and gain
I expected only new facts to be evaluated as I'm running stateful session It only works this way if you let your session alive in a separate Thread, using fireUntilHalt(). If you use fireAllRules() (by instance each 5s), then yes, everything will be re-evaluated, just as if it were a new session. NB : I hope you have something to clean up your facts too ! - Mail original - De: rvkhakhkhar1 rvkhakhk...@gmail.com À: rules-users@lists.jboss.org Envoyé: Mercredi 29 Août 2012 11:58:51 Objet: [rules-users] Timer Cron reevaluating same facts again and gain I have a rule which fires let's say every 5 secs. I have thread which continously infuse facts to ksession simultaneoulsy. For example, At 5th sec, I have 500 matching facts, with total 1000 facts Before the next invocation I infuse another 1000 facts. So, at 10th sec, Rule considers whole working memory including previously evaluated facts. I expected only new facts to be evaluated as I'm running stateful session View this message in context: Timer Cron reevaluating same facts again and gain 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] A few general questions on scaling StatefulKnowledgeSessions
If you do nothing heavy in the RHS, indeed, rules' action part execution is faster than fact insertion, but this is because of your design, not something relevant for all usages. In an inference system using RETE like drools, the most of time is spent to update the RETE network. Updates of this network is done at insert/retract/modify, and these actions can be called from outside OR inside the rules RHS. In an inference system, you may be interested by chaining, ie your rules' RHS do modify the fact base heavily, and thus the RHS exec takes time. What you describe in your post is almost a sequential behaviour, ie rules exec does not modify the fact base. I agree that this is a very common usage, but you can't oppose fact insertion and RHS execution without the precision of your design choices, which can be too restrictive for other usages that require chaining. - Original Message - From: Stephen Masters stephen.mast...@me.com To: Rules Users List rules-users@lists.jboss.org Sent: Friday, August 17, 2012 3:54:41 PM Subject: Re: [rules-users] A few general questions on scaling StatefulKnowledgeSessions Actually, I do mean that! :D But maybe I should explain… To be more precise, most of the time in my apps is taken in marshalling facts and inserting them into the session. From firing rules, it tends to take 10s of microseconds for a decision to be made. Obviously if the RHS is doing more than just making a decision based on facts already in the system (i.e. the RHS code queries databases, etc) then firing can get very slow. However, I tend to follow the best practices that I learned from various FICO (!) consultants, who recommended against doing anything heavy in the RHS, but rather getting back out of the rules engine ASAP and doing those heavy tasks in the invoking application. This approach works nicely, because the rules engine does what it's good at (making decisions based on facts that are in working memory) and my Java (Spring) app does what it's good at (getting data and integrating with other systems). The added benefit is that if I need to synchronise access to the session, it's not such an issue if each request is back out of the rules engine in microseconds. Steve On 17 Aug 2012, at 13:01, Wolfgang Laun wolfgang.l...@gmail.com wrote: On 17/08/2012, Stephen Masters stephen.mast...@me.com wrote: But here are some slightly more practical thoughts from my experience... Inserting new facts is slow. (although still sub-millisecond) Evaluating rules is fast. Left hand sides of rules are evaluated while new facts are inserted, so the above distinction does not make sense for me. Perhaps you can explain what you mean by evaluating rules? Executing (firing) rules depends on what's done on the right hand side, so you can't mean that. -W ___ 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] Audit Logs: Business Case? Any pearls of wisdom?
I agree with Wolfgang on it is common sense to have audit logs for a real application, and of course the way to do it with listeners. Most of time, for my experience, these logs (which rule has triggered, what are the changes made (insert, retract, update...) ...) are simply dumped in the main application log file, and follow the same life cycle (deleted after some fixed time). Except for some really critical application that needs a strong justification of their results (like something doing quotations, or computing salaries), I don't see the utility of keeping all audit for all transactions in a production evironnement. But for debug phase (and also users training phase), it is really useful. In your mail, I see two distincts questions : - Should you add in your system some audit functionnalities to log what happend somewhere : I would say yes - Should you keep all this stuff somewhere, and how to store and how to format these information : I would say that raw logging is enough for debugging, but not if you have other requirements (like giving access to this to non IT rules author, use the audit result in a automated alert system, do report on rules usage, being able to answer to claims for a long period of time ...). - Mail original - De: Wolfgang Laun wolfgang.l...@gmail.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Jeudi 9 Août 2012 20:31:29 Objet: Re: [rules-users] Audit Logs: Business Case? Any pearls of wisdom? If you need to keep track of changes in your WM database, a property change listener is one solution. In addition with an AgendaEventListener listening to rules being fired you should be able to document what was done and by which rule. I'd say it is common sense to have this in a business application that uses rule to modify data. There are simpler scenarios such as validating or analyzing data where it might not be necessary (after testing). -W On 9 August 2012 20:14, BenjaminWolfe benjamin.e.wo...@gmail.com wrote: Hello all, My company is just venturing into Drools, and I'd like to help make the endeavor as successful as possible. We'll be incorporating the rules engine into a broad range of use cases (depending on how successful the first few are, of course), with a wide range of business users, most of them using the Guvnor interface. It seems to me we'll want some sort of audit log in the form of a transaction-level table, simply to answer the question (in any given case, for any reason) of /what happened?/. On the other hand, a transaction-level table -- for a whole set of rules -- for a *lot* of facts (built up over time) -- could get pretty big. And our tech folks might not want to allocate resources to store and maintain the table. So I have a couple of questions for the more experienced Drools users: 1. How might you build a solid business case for such logging? Do you have any specific examples of the problems an audit log would solve, or the benefits it would create? 2. How common is it to keep audit logs? Do almost all of your projects include them, almost none, or somewhere in between? 3. Maybe I'm missing some nuance. Do you include audit logs of some rules fired, in some applications, but not others? Any other nuggets of wisdom? Thanks everyone, Benjamin -- View this message in context: http://drools.46999.n3.nabble.com/Audit-Logs-Business-Case-Any-pearls-of-wisdom-tp4019073.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 mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Best design pattern for: Set of events with countdown timers?
did you check here : http://drools.46999.n3.nabble.com/please-provide-a-rule-for-events-timeout-cases-td3907955.html - Mail original - De: dunnlow dunn...@yahoo.com À: rules-users@lists.jboss.org Envoyé: Vendredi 10 Août 2012 16:19:33 Objet: [rules-users] Best design pattern for: Set of events with countdown timers? Hi, I am receiving events from a group of about 15 different event producers - each with different names (located in the message). I want to make sure that I get at least one event from each of those 15 producers within a pre-determined period of time; the period can be different for each producer. I am planning to use a template rule to relate producer name to time period. Then, I'll insert a myTimoutObject for each producer (not quite sure yet where/how I'll do that) which will count down from the provided time period and trigger an alert condition if they reach zero (and reset whenever a new event from that producer arrives into the ksession). Does anyone have experience with a better way to implement this count-down pattern? Thanks for any insight, -J -- View this message in context: http://drools.46999.n3.nabble.com/Best-design-pattern-for-Set-of-events-with-countdown-timers-tp4019091.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] Web decision tables (Guvnor)
Hi I was wondering why you need the otherwise here. May be it is only because you have simplified your sample, but the table you sent is like a truth-table telling what currency can be converted for a particular account. So, as you have a 2 state answer, you can simply add rules to specify the true answer, by modifying the answer flag that is set to false initially. In other words, you cannot convert the currency unless a rule have triggered to set the flag to true. Or if you use a fact to store the answer, if the fact is there you can convert, if not (because no rule had triggered) you can't convert. This way, your table becomes quite simple, but I don't know if my assumption is generalizable to your whole application. - Original Message - From: Michael Anstis michael.ans...@gmail.com To: Rules Users List rules-users@lists.jboss.org Sent: Friday, August 10, 2012 5:07:54 PM Subject: Re: [rules-users] Web decision tables (Guvnor) Hi Stephen, You've made my afternoon ;) The operation of otherwise is rather dumb. It does not have any understanding of what groups of rows it is meant to limit it's search of values to construct the not in part. As you have discovered, in your case, the Account column has no significance at all (to the web-guided decision table) although it does to the business analyst. The immediate workaround would be to move each group to a different decision table; i.e. Account=1 and Account=2. I appreciate your example is probably a simplification of the real problem. A better solution would be to furnish the otherwise value with the information it would need to determine it's search range. e.g. define otherwise with a key column of Account. This is however an enhancement :( Feel free to raise a JIRA (for GUVNOR)... no promises as to when I'll get a chance to do anything about it though :( More complex requirements exist, for example given:- Account Qualifier Currency CanTrade 1 A EUR Y 1 A USD Y 1 B IDR Y 1 A Otherwise N 2 A EUR Y 2 B USD Y 2 B Otherwise N Account=1, Qualifier=A, Otherwise = not in (EUR, USD) Account=1, Qualifier=B, There is no otherwise Account=2, Qualifier=A, There is no otherwise Account=2, Qualifier=B, Otherwise = not in (USD) etc So Otherwise will need a set of key\group columns. With kind regards, Mike On 10 August 2012 15:50, Stephen Masters stephen.mast...@me.com wrote: Hi folks, Given a decision table a bit like this (hopefully the monospaced font lays it out ok!): Account Currency CanTrade 1 EUR Y 1 USD Y 1 IDR Y 1 Otherwise N 2 EUR Y 2 USD Y 2 Otherwise N LHS conditions are generated a bit like this: account == 1, currency == 'EUR' account == 1, currency == 'USD' account == 1, currency == 'IDR' account == 1, currency not in ('EUR', 'USD', 'IDR') account == 2, currency == 'EUR' account == 2, currency == 'USD' account == 2, currency not in ('EUR', 'USD', 'IDR') … which has the effect that for account 2, currency IDR, the rule does not fire. For the business analysts building the rules, this does't make a lot of sense, as they're expecting it to mean: account == 2, currency not in ('EUR', 'USD') Unfortunately this means that if a currency is permitted for one account, then a row must be added for every other account, indicating that the currency is not permitted. I'm trying to achieve a sensible default (fire the rule to reject the trade) unless the currency is explicitly permitted. Is there a decent mechanism for achieving this in a decision table? One alternative I can think of is to create a technical rule which logically inserts a rejection which exists as long as this rule hash't fired. But I would really prefer to avoid doing anything like that, as I reckon it would be something of a maintenance nightmare. Any thoughts? Cheers, Steve ___ 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] Matching consecutive events
May be something with the internal clock and timestamps assigned as events dates and inclusive (or not I don't remember) bounds in after/before operators evaluation ... in short, I am not sure of the expected result if all your event (or 2 among your 3 events) have the same event date. But apart from that, may be you can implement a Listener (on insert callback) that maintains an explicit insertion order directly inside the event. This way, no need to use complex LHS to test that an event is directly preceeded by another. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Apply role to whole class hierarchy
I had the same strange problem some time ago (last winter), but I never managed to reproduce a small sample I checked, and my problematic class hierarchy also lived in different packages (and never tried that that for my smaller samples) . - Mail original - De: Joerg Henne hennejg+nab...@googlemail.com À: rules-users@lists.jboss.org Envoyé: Lundi 30 Juillet 2012 16:04:50 Objet: Re: [rules-users] Apply role to whole class hierarchy After some debugging I was able to shed some light on what causes the problem, even if I don't fully understand it. The problem is produced by the event base class, which is declared with @role(event), i.e. (VSCPEvent) living in a different package than the ButtonEvent. If I move then into the same package, everything works just fine. The two package instances are merged in PackageBuilder.mergePackage(...), but the RuleBuilder still seems to operate on two separate instances, one with the declarations and Package.isEvent(...) returning true for the ButtonEvent and the other without them. Unfortunately, as I know too little about the workings of the various builders, I can't provide you with a ready-made idea of how to fix the problem. See https://issues.jboss.org/browse/JBRULES-3587 Thanks Joerg -- View this message in context: http://drools.46999.n3.nabble.com/Apply-role-to-whole-class-hierarchy-tp4018930p4018963.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] Using Global Model for all packages
Never managed to get that working properly too ... 3 options : - Try again to really share the model from global area to all package. - Put the jars in Guvnor classpath (or tomcat classpath) - Write a REST client that upload the jar to all packages. - Mail original - De: starfish15 pooja.gh...@accenture.com À: rules-users@lists.jboss.org Envoyé: Mardi 24 Juillet 2012 14:15:45 Objet: [rules-users] Using Global Model for all packages Hi Admins, I have been using GUVNOR 5.2 from sometime now. We have different packages created, as per the requirement of different teams. However, they do use the same MODEL. I was wondering if we could simply upload a jar in the global area, and use the same in every other package. I know that we can create models for each package and say Import asset from global area. However doing the same again and again, isnt helping me in any manner. The rules arent getting updated with the class files and the rules validation failes with in the Business Rule Assets. Is it that this doesnt work or is it that am missing on something??? Kindly assist ASAP. Regards, starfish -- View this message in context: http://drools.46999.n3.nabble.com/Using-Global-Model-for-all-packages-tp4018861.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] java.lang.NullPointerException at org.drools.reteoo.ReteooFactHandleFactory.newFactHandle(ReteooFactHandleFactory.java:56)
I guess that entryPoints is a map that you build at init. Are you sure that the entry points in it are in sync with the actual session ? Why not using kSession.getWorkingMemoryEntryPoint(name).insert(...) directly ? @Wolfgang : Why can't there be a bug in NamedEntryPoint.insert(...) ? Having a NPE here is problematic, especially for a internal variable got from inside the same internal method. May be this is not called a bug, but at least the exception should be more explicative.. Best guess for now is that the problem is inside your code (dont know where) and not inside drools code. The NPE, even if it should have been more user friendly, is certainly just a consequence of a bad usage somewhere. If it works well using DRL, and not using Guvnor, it may be a good track to follow. If you have the same usage (session creation, inserts, fire ...), then you have differences between the two ruleset (rules and/or model is different). With Guvnor, you can also download the source (just like a big DRL) instead of the pkg. This can be a solution too. - Mail original - De: Carolina Pellecchia carolina.pellecc...@gmail.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Mardi 24 Juillet 2012 14:27:34 Objet: Re: [rules-users] java.lang.NullPointerException at org.drools.reteoo.ReteooFactHandleFactory.newFactHandle(ReteooFactHandleFactory.java:56) The entryPoint and obs aren't null. I'm sorry, where do you see the error? Carolina 2012/7/24 Wolfgang Laun wolfgang.l...@gmail.com Well, then it's a bug in your code. Do we all agree on this now? -W On 24/07/2012, Carolina Pellecchia carolina.pellecc...@gmail.com wrote: If there is an insert() call in org.tass.utils.ExpertSystemManager.java in line 156 then *this* is where the insert occurs, not the insert() in the rule. org.tass.utils.ExpertSystemManager.java is our class and the source code is this: 153. *public* *void* insertObservation(String entryPoint, Observation obs) { 154. *try* { 155. *if*(entryPoints.containsKey(entryPoint)) { 156. entryPoints.get(entryPoint).insert(obs); 157. 158. ksession.fireAllRules(); 159. } 160. } 161. *catch* (Exception e) { 162. logger.error(e, e); 163. } 164. } Where is org.tass.utils coming from? Where is org.tass.utils coming from? it is our class. It's still a mystery to me how it's possible to have a stack trace element from NamedEntryPoint.java line 48 - there's no code in this line. I agree, at the line 48 there isn't code. It would seem that Drools 5.3.0 final has different binary and source code. There is another mystery : why this is working when getting rules from a DRL file and not from Guvnor ... Did you add the POJO model into the Guvnor's package ? Yes, I did. But if this is it, package compilation should raise a compilation error ... The package compilation is ok. What is sure is that the problem does not comes from the rules, as the stack trace shows an insert call outside the rules, otherwise there would be a reteoo...ConsequenceInvocator (something like that) before .. yes, It is sure And a last question : is org.tass.utils.ExpertSystemManager a class from you, or does it take place into another third-party framework (that could use a different or modified version of drools). org.tass.utils.ExpertSystemManager.java is our class. We aren't using third-party framework. Thank you Carolina 2012/7/23 Vincent LEGENDRE vincent.legen...@eurodecision.com There is another mystery : why this is working when getting rules from a DRL file and not from Guvnor ... Did you add the POJO model into the Guvnor's package ? But if this is it, package compilation should raise a compilation error ... What is sure is that the problem does not comes from the rules, as the stack trace shows an insert call outside the rules, otherwise there would be a reteoo...ConsequenceInvocator (something like that) before .. And a last question : is org.tass.utils.ExpertSystemManager a class from you, or does it take place into another third-party framework (that could use a different or modified version of drools). ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] java.lang.NullPointerException at org.drools.reteoo.ReteooFactHandleFactory.newFactHandle(ReteooFactHandleFactory.java:56)
@Vincent: I'm concerned about the first stack trace line, which is where no executable code can be. Clear this up first... Me ? Really no idea why this line ... This line, in 5.3 code, is the class declaration. Indeed, node an executable piece of code ... I've found another thread : http://drools.46999.n3.nabble.com/rules-users-Drools-5-4-0-FINAL-and-OSGI-Unable-to-instantiate-service-for-Class-org-drools-concurren-td4017660.html where we can see a stack trace giving a org.drools.common.NamedEntryPoint.insert(NamedEntryPoint.java:53) which is the class declaration line in 5.4 source code... May be that some JVMs points that because there are some static inits in the class ? Or may be some AOP usage ? All other line calls (insert etc etc) matches exactly the lines shown in the stack trace, so to me, it is not so important ... at least not for the problem here. The real problem is why ObjectTypeConf conf .getTypeDeclaration(); returns null using Guvnor compiled pkg and not via DRL local compilation ... ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] java.lang.NullPointerException at org.drools.reteoo.ReteooFactHandleFactory.newFactHandle(ReteooFactHandleFactory.java:56)
Our application is using this url: http://localhost:8080/guvnor/org.drools.guvnor.Guvnor/package/org.dfms.model/LATEST to loading from Guvnor5.3.0 the pkg. Is it correct? Yes, to get the compiled package, compiled inside Guvnor , but this is the problem here. The compiled package is a serialized kPackage object . When you get this from guvnor, and put it inside your kBase, the object is simply deserialized. The ObjectTypeConf conf .getTypeDeclaration() will look in the kBase, and for guvnor compiled package this method returns null (don't know why). I think you may have a difference between your Guvnor version and the drools runtime version. You can either use the source got from guvnor ( http://localhost:8080/guvnor/rest/packages/org.dfms.model/source ) to build your kBase, and this should work fine. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] java.lang.NullPointerException at org.drools.reteoo.ReteooFactHandleFactory.newFactHandle(ReteooFactHandleFactory.java:56)
are you sure that your SituationManager.createAccessControlEvent method returns something not null ? - Mail original - De: Carolina Pellecchia carolina.pellecc...@gmail.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Lundi 23 Juillet 2012 12:44:28 Objet: Re: [rules-users] java.lang.NullPointerException at org.drools.reteoo.ReteooFactHandleFactory.newFactHandle(ReteooFactHandleFactory.java:56) Is there anybody that can help ME with this issue, please? Regards, Carolina 2012/7/20 Carolina Pellecchia carolina.pellecc...@gmail.com Hi everyone! I'm loading from Guvnor5.3.0 the pkg below into my application. package org.dfms.model; import org.dfms.model.observation.ACObservation; import org.dfms.model.situation.AccessControlEvent; import org.dfms.model.situation.SituationManager; import org.dfms.model.situation.Event; import org.dfms.model.mapfeature.AccessControlPoint; import java.util.HashSet; import java.util.ArrayList; declare ACObservation @role(event) end declare AccessControlEvent @role(event) end rule AccessControl no-loop when $obs : ACObservation( $sensorid : sensorId, $location : location ) over window:length(1) from entry-point access_control then insert ( SituationManager.createAccessControlEvent( $obs, Access Control Detection , Event.THREAT_NO, $location, $sensorid )); end When the rule is executed the application get this exception: [ java ] ERROR [2012-07-20 14:32:17,422] [Thread-19] ( ExpertSystemManager.java:162 ) - java.lang.NullPointerException [ java ] java.lang.NullPointerException [ java ] at org.drools.reteoo.ReteooFactHandleFactory.newFactHandle( ReteooFactHandleFactory.java:56 ) [ java ] at org.drools.common.AbstractFactHandleFactory.newFactHandle( AbstractFactHandleFactory.java:80 ) [ java ] at org.drools.common.AbstractFactHandleFactory.newFactHandle( AbstractFactHandleFactory.java:65 ) [ java ] at org.drools.common.NamedEntryPoint.createHandle( NamedEntryPoint.java:720 ) [ java ] at org.drools.common.NamedEntryPoint.insert( NamedEntryPoint.java:280 ) [ java ] at org.drools.common.NamedEntryPoint.insert( NamedEntryPoint.java:116 ) [ java ] at org.drools.common.NamedEntryPoint.insert( NamedEntryPoint.java:48 ) [ java ] at org.tass.utils.ExpertSystemManager.insertObservation( ExpertSystemManager.java:156 ) [ java ] at org.tass.vsensor.ExpertVS.dataAvailable( ExpertVS.java:59 ) [ java ] at gsn.beans.InputStream.executeQuery( InputStream.java:277 ) [ java ] at gsn.beans.StreamSource.windowSlided( StreamSource.java:325 ) [ java ] at gsn.beans.windowing.SQLViewQueryRewriter.dataAvailable( SQLViewQueryRewriter.java:83 ) [ java ] at gsn.beans.windowing.TupleBasedSlidingHandler.dataAvailable( TupleBasedSlidingHandler.java:56 ) [ java ] at gsn.wrappers.AbstractWrapper.postStreamElement( AbstractWrapper.java:222 ) [ java ] at gsn.http.rest.LocalDeliveryWrapper.writeStreamElement( LocalDeliveryWrapper.java:147 ) [ java ] at gsn.http.rest.DefaultDistributionRequest.deliverStreamElement( DefaultDistributionRequest.java:57 ) [ java ] at gsn.DataDistributer.flushStreamElement( DataDistributer.java:165 ) [ java ] at gsn.DataDistributer.run( DataDistributer.java:220 ) [ java ] at java.lang.Thread.run( Thread.java:662 ) How can I solve this issue? Thank you in advance, Carolina Pellecchia ___ 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] java.lang.NullPointerException at org.drools.reteoo.ReteooFactHandleFactory.newFactHandle(ReteooFactHandleFactory.java:56)
There is another mystery : why this is working when getting rules from a DRL file and not from Guvnor ... Did you add the POJO model into the Guvnor's package ? But if this is it, package compilation should raise a compilation error ... What is sure is that the problem does not comes from the rules, as the stack trace shows an insert call outside the rules, otherwise there would be a reteoo...ConsequenceInvocator (something like that) before .. And a last question : is org.tass.utils.ExpertSystemManager a class from you, or does it take place into another third-party framework (that could use a different or modified version of drools). ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Web guided Decision table
predicate type column allow you to write anything, using $param placeholder to retrieve your cell's content. - Mail original - De: abhinay_agarwal abhinay_agar...@infosys.com À: rules-users@lists.jboss.org Envoyé: Jeudi 19 Juillet 2012 13:39:40 Objet: [rules-users] Web guided Decision table is there a way by which i can use drools.setFocus() and drools.getWorkingMemory().clearAgendaGroup() in a Web guided Decision table ?? -- View this message in context: http://drools.46999.n3.nabble.com/Web-guided-Decision-table-tp4018776.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] Web guided Decision table
or create a false setter in your POJO and modify it ... by instance by giving it the agenda-group you want to focus ... - Mail original - De: Michael Anstis michael.ans...@gmail.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Jeudi 19 Juillet 2012 14:39:44 Objet: Re: [rules-users] Web guided Decision table If you're using 5.4 you can add a BRL Action column and use a free-format DRL fragment. Prior to 5.4 the above is not possible. In which case an alternative might be to use Rule Templates instead. On 19 July 2012 13:02, abhinay_agarwal abhinay_agar...@infosys.com wrote: by what i see predicate can be added to the condition column of the decision table... i wan to add the setFocus() to my action column !! -- View this message in context: http://drools.46999.n3.nabble.com/Web-guided-Decision-table-tp4018776p4018779.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 mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] drools-camel-server RetractAll() Command?
... and don't forget the 'Cleanup trigger' cleanup rule too ... You can also do that kind of rule without 'Cleanup trigger', using a very low salience, or specific agenda-group or ruleflow-group. But if you really retract ALL facts, it will be far much faster to create a new kSession (not a new KB, but a new session of the same KB, terms are important here). Remember that retracting facts will trigger RETE evaluation (and beware if you have logical insertions too). And last (but not least), at end of rules execution, I think you are expecting to get the newly created objects ... but they won't be there anymore. To me, massive retracts inside rules are only relevant if you want to keep some knowledge in the current kSession. And even in this case, I really find cleaner to insert-at-init / retract-at-end in the same place (both java or both rules). ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] RuleFlow not Found
up to drools 5.1 (more or less), the new default is jbpm flows, for rules or not. JBPM let you do what you can do with former .rf files. To be shorter : It is the same, at least seen from a ruleflow usage. Before you ask : you need to add jbpm jars to your drools runtime in order to make the flows work. Note that you can still use .rf format (editors works as well), but you still need to add jpbm jars. - Mail original - De: abhinay_agarwal abhinay_agar...@infosys.com À: rules-users@lists.jboss.org Envoyé: Mardi 26 Juin 2012 16:19:42 Objet: Re: [rules-users] RuleFlow not Found yeah !! -- View this message in context: http://drools.46999.n3.nabble.com/RuleFlow-not-Found-tp4018251p4018269.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] RuleFlow not Found
Yep, but this is because the sample is quite old now. If one day they decide to get rid with .rf files, it's better to start using jbpm format. Oh yeah, sample should be upgraded too ... - Mail original - De: paco fifi_nji...@yahoo.fr À: rules-users@lists.jboss.org Envoyé: Mardi 26 Juin 2012 17:24:06 Objet: Re: [rules-users] RuleFlow not Found I am using Drools 5.4.0, when I create a simple HelloWorld project the file. rf is also created, from here I can know how I can create files. rf. This can help you to solve your problem. Paco -- View this message in context: http://drools.46999.n3.nabble.com/RuleFlow-not-Found-tp4018251p4018271.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] Setting unused globals on a session
@gqmulligan : ... hum, you're rigth, Globals does not expose much ... use kSession.setGlobal(...) in a try catch if you want to stick to the API. @wolfgang : agreed ... ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] drools-planner drl file help
... Should I repeat what Geoffrey told you in your previous thread ? Will you try again and again to post your project, hoping we will do your work for you ? I gave you the main ideas, first work with that, and come back with precise questions. - Mail original - De: Ricardo sprabak...@gmail.com À: rules-users@lists.jboss.org Envoyé: Mercredi 20 Juin 2012 19:23:17 Objet: Re: [rules-users] drools-planner drl file help you got me exactly where I am, I am bit confused using drools-planner, I gone through the user guide documents and example in the src download http://drools.46999.n3.nabble.com/file/n4018108/PlannerProject.rar PlannerProject.rar attached is my sample project, I am try to imitate the bin packing project. First I used with length and width only, I don't want to use the size attribute. with out the size attribute don't know how to use in drl. Attached zip file is the src for what I am trying to achieve. It would be grateful, if you see the code and guide me to clear my confusion. warm regards, - with kind regards, -- View this message in context: http://drools.46999.n3.nabble.com/drools-planner-drl-file-help-tp4018104p4018108.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] Setting unused globals on a session
I am not sure to have fully understood you last requirement, nor if you set the global inside or outside the rules. Anyway, I see these options : - declare your globals for all packages, but it seems that this is not what you want - enclose the global setting in a try...catch and just forget the thrown exception. It does not harm the session at all. - use kSession.getGlobals() that returns all the globals' ID, and only set if the ID is there (but it is the same thing done in the setGlobal(String) anyway). I am using this last way to set 'as much globals as I can', according to their names/types and my 'config' POJO attributes names (something close to spring auto-injection idea). Hope this helps - Mail original - De: gqmulligan gqmulli...@gmail.com À: rules-users@lists.jboss.org Envoyé: Jeudi 21 Juin 2012 21:46:37 Objet: [rules-users] Setting unused globals on a session I save many different knowledge packages for different accounts to a database. Most accounts use a particular service to pull data from the database but not all of them. Because of this I wanted to set this service as a global on the session. However, because not all accounts use the service I get an exception when I try to set it on the session for an account that does not use the service anywhere in its rules. Does an exception really need to be thrown in this case? Also, do I have any options to work around this exception without having some sort of master rule that is automatically put into all accounts and declares all globals? The service is being pulled from a bean so I would like to stay away from having to find it by name and keep to injecting any global services if possible. Thanks. -- View this message in context: http://drools.46999.n3.nabble.com/Setting-unused-globals-on-a-session-tp4018146.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-planner drl file help
I am not sure to understand your problem exactly, and espacially chat you intend to do, but it is likely because you don't declare the suitable criterion so the solution you have (could help if you post it too) is equivalent (according to the score you define) to the expected one... If I try to summarize, it is a bin-packing problem : you try to place 'as much tables as possible' in your 2 rooms by maximizing the global remaining space ? If yes, it should look like this : - rule(s) that check that tables can enter in the room post HARD constraints - rule(s) that count the unassigned tables and post SOFT (with big weight) constraints - rule(s) that compute the remaining space and post SOFT (with low weight) constraints I can't find these rules in what you sent (so may be I am completely wrong here). According to what I imagine and what I see, I think that you are confusing the planner violated contraints (which are objects to insert into WM under some conditions) and the LHS conditions (like those : length $length, width $width). A last thing not clear : you defines items with 2 dimensions, but it seems that you only have a 'size' attribute which is used as a number ... - Mail original - De: Ricardo sprabak...@gmail.com À: rules-users@lists.jboss.org Envoyé: Mercredi 20 Juin 2012 17:57:07 Objet: [rules-users] drools-planner drl file help Hi, My use case is 2 rooms and multiple table in various size, I want planner to organize the table in the available rooms in our case 2 rooms. room1 - 10x10 (length x width) room2 - 5x5 table1 - 5x5 (length X width) table2 - 2x3 table4 - 2x3 table5 - 7x4 table6 - 4x2 *my drl file as follows...* rule requiredRoomSpace when $room : Room($length : length, $width : width, $size : size) $requiredSizeTotal : Number(intValue $size) from accumulate( Table( room == $room, length $length, width $width, $requiredSize : requiredSize), sum($requiredSize) ) then insertLogical(new IntConstraintOccurrence(requiredRoomSpace, ConstraintType.NEGATIVE_HARD, $requiredSizeTotal.intValue() - $size, $room)); end // // Calculate score // // Accumulate hard constraints rule hardConstraintsBroken salience -1 // Do the other rules first (optional, for performance) when $hardTotal : Number() from accumulate( IntConstraintOccurrence(constraintType == ConstraintType.NEGATIVE_HARD, $weight : weight), sum($weight) // Vote for http://jira.jboss.com/jira/browse/JBRULES-1075 ) then scoreHolder.setHardConstraintsBroken($hardTotal.intValue()); end */when i run the program...it assign all the tables into room1 only...I am not sure what went to wrong...help will be appriciatedif need more info ..I will provide.../* warm regards, - with kind regards, -- View this message in context: http://drools.46999.n3.nabble.com/drools-planner-drl-file-help-tp4018104.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] Hibernate Configuration with Drools 5.4
To me, the problem discussed in this thread highlights a deeper problem (more than DT compile time) : using DT as data storage is bad. Wolfgang's post demonstrate this fact. Previous posts demonstrate another problem : having 50k, 100k rules with the very same (basic) structure demonstrate that people don't think much about what they are doing (and using), but fall into quick-and-dirty additions into an already too fat and confuse system. This sentence from zeeshan is symptomatic : because if it can run for 26k initially, then it should continue running with the same or more number of records ... no, everything has a limit. Indeed, rules system allows to handle big KB and big data set, but they are not magic (another sentence from zeeshan : ... when I started working on Drools, I was assured with performance and ease in developing business rule : Does your guy assumes that whatever KB or data size ??? If yes, stop believe him). And I am pretty sure that the WHOLE COMMUNITY is almost never using such big DT (or at least I hope so). ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] java.lang.NullPointerException at org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java:291)
You could probably also consider simplifying the rule structure... many - if not all - the evals and explicit getters seem unneeded.. that would make the rule more efficient and definitely more readable. ... and will potentially protect against null usage in operations, like the operation just before the condition you cite : ((lcki.getWS_RiskScore() - lcki.getWS_RiskScore())/lcki.getWS_RiskScore()) = 4) .. even if it reduce to false every time, using null there will raise a NPE ... Did you check that your all the used fields are not null ? ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Hibernate Configuration with Drools 5.4
Did you really send a 50k rows table to a personal email ??? I can't believe it ... I think you should : - read the mailing list rules - read the previous Wolfgang post telling that you should consider not using such big tables (consider a rule using your 50k rows as parameters) - ask questions that are related to rules, and not java heap size limits ... - Mail original - De: zeeshan zeeshan.spr...@gmail.com À: rules-users@lists.jboss.org Envoyé: Lundi 18 Juin 2012 08:19:27 Objet: Re: [rules-users] Hibernate Configuration with Drools 5.4 Hi Laune ! I have mailed you my spreadsheet at ur gmail id. Thanks ! -- View this message in context: http://drools.46999.n3.nabble.com/Hibernate-Configuration-with-Drools-5-4-tp4017981p4018017.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] Hibernate Configuration with Drools 5.4
ok sorry ... may be one idea then: drools is using POI as java layer to read xls sheets, and it is very very very memory consuming ... especially with .xlsx format. May be that drools parser don't even reach a point where it can check the row count ... hope this helps... sorry again . - Mail original - De: Wolfgang Laun wolfgang.l...@gmail.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Lundi 18 Juin 2012 19:40:25 Objet: Re: [rules-users] Hibernate Configuration with Drools 5.4 Relax, Vincent, it was sent due to my explicit request, and it was a maller size version. I've taken this off-list to get a first-hand impression of why these DTs are considered as a viable solution, and how it fails, etc.. And I think that the OPs Q is legitimate; techniques propagated in Drools Expert without any caveats (e.g., don't do it for more than N rows) should fail gracefully, with an error message such as after umpteen zillion rules: out of memory and not just turn belly-up. After having received some feedback from the OP about alternative approaches I'll report back to the list. -W On 18 June 2012 19:26, Vincent LEGENDRE vincent.legen...@eurodecision.com wrote: Did you really send a 50k rows table to a personal email ??? I can't believe it ... I think you should : - read the mailing list rules - read the previous Wolfgang post telling that you should consider not using such big tables (consider a rule using your 50k rows as parameters) - ask questions that are related to rules, and not java heap size limits ... De: zeeshan zeeshan.spr...@gmail.com À: rules-users@lists.jboss.org Envoyé: Lundi 18 Juin 2012 08:19:27 Objet: Re: [rules-users] Hibernate Configuration with Drools 5.4 Hi Laune ! I have mailed you my spreadsheet at ur gmail id. Thanks ! -- View this message in context: http://drools.46999.n3.nabble.com/Hibernate-Configuration-with-Drools-5-4-tp4017981p4018017.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 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] Is a single StatefulKnowledgeSession with Distributed Memory cache possible?
May be you can think differently : Instead of keeping all objects for 90 days, keep only the accumulate results for each previous day. - Mail original - De: chrisLi shengtao0...@163.com À: rules-users@lists.jboss.org Envoyé: Jeudi 14 Juin 2012 18:06:50 Objet: [rules-users] Is a single StatefulKnowledgeSession with Distributed Memory cache possible? Hi All, I am working on a banking fraud detection project with Drools Fusion, which will match a transaction against hunreds of rules to check whether the transaction is suspicious. In some rules, I use time-based sliding window to calculate the average transaction amount of an account in the past 3 or 6 months. One possible rule will be as below: rule Single Large Amount Transaction dialect mvel when $account : Account($number : number) $averageAmount : BigDecimal() from accumulate( TransactionCompletedEvent(fromAccountNumber == $account.number, $amount : amount) over window:time(90d) from entry-point TransactionStream, bigDecimalAverage($amount)) $t1 : TransactionCreatedEvent(fromAccountNumber == $account.number, amount $account.creditAmount * 0.5, amount $averageAmount * 3.0) from entry-point TransactionStream then end In such cases, the Fusion Engine will hold TransactionCompletedEvent in its memory for 90 days. And we have about 1 billion Accounts in total, so the TransactionCompletedEvent will be huge, we will very soon run out of memory. I have been blocked here for a long time! Is it possible to distribute a single StatefulKnowledgeSession in multiple JVMs or machines using Distributed Memory cache such as Hazelcast? If yes, could you give me some opinion on the solution? Or is this the problem the Drools Grid project try to handle? Or there are other techonology to handle large numbers of facts or events problem? As far as I know, Drools Grid distribute multilple ksessions on multiple machines in the Grid, each or several kseesions on one node? Is my understandings right? Any response or opinion from you will be appriciated! Thank you very much! -- View this message in context: http://drools.46999.n3.nabble.com/Is-a-single-StatefulKnowledgeSession-with-Distributed-Memory-cache-possible-tp4017968.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] BigDecimal comparison
Done a little test using 3 approachs (with new BigDecimal(-12.321)), all are working: rule test big decimal 1 when Pojo(bigDecimal 0.0) then System.out.println(test big decimal 1); end rule test big decimal 2 when Pojo(bigDecimal.doubleValue 0.0) then System.out.println(test big decimal 2); end rule test big decimal 3 when Pojo(bigDecimalValue 0.0) // with then System.out.println(test big decimal 3); end with a wrapper method for the 3rd rule : public Double getBigDecimalValue() { if (bigDecimal == null) { return null; } else { return bigDecimal.doubleValue(); } } Your problem come from somewhere else (other conditions, wrong number in your object, missing import, too old version ...) - Mail original - De: devan vanreenen devan.vanree...@gmail.com À: rules-users@lists.jboss.org Envoyé: Dimanche 10 Juin 2012 19:38:42 Objet: [rules-users] BigDecimal comparison Hi there, Please assist. I have an object MaxCap that has a single property capAmount of type BigDecimal. The BigDecimal is negative when the rule is MaxCap( capAmount.doubleValue 0.00 ) it doesnt fire, which I expect it should but when the rule is MaxCap( capAmount.doubleValue 0.00 ) then the rules fires, so the rule recognises my negative number as a positive one. Any help would be appreciated. Thanks Devan -- View this message in context: http://drools.46999.n3.nabble.com/BigDecimal-comparison-tp4017841.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] Initial rule delay
In 5.4 timers support expressions for values. You can thus use a fact used to hold timer values (init and delay). This fact is created with some non-zero values, and reset all to zero once a first rule has triggered rule delayAtFirstTime timer(expr: $timerSpec.getDelay()+s , 0s) when $timerSpec : TimerSpec() then $timerSpec.setDelay(0); update($timerSpec); end Another solution is to create a fact that enable rule triggering that you insert later (may be that's the problematic aspect ...), something like that rule DoSomethingWhenYouCan when exists( OkToGo() ) then ... end Note that the OkToGo() fact can be inserted by a rule too ... rule OkToGoAfter10s timer(10s 0) when not( OkToGo() ) then insert( new OkToGo() ); end - Original Message - From: Paul R. reverselo...@gmail.com To: Rules Users List rules-users@lists.jboss.org Sent: Mercredi 6 Juin 2012 16:47:03 Subject: [rules-users] Initial rule delay Hi, I'm looking for a way to delay a rules initial execution? In the following example, I would like to prevent the rule from firing when the first Foo event is inserted into the working memory. rule DelayTest when $n : Number() from accumulate( $f : Foo() over window:time(10s) count($f) ) then // bla end The timer attribute seems to almost support what I'm looking for, i.e. it allows for an initial-delay to be specified; but if the repeat interval is omitted, it uses the initial delay as the repeat interval. timer ( int: initial delay repeat interval? ) In my case I would like to block the execution of the rule for an initial-delay period, but after that time has elapsed the rule should fire when every time a new Foo event is inserted into the working memory. What is the recommended way to do this? Thanks Regards, Paul ___ 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] Initial rule delay
Yes of course ... Simpler this way ... - Original Message - From: Wolfgang Laun wolfgang.l...@gmail.com To: Rules Users List rules-users@lists.jboss.org Sent: Mercredi 6 Juin 2012 18:02:40 Subject: Re: [rules-users] Initial rule delay Try: timer( int: initial 0 ) -W On 06/06/2012, Paul R. reverselo...@gmail.com wrote: Hi, I'm looking for a way to delay a rules initial execution? In the following example, I would like to prevent the rule from firing when the first Foo event is inserted into the working memory. rule DelayTest when $n : Number() from accumulate( $f : Foo() over window:time(10s) count($f) ) then // bla end The timer attribute seems to almost support what I'm looking for, i.e. it allows for an initial-delay to be specified; but if the repeat interval is omitted, it uses the initial delay as the repeat interval. timer ( int: initial delay repeat interval? ) In my case I would like to block the execution of the rule for an initial-delay period, but after that time has elapsed the rule should fire when every time a new Foo event is inserted into the working memory. What is the recommended way to do this? Thanks Regards, Paul ___ 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] Initial rule delay
try with a negative number ? - Original Message - From: Paul R. reverselo...@gmail.com To: Rules Users List rules-users@lists.jboss.org Sent: Mercredi 6 Juin 2012 19:26:22 Subject: Re: [rules-users] Initial rule delay Thanks Wolfgang, but setting the repeat-interval to 0 seems to have the same effect as omitting the repeat-interval [Tested in 5.1 5.4]. Thanks Vincent, this seems to work. However I was hoping for a simpler solution :) - Paul On Wed, Jun 6, 2012 at 5:06 PM, Vincent LEGENDRE vincent.legen...@eurodecision.com wrote: Yes of course ... Simpler this way ... - Original Message - From: Wolfgang Laun wolfgang.l...@gmail.com To: Rules Users List rules-users@lists.jboss.org Sent: Mercredi 6 Juin 2012 18:02:40 Subject: Re: [rules-users] Initial rule delay Try: timer( int: initial 0 ) -W On 06/06/2012, Paul R. reverselo...@gmail.com wrote: Hi, I'm looking for a way to delay a rules initial execution? In the following example, I would like to prevent the rule from firing when the first Foo event is inserted into the working memory. rule DelayTest when $n : Number() from accumulate( $f : Foo() over window:time(10s) count($f) ) then // bla end The timer attribute seems to almost support what I'm looking for, i.e. it allows for an initial-delay to be specified; but if the repeat interval is omitted, it uses the initial delay as the repeat interval. timer ( int: initial delay repeat interval? ) In my case I would like to block the execution of the rule for an initial-delay period, but after that time has elapsed the rule should fire when every time a new Foo event is inserted into the working memory. What is the recommended way to do this? Thanks Regards, Paul ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Decision Table, multiple actions accumulation
The formula trick works : POI (api used inside drools) is reading values by default for cells (at least the last time I used that in 5.1 version). The main problem of this is when users adds new rows : you must ensure that formula are copied too and this lead to other dirtier tricks (like using VB ...) or strict user manual (to force users to COPY row instead of adding brand new one ...) - Original Message - From: Wolfgang Laun wolfgang.l...@gmail.com To: Rules Users List rules-users@lists.jboss.org Sent: Lundi 4 Juin 2012 09:11:19 Subject: Re: [rules-users] Drools Decision Table, multiple actions accumulation On 04/06/2012, FrankVhh frank.vanhoensho...@agserv.eu wrote: Hi all, There is a small remark/comment that pops into my head when reading this. Giving the effort that has already been spent on the issue, this might come a bit late to you, but whatever... Wouldn't it also be possible to keep your excel decision table exactly the way it originally was (everything in one column) and then exploit the excel capabilities? I.e. 1) Insert two extra columns (one for the key, one for the value). 2) Do not annotate them with CONDIITION! I guess you mean ACTION. 3) Create a function in your initial column that would compose the value of the two new columns. I haven't tried it either, but I'd think that the API accessing the spreadsheet would have to return the formula rather than the value computed from it. And, IIRC, if the additional columns aren't headed with one of CONDITION, ACTION,... they'd stop access by the spreadsheet parser. So they would have to be the rightmost columns, which might not be convenient in general. -W 4) Hide the real condition column. I have not yet tried this myself, but it might work. regards, Frank manstis wrote But each column became a separate DRL fragment ;) but glad to read you got it working :) One for me to remember. Thanks Vincent sent on the move On 2 Jun 2012 01:47, chsekhar lt;chandrasekhar.a@gt; wrote: I was able to merge data from multiple ACTION columns in decision table. First ACTION column: (kept all keys as comma separated in single column. we can have it in individual columns) KeyPojo keys = new KeyPojo($1,$2,$3); Second ACTION column: $myMap.put(keys, $param); This worked great. Thanks Vincent for your answer. -- View this message in context: http://drools.46999.n3.nabble.com/Drools-Decision-Table-multiple-actions-accumulation-tp4017733p4017740.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@.jboss https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@.jboss https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://drools.46999.n3.nabble.com/Drools-Decision-Table-multiple-actions-accumulation-tp4017733p4017742.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 mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Decision Table, multiple actions accumulation
... which would mean I should be able to pass the value present in both the columns in one method call. Or create a Pojo for your keys (you should have already one as java maps only have one key ...), instanciate it in the first column in a local (to RHS) variable, use setters to set internal keys, then use this KeyPojo to add your value in the last column. In DRL this could be : ... then KeyPojo keys = new KeyPojo(); keys.setKey1(...); ... keys.setKeyk(...); ... keys.setKeyN(...); $myMap.put(keys, value); end basically, the fist action column will contains the 2 first DRL statements. The last action column will contains the 2 last DRL statement. Intermediate columns only use the setters. Of course, this works only if you are sure that your first and last action columns are always set ... Otherwise, hope this help ! ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] how to use only updated value in drools
what is the initial value of b ? what are the salience of your rules ? and why not posting your rules directly ? - Original Message - From: learner anandbabu6...@yahoo.com To: rules-users@lists.jboss.org Sent: Mardi 29 Mai 2012 12:29:28 Subject: [rules-users] how to use only updated value in drools I am having a drl file with 2 rules The 1st rule updates a attribute, say updates attribute b to 10 based on some condition. The 2nd rule has a check for values with b not equal to 10. It logs error for those values not equals to 10. The b value gets updated to 10 in rule 1. However in the second rule it does not use updated value and logs error. Is there a way to use the updated b value in the 2nd rule. I tried using modify but still the error gets logged. -- View this message in context: http://drools.46999.n3.nabble.com/how-to-use-only-updated-value-in-drools-tp4017626.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] getting mismatched '==' error
Your table seems correct, and writing a new one won't change the problem. But errors are reported according to the generated DRL, so it is hard to say which constraint is the problem. To generate the DRL, you can use SpreadsheetCompiler (or may be something more up-to-date?) like this : SpreadsheetCompiler compiler = new SpreadsheetCompiler(); String bigDrl = compiler.compile(new FileInputStream(xlsFile), InputType.XLS); Generate the DRL, then locate the error, then re-post here if the solution does not pops up by itself, or just to report back :) - Original Message - From: zeeshan zeeshan.spr...@gmail.com To: rules-users@lists.jboss.org Sent: Mardi 29 Mai 2012 14:03:40 Subject: Re: [rules-users] getting mismatched '==' error I tried ur suggestion.still same error. :( I think I will have to create a new Excel file -- View this message in context: http://drools.46999.n3.nabble.com/getting-mismatched-error-tp4017627p4017655.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] Can we retrieve the rules as XML from guvnor using java code?
Guvnor can provide rules to any instance, thus used as a shared repository... Are you trying to duplicate Guvnor rules from one Guvnor instance to another ? If yes : - You can use repository export / import (Administration panel under Guvnor) - You can use the REST api of Guvnor to query assets and their raw content, and send to another guvnor instance - Original Message - From: bbarani bbar...@gmail.com To: rules-users@lists.jboss.org Sent: Jeudi 24 Mai 2012 16:41:18 Subject: [rules-users] Can we retrieve the rules as XML from guvnor using java code? Hi, I am using Guvnor as knowledge repository and using drools rule engine to evaluate the rules stored in Guvnor. Now I have one more rule engine for which we are planning to use the same rules stored in Guvnor, but I am not sure how to expose the rules present inside Guvnor to new system. Can someone let me know if there's a way to retrieve the rules as XML or some other format that I can use in another system? Thanks, Barani -- View this message in context: http://drools.46999.n3.nabble.com/Can-we-retrieve-the-rules-as-XML-from-guvnor-using-java-code-tp4013660.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] Exception on at org.drools.reteoo.LeftTuple.get(LeftTuple.java:300) drools 5.0.1
When using or, only one pattern of the or expression will be bound. So, at runtime, onlty one variable $p1 or $p2 exists, and the other is null so the NPE at runtime. By the way, I can't see you are using a or here, as you test exactly the same things ... - Mail original - De: Joana Lopes joa...@gmail.com À: rules-users@lists.jboss.org Envoyé: Vendredi 18 Mai 2012 13:14:19 Objet: [rules-users] Exception on at org.drools.reteoo.LeftTuple.get(LeftTuple.java:300) drools 5.0.1 Hi There, I'm new to drools and i'm having a problem with a rule which has an OR: /* Rule 25_OFF */ rule 25_OFF when $p1:InferenceFactValue( param!=null, param.parameterName == sonar_8_cm, $v1:param.valueFloat = 10 ) or $p2:InferenceFactValue( param!=null, param.parameterName == sonar_8_cm, $v2:param.valueFloat = 10 ) then InferenceUtils.log( LogLevel.DEBUG, InferenceUtils.DROOLS_RULE, Global Clock: + InferenceDateUtils.dateString( globalClock, false ), true, false ); InferenceUtils.log( LogLevel.DEBUG, InferenceUtils.DROOLS_RULE, \t\tRegra 25_OFF + 25, true, false ); InferenceFactValue[] params = {$p1, $p2}; RuleFire.addEndAlarm( inferenceAgent, droolsEngine, AlarmPackage, 25, 25, params, globalClock ); end No errors in knowledge builder What happens is: org.drools.runtime.rule.ConsequenceException: java.lang.NullPointerException at org.drools.runtime.rule.impl.DefaultConsequenceExceptionHandler.handleException(DefaultConsequenceExceptionHandler.java:23) at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:943) at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:885) at org.drools.common.DefaultAgenda.fireAllRules(DefaultAgenda.java:1086) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:660) at org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:627) at org.drools.impl.StatefulKnowledgeSessionImpl.fireAllRules(StatefulKnowledgeSessionImpl.java:183) at pt.holos.dva.agents.inference.process.DroolsInferenceEngine.fireAllRules(DroolsInferenceEngine.java:644) at pt.holos.dva.agents.inference.process.DroolsInferenceEngine.receiveDataFromBuffer(DroolsInferenceEngine.java:342) at pt.holos.dva.agents.inference.process.BufferedDataReceiver.sendDataToDrools(BufferedDataReceiver.java:454) at pt.holos.dva.agents.inference.process.BufferedDataReceiver.run(BufferedDataReceiver.java:68) Caused by: java.lang.NullPointerException at org.drools.reteoo.LeftTuple.get(LeftTuple.java:300) at AlarmPackage.Rule_25_OFF_0ConsequenceInvoker.evaluate(Rule_25_OFF_0ConsequenceInvoker.java:15) at org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:934) ... 9 more I've tried to see the source code and the declaration in org.drools.reteoo.LeftTuple.get(LeftTuple.java:300) is null. Can you give me some pointers please? Thank you, Joana P Lopes -- LinkedIn - http://pt.linkedin.com/in/joanpl My Bla Bla Bla: http://joanpl.blogspot.com ... The intuitive mind is a sacred gift and the rational mind is a faithful servant. We have created a society that honors the servant and has forgotten the gift. Albert Einstein. Doubt is not a pleasant condition, but certainty is absurd. Voltaire ___ 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] Classnotfound exception on POJO model upload in guvnor
I think (not sure) that an uploaded jar must be complete by itself. The only things (classes) it can reference must be in guvnor's classpath (guvnor own libs and tomcat and java, but not current package other jars). So : - try using a single jar - or put all your jars in guvnor classpath (tomcat libs or guvnor war's libs) PS : When using your app, the classpath will be your app's one. When you get rules from guvnor, you don't get jars with them ... so it is two different environments. - Mail original - De: mpgong michael.p.g...@lmco.com À: rules-users@lists.jboss.org Envoyé: Vendredi 18 Mai 2012 17:37:55 Objet: [rules-users] Classnotfound exception on POJO model upload in guvnor Hello, I'm trying to use Guvnor but when i upload my POJO models that my DRL needs i get a classnotfoundexception even though i uploaded the jar that has the class in it first. So i basically upload a jar that provides some common classes,utilities, that have no dependencies other than on the core java libs. This jar uploads fine. I then upload my model jar that contains my facts and other classess that the DRL needs and it complains that it can't find the class from the first common jar even though i uploaded it first and it is loaded without errors. How do i load all of my jars so that they are available in Guvnor to use such as in creating a test scenario? It looks like the jars are upload but i get the error, i can also build the package but i'm worried it won't work when i try to use it in my app. Any ideas or insight to this issue. I'm using drools.5.3.0 final. Thanks -- View this message in context: http://drools.46999.n3.nabble.com/Classnotfound-exception-on-POJO-model-upload-in-guvnor-tp4001060.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] Killing a session
I already used a global limit of rule's firing with success to prevent these kind of problems (with a big number, eventually calculated from rules as Wolfgang said). This works, at least to detect infinite loops, because usually, when this happend, the number of firing increases very fast so the big number is hit quite early. Of course, if you have many rules, and/or many facts, an absolute number could be problematic to set (generally solved by making it easily modifiable so the rules' writer can change this quickly if it find it too low). And if you session is a living daemon thread, you have to find a way to reset the counter... And I agree with Wolfgang, 'most of time', a single rule is looping. May be two... 3 or 4 is rare ... May be you can maintain (in a Session's AgendaListener) a map that count firing for each rule and put a global max number of activation, but by rule. Time duration is a good way too, but needs a additionnal thread to monitor time consumed so far, and the value could be hard to set. Another safer way is to force your users to execute some kind of unit tests before deploying their rules (and these tests are executed with a time and/or rule firing global limit). You can also (if you have some kind of deployment procedure by code), execute these tests as a condition to accept the deployment. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to control the order of rule execution
*Questions:* 1st -What cud be d problems in the above case? .rf are not supported in guvnor. Use jbpm instead. See some previous (and numerous) posts ... 2nd- can I create a test case for our rule flow in guvnor and execute it? don't know if the session used for test scenario in guvnor use a default process if only a single bpm is set ... don't know if it even compiles the flow ... Did you tried ? If yes and did not work, consider using your own test cases ... By the way, setting a lot of test directly under guvnor is not very easy if you want to test with a lot of data, as you must specify objects one by one ... or if you want to automate using junit ... and/or not to be sticked with guvnor and use a mix of guvnor rules and DRL rules (and other things). 3rd- given our requiments is there any better way of executing it other than rule flow in Drools? See doc about agenda-group and salience to use a single session. Consider also using different session that are connected programmatically (and transfert WM's object from one bow to the next). ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Evaluation of the of rules with 'window:length' event windows
Seems that there is a confusion here ... window:length(X) is constraining the events timestamps to be in a time-windows of length X (in seconds). To contrain the number of accumulated facts, it must be done by adding a constraint in the resulting list : $list : ArrayList(size Nb) from accumulate(Class1($a:a) over window:length(X) from entry-point Point ... @wolfgang : if you use an internal counter in the accumulate, how can you test it internaly ? return empty (or null) list if max not reached ? $list : ArrayList() from accumulate($obj : Class1($a:a) over window:length(X) from entry-point Point init ( ArrayList list = new ArrayList(); ), action ( list.add($obj); ), return ( if (list.size() Nb {return null;} else {return list;} )) - Mail original - De: Wolfgang Laun wolfgang.l...@gmail.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Mercredi 16 Mai 2012 13:02:46 Objet: Re: [rules-users] Evaluation of the of rules with 'window:length' event windows Accumulate the count of elements (in addition to whatever you accumulate) and test the result as being == X. As of (IIRC) 5.3.0, you can write multi-function accumulates. -W On 16/05/2012, senyatur senya.touret...@emc.com wrote: Hi guys We are using Drools for event processing. So we have rules that, for instance, put accumulation function over window of number of elements (not time). ... from accumulate(Class1($a:a) over window:length(X) from entry-point Point... The problem we are experiencing that when evaluating the rule when there are *less* elements than X (window length) the accumulation function is still calculated which leads to wrong results. Is there a way in Drools to restrict firing of this type of rules when there are less than 'length' elements in the session? Thanks -- View this message in context: http://drools.46999.n3.nabble.com/Evaluation-of-the-of-rules-with-window-length-event-windows-tp3996829.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 mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools 5.0 how to create reports analytics on rules usage
heavilly discussed subjects ... This list should contain a lot of answers already ... To summarize : - user date/time when rule last changed : Can be got from Guvnor, if you are using it. If not, you have to plug something between your editor and your storage - date/time rule last executed : Nothing out-of-the-box. You have to plug a AgendaListener in the sessions and store the usage somewhere. - Mail original - De: thatz thomash...@yahoo.com À: rules-users@lists.jboss.org Envoyé: Mercredi 16 Mai 2012 13:40:25 Objet: [rules-users] Drools 5.0 how to create reports analytics on rules usage An app we purchased uses Drools 5.0. We have built 600+ rules within 50+ rule sets. Since Drools not a relational db, how can we create reports and analytics on rules usage, such as user date/time when rule last changed, also date/time rule last executed. We are usin SQL Server Report Services for app reports, but doesn't seem like we can get to the rules with that method. Really appreciate your ideas -- View this message in context: http://drools.46999.n3.nabble.com/Drools-5-0-how-to-create-reports-analytics-on-rules-usage-tp3996898.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] Evaluation of the of rules with 'window:length' event windows
On 16/05/2012, Vincent LEGENDRE vincent.legen...@eurodecision.com wrote: Seems that there is a confusion here ... window:length(X) is constraining the events timestamps to be in a time-windows of length X (in seconds). Definitely not. It's window:time that restricts by a time interval. oups ... Should have checked before ... sorry. So window:length(X) take only a max of X previous events (so including from 0 to X, which the problem here) @wolfgang : if you use an internal counter in the accumulate, how can you test it internaly ? accumulate( Whatever(...), $count: count(1), ... ) eval( $count == X ) strange construction ... $count: count(1) is part of the pattern ? then automatically incremented in $count variable ? Does the accumulate still return a List or something else ? ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Evaluation of the of rules with 'window:length' event windows
ok, got it. not a strange construction, but a beautiful one !! thx - Mail original - If you want to have a list, you can have it in addition to count: accumulate( $w: Whatever(...) from window:length( 10 ), $count: count(1), $list: collectList( $w ),... ) although that would be redundant. But if you'd just need the (for instance) sum, it would be useful. accumulate( Whatever( $x:x, ... ) from window:length( 10 ), $count: count(1), $sum: sum( $x ) ) Note that this is a *complete* CE, beginning with accumulate. -W ___ 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] use of enum with in on LHS
Another potentiel trick : In State enum, add a method to build a State list from a list of string enum State { ... static ListState buildList(String listAsStr) { // well, don't need to detail that ... // ... but think to keep a cache somewhere to avoid unecessary iterations at each rule's evaluation ... } } and in your DSL : [*][when]- state is {stateList}=state in (State.buildList({stateList})) Don't know if it really works, just an idea that could be better than replacing all NEW/OLD strings ... If ot works, it can even be better to handle weird items list in a big string ... ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Decision table call external method
According to your post, I guess that your problem is not really for editing the table, but at runtime the table does not behave like expected, yes ? Could you post your table and the resulting DRL, and explain a bit more what you have tried to do ? - Mail original - De: SuperGG jerome-m.pe...@thalesgroup.com À: rules-users@lists.jboss.org Envoyé: Vendredi 11 Mai 2012 10:47:01 Objet: Re: [rules-users] Decision table call external method I did a drools project on eclipse, so I guess it's just drools-decisiontables. -- View this message in context: http://drools.46999.n3.nabble.com/Decision-table-call-external-method-tp3976910p3979352.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] Formula error in Business Rule(Guided editor)
$r.installations only works if the attribute is public in RuleObject (and numeric). try $r.getInstallations() instead ... Also, always have a look to the generated DRL (View Source under Guvnor) - Mail original - De: Manasi manasi.a.da...@capgemini.com À: rules-users@lists.jboss.org Envoyé: Vendredi 11 Mai 2012 12:34:02 Objet: [rules-users] Formula error in Business Rule(Guided editor) Hi, Currently I am facing following issue while inserting a formula in Business Rule(Guided Editor): 1) I have written following formula to be executed in Business Rule(Guided Editor): WHEN 1. The following exists: There is a RuleObject [$r] with: installations 100 THEN 1. Insert RuleObject: calulatedValue = $r.installations*3 But it gives error 'Unable to analyse expression' when i try to Verify the rule. I want my end result will be a calculated value instead of Literal value. Please let me know the correct syntax to use formula in this type of rule. Thnaks. -- View this message in context: http://drools.46999.n3.nabble.com/Formula-error-in-Business-Rule-Guided-editor-tp3979546.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] Decision table call external method
In ACTION, you can use : - static methods - non-static method on a previous matched objects using addNode(...) like this is nonsense, even in plain java If your addNode method applies to your matched Service object (which you binded to variable s), use s.addNode(...) Otherwise, you have to get the object in which this method is defined in order to call it - Mail original - De: SuperGG jerome-m.pe...@thalesgroup.com À: rules-users@lists.jboss.org Envoyé: Vendredi 11 Mai 2012 14:43:06 Objet: Re: [rules-users] Decision table call external method http://drools.46999.n3.nabble.com/file/n3979822/Sans_titre.jpg I have this decision table. I have a Class XMLTool which contains static fields as SICF and some methods (non static) as addNodes(String str); I don't find the way to use the method addNodes in my decision table. (I import all the good classes) I tried several stuff but no success. I'm sure there is one good way to do it. Thx -- View this message in context: http://drools.46999.n3.nabble.com/Decision-table-call-external-method-tp3976910p3979822.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] Decision table call external method
Sorry, I read too fast ... You have addNode(...) on XMLTool ? So you have to get a XMLTool somewhere in CONDITION or make it a global variable, or a java singleton, or link it with your service. If you can't do all previous, then you will have to find a trick to match it in your conditions, but it will be a trick ... - Mail original - De: Vincent LEGENDRE vincent.legen...@eurodecision.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Vendredi 11 Mai 2012 15:06:35 Objet: Re: [rules-users] Decision table call external method In ACTION, you can use : - static methods - non-static method on a previous matched objects using addNode(...) like this is nonsense, even in plain java If your addNode method applies to your matched Service object (which you binded to variable s), use s.addNode(...) Otherwise, you have to get the object in which this method is defined in order to call it - Mail original - De: SuperGG jerome-m.pe...@thalesgroup.com À: rules-users@lists.jboss.org Envoyé: Vendredi 11 Mai 2012 14:43:06 Objet: Re: [rules-users] Decision table call external method http://drools.46999.n3.nabble.com/file/n3979822/Sans_titre.jpg I have this decision table. I have a Class XMLTool which contains static fields as SICF and some methods (non static) as addNodes(String str); I don't find the way to use the method addNodes in my decision table. (I import all the good classes) I tried several stuff but no success. I'm sure there is one good way to do it. Thx -- View this message in context: http://drools.46999.n3.nabble.com/Decision-table-call-external-method-tp3976910p3979822.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] Knowledge Base and Multiple Sessions
I would say no. I think that every session has its own RETE nodes filled with its own facts. May be the different RETE instances share some evaluators (or at least generated dynamic classes that represent nodes) so it could use a bit less memory than recreating the same kbase again and again (which can affect PermGenSpace on some jvm where GC is not good at purging the permgen). But the real perf hit should be due to using multiple Thread in a single jvm : if you add too much threads, gc, swap and so on can become long. To test that may be you can test with using the same kbase for all session, and test the same with creating a new kbase for each session, and then compare the perfs (ignoring objects creation of course) ... ... and post the results back here :) My own experience of usage of multi-thread with rules is for chaining multiple rule box having distinct kbase, so I never tried that. - Mail original - De: gboro54 gbor...@gmail.com À: rules-users@lists.jboss.org Envoyé: Jeudi 10 Mai 2012 19:12:28 Objet: [rules-users] Knowledge Base and Multiple Sessions If you have multiple sessions running on different threads against the same knowledge base, is there any performance hit during evaluation? -- View this message in context: http://drools.46999.n3.nabble.com/Knowledge-Base-and-Multiple-Sessions-tp3977702.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] Multiple DRL for one Package
I think that RETE is stored in kbase, and kPackage contains only some kind of AST for rules. So adding some rules (of same package or not) in a kbase (or a kbuilder) don't use the origin .. And mroe than that, I am pretty sure that rules are shared in RETE even if they are from different packages (this way the RETE can share more patterns and improve propagation). But I am not a DEV guy, so all of the previous is only my own conclusions. When you do that, using your kbuilder, does the kbuilder return 1 or 2 knowledgePackage ? And anyway, why does it matters ? The rules should work as if they were in a single file (no matter if the RETE is partionned or not). Is it for perfs ? - Mail original - De: gboro54 gbor...@gmail.com À: rules-users@lists.jboss.org Envoyé: Vendredi 11 Mai 2012 15:33:06 Objet: [rules-users] Multiple DRL for one Package I have created multiple DRLs declaring the same packaged(logical separation of rules). When I compile this knowledge base with all the files does the rete tree get built as if all the rules were in the same file or does each file get it's own built tree? -- View this message in context: http://drools.46999.n3.nabble.com/Multiple-DRL-for-one-Package-tp3979955.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] Is there a faster way of doing this in Drools ?
ok thanks. seems dangerous anyway .. and you said should be possible, which is (according to what I know in english) not really sure ? - Mail original - De: Davide Sottara dso...@gmail.com À: rules-users@lists.jboss.org Envoyé: Mercredi 9 Mai 2012 23:50:54 Objet: Re: [rules-users] Is there a faster way of doing this in Drools ? @Vincent: it should indeed be possible to hot-plug rules directly into a knowledge BASE (meaning all sessions derived from that KB will be affected: existing facts will be matched against the new rules). More typically, this is done using a Knowledge Agent to manage the Knowledge Base. Whether this is appropriate for this use case or not, is a totally different matter, as thoroughly discussed :) -- View this message in context: http://drools.46999.n3.nabble.com/Is-there-a-faster-way-of-doing-this-in-Drools-tp3973888p3975487.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] Is there a faster way of doing this in Drools ?
Users changing rules IS the correct use-case of drools (I would even say that if rules never change, drools is likely to be worse than pure java). What others said is changing the rules at each request by regenerating and recompiling is not. I can't imagine that users may change rules at each request, so you must have, at least for some time (thus a lot of requests), a stable rule base. What is costly is to compile rules, but you already know that. So the idea is to keep in some kind of cache the actual rules, and only recompile them when they change. The source of rules does not matter : you can generate the DRL according to your configuration, or make you users directly write rules (with guvnor, which will fits well if your rules are only basic filters). The optimisation you have to do is to keep your compiled rules somewhere (by serializing your KnowlegdePackages or simply keep it in a kind of map), and reuse it until your source change : you have to find a way to detect that rules (or the config that is used to generate them) have changed, and then recompile a new up-to-date KnowledgePackage. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Is there a faster way of doing this in Drools ?
At this point I'm designing for the worst case i.e., I'm assuming the rules with change with every request. Keeping a cache will work for the worst case, but will work faster for normal (see below) cases. You can imagine the user changing these rules in a span of less than a minute. Well, no ... it is really hard to imagine that kind of frequence as a normal use over a long time. For all systems I made, rules are stable for much more than that. When changing rules, you may change them every minutes (to test the outcomes, just like debuging a java code), but the objective is to produce something stable that will be used in a production environment ... Changing rules every minutes or less in a production environment is definitely not a usual use-case ... Why your rules should change every minute ? What is the system your are building ? I understand that Drools is designed for cases when rules changes often. But can it support something like the one I described above where rules are changing at a much faster rate? You won't be able to speed up the compile time. You can only act on the volume and organization of what you are compiling. So, you can use cache (as said before), and may be you can also cut your rules in smaller packages and only recompile the package where some modifications take place (if it take really some mesureable time, it is likely also because you have plenty of rules to compile). If you have a single package with few rules, compile time should not be a problem.. And a last thing : In your first post, you said : Based on the timing logs the code take majority (more than 80%) of time in only these two operations. Is there a way to make it faster ? KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add( org.drools.io.ResourceFactory.newByteArrayResource(getRule()), ResourceType.DRL); You first have to make the distinction between KnowledgeBuilder compilation time (up to drools code, and you can't change anything, at least easyly), and your getRule() method (guess one of your custom code), with may be speeded up. For instance, if you can't globally cut your compiled rules into smaller compiled packages, may be you can cut your big resulting DRL in smaller pieces, regenerating only what have changed ... ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Is there a faster way of doing this in Drools ?
I did not assume that I've seen all use cases, nor that what I am a telling is the absolute truth. See no offense in my previous post. Yes, I was supposing some use case of my own experience, but please note it is the first post when you describe what you are really trying to do, ie implementing a dymanic filter configured with a web form that generates rules to do the filtering job. This is indeed highly dynamic, and for 10 rules, the cache will not be very relevant. And you are perfectly correct when you say that if rules change at each request, using a cache won't speed the process. The cache is only usefull if the rules are stable for a time, or if only some few rules change from one time to the next one. But if you have 10 rules, compile time should not be so long, so I guess that the guy writing filtering rules is expecting very quick results (so I guess that you have few data too, otherwise the compile time would be far much smaller that processing time, especially for 10 rules ...). You want to test the adequation of drools for a use case where a user can set a set of filtering rules via a web form to filter some data somewhere ... I would say that : - If there is only simple filters you should not use drools (an in-memory DB is not so costly, at least not more than a drools' WM, and with hibernate you can write queries using a POJO-like syntax which is very close to rules' LHS) - You said that you are looking to drools to allow writing more complex rules than simple filter rules (like chaining and so on). In that case, SQL won't fit, and then you have to accept a performance overcome just because drools does much more than SQL. And to deal with that overcome, you have to think about partitionning/caching your rules (but for 10 rules, it will be difficult) ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Is there a faster way of doing this in Drools ?
And I did not see all pending posts ... By reading them, there is another fact that lead to don't use drools. You said that you query a distant DB. So, if you write rules to filter your data, you will have first to get ALL data from your distant DB, add ALL data in the drools WM, and only then fire rules on them to filter the data and get only a subset of them. To me (my opinion), it is an anti-pattern. Filtering a large amount of data and return only a subset of them is the database job. Oh, yes, you intend to do complex rules that cannot be set as SQL like syntax ... You should think of cutting you system in two, by making each tool doing what it is designed for : - use SQL like for basic filtering, by sending the query to the distant DB and thus getting ONLY the data needed - make drools running of this subset of data to implement more complex things ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Is there a faster way of doing this in Drools ?
... OR load everything into a WM and then apply these dynamic rules. Beware, I am not sure whether we can add/remove rules in an existing session (I don't think so but I may be wrong). Basically, a WM is built from a kBase, not the inverse ... So you will have to recompile rules, that re-add all data in the WM ... really not a good idea then ... But, if you have your own GUI to set the filters, you should have some masks to speficify your filtering values, or at least some objects to store the filters/user's choices to display them in some screens, right ? In that case, you can add these objects directly in the WM, and write generic rules that use these objects to filter the raw data (as 2 or 3 previous post suggest). This way, you build your KB once, create a 'deamon' session, add all raw data once, and then only insert/retract filtering objects, with the results updated dynamically too. And if you can only work on differences (ie a result entering or getting out the global result list by invoking a gui callback), it can even be faster than a DB ... because RETE is good to propagate small diffs over a large amount of data and deduce related diffs on the outcome (this is drools-planner raw idea too). ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] agenda-groups
I am having an issue where I have a catch all retraction rule setup as the lowest salience. Not sure to understand that (note that I am not english native ...) I see activations created for the facts but they are never fired. Any thoughts on why this may happen? Send some rules. Activations never fired is just too vague to have a single answer. If you use agenda groups, may be that the group is simply not on focus ... Add a first rule that set the focus, or set auto-focus for all your low salience rules, or don't set agenda group for them (their group will be the MAIN group). The session is run on a separate thread with fireAllRules called every 1/2 second. I have tried syncronizing inserts on the session so that thread would not be in the middle of firing when new facts come in but that does not seem to do anything Why not using fireUntilHalt instead ? Run your session.fireUntilHalt in a separate thread, and insert things in that session. insert (or update or retract) will wake up the session. Of course, one day, you have to call halt() on your session to get out. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Automatic PDF rule documentation does not include dsl based business rules
Are you sure that your rule compiles without errors ? If the doc generation uses verifier, rules must first pass the raw compilation ... - Mail original - De: ssprick s.spr...@tiq-solutions.de À: rules-users@lists.jboss.org Envoyé: Mercredi 2 Mai 2012 15:04:01 Objet: Re: [rules-users] Automatic PDF rule documentation does not include dsl based business rules To isolate the problem I started with an empty package and copying only the necessary assets (the two dsls, businessModel). Then I also copied a business rule which uses the two dsls. This rule did not appear in the doc. (the rule type is DSL business rule text editor) Then I created a new and empty business rule of the type Business Rule guided editor. This rule showed up in the doc. At last I created a new and empty business rule of the type DSL business rule text editor. Same as the first rule I copied, that one also does not show up in the pdf doc. Is there anything special to configure for the according two dsl files? When examining the drools source code, where should I take a first look? -- View this message in context: http://drools.46999.n3.nabble.com/Automatic-PDF-rule-documentation-does-not-include-dsl-based-business-rules-tp3954720p3954993.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] Dynamically create drools mvel rules
Have a look to : - templates : http://docs.jboss.org/drools/release/5.3.0.Final/drools-expert-docs/html_single/index.html#d0e7413 - fluent API - generate DRL, or XML, or use internal Guvnor classes to do so In fact, while searching for links to put there (with google), I found this 'not so old' thread, with plenty of details : http://drools.46999.n3.nabble.com/How-to-create-a-drl-file-or-decision-table-dynamically-td3772708.html - Mail original - De: Anton Hughes kurren...@gmail.com À: rules-users@lists.jboss.org Envoyé: Vendredi 27 Avril 2012 12:58:03 Objet: [rules-users] Dynamically create drools mvel rules Hi I remember seeing this functionality, but after googling - and not finding anything - I thought I would ask here. I have a lot of xml files that contain if conditions. I would like to read these, and convert them to drools mvel rules. Can someone suggest the best way to do this? Thanks and regards, Anton ___ 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] Guvnor guided editor and non argument constructor
JavaBeans convention : all default constructible and plenty of setters (for writeable properties) and getters (for readeable properties) - Mail original - De: Michael Anstis michael.ans...@gmail.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Jeudi 26 Avril 2012 15:40:27 Objet: Re: [rules-users] Guvnor guided editor and non argument constructor Seems reasonable enough. On 26 April 2012 14:36, Sean Su sean.x...@gmail.com wrote: It seems that the new fact created by the guided editor must be from the java class that has the default non argument constructor in Guvnor. There seems no way we can customize it to pass arguments in. This would force us to provide setters to the object. Is this a true statement? Thanks Sean Sent from my iPad ___ 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] Guvnor guided editor and non argument constructor
Should use a DSL then. - Mail original - De: Sean Su sean.x...@gmail.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Jeudi 26 Avril 2012 19:06:57 Objet: Re: [rules-users] Guvnor guided editor and non argument constructor What I am prototyping is part of the event processing (with or without fusion). I want to use the rules created by the Guvnor to create the new events. However, as you would understand, once the event has been created, it should not be modified as it happened in the past. So I am trying to avoid setters if possible. Sean Sent from my iPad On Apr 26, 2012, at 12:49 PM, Vincent LEGENDRE vincent.legen...@eurodecision.com wrote: JavaBeans convention : all default constructible and plenty of setters (for writeable properties) and getters (for readeable properties) - Mail original - De: Michael Anstis michael.ans...@gmail.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Jeudi 26 Avril 2012 15:40:27 Objet: Re: [rules-users] Guvnor guided editor and non argument constructor Seems reasonable enough. On 26 April 2012 14:36, Sean Su sean.x...@gmail.com wrote: blockquote It seems that the new fact created by the guided editor must be from the java class that has the default non argument constructor in Guvnor. There seems no way we can customize it to pass arguments in. This would force us to provide setters to the object. Is this a true statement? Thanks Sean Sent from my iPad ___ 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 /blockquote blockquote ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users /blockquote ___ 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] Best practice for 0..1 relations
The fact that you can bind from a constant is good to know. But if I can give my feeling, I don't think that this more readable nor more maintainable. To me, if you really want to factorize, using accumulate is better ... Mark's rule has a relatively big an complex 'then' part that justify an extreme conditions factorization, which is not really your case. But this is just a matter of taste ... Here is my ideal rule for this problem, using accumulate : rule household income when $p1 : Person() $additionnalIncome : Number() from accumulate ( Relation(person1 == $p1, type == spouse, $p2income: person2.getIncome()) , sum( $p2income ) ) then insertLogical(new Income($p1.getIncome() + $additionnalIncome)); end Note that this is working for multiple spouses too ... But I have one question : will this work properly with insertLogical ? - Mail original - De: Christopher Dolan christopher.do...@avid.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Mercredi 25 Avril 2012 20:39:14 Objet: Re: [rules-users] Best practice for 0..1 relations Aha, that makes sense! I didn't realize you could bind a variable from two different branches of an or. Following that pattern, my strawman rule becomes this: rule household income when $p1 : Person() ((not Relation(person1 == $p1, type == spouse) and $p2income : int from 0) or Relation(person1 == $p1, type == spouse, $p2income: person2.getIncome())) then insertLogical(new Income($p1.getIncome() + $p2income)); end Thanks! That's a good compromise of readability and maintainability. Chris -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Mark Proctor Sent: Tuesday, April 24, 2012 9:12 PM To: rules-users@lists.jboss.org Subject: Re: [rules-users] Best practice for 0..1 relations On 23/04/2012 21:31, Christopher Dolan wrote: Sorry, I wasn't clear... In the example, it's the spouse that's the optional fact. I want the rule to fire whether or not a spouse exists, but the RHS computes the income differently if a spouse exists or not. If a spouse is added/removed, I want the rule to re-fire and the income should be changed. Take a look at my Pong game and the Create Ball rule https://github.com/droolsjbpm/drools/blob/master/drools-examples/src/main/resources/org/drools/games/pong/init.drl I create a ball with different dx directions depend on different states, all from within one rule: rule Create Ball when not Ball() ( PointWin(player.id == PlayerId.PlayerOne ) and dx : Number() from 2 ) or ( PointWin(player.id == PlayerId.PlayerTwo ) and dx : Number() from -2 ) or ( not PointWin( ) and dx : Number() from -2 ) then ball = new Ball( (pconf.tableWidth/2)-(pconf.ballWidth/2), (pconf.tableHeight/2)-(pconf.ballWidth/2), pconf.ballWidth); ball.speed = pconf.ballStartingSpeed; ball.dx = dx; insert( ball ); end Chris -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Welsh, Armand Sent: Monday, April 23, 2012 3:22 PM To: rules-users@lists.jboss.org Subject: Re: [rules-users] Best practice for 0..1 relations So, I assume the fact that is not needed in the LHS is Income. By inserting Income into Working Memory, you are subjecting it to rete evaluation against the current knowledge tree. I consider the cost of each operation. Insert is very costly, and insertLogical even more costly. I don't know anything about how your data model is built, but based on this very simple example, I would think you would be better off with a Global like this: Global Income income Style 1: one rule for each scenario rule household income, single when $p1 : Person() not Relation(person1 == $p1, type == spouse) then income = new Income($p1.getIncome()); end rule household income, married when $p1 : Person() Relation(person1 == $p1, type == spouse, $p2: person2) then income = new Income($p1.getIncome() + $p2.getIncome()); end Style 2: a single rule with a collection rule household income when $p1 : Person() $rels : List() from collect(Relation($p1 == person1, type == spouse)) then income = new Income($p1.getIncome() + ($rels.size() == 0 ? 0 : $rels.get(0).getPerson2().getIncome()); end Then in code, you can get the Global value to determine what it got set to, if you need outside of the Drools processing. All thread safety factors must be considered in a multi-threaded environment. Global are not objects know to rete, and therefore, use of them
Re: [rules-users] please provide a rule for events timeout cases
and thanks for providing feedback ! - Mail original - De: skatta1986 shivaprasad_...@yahoo.co.in À: rules-users@lists.jboss.org Envoyé: Mardi 24 Avril 2012 16:08:02 Objet: Re: [rules-users] please provide a rule for events timeout cases thanks for the reply its giving expected results -- View this message in context: http://drools.46999.n3.nabble.com/please-provide-a-rule-for-events-timeout-cases-tp3907955p3935376.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] Rules and Ruleflow GroupS
No you can't ... or I really don't know how .. You can duplicate a ruleflow group in a ruleflow (if your rule is only dependant of others rules in the same group), but if a rule is a subpart of multiple groups ... well ... I think you can't avoid to write your own agenda filter, or try to use agenda groups. - Mail original - De: Armand Welsh awe...@statestreet.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Lundi 23 Avril 2012 17:59:24 Objet: [rules-users] Rules and Ruleflow GroupS A while back, I was looking to use Ruleflow-Groups and a process flow. Due to some issues in the code that affected the use of the process flow, I was unable to use them. I believe those issues have been worked out, and now I am looking into using them again. One thing I am not clear on, is if I can have a single rule participate in more than one ruleflow group? Regards, Armand ___ 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] Rules and Ruleflow GroupS
Tell me if I understand well : - you have a set of lookup rules that are independant of initial data in the WM - you have another set of lookup rules that depends of data currently in the WM, that should trigger in the middle of data processing. In this second group, some business rules can update a fact that should immediately lead to insertion of other object via the lookup rules ? Clearly, the second is the problematic one if it must be immediate ... If you can delay the insertion, I can't see why you can't place them in a separate ruleflow group (and the ruleflow-group identifier is reused in multiple main ruleflows ...) May be you can use agenda groups here. All the 'same function' lookup rules could be placed in the same agenda-group, with auto-focus to true. And you then have to add some control rules that give focus to you data-lookup group when you need. This is one way I know that allow to trigger a group of rules in the middle of other rules execution. The other way is control facts ... In summary, you have the choice between adding control fact in each condition, or set an agenda-group and auto-focus on each rule + a main control rule. I prefer the agenda-group option because once the control rule done, you can add rules to the group by declaring its group whether that adding a condition (which should be reserved to business logic in a ideal system). - Mail original - De: Armand Welsh awe...@statestreet.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Lundi 23 Avril 2012 19:03:17 Objet: Re: [rules-users] Rules and Ruleflow GroupS Thanks for the feedback Yeah.. my rules deal with data transformation. We convert vendor feed data to internal data for making trade decisions. So we have large data sets that need to be evaluated. So instead of inserting all data into working memory from our lookup tables in our DB, I have lookup rules that get just the data needed for the datasets. These rules insert just those lookup facts that are needed for the rules. Since many rules can share a common lookup criteria, I don't lookup use the from condition on each rule, instead I use the from condition on the lookup rule, that extracts the facts I need and inserts just those facts into working memory. The reason for this, is that inserting into working memory is a costly process. So inserting 100 facts is less intensive than inserting 10,000 facts, when I only need 100 for that specific set of data. Most lookups can happen before any processing, because the bound conditions are set before execution, and they don't change. However, I have a small set of lookups that occur more than once, because they are based on fields that are generated by other rules, and each time the value changes, I need to the lookup to be reactivated, but I could benefit from having my lookup rules in their own rule flow group, and a small subset of those also in the data manipulation rule flow group, so that they get preloaded before any data processing decisions are made, and then they re-fire during data processing the dependent facts change. I guess I will just have to use a processing control fact to prevent firing my lookup rules until I know the lookup has either completed, or failed to find lookup values. Regards, Armand -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Vincent LEGENDRE Sent: Monday, April 23, 2012 9:26 AM To: Rules Users List Subject: Re: [rules-users] Rules and Ruleflow GroupS No you can't ... or I really don't know how .. You can duplicate a ruleflow group in a ruleflow (if your rule is only dependant of others rules in the same group), but if a rule is a subpart of multiple groups ... well ... I think you can't avoid to write your own agenda filter, or try to use agenda groups. - Mail original - De: Armand Welsh awe...@statestreet.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Lundi 23 Avril 2012 17:59:24 Objet: [rules-users] Rules and Ruleflow GroupS A while back, I was looking to use Ruleflow-Groups and a process flow. Due to some issues in the code that affected the use of the process flow, I was unable to use them. I believe those issues have been worked out, and now I am looking into using them again. One thing I am not clear on, is if I can have a single rule participate in more than one ruleflow group? Regards, Armand ___ 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] Best practice for 0..1 relations
In fact, you question is : What's the best way to define something that's needed in the RHS but is not matchable in the LHS? You said not important, but you want the income to be updated (I guess for other rules' LHS) ... so it was not clear. And what about using an accumulate rather than a collect ? You won't use List anymore.. If you are reusing the same values again and again, have a look to queries. If your problem is really restricted to a two-state one, then two rules can be ok, and especially if you think this is the natural way (it may be clearer this way so easier to maintain too). But what if the list of relation's types grows? You add a 3rd rule? A 4th? A big rule that accepts some Relations (based on a variable list of relation's types set in one unique place) and add their contribution to a sum using an accumulate seems more natural in this case. It depends on how your are sure of your only two states ... - Mail original - De: Christopher Dolan christopher.do...@avid.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Lundi 23 Avril 2012 22:31:52 Objet: Re: [rules-users] Best practice for 0..1 relations Sorry, I wasn't clear... In the example, it's the spouse that's the optional fact. I want the rule to fire whether or not a spouse exists, but the RHS computes the income differently if a spouse exists or not. If a spouse is added/removed, I want the rule to re-fire and the income should be changed. Chris -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Welsh, Armand Sent: Monday, April 23, 2012 3:22 PM To: rules-users@lists.jboss.org Subject: Re: [rules-users] Best practice for 0..1 relations So, I assume the fact that is not needed in the LHS is Income. By inserting Income into Working Memory, you are subjecting it to rete evaluation against the current knowledge tree. I consider the cost of each operation. Insert is very costly, and insertLogical even more costly. I don't know anything about how your data model is built, but based on this very simple example, I would think you would be better off with a Global like this: Global Income income Style 1: one rule for each scenario rule household income, single when $p1 : Person() not Relation(person1 == $p1, type == spouse) then income = new Income($p1.getIncome()); end rule household income, married when $p1 : Person() Relation(person1 == $p1, type == spouse, $p2: person2) then income = new Income($p1.getIncome() + $p2.getIncome()); end Style 2: a single rule with a collection rule household income when $p1 : Person() $rels : List() from collect(Relation($p1 == person1, type == spouse)) then income = new Income($p1.getIncome() + ($rels.size() == 0 ? 0 : $rels.get(0).getPerson2().getIncome()); end Then in code, you can get the Global value to determine what it got set to, if you need outside of the Drools processing. All thread safety factors must be considered in a multi-threaded environment. Global are not objects know to rete, and therefore, use of them is very fast in the LHS. And the RHS is never aware of changes to Globals (drools assumes them to be static values, that do not change) so care must be taken if using them in the RHS of rules, which I would advise against doing except for special cases where you know a change in the global variable won't be a problem (such as this simple scenario where the global is not used in the RHS at all). -Original Message- From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Christopher Dolan Sent: Monday, April 23, 2012 1:01 PM To: rules-users@lists.jboss.org Subject: [rules-users] Best practice for 0..1 relations What's the best way to encode a fact that's needed in the RHS but is not important in the LHS? Consider a contrived example of computing total household income for single or married persons. I can think of two ways to encode this rule, but I don't like either of them: Style 1: one rule for each scenario rule household income, single when $p1 : Person() not Relation(person1 == $p1, type == spouse) then insertLogical(new Income($p1.getIncome())); end rule household income, married when $p1 : Person() Relation(person1 == $p1, type == spouse, $p2: person2) then insertLogical(new Income($p1.getIncome() + $p2.getIncome())); end Style 2: a single rule with a collection rule household income when $p1 : Person() $rels : List() from collect(Relation($p1 == person1, type == spouse)) then insertLogical(new Income($p1.getIncome() + ($rels.size() == 0 ?
Re: [rules-users] please provide a rule for events timeout cases
And make sure to use '==' when testing for equality! Oh yes of course !! Did not noticed ... ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] please provide a rule for events timeout cases
without the error trace, hard to say why it crashes ... But your rules can be simplified/clarified : - and to connect conditions is not needed - in your first 'not' condition, which you add to test that no other event takes place between the two objects matched in previous patterns, you should test the two response types, as you don't want *any* response ... - again in your first 'not' condition, the after/before should not be in a interval. Why not using after/before only ? For timeout ? Should be a third rule to me ... and should add a rule to handle response coming after the timeout too. - I cant see the utility of you second 'not' pattern (may be because of my previous remarks) Another question : why don't you retract the response too ? Is it because you want to keep them ? To me it is better to retract it, especially if it takes place between another initial EventRequest and its response. at least mark the response as treated and ignore the treated responses in your conditions So, your rules will become 2 groups of rules : first group to handle the response that correspond to a request, second group to handle the timeout cases : rule event_success_case when $req : EventRecord( type=EventRequest, $user : user ) $resp : EventRecord( type=EventResponseSuccess, user=$user, this after $req ) not (EventRecord( type=EventResponseSuccess || EventResponseFailure, user=$user, this != $resp, this after $req , this before $resp))) # 'this != $resp' is not mandatory as you test after/before (which are strict), but it does not harm ... then System.out.println(Success case for user + $req.getUser()); retract($req); retract($resp); end rule event_failure_case : same but testing the other status rule event_timeout_case when $req : EventRecord( type=EventRequest, $user : user ) not (EventRecord( type=EventResponseSuccess || EventResponseFailure, user=$user, this after[0,10s] $req))) // assuming 10s for timeout then System.out.println(Timeout case for user + $req.getUser()); retract($req); end rule event_response_after_timeout_case when $resp: EventRecord( type=EventResponseSuccess || EventResponseFailure, $user : user ) not (EventRecord( type=EventRequest, user=$user, this before $resp))) then System.out.println(Response coming after timeout case for user + $req.getUser()); retract($resp); end ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Sir, Seekin your's Help on Drool
You said that you will stick to the norms here but you do the opposite in your post : Where are the rules ? As far I can guess from all you wrote so far, the errors you have are all easily fixable by reading the very basis of drools doc, like what is a field constraint, how to specify it and how it is transformed (this will explain why your maturityAge(pp) $1 has no chance to work). The errors mismatched input or cannot find ... are basic errors that are theorically fixed as soon as you have the DRL under your eyes... If you have read the doc, you know that a decision table is a way to write rules templates, and it finally generates some DRL (the only executable format for drools). Decision table design and debug cannot be done without a close analysis of produced drl code. The consequence of that is if you can't write a simple DRL that do the job, you won't be able to do the same with a decision table. So, start by getting the generated DRL, fix it, then go back to your decision table and fix it accordingly. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Best way to write a rule where pattern has multiple constraints
First approach is more like a quick-n-dirty trick. It only works if you are sure that only one RuleContext exists in the working memory. If not ... the rule will lead to really strange results ... The real question is why you have rules like that, what was the initial justification? To me it seems to be a mistake, written by someone that did not understand well inferences systems, who has fixed his bugs by restricting to one single RuleContext object... or may be not even ask hilmself the question if this was a initial constraint to have one single object. The second approach is the correct one because : - You want to test one single objet -- You write one single pattern. Using two patterns means (in common sens of everybody writing rules) matching two objects ... - If you give more than one RuleContext, it will still work Does it matter? Not sure that it will change perfs for one single object in WM, but it is the correct way to do, so yes (to me). At least, add a test in all you first rule's pattern to test a common identifier or the object's reference (to ensure that this is the same object), but it will remain a trick (safer, but still not clear) - Mail original - De: larryc larry.chamb...@sentry.com À: rules-users@lists.jboss.org Envoyé: Mercredi 18 Avril 2012 18:15:09 Objet: [rules-users] Best way to write a rule where pattern has multiple constraints I was reviewing some of our DRLs and noticed some rules written like this: when RuleContext(billingSystem == ABC) RuleContext(policyStatus == active) RuleContext(renewalDueDate != null) then ... while others were written this way: when RuleContext(billingSystem == ABC, policyStatus == active, renewalDueDate != null) then ... There should only be one RuleContext fact in the knowledge base at one time. Which approach is better? Is one approach more efficient for Drools than the other? Does it matter? Thanks! -- View this message in context: http://drools.46999.n3.nabble.com/Best-way-to-write-a-rule-where-pattern-has-multiple-constraints-tp3920532p3920532.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] Trying to compare variables of two objects, not working. (compiles, but not desired result)
Le 13/04/2012 10:46, Wolfgang Laun a écrit : 5.3.0 and 5.4.0.Beta2: Comparing int and Integer fails unless the traditional (up to 5.1.1) return value construct - parentheses around the expression - is used: lineItemId == ($lineItem.getID()) // OK lineItemId == ($id) // OK with $id bound as LineItem( $id: ID 0 ) Do you mean that this is a new feature since 5.3 and comparing Integer worked with values prior to this version ? This is confusing, as I really though that drools uses equals instead of == for String and all primitives as Object like Long, Integer and so on ... And this is strange, as in Java, == works with values for Integer, and drools is in java ... And I never faced this problem before, and I am pretty sure that I did use Long in tests ... well in fact I was sure before this mail, less now ... Can you develop more on why this is done this way, and why this is not behaving like java ? ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Trying to compare variables of two objects, not working. (compiles, but not desired result)
I think (not sure) that the problem comes from the right part of your test : $lineItem.ID Try with $lineItem.getID(), or use 'dialect mvel' as rule property You can also bind the id in LineItem and test it in the next pattern : rule Test when $lineItem : LineItem( $lineID : ID 0 ) $trans : TransactionItem( ID 0, AccountName != null, LineItemID == $lineID) $amount : AccountingItem( TransactionID 0, CalculatedCommission 0.0 ) then System.out.println( $amount.getCalculatedCommission() + + $lineItem.getID() ); end But this is very strange. To me it should work ... What is not usual too is your use of _ before member attributes (let me guess, you did a lot of C++ ?), which is not the java POJO standards. And may be that drools relies on fields names too ... And inside your tests, instead of LineItemID you should use lineItemID (with a lower case letter first, like the name your internal attribute should have, following the common java conventions). But if all of this is a problem, the symptom should be a compilation error so it is still strange ... ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Trying to compare variables of two objects, not working. (compiles, but not desired result)
Or may be something more basic : drools does not 'interpret' Integer types as int, so == is testing object references ... This explanation explain why it compiles but not working, whereas if my previous ideas are right, it should raise a compilation error ... Try using 'int', or use Integer.valueOf(1) (that will return a shared instance of Integer). But this is still very strange as doing the same test in java works (Integer is treated as a int, and == is testing values ...) - Mail original - De: Vincent LEGENDRE vincent.legen...@eurodecision.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Jeudi 12 Avril 2012 20:44:41 Objet: Re: [rules-users] Trying to compare variables of two objects,not working. (compiles, but not desired result) I think (not sure) that the problem comes from the right part of your test : $lineItem.ID Try with $lineItem.getID(), or use 'dialect mvel' as rule property You can also bind the id in LineItem and test it in the next pattern : rule Test when $lineItem : LineItem( $lineID : ID 0 ) $trans : TransactionItem( ID 0, AccountName != null, LineItemID == $lineID) $amount : AccountingItem( TransactionID 0, CalculatedCommission 0.0 ) then System.out.println( $amount.getCalculatedCommission() + + $lineItem.getID() ); end But this is very strange. To me it should work ... What is not usual too is your use of _ before member attributes (let me guess, you did a lot of C++ ?), which is not the java POJO standards. And may be that drools relies on fields names too ... And inside your tests, instead of LineItemID you should use lineItemID (with a lower case letter first, like the name your internal attribute should have, following the common java conventions). But if all of this is a problem, the symptom should be a compilation error so it is still strange ... ___ 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] Return List of Fired Rule Name from Decision table
Title: CARTE DE VISITE You should use an AgendaListener instead of polluting your rules with such things. see there : http://docs.jboss.org/drools/release/5.4.0.Beta2/drools-expert-docs/html_single/index.html#d0e2003 Le 09/04/2012 03:21, s a a crit: I have resolved this problem using the following approach Create a Class with a method (say) PrintRuleName(KContext kcontext) { System.out.println(kcontext.getRuleName());} In the decision table in the action Create an Instance of this class and call this method by passing kcontext. Action would look like ( Action for each row in decision table will have this) PrintClass ThePrintClass = new PrintClass(); ThePrintClass.setPrintRuleName(kcontext); SA From: srinivasasanda srinivasasa...@gmail.com To: rules-users@lists.jboss.org Sent: Thursday, April 5, 2012 8:56 AM Subject: [rules-users] Return List of Fired Rule Name from Decision table Hi, when a rule fires i am storing the rule name in Result field of type list as result.add(drools.getRule().getName()) -- in 'part' of a normal rule. Now i am using decision table,how can i get the rule names fired. I am not able to give java statement in action or in row contain field.Where to write that Java statement in Decison Table?Can you suggest me please. Thanks Srinivasa Sanda -- View this message in context: http://drools.46999.n3.nabble.com/Return-List-of-Fired-Rule-Name-from-Decision-table-tp3887158p3887158.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 -- Vincent LEGENDRE Consultant Snior EURODECISION 9A rue de la Porte de Buc 78000 VERSAILLES Tl. : +33 (0)1 39 07 12 40 Direct : +33 (0)1 39 07 26 16 www.eurodecision.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Fwd: Re: make the Guvnor interface into French
This is exactly what I did. This procedure works like a charm. You said a lot of errors ? I can't be possible :) !! Did you tag your corrections ? the NWELL ? Message original Sujet: Re: [rules-users] make the Guvnor interface into French Date : Fri, 6 Apr 2012 21:27:47 +0100 De :Michael Anstis michael.ans...@gmail.com Répondre à :Rules Users List rules-users@lists.jboss.org Pour : Rules Users List rules-users@lists.jboss.org Hi Quentin, The droolsjbom-build-bootstrap\README.md is a good source (and kept up to date). The simplest (and preferred) approach might be to fork the github repository, apply your changes and submit a pull request. Please see here https://hudson.jboss.org/hudson/job/droolsjbpm-knowledge/lastSuccessfulBuild/artifact/droolsjbpm-introduction-docs/target/docbook/publish/en-US/html_single/index.html#gettingstarted for more information. With kind regards, Mike On 6 April 2012 10:53, Qchevalier quentin.chevalier.alt...@gmail.com mailto:quentin.chevalier.alt...@gmail.com wrote: Hello, I got your last file (Constants_fr_FR.properties) Vincent, but I found a lot of errors. So here is my corrected file : http://drools.46999.n3.nabble.com/file/n3889908/Constants_fr_FR.properties Constants_fr_FR.properties I didn't manage to integrate this file into the guvnor war file. I understood that I have to rebuild the sources of guvnor, but I didn't manage to do it. I found several documentations about how to build guvnor sources but each time it was either old instructions, either partial instructions. Can you share a good instruction source? Thanks Regards, Quentin -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-make-the-Guvnor-interface-into-French-tp3737267p3889908.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
Re: [rules-users] In drools what is the exact difference between Insert and Update ??
Far much valuable reply than mine :) A great summary of common concerns that must be evaluated before starting coding a rule system. Also consider : - using rule flow (if you are allowed to) - use sequential mode and pipe your data 'in the next rule box' programmatically (using rules?) - ask your architect ? He is true for no-loop, but for others, re-writing existing DRL code that used all that stuff, and throw all at once is farly more dangerous ... remove all salience from rules and make the rules independent (don't decide its execution flow) This is all the question. It mainly depends of the usage, as Davide said. It also depends of who is authoring/specifying rules : if the guy supposes some flow, he is not writing independant rules ... these other rules depend of the first : 2.no drools functions 3.Activation group / ruleflow / salience ... 5.don't call any java function (thus no functions at all, no predicates/utils methods, only DSL? only POJO?). this one is suspect ... 4.Don't use UPDATE and Global in drools . ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] In drools what is the exact difference between Insert and Update ??
Drools expert doc has a first chapter that adresses these questions (section 1.2) , or at least the questions that must be asked at start of a project. It covers in details the main key question : rules or not ? Using rules implies more constraints on IT because you allow more freedom in business logic part, so you need a more robust IT code . Best pratices are then edicted by the architect, this last one having in mind the requirements of : - business users (most important as they specify rules, at least some representatives samples), - the people who will write the rules (very very important if they are the business users, who are not IT guys, which to me forbid the usage of salience or groups or functions ...) - the other IT guys that will provide data streams to your new application, or who will call your app (it can bring constraints because of data volumetry by instance) In fact, you can't start a real rule project without having enough material in specifications, but this is also true for any project. So there is no (in my opinion) global best pratices (as there is no global best pratices for a random IT project...), with eventually an exception for no-loop (its usage generally shows a lack of design, again, it is my opinion, and I already used them anyway...). Once again, as Davide said, it depends of the usage. So it seems barely impossible to edit (and keep up to date) such a section with all potential use-cases ... May be create a rule application that deduce best pratices ;) ? - Mail original - De: Patrik Dufresne ikus...@gmail.com À: Rules Users List rules-users@lists.jboss.org Envoyé: Jeudi 29 Mars 2012 15:20:21 Objet: Re: [rules-users] In drools what is the exact difference between Insert and Update ?? Sorry to disrupt your discussion, I've start using Drools a while ago and I find your discussion very interesting about how to use what feature when and why. The current Drools Expert user guide is very nice, but it miss this crucial information. May I suggest to create a 'Best Practice' chapter with the recommendation you made. Patrik Dufresne On Thu, Mar 29, 2012 at 8:21 AM, Vincent LEGENDRE vincent.legen...@eurodecision.com wrote: Far much valuable reply than mine :) A great summary of common concerns that must be evaluated before starting coding a rule system. Also consider : - using rule flow (if you are allowed to) - use sequential mode and pipe your data 'in the next rule box' programmatically (using rules?) - ask your architect ? He is true for no-loop, but for others, re-writing existing DRL code that used all that stuff, and throw all at once is farly more dangerous ... remove all salience from rules and make the rules independent (don't decide its execution flow) This is all the question. It mainly depends of the usage, as Davide said. It also depends of who is authoring/specifying rules : if the guy supposes some flow, he is not writing independant rules ... these other rules depend of the first : 2.no drools functions 3.Activation group / ruleflow / salience ... 5.don't call any java function (thus no functions at all, no predicates/utils methods, only DSL? only POJO?). this one is suspect ... 4.Don't use UPDATE and Global in drools . ___ 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] In drools what is the exact difference between Insert and Update ??
Quick summary of : http://docs.jboss.org/drools/release/5.4.0.Beta2/drools-expert-docs/html_single/index.html#d0e5989 insert = inserts a new object in the working memory update = tells the engine that an existing object in the working memory has changed Unexpected question from someone that had written many rules in my previous project and also successfully applied it's (Drools) most of the features (according to another post from you)... These concepts are the very basic one of an expert-system (drools or others), and are described in details in the very first chapter of the drools-expert documentation (or in any description of how an inference engine works, like on wikipedia). I think you should really start by reading the doc before asking such questions. And I am still wondering how you can have used drools before without knowing that ... - Mail original - De: Bhushan Sonaje bhushanson...@gmail.com À: rules-users@lists.jboss.org Envoyé: Mercredi 28 Mars 2012 20:18:56 Objet: [rules-users] In drools what is the exact difference between Insert and Update ?? what is the exact difference between Insert and Update ?? I am little confused here when to used insert and when to use update ?? and is it possible to retrieved updated object from working memory without using *UPDATE* keyword -- View this message in context: http://drools.46999.n3.nabble.com/In-drools-what-is-the-exact-difference-between-Insert-and-Update-tp3865471p3865471.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] Data comparing in CONDITION column decision table
Thanks for the warning, some old bugs appears clearer now !!! Is it planned in a near future to only exclude the constraint and not the whole fact pattern ? To me, it seems more accurate to do this way. Le 19/03/2012 22:57, Michael Anstis a écrit : This is true, but be aware that if a cell value in the Template data is empty the whole Fact Pattern is omitted. For example:- rule Discount @{row.rowNumber} when Account( $v : @{field} != null ) $c : Customer( @{field} == $v , accno == @{accno} ) then $c.setDiscount(1); end If field is empty neither Account or Customer will be included in the generated DRL. If accno is empty Customer will not be included in the generated DRL. This may have an impact on what you want to achieve. With kind regards, Mike ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users