[rules-users] Lock-on-active and FROM
Hello all It has been a while since I posted on this forum as I was assigned to other tasks for a while. Anyway, I have not forgotten about the source of knowledge that is this user forum! We are using Drools 5.3.0. In the expert manual, section 5.8.3.6.2, the odd behavior of lock-on-active and FROM is highlighted. However, we cannot reproduce this reported behaviour. See annex for .java file and drl file. In the documentation, it is sated that only one rule should fire, in the example and as we run it, we can get both rule activations to execute. Could anyone cast the bright light of explanation on this phenomenon? It would also be helpful if someone could provide us with some additional information about why you should expect only one rule to fire. Thank you very much for your time and highly appreciated explanations! Sample.drl http://drools.46999.n3.nabble.com/file/n4030146/Sample.drl DroolsTest.java http://drools.46999.n3.nabble.com/file/n4030146/DroolsTest.java -- View this message in context: http://drools.46999.n3.nabble.com/Lock-on-active-and-FROM-tp4030146.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to pass variables to a drools rule file?
It is looking for com.sample.Qos. Try to add the import statement test.java.Qos somewhere on top of your file. Regards, Frank penny wrote Hi,there.I have a class in test.java file.It looks like: class Qos{ boolean S; boolean W; Qos(){ S = true; W = false; } public boolean getS(){ return S; } public boolean getW(){ return W; } } Now I want to use the Qos class in my rule file like this: rule rule1 ruleflow-group myRules salience 4 when //conditions $qos:Qos(S==true W==true); then System.out.println(rule1); end But here is an error. [Error: could not access field: com.sample.Qos.S] [Near : {... S == true }] ^ [Line: 1, Column: 1] How can I do? -- View this message in context: http://drools.46999.n3.nabble.com/How-to-pass-variables-to-a-drools-rule-file-tp4022607p4022608.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Evaluate rules for multiple facts of the same type within a StateuflSession
Hi, Just as a small remark: it is not always clear to me why some approaches are considered cumbersome and others are considered to be fine. Imagining your example - let me try to clarify. What is your business rule? When a shopping cart contains a dog and dog food Then apply a reduction of 10% to the cart Or is it: When a shopping cart contains a dog and a dog food AND no other reductions are applied Then apply a reduction of 10% to the cart To me, it seems like the latter would be the business rule... Then, why is there so much obstruction against using the fact that an other reduction applied as a blocker in other rules? Regards, Frank I would like to apologize in advance if I seem angry or upset in this reply. I can assure you, I'm not. Let me proof this with a smiley :-D -- View this message in context: http://drools.46999.n3.nabble.com/Evaluate-rules-for-multiple-facts-of-the-same-type-within-a-StateuflSession-tp4022157p4022271.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Evaluate rules for multiple facts of the same type within a StateuflSession
Hmm, it is very uncommon that I am solely addressed in a post where both me and the great Wolfgang Laune replied to. It is quite obvious that I have the lesser mind in this area. Anyway... There is a variety of ways to deal with it and it all depends on your use case. Salience is not the best way to go because it is difficult to manage and maintain in the ling run. Suppose that you would have 50 reductions and suppose that you would have to apply the reduction with the highest percentage (I am guessing that is the case in your example). IN this scenario, if you would add a 51th discount, that should be second in the prioritization order, you would have to adapt all saliences of the other rules to make it fit. This is not what you want. Also if you rely on saliences only, you might be impacted by other rules in other logical rule groups that also rely on salience only. If you must use salience and the amount of the reduction is the prioritization key, you could use the discount amount as the salience value. If there is any other kind of rule sequence, make sure it is done nice and tidy. Only rely on salience within the groups, not accross. An other approach is that you decouple the validity checking of the reduction from applying the reduction. rule agenda-group discount eligibility when ... then insert new Discount(code?, amount?, shoppingCart) rule agenda-group apply discounts when $cart: ShoppingCart() not DiscountApplied(cart == $cart) $myDisc: Discount() not Discount(amount $myDisc.amount) then cart.setDiscount($myDisc.getAmount()); insert(new DiscountApplied()); end This implies that setDiscount knows how to process the discount. You might need different extensions of Discount to fulfill all your needs. Regards, Frank pdario wrote @FrankVhh It looks ok to have a no other reductions are applied as a blocker, I find cumbersome to repeat all the conditions of other rules negated. Anyway, I'll try to summarize my situation: rule 20% discount salience 0 effective 1st Feb - 28th Feb activaction-group online discounts when paying with credicard cart contains special product A then cart.setDiscount(20) rule 15% discount salience -10 effective 1st Feb - 28th Feb activaction-group online discounts when paying with credicard cart contains special product B then cart.setDiscount(15) rule 10% discount salience -20 activaction-group online discounts when paying with credicard then cart.setDiscount(10) rule No discount salience -30 activaction-group online discounts when paying not with creditcard then cart.setDiscount(0) I thought activation-group / salience combination was the easiest and more natural way to follow business rules. How would you suggest to change these? -- View this message in context: http://drools.46999.n3.nabble.com/Evaluate-rules-for-multiple-facts-of-the-same-type-within-a-StateuflSession-tp4022157p4022275.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Why all rule condition fired when insert object in drools session?
Hi Zhao, You could insert a helper fact and use it as a first pattern in your conditions. That way, the engine will not evaluate too many patterns from rules that are not to be executed. When ActiveGroup(name == GroupA) ... Then ... Implications * You will have to take care of the status of ActiveGroup and update its value yourself. Make sure you do it at the appropriate moment. (Low salience rule?) * You would have to re-evaluate the need for the agenda-group. Its functinos are taken over by the fact, do you still need the group? * Whether it will improve performance or not is a whole different question all together and is depending on your ruleset. I never did severe testing on it, but imho, there are certainly cases where the agenda-group is faster than the fact. As a rule of thumb, I would say that if you do a lot of update/modify calls in your consequences, you might get an improvement by blocking the evaluation of patterns early. Regards, Frank PS You could also create a different fact per agenda-group. It should be mildly faster while providing quite a lot less flexibility. -- View this message in context: http://drools.46999.n3.nabble.com/Why-all-rule-condition-fired-when-insert-object-in-drools-session-tp4021769p4021779.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to use Drools's global object in a *.java file?
java.lang.Double result = new java.lang.Double(0); ksession.setGlobal(result, result); ? penny wrote test.java file: KnowledgeBase kbase = readKnowledgeBase(); StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); ksession.setGlobal(result, new java.lang.Double(0)); I have used the global variable “result” in the rule file,how to use it in the test.java file? I need a judgement like “if(result0)”. -- View this message in context: http://drools.46999.n3.nabble.com/How-to-use-Drools-s-global-object-in-a-java-file-tp4021532p4021535.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Refer to later binding
Correct. Next patient! johnysums wrote Just making sure of something. Drools doesnt allow us to refer to bindings made in some later pattern, like this: Person(age 10, age == $otherAge) Person(age 20, $otherAge: age) Correct?? -- View this message in context: http://drools.46999.n3.nabble.com/Refer-to-later-binding-tp4021451p4021460.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Solution for reasoning over XML?
With Wolfgang's approach, your patterns looking like: XmlElement(name=SomeClass,value=foo,attribute[myAttr] == bar) Would turn into: SomeClass(value == foo, myAttr == bar) Without having any numbers, we can still safely say that the performance improvement that you should get from using the pojo's, especially with big files, should be somewhere in between quite considerable and huge. Out of curiosity: A) Do you also call Modify or Update in your THEN clause? B) What does this DSL phrase resolve to? An XML element exists - named someName with a value of - at path /some/xpathlike/path with a value in someVal,someOtherVal Regards, Frank -- View this message in context: http://drools.46999.n3.nabble.com/Solution-for-reasoning-over-XML-tp4021454p4021462.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Solution for reasoning over XML?
Sorry, I apologize. It was wrong for me to say With Wolfgangs approach, as I do not know it well enough at all. I was referring to an approach were you would use JAXB to create pojo objects form the xml and reason on them. My brain must have fooled me in equalizing it with your approach. Sorry to deceive you all. Regards, Frank laune wrote On 11/01/2013, FrankVhh lt; frank.vanhoenshoven@ gt; wrote: With Wolfgang's approach, your patterns looking like: XmlElement(name=SomeClass,value=foo,attribute[myAttr] == bar) Would turn into: SomeClass(value == foo, myAttr == bar) Not quite. A DOM tree would be represented by a very small object hierarchy according to the XML node typology: node-element-attribute-text, etc. What I proposed in my IntelliFest 2012 paper is the addition of facts representing the DOM *structure* to Pojos unmarshalled from the DOM tree. Without having any numbers, we can still safely say that the performance improvement that you should get from using the pojo's, especially with big files, should be somewhere in between quite considerable and huge. It may reduce the number of facts by an order of magnitude, depends on the XML tree's fan out, with consequences for insert, etc. There may also be a penalty due to remaining at the level of all is String (depends on the data). -W Out of curiosity: A) Do you also call Modify or Update in your THEN clause? B) What does this DSL phrase resolve to? An XML element exists - named someName with a value of - at path /some/xpathlike/path with a value in someVal,someOtherVal Regards, Frank -- View this message in context: http://drools.46999.n3.nabble.com/Solution-for-reasoning-over-XML-tp4021454p4021462.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/Solution-for-reasoning-over-XML-tp4021454p4021468.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] modify and update is not working in the rule file
When a rule is activated where the auto-focus value is true and the rule's agenda group does not have focus yet, then it is given focus, allowing the rule to potentially fire. (c) Drools 5.4 Documentation Rana wrote Ok it worked when I changed the rule file a little to add the negative rules. Focus on the Agenda should be dynamic so I have tried writing if-else stmts to focus on for different drugs? it did not work ksession.getAgenda().getAgendaGroup( AndroGel ).setFocus(); Basically for every unit test even though I have set the focus, it is still siring all the rules of the other rule files also. How can I fix this. Also I have new requirement saying that when a rule satisfies, they only few rules to get fired based on the user input (like a grouped rules), so I thought I will use activation-groups apart from agenda-groups. But how can I focus on activating those activation-groups from Drools Rule File. Thanks. -- View this message in context: http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the-rule-file-tp4019158p4019298.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Anyway to get Failed Reason for Failed Rule?
Hi there, Just a minor remark. If you prefer this way of working, do not add the log as a Fact. Add it as a global. Otherwise, it would clutter the rete tree and slow down the execution. Unless you want to use the RuleLog to control the further execution, that is. Regards, Frank jasonxzhong wrote A simple solution is to pass in a string list and for each rule that is fired, append the rule name to the list. Example In your Java code declare: class RuleLog { List log = new ArrayList(); public void add(String logEntry) { log.add(logEntry); } ... } Then insert an instance of RuleLog as a fact to the rules engine. The log entries generated can be retrieved after the rule session is completed. In your rule: rule foo when logger: RuleLog() Then // this will add the current rule name to the log when this rule is fired logger.add(drools.getRule().getName()) ... end Jason -Original Message- From: rules-users-bounces@.jboss [mailto:rules-users-bounces@.jboss] On Behalf Of Rana Sent: Thursday, August 09, 2012 5:00 PM To: rules-users@.jboss Subject: Re: [rules-users] Anyway to get Failed Reason for Failed Rule? Hi Davide, your second guess is right. Sorry I should have said failed condition. I wanted to know which rule got fired and which one did not (because the condition failed in when clause). I wanted to know those, because we have requirement which asks for what are the rules which have passed and failed copnditions, so that we can make some decisions. Also, I wanted to know that in a rule rule name when //condition then //consequence end when the condition is failed will the rule goes to consequence or not. (I am fairely new to Drools. sorry). Thanks. -- View this message in context: http://drools.46999.n3.nabble.com/Anyway-to-get-Failed-Reason-for-Failed-Rule-tp4019070p4019077.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/Anyway-to-get-Failed-Reason-for-Failed-Rule-tp4019070p4019088.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Calling a function from When part
rule sample when eval( sampleFunction() ) then //Take some action end -- View this message in context: http://drools.46999.n3.nabble.com/Calling-a-function-from-When-part-tp4018987p4018989.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Rule Templates
Hi, It is not quite clear to me what you are actually having problems with. I think the documentation explains it quite nicely. See section 6.2 Templates http://docs.jboss.org/drools/release/5.4.0.CR1/drools-expert-docs/html_single/index.html#d0e7468 If you have a more specific question. Feel free to ask. Regard, Frank -- View this message in context: http://drools.46999.n3.nabble.com/Rule-Templates-tp2820139p4018952.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Rule Templates
The information that would help me is (using Eclipse or JBDS) can one edit, It depends if you mean edit the templates or edit the data that you use to populate it. You can create a rule template in any text editor you like and, AFAIK, it can have any extension you prefer. Convert it to an inputstream and use it in the code as is documented. Regarding the data source, you have multiple options to collect the data. Editing this data depends a bit on the type you are using. I typically convert xml objects to java objects and use (and, sometimes, abuse) them to fill the template and generate rules. compile to drl Compile to drl is done using the code as documented. String drl = converter.compile( objs, templateStream ); You can do with the String whatever you like. use it to feed a knowledgebuilder directly, or write it to a file. and test the rule templates Again. This depends on what you mean. If test the rule templates means: check whether it generates a correct drl, than there are 2 things you can do. 1) Manually check that the rules are as you expect them to be. 2) Verify that the drl compiles in a knowledgebuilder. If test means, check whether my generated rules can construct a correct decision, then you wikk have to set up a service/a method/ a unit test in which you use the rules to create a knowledge base and which takes input data to generate a certain output. If you want, you can use guvnor to create test scenarios or implement a testing tool by your own. Regards, Frank mclovis wrote Frank, Thank you for your quick reply. I had previously read your suggested documentation and understand the basics of rule templates. The information that would help me is (using Eclipse or JBDS) can one edit, compile to drl and test the rule templates. The information in the article does not reflect these things and furthermore has a lists of file types for Drools that is not in current versions of IDEs (example: rules resource). If you have knowledge of the mechanics of these things (using even Ant or Maven to compile), it would be much appreciated. Thanks in advance, Mike -- View this message in context: http://drools.46999.n3.nabble.com/Rule-Templates-tp2820139p4018956.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Slow compilation (4h) for a single rule
Hi, There is something that I must ask... Why do you evaluate perfectly simple patterns in an eval, I wonder? rule CONFIG_1-3UCO07 salience -90 when Number(rel_4226982244: intValue 1 ) Number(rel_7521194: intValue 1 ) Number(rel_787633980: intValue 1 ) Number(qty_1331544548: intValue != 1 ) Number(rel_1425187049: intValue != 1 ) Number(rel_1180441096: intValue != 1 ) Number(rel_3132221704: intValue != 1 ) Number(rel_1663554156: intValue != 1 ) Number(rel_1940612775: intValue != 1 ) Number(rel_1735126416: intValue != 1 ) Number(rel_3962361266: intValue != 1 ) Number(rel_882187: intValue != 1 ) Number(rel_1169008280: intValue != 1 ) Number(rel_3495503197: intValue != 1 ) Number(rel_70290066: intValue != 1 ) Number(rel_1333860961: intValue != 1 ) Number(rel_2793542368: intValue != 1 ) Number(rel_952404632: intValue != 1 ) Number(rel_2712335119: intValue != 1 ) Number(qty_4276673135: intValue != 1 ) Number(qty_3950051097: intValue != 1 ) Number(rel_3391032645: intValue != 1 ) Number(rel_2738029181: intValue != 1 ) Number(qty_4125201080: intValue != 1 ) Number(rel_663254919: intValue != 1 ) Number(rel_3059142355: intValue != 1 ) then vh.error(kcontext, Error ...); end Of course, this is still nonsense as long as you do not have a way to constrain the number that you evaluate. The rule, as written above, will fire from the moment you have one single number that has an intValue below 1. Regards, Frank -- View this message in context: http://drools.46999.n3.nabble.com/Slow-compilation-4h-for-a-single-rule-tp4018855p4018860.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Else condition in drl file
Hi, You could put them all in the same activation-group and give low salience to the default rule. See documentation for more details. It seems they are doing a bit of maintenance on the website, so you might have to be patient for a while. Regards, Frank learner wrote Hi, I have a scenario like if(value == 200){ // then do something }else if(value == 100){ // then do something }else{ value = 0 } I created drl with 3 rules Rule 1 : value equal 200 Rule 2 : value equal 100 Rule 3 : value not equal to 100 or 200(ie by value!=200 value!=100 ). Is there a way by which I can simplify the condition in rule 3. -- View this message in context: http://drools.46999.n3.nabble.com/Else-condition-in-drl-file-tp4017903p4017909.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Decision Table, multiple actions accumulation
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! 3) Create a function in your initial column that would compose the value of the two new columns. 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
Re: [rules-users] Drools Decision Table, multiple actions accumulation
Sorry for the confusion, of course I mean ACTION. Although I still did not try it, I also get from the documentation that you would need a column header. The way I see it, there are multiple workarounds for that. One more ugly than the other, so it's up to you to decide if it's worth it. 1) As you said, append all helper columns to the right of the actual decision table. 2) Hide all of the real decision table and create a complete helper table that will feed the real decision table. 3) Mark your helper action column as ACTION as well, if the column is filled in, it will generate a colon ;. I seem to remember having an excel function in the decision table without any problems. Regards, Frank laune wrote I guess you mean ACTION. 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 ___ 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-tp4017733p4017744.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] use of enum with in on LHS
Hi, Unless there is another workaround, I think you would have to do it something like this: [*][when]the received object=result : RulesResult();$stm : Report() [*][keyword]NEW=State.NEW [*][keyword]OLD=State.OLD [*][when]- state is {stateList}=state in ({stateList}) Regards, Frank -- View this message in context: http://drools.46999.n3.nabble.com/use-of-enum-with-in-on-LHS-tp3997081p3997136.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] DRL to DT
The ignorant poster in the next post had an issue that has some remarkable resemblances with your case: http://drools.46999.n3.nabble.com/Decision-Table-td2150980.html There is a sample xls attached somewhere that should help answering your questions. Regards, Frank drools_newbie wrote Hello All, I'm trying to write one simple rule (As I have in .drl file) dialect mvel rule Forst no-loop when $weather: Weather(temperature -12.0) $assignment:Assignment() then modify($assignment){ message=very cold !!!, level=Assignment.MAINROADSANDCITYCENTERS; } end in a Decision table. How do I declare *assignment* object type in decision table? Thanks, Anita -- View this message in context: http://drools.46999.n3.nabble.com/DRL-to-DT-tp3953737p3954924.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] ClassCastException when comparing date type with literal
Let me rephrase my question: As date is an attribute of message, why don't you use: $msg : Message( date ...) Constraining an attribute of Message in the Order pattern seems a weird thing to do. Zeke-3 wrote It seems not work. When I try *$msg : Message($date : date) Order ( $date Mar-01-2012 )* I meet error Unable to create Field Extractor for '$date' of '[ClassObjectType class=org.drools.examples.HelloWorldExample$Second]' in rule 'default' : [Rule name=default, agendaGroup=MAIN, salience=0, no-loop=false] When I try *$msg : Message($date : date) eval ( $date Mar-01-2012 )* If the dialect is java, I meet error Rule Compilation error : [Rule name=default, agendaGroup=MAIN, salience=0, no-loop=false] org/drools/examples/test/Rule_default_0.java (8:354) : The operator is undefined for the argument type(s) Date, String If the dialect is mvel, I meet the same ClassCastException. On 29 March 2012 22:28, FrankVhh lt;frank.vanhoenshoven@gt; wrote: This may sound a bit rude, but... why would you want to do such a thing? If there is a constraint on the message, then why not put that constraint in the message structure? Btw, I think it would work by using eval($date ...) but see no use for it either. Joe Zendle wrote did you try: *$msg : Message($date : date) Order ( $date Mar-01-2012 )* 2012/3/29 Zeke lt;xanadu860122@gt; Hi, guys: I meet a strange issue and need your help again... I am using Drools 4.0.7. When my rule condition is as *Message( date Mar-01-2012 )*, everything is OK. But if I change it to be as below: *$msg : Message() Order ( $msg.date Mar-01-2012 )* I will meet java.lang.String cannot be cast to java.util.Date ClassCastException. Order is another fact. I attach the exception call stack. Please check it. It looks like a bug to me. Do we fix it in later release? If so, can you tell me which release contains the fix? Thanks! ___ 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/rules-users-ClassCastException-when-comparing-date-type-with-literal-tp3867229p3867832.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/rules-users-ClassCastException-when-comparing-date-type-with-literal-tp3867229p3870029.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] ClassCastException when comparing date type with literal
This may sound a bit rude, but... why would you want to do such a thing? If there is a constraint on the message, then why not put that constraint in the message structure? Btw, I think it would work by using eval($date ...) but see no use for it either. Joe Zendle wrote did you try: *$msg : Message($date : date) Order ( $date Mar-01-2012 )* 2012/3/29 Zeke lt;xanadu860122@gt; Hi, guys: I meet a strange issue and need your help again... I am using Drools 4.0.7. When my rule condition is as *Message( date Mar-01-2012 )*, everything is OK. But if I change it to be as below: *$msg : Message() Order ( $msg.date Mar-01-2012 )* I will meet java.lang.String cannot be cast to java.util.Date ClassCastException. Order is another fact. I attach the exception call stack. Please check it. It looks like a bug to me. Do we fix it in later release? If so, can you tell me which release contains the fix? Thanks! ___ 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/rules-users-ClassCastException-when-comparing-date-type-with-literal-tp3867229p3867832.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Complexity Conflict Resolver not working as expected
Hi, To my knowledge, conflict resolvers are only used to determine priority of rule activations. It does not prevent rules from firing. You should be able to get the behavior you want by adding activation-groups. In an activation group, only one rule can fire. See documentation. Regards, Frank vanithap wrote I have 3 rules R1 - state=GA, policy type = Home Owner, Rating program = Standard, then print a R2 - State=GA, Rating Program = Standard, then print b R3 - State=GA, then print c Now I insert the fact with state = GA, policy = HOwner, rating program = Standard, it matches on all the above 3 rules. So I wrote my own ComplexityConflictresolver so only one rule should fire based on the most matched conditions. But it is firing all the above three rules. This is the piece of code I have in complexity resolver public int compare(Activation lhs, Activation rhs) { Rule lhsRule = lhs.getRule(); int numLhsConstraints = getNumConstraintsForRule(lhsRule); Rule rhsRule = rhs.getRule(); int numRhsConstraints = getNumConstraintsForRule(rhsRule); //return numRhsConstraints - numLhsConstraints; if ( numLhsConstraints numRhsConstraints ) { return 1; } else if ( numLhsConstraints numRhsConstraints ) { return -1; } else { return 0; } } private int getNumConstraintsForRule(Rule rule) { int numConstraints = 0; Declaration[] declarations = rule.getDeclarations(); for (Declaration declaration : declarations) { List constraints = declaration.getPattern().getConstraints(); if (null != constraints) { numConstraints += constraints.size(); } } return numConstraints; } This is the piece of code where I hook in the resolver RuleBaseConfiguration configuration = new RuleBaseConfiguration(); ConflictResolver[] conflictResolvers = new ConflictResolver[] { com.test.rulesengine.conflict.ComplexityConflictResolver.getInstance() }; CompositeConflictResolver resolver = new CompositeConflictResolver(conflictResolvers); configuration.setConflictResolver(resolver); KnowledgeBase knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(configuration); It looks like it is adding all three activations to Agenda and firing each one of them. What am I doing wrong. Any help will be appreciated. Thanks -- View this message in context: http://drools.46999.n3.nabble.com/Complexity-Conflict-Resolver-not-working-as-expected-tp3851854p3858196.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Using 'in' operator to find objects inside a list
As documented: Use 'memberOf' instead of 'in'. Regards, Frank purna wrote drl file looks like this.. global ArrayListLong accountNumberBlackList . . . rule blackListToCheck when $transaction : Transaction(accountTo.number in (accountNumberBlackList)) then $transaction.setStatus(Transaction.Status.DENIED); //.. do something else? end I want to use 'in' operator to find numbers that are stored in global variable accountNumberBlackList. Is the above syntax(in double quotes) correct? is there any alternative to look inside a list? -- View this message in context: http://drools.46999.n3.nabble.com/Using-in-operator-to-find-objects-inside-a-list-tp3812727p3812768.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Loop Drools on Multi Element
Actually, I think that laune's solution is preferable as it should be a bit more understandable. Basically the rule states If An order is not high priority And There is no item with a quantity = 2 in that order (Meaning, all items in the order have a quantity 2) Then Set prioiry of order to high The main difference between his rule and your rule would be that you would have to access quantity via your nested objects, while laune assumed it to be accessible directly. As for the example of forall, I never tried it with a list. Maybe I'll do it later today. I would suggest you try it the laune-way. Regards, Frank aliosha79 wrote Can you give me an example using forall? as i tried with a list object and i m not able to make it to work. You can take into account the classes generated by the jaxb engine described within my previous post. Really thanks! Alessio -- View this message in context: http://drools.46999.n3.nabble.com/Loop-Drools-on-Multi-Element-tp3761638p3765759.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] Indexing possible when implementing comparable interface ?
Hi all, Suppose I implement the comparable interface to my objects and overwrite the compareTo method. This would allow me to use the common operators to evaluate my objects in LHS of a rule. But does this also allow the rule engine to index the results or is it just translated behind the scenes to an eval statement? Would there be any theoretical performance improvement? Thanks a lot. Regards, Frank -- View this message in context: http://drools.46999.n3.nabble.com/Indexing-possible-when-implementing-comparable-interface-tp3765776p3765776.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Loop Drools on Multi Element
Hi, See forall element in Drools manual: 5.8.3.6.1. Conditional Element forall It does exactly what you describe. For the record, you may want to insert all your line items separately to working memory. Kind regards, Frank aliosha79 wrote Hi, i'm Alessio and i'm new in this forum. I'm learning to use drool in this period and i'm facing a problem. Briefly: 1- i have an xml document with a repeated element i.e.: order orderLine lineItem nameitem1/name quantity35/quantity /lineItem orderline orderLine lineItem nameitem2/name quantity65/quantity /lineItem orderline orderLine lineItem nameitem3/name quantity52/quantity /lineItem orderline priorityNormal/priority /order 2- i marshalled it in a java class named OrderType using jaxb library 3- then i want to apply a rule stating: /IF EVERY LINEITEM QUANTITY IS GREATER THAN 2 THEN SET PRIORITY TO HIGH/ i can access every single order line Element using this rule: when $Order : OrderType($Order.OrderLine[0].LineItem.Quantity.Value 2) then $Order.getUBLRuleEnginePriority().setValue(High); $Order.addApplyedRule(hpRule); end But how can i cycle on each of them writing the rule at point 3? Thanks a lot. Aliosha -- View this message in context: http://drools.46999.n3.nabble.com/Loop-Drools-on-Multi-Element-tp3761638p3762858.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] having more than one rule in drools template - drt
AFAIK, you can have as many rules as you like. However, the object type from which you collect the data for the rules needs to be the same for the entire template. I never tried if it could work with multiple object types as well, so I would be happy to be overruled. Regards, Frank domingo wrote Hi, can i create more than one rule in one rule template? from the doc, source and example my understanding is only one. Is it possible to break this limitation, please give me some tips... thanks, -- View this message in context: http://drools.46999.n3.nabble.com/having-more-than-one-rule-in-drools-template-drt-tp3753919p3753951.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] logical insertion
Hi, Assuming you are complaining about not being able to logical insert a object from Java code, let me try to explain. The problem is that your understanding of logicalInsert is not quite correct. You can only call logicalInsert from within a rule consequence. The inserted object will remain in working memory for as long as the inserting rule holds true. Therefore, it does not make sense to call logicalInsert from your Java program. Regards, Frank albertorugnone wrote Hi to every body. It is my first post here, and obviously I suppose it will be a silly question. I am using a StatefullQuestion but I can't insert logically any fact, because there is only insert as method and not insertLogical (There is instead in working memory). How I can do? My understanding about logical insertion is that after a certain amount of time (how much?) a fact will be automatically retract. Is it correct? Thank you in advance for your answer. Alberto -- View this message in context: http://drools.46999.n3.nabble.com/logical-insertion-tp3750505p3752924.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] setting different value in consequence ( RHS part) based on a conditional check
Hi Wolfgang, Can I push you for a clarification on this statement? Imho, any of the following reasons is good enough to put a decision in rules A- The decision logic is likely to be subject to change B- The decision logic is too complex to implement in a procedural way C- The decision logic is making sense to business users. (i.e. non-technical logic) In this case, option B is opviously way off. But one can only guess regarding A and C. Regards, Frank laune wrote Oh my, aren't we a wee bit too dogmatic? I've certainly been known as being a stickler to style and best practice and what not, but in this particular case I'd use a single rule and offload the earth-shaking decision between 'Y' and 'N' into a function: rule x when samplefact1( $status: status, state == CA ) then fact0.setField1( yn( $status) ); end Cheers -W ___ 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/setting-different-value-in-consequence-RHS-part-based-on-a-conditional-check-tp3690826p3692750.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] FireAllRules for all agenda
This is interesting... Is there A) Any reason why it is not possible to put rules into multiple agenda groups? After all, it should be a filter, not a package. B) Any plans on making this feasible in future releases? ftr, The same questions can be asked about ruleflow-groups. Until now, I actually always assumed that it was possible to put rules into multiple groups. Apparently, this was something that I never really tried. It is a bit sad to start the weekend being disappointed. Thanks in advance. Frank -- View this message in context: http://drools.46999.n3.nabble.com/FireAllRules-for-all-agenda-tp3674638p3675641.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Template Key in DSL
Hi, laune wrote As much as I like source code generators, I must confess that I've come to dislike the generation of many almost identical chunks, e.g., varying only in literals. Imho, that would be a case to put in a decision table. laune wrote This means that using templates without an if in the available macro language is a weak tool. Consequently, this triple layering isn't on my tops list. You are probably right with this. Templates should probably be considered as a tool that allows you to generate quite complex rules with only minor coding. Of course, the more coding the more rigid (and less agile) the solution will become. Actually, this will split your data in two separate layers, the original data and the transformed data and will burden you with the overhead of the transformation code. However, there might be a valuable trade-off in going for this approach. Regards, Frank laune wrote Hi Frank, thanks for your follow-up. As much as I like source code generators, I must confess that I've come to dislike the generation of many almost identical chunks, e.g., varying only in literals. This means that using templates without an if in the available macro language is a weak tool. Consequently, this triple layering isn't on my tops list. Basically, I agree with your assessment, the only caveat being the level of complexity and extend that is convenient to achieve with a DSL. Regards Wolfgang -- View this message in context: http://drools.46999.n3.nabble.com/Template-Key-in-DSL-tp3634710p3647236.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Template Key in DSL
Hi, Sorry to have kept you waiting. If you use plain DRL, you have 1 source of information. If you use DSL, you add an extra source of information by inserting the data in it. Adding DSL on top of that, adds a third source of information in the form of a vocabulary. In theory, the more disperse your information, the more difficult it will be to maintain. Until now, I debugged all templates in the same way. Expand them all completely and have them outputted to a real DRL file. Than, debug the outputted file and make corrections in your template accordingly. Here, imho, there is not much difference in a DSLR template and a DRL template, provided that you have a stable DSL. This is not a debugging method that I particullary like, but it gets the job done. If you assess the difference between a DSLR and a DRL template, the only differentiator is the DSL. In that case it comes down to the question whether you have a stable DSL or not. If your DSL is mature, I would prefer DSLR over DRL for reasons of understandability to non-technical users. Unless your template is meant to be hidden from the user. Regards, Frank laune wrote OK, thanks for the confirmation. Do you have any comments w.r.t. to usability during development (debugging?!) and maintenance? The example is simple enough, but what's your feeling? -W On 6 January 2012 08:46, FrankVhh lt;frank.vanhoenshoven@gt; wrote: laune wrote What I suggested is a non-standard way of rule authoring, and I just think that it is possible - I've never tried it. This should work. I tried it once with Drools 5.0, so I assume it is still OK. http://drools.46999.n3.nabble.com/file/n3637269/voc.dsl voc.dsl http://drools.46999.n3.nabble.com/file/n3637269/Sample.dst Sample.dst http://drools.46999.n3.nabble.com/file/n3637269/DroolsTest.java DroolsTest.java -- View this message in context: http://drools.46999.n3.nabble.com/Template-Key-in-DSL-tp3634710p3637269.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/Template-Key-in-DSL-tp3634710p3644953.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Template Key in DSL
laune wrote What I suggested is a non-standard way of rule authoring, and I just think that it is possible - I've never tried it. This should work. I tried it once with Drools 5.0, so I assume it is still OK. http://drools.46999.n3.nabble.com/file/n3637269/voc.dsl voc.dsl http://drools.46999.n3.nabble.com/file/n3637269/Sample.dst Sample.dst http://drools.46999.n3.nabble.com/file/n3637269/DroolsTest.java DroolsTest.java -- View this message in context: http://drools.46999.n3.nabble.com/Template-Key-in-DSL-tp3634710p3637269.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Regular expression problem in .dsl
Hi, The placeholder will just be replaced by whatever the user input is, there is no need to do those String operations. In your dsl, copy your DRL and replace everything that is user input by {keyword}. Nothing else has to be done. Regards, Frank fiitkar wrote Hello, I have a problem how to define the proper regular expression in .dsl file, LHS part, when searching a string with a defined input character. Before I used .drl file, the rule looks like: plan : Plan( item matches S.*|.*[^#]S.* ) - that's OK. So it matches an input with S, but not #S - that is not the point... But how to define it in .dsl file? Keep in mind that character S comes from the user, so it have to be merged with my regular expression. I tried it that way: [condition][]There is a Plan with item1 {inputCharacter}=$Plan : Plan(item matches {inputCharacter} + .*|.*[^#] + {inputCharacter} + .* ) But I got compilation error: mismatched token So I want to create a regular expression using the input character. I use Drools 4.0.7 Regards, Peter -- View this message in context: http://drools.46999.n3.nabble.com/Regular-expression-problem-in-dsl-tp3551037p3551706.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] string replace collision problem
I am sorry, but that would not work either. The first rule would not catch those sentences that have both S and SF in them. You will have to work in three steps and use an intermediate value. 1. Change SF to Q 2. Change S to VOL 3. Change Q to S Separate your steps by using ruleflow or agenda-groups. Make sure to update your WM after every change. Sorry for the confusion. Regards, Frank FrankVhh wrote Hi, Sorry, but I fogot about you :-(. It does not work because both wolfgang and I did get your question wrong. If I were you, I would try to work from the opposite direction and check whether a String matches S but not SF. Than replace that S by VOL. A second rule could than safely check for SF and replace that by S. In short, reverse your salience, check that S is not SF and make sure that you replace the right S in the RHS of your rules. You do not want to update the WM. Regards, Frank fiitkar wrote Sorry, it does not work. For input SF I allways get VOLVOLFVOL. Once again: if the input is S the output should be VOL. But if the input string contains SF the output should be S and not VOL. For example: SF -- S SSF -- VOLS SFSF - SS etc. -- View this message in context: http://drools.46999.n3.nabble.com/string-replace-collision-problem-tp3518826p3533054.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Multiple Insert and negative rule
rule test2 salience 5 when not ( Event( (system == anySystem catagory == anyCatagory ) || (system == anyHost message matches .*Hello.*))) then System.out.println( No strange message :-) ); end Hi, Probably it is because you are using NOT (). The engine will not fire this rule for every event in the WM. Consider changing from not ( Event( system == any ) ) to Event( system != any ) That will force the engine to execute it for each Event in memory. Regards, Frank annam2011 wrote Hello, I'm a newbie to drools. I would like to know why i get the following output on the console : Test Message found!! No strange message :-) Test Message found!! Test Message found!! NotifyEngineTest.java creates 10 events. Rule test2 should be activated with every event, so that the output should look like this: Test Message found!! No strange message :-) Test Message found!! No strange message :-) Test Message found!! No strange message :-) Could somebody help me with this ? I appriciate your help Thanks in advance, Anna // NotifyEngineTest.java// for (int i = 0; i 10; i++){ Event e = new Event(); e.setId(ID+Math.random()); e.setTimestamp(new Date()); e.setCatagory(TEST); e.setMessage( i + Test); e.setSystem(localhost); ruleEngine.insert(e); _ // RuleEngine.java// public void insert(Event e) throws RuleEngineException { FactHandle factHandle = ksession.insert(e); int numberOfRules = ksession.fireAllRules(); logger.debug(Rules fired: +numberOfRules); } __ // Notify.drl// rule test salience 10 when $r: Event(message matches .*Test.*) then System.out.println(Test Message found!! + $r); end rule test2 salience 5 when not ( Event( (system == anySystem catagory == anyCatagory ) || (system == anyHost message matches .*Hello.*))) then System.out.println( No strange message :-) ); end -- View this message in context: http://drools.46999.n3.nabble.com/Multiple-Insert-and-negative-rule-tp3531135p3531203.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] multi-factor rule
Hi, If you do not want to check for all alternative cases, you might need a showstopper to stop the firings of unwanted rules. This can be achieved by executing insert(new ShowStopper() ); in your RHS. All LHS of the rules will check for not( ShowStopper() ) Alternatively, you can use the new -experimental - feature of drools called declarative agenda. You could use this to block activations of rules directly. Also, be aware that relying on salience alone is very hard to maintain over time. Regards, Frank ronalbury wrote Hi - I am a Drools newbie and I apologize in advance if the answer to my question is intuitively obvious to the casual user. I have an object that has two fields: location(there are more than 50 locations) and age. I am having difficulty building clean rules for the following pseudo-code // Rule One if(location == A) { if(age 60) do_something(); } // Rule Two else if(location == B) { if(age 70) do_something(); } // Rule Three else if(location == C) { if(age 80) do_something(); } // Rule Four else { if(age 65) do_something(); } The issue comes with Rule Four. How do I avoid writing the rule so that I don't have to say (location!=Alocation!=Blocation!=C) ? I also don't want to have to write an explicit rule for every possible location. I considered an activation-group with salience to have the rules executed in order, but the problem is that if rules 1-3 do not fire, then rule 4 fires for all locations - I can get a hit if location==C and age==70. Is it possible to have a 'Map' and do something like (agemap.get(location)) ? I could live with creating a map with all possible locations for key, although I'd rather not go this route. This problem is typical for the types of rules I'll be writing ... there can be completely different sets of rule criteria depending on location. Thanks in advance for your suggestions and your patience. ___ 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/rules-users-multi-factor-rule-tp3531130p3531237.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] string replace collision problem
Hi, Sorry, but I fogot about you :-(. It does not work because both wolfgang and I did get your question wrong. If I were you, I would try to work from the opposite direction and check whether a String matches S but not SF. Than replace that S by VOL. A second rule could than safely check for SF and replace that by S. In short, reverse your salience, check that S is not SF and make sure that you replace the right S in the RHS of your rules. You do not want to update the WM. Regards, Frank fiitkar wrote Sorry, it does not work. For input SF I allways get VOLVOLFVOL. Once again: if the input is S the output should be VOL. But if the input string contains SF the output should be S and not VOL. For example: SF -- S SSF -- VOLS SFSF - SS etc. -- View this message in context: http://drools.46999.n3.nabble.com/string-replace-collision-problem-tp3518826p3531296.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools 5.3 DSL and DRL
Hi, I am not entirely sure about 5.3, but you certainly could escape pure DRL phrases during DSL and DSLR parsing in V5.1. It would surprise me if they threw that out. You could escape a DRL line by using 'greater than' Regards, Frank gboro54 wrote That is what I thought... I was hoping we would be able to write a rule using a combination of our DSL and rule syntax -- View this message in context: http://drools.46999.n3.nabble.com/Drools-5-3-DSL-and-DRL-tp3524786p3525135.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] string replace collision problem
Cautionç This is answered after only a quick look. You must notify the engie that a change has occured by calling update(plan); in the RHS. Not calling update will modify the object, but the engine will not take these changes into account. Regards, Frank fiitkar wrote: Hello, I've problem with string replacement. See the following example. Input string: SF I've written two simple rules: The first one transforms SF to S The second one transforms S to VOL. The expected output after the transformation should be S, but I get VOL. (as for example for the rules: A-Z, Z-K, input A, output will be Z and not K). So my question is how to avoid this problem (I suppose the problem is that the first transformation returns substring of the input and moreover does exist another transformation rule for it). rule Rule1 for parameter 1 salience 2 when plan : plan( parameter1 matches .*SF.* ) then plan.setParameter1(plan.getParameter1().replace(SF,S)); end rule Rule2 for parameter 1 salience 1 when plan : plan( parameter1 matches .*S.* ) then plan.setParameter1(plan.getParameter1().replace(S,VOL)); end Thank you for your response. Peter -- View this message in context: http://drools.46999.n3.nabble.com/string-replace-collision-problem-tp3518826p3518860.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] string replace collision problem
It is also answered without spell check, sorry... FrankVhh wrote: Cautionç This is answered after only a quick look. You must notify the engie that a change has occured by calling update(plan); in the RHS. Not calling update will modify the object, but the engine will not take these changes into account. Regards, Frank fiitkar wrote: Hello, I've problem with string replacement. See the following example. Input string: SF I've written two simple rules: The first one transforms SF to S The second one transforms S to VOL. The expected output after the transformation should be S, but I get VOL. (as for example for the rules: A-Z, Z-K, input A, output will be Z and not K). So my question is how to avoid this problem (I suppose the problem is that the first transformation returns substring of the input and moreover does exist another transformation rule for it). rule Rule1 for parameter 1 salience 2 when plan : plan( parameter1 matches .*SF.* ) then plan.setParameter1(plan.getParameter1().replace(SF,S)); end rule Rule2 for parameter 1 salience 1 when plan : plan( parameter1 matches .*S.* ) then plan.setParameter1(plan.getParameter1().replace(S,VOL)); end Thank you for your response. Peter -- View this message in context: http://drools.46999.n3.nabble.com/string-replace-collision-problem-tp3518826p3518861.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Whether use agenda group or rule flow
Essentially, agenda-groups and rule-flow groups do the same job. They filter rules based on their group membership such that rules from active groups will fire. The difference is in the implementation. Ruleflow-groups require a ruleflow to be defined. A group will become active when the token has reached the corresponding rule task. When working with agenda-groups, focus has to be set either explicitly, by calling setFocus(), or automatically, by using the attribute auto-focus. Most of the times, there will probably be no clear preference of one over the other. Imho, it seems that rule-flow groups are a bit more understandable and a little bit easier to debug. Agenda-groups, however, allow for more flexibility because the sequence of the groups can be defined dynamically. As an example where I consider agenda-groups a better choice: Imagine there is a supplement/reduction that has to be applied at different moments during price calculation, depending on certain parameters. Imho, it is easier to set focus to the supplement/reduction group whenever necessary, rather than implementing all different branches in a flow. If the sequence is fixed and well known, ruleflow-groups are probably better. But anyway, feel free to disagree. Regards, Frank Zhao Yi wrote: We have many unit fields which has dependence on each other. I want to implement a serial of rules to reflect the dependence among them. I am not sure whether I use agenda-group or rule flow. What is the different between them? -- View this message in context: http://drools.46999.n3.nabble.com/Whether-use-agenda-group-or-rule-flow-tp3512486p3513063.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to run an agenda group multiple times?
What Davide is saying is correct, as is your quotation of the docmentation. I'll try to rephrase Davide's explanation: the group should be activated twice, but the rules aren't necessarily fired. The conditions (incl. rule attributes) should still match before anything fires. Zhao Yi wrote: According to Drools export document, *Each time setFocus() is called it pushes that Agenda Group onto a stack. When the focus group is empty it is popped from the stack and the focus group that is now on top evaluates. An Agenda Group can appear in multiple locations on the stack. * If I run setFocus() on an agenda group two times, the agenda group should be in multiple locations on the stack, why the rules in this agenda group are fired only once? Thanks, Zhao Yi -- View this message in context: http://drools.46999.n3.nabble.com/How-to-run-an-agenda-group-multiple-times-tp3504139p3506641.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Rule Flow: Diverge/Converge Issue with one-to-many paths being exected
Hi, I do not reallt know whether there is a native way in jBPM to implement the m out of n-case you are describing. Anyway, imho, the easiest way to roundtrip this is probably this: Create a series of simple decision gateways: If(A has to execute), fire A; else do nothing; If (B has to execute); fire B; else do nothing;... Each time a task is not to be execute, the token will follow an empty path. You can use the or convergence to join the branches together again and lead them to the next divergence. Hope this helps. Regards, Frank dcrissman wrote: Swindells, Thomas wrote: Can you split it into two separate diverges? Diverge to B first and always follow the other path which then does the A C, Similarly at the other end wait for A C and then a second wait to add in the condition for B. Thomas I am not sure I entirely follow your suggestion. A, B, C could fire in any combination, but always at least one. -- View this message in context: http://drools.46999.n3.nabble.com/Rule-Flow-Diverge-Converge-Issue-with-one-to-many-paths-being-exected-tp3493775p3493922.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to convert .drl file to XML ...
Hi, You could also use the following functions as described in the Drools Expert documentation. XmlDumper - for exporting XML. DrlDumper - for exporting DRL. DrlParser - reading DRL. XmlPackageReader - reading XML Of course, this will imply that you agree to work with the Drools xml format :-) Regards, Frank -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-How-to-convert-drl-file-to-XML-tp3412206p3412906.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] Eclipse reports error when declaring FactType
Hi all, This question might make me look like a bit of a moaner. Then again, you shouldn't be a member of an internet forum if you'd worry about what other people think of you. Therefore: If you declare a type in one of your rule files, and use that type in another drl file, Eclipse will return an error message claiming that the type in question does not exist. And actually, he is quite right, as the type will only start existing when the kbase is created. So, the rules you created *will* work at runtime (provided you did not commit any other foolishness). The thing is, these errors are a bit annoying. Is there any way to circumvent this, moan-moan ? Or is the only way to get rid of the error messages to create the objects in java? Thanks a lot. Regards, Frank -- View this message in context: http://drools.46999.n3.nabble.com/Eclipse-reports-error-when-declaring-FactType-tp3283749p3283749.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Error is Java.lang.RuntimeException
Hi, Maybe you can put something like the following in the code: SpreadsheetCompiler xlsCompiler = new SpreadsheetCompiler(); String drl = xlsCompiler.compile(ResourceFactory.newClassPathResource(Sample.xls).getInputStream(),InputType.XLS); System.out.println(drl); This should enable you to see the generated drl (Syntax not checked, also I am not entirely certain whether it always works) Otherwise, maybe you could post your .xls file. Together with your code, it shouldn't be to hard to replicate the error. Regards, Frank -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-no-subject-tp3280773p3281195.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Rule error
Hi, It depends upon which version of drools you are using, but if it is a version pre 5.2.0, than your last line should be: eval($c.getDoMin()=$m.getDoMin()) If you are using 5.2.0, the parser allow a bit more freedom, allthough I am not sure about this very case. You surely will have to omit the ; at the end of your condition. Regards, Frank michou89 wrote: rule ValidMechanism when $c : Capacity(doMin20) $m : Mechanism(DMOMax=30, doMax50 doMin40 maxPower180 minPower=100 bidPower100 200) $c.getDoMin()=$m.getDoMin(); then System.out.println(Capacity n°+$c.getIdCapacity()+ eligible to the mechanism n°+$m.getIdMechanism()+ for rule 1 ); end My error : org.drools.rule.InvalidRulePackage: [40,15]: unknown:40:15 mismatched token: [@100,813:814='=',78,40:15]; expecting type THEN (this is the last line before the then) I don't understand why I can't compare 2 values. -- View this message in context: http://drools.46999.n3.nabble.com/Rule-error-tp3162619p3165771.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] Serializing knowledgepackages - execution behaviour
Hi all, After playing with serializing knowledgepackages a bit, I stumbled upon some behaviour which I cannot explain at the moment. I can only hope someone can deliver a hint of insight into this. The situation: Creating and executing a rule engine with the very same rules. In the first attempt, rules are serialized first. Note that only the rules are serialized, not the engine. In the second attempt, the normal (= as in the hello world sample) procedure is used to feed the rules to the engine. I noticed some performance differences at execution time, which amaze me a bit, as I can't see a reason why execution would differ... When loading the serialized rules, rule execution is slightly slower and, more important, there are some glitches in the performance (execution times over 10 times slower than average execution). Unserialized rules run much smoother and much more consistent. Does anyone have any explanation for this? I am very interested to find out. Thanks a lot. Regards, Frank -- View this message in context: http://drools.46999.n3.nabble.com/Serializing-knowledgepackages-execution-behaviour-tp3165804p3165804.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] RuleSet (RuleFlowGroup)
Hi, The thing you explain is actually the expected behaviour. If the process encounters a rule task, it will examine all rules inside the ruleflowgroup in question. Rule execution continues until no more matching conditions are found. From then on, the process continues to the next task. If you would like to stop the process based on some business rules, you will have to guide it towards a terminate node or kill it by calling the API. Guiding towards a terminate node can be done with the help of decision gateways and (rule) outcomes. The code to kill it via the API can be found in the documentation. Regards, Frank rchemisa wrote: Hello, I'm trying tp understand how does the Rule Set works and I'm experiencing some problems. I need it to stop when the process finds a 'rule set' and it doesn't match with the conditions, however, the process continues even the facts do not fulfill the conditions. Can someone explain me how does the 'rule set' works or can u give an example? thank you very much -- View this message in context: http://drools.46999.n3.nabble.com/RuleSet-RuleFlowGroup-tp3165058p3165831.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] RuleSet (RuleFlowGroup)
A rule engine will reason upon all the facts that are in its working memory, no matter what facts are in there. Therefore, it can not natively know whether it has enough facts, neither does it (natively) know which facts are missing. Call fire all rules, the engines starts thinking and will stop thinking from the moment there are no more rules that are matching. Whether the results make sense or not... well, it actually doesn't care. In theory, you should provide all necessary facts before calling the rule engine. I.e. add a task/step before calling the engine to collect all missing facts. In practice, you are able to hack the philosophy, as the THEN part of a rule is pure JAVA code, you can pretty much do what you want and add a rule/rules that go after the required inputs (WHEN not veryImportantObject() THEN getMyVeryImportantObject();END Does this make sense to you? Regards, Frank rchemisa wrote: Ty so much for answering FrankVhh, I dont understand if you can stop the process (just wait) in the Rule Set waiting to be inserted in the session some fact that makes the rules associated conditions are met (the result of the conditions true) So, the Rule Set act as a Wait State but may outsource the rules in the drl. Regards -- View this message in context: http://drools.46999.n3.nabble.com/RuleSet-RuleFlowGroup-tp3165058p3166451.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Can I solve the 'Zebra Puzzle' in drools?
Hi, This is a puzzling one... but then again, I believe that is the idea. I should have a very close look at it, but a loop always suggests that there are rules that re-activate themselves or eachother. For example: rule 抽kools牌的香烟的人与养马的人是邻居 when $h1:House(cigarette == Cigarette.kools) $h2:House(pet == Pet.horse) $h3:House(eval(position - $h2.position == 1) || eval(position - $h2.position == -1)) eval($h1.position - $h2.position != 1 $h1.position - $h2.position != -1) then System.out.println(抽kools牌的香烟的人与养马(horse)的人是邻居); modify($h1){setCigarette($h3.cigarette)}; modify($h3){setCigarette(Cigarette.kools)}; end In this rule, $h3 and $h1 might be the same house OR $h1 and $h2 might be the same house. I think you need to add extra constraints to make sure that all 3 houses are different. But still, I haven't had a thorough look at all the rules neither did I refresh my knowledge of the zebrapuzzle, so I am not sure whether this is a complete answer (if any). Please let us know. Regards, Frank -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-Can-I-solve-the-Zebra-Puzzle-in-drools-tp3066485p3067138.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Can I solve the 'Zebra Puzzle' in drools?
Hi, Just a last quick reply before getting stuck in a traffic jam. As said, I haven't had a real good look at the rules, but imo they might be able to work when you feed the engine an initial solution. I.e. insert five house objects into working memory with a random assignment of the attributes. The engine could then re-arrange the objects until all constraints are satisfied. But again, I am not really certain about these statements, but it is an interesting topic to think about... Regards, Frank Wolfgang Laun-2 wrote: This puzzle can be solved using forward chaining, i.e., by using Drools or any similar RBS, but it isn't possible by implementing the givens as rules, expecting that an increase in the filled-in values will result in a (the) solution. Certainly, it is possible to write a rule such as rule EnglishRed when $h: House( nationality == null colour == Colour.RED || nationality == Nationality.ENGLISHMAN colour == null ) then modify( $h ){ setNationality( Nationality.ENGLISHMAN ), setColour( Colour.RED ) } end which adds red or Englishman to a House as soon as the other property is present. But this approach comes to a standstill as soon as more sophisticated mental processes are required in the manual solution technique. One approach I've tried successfully is to generate all permutations of animals, colours, drinks, nationalities and smokes (120 each), insert them as facts, and to write one big rule according to the givens. A similar approach uses facts consisting of an attribute indication (animal,... smoke), a value and a reference to a House, again starting with all possible associations and using one rule to select the attribute combinations satisfying the givens. I'm not quite sure how the rules presented by Miles should work, but I don't think that swapping values between House facts is going to work, even when more defensive strategies against looping are employed. -W On 15 June 2011 14:47, FrankVhh lt;frank.vanhoensho...@agserv.eugt; wrote: Hi, This is a puzzling one... but then again, I believe that is the idea. I should have a very close look at it, but a loop always suggests that there are rules that re-activate themselves or eachother. For example: rule 抽kools牌的香烟的人与养马的人是邻居 when $h1:House(cigarette == Cigarette.kools) $h2:House(pet == Pet.horse) $h3:House(eval(position - $h2.position == 1) || eval(position - $h2.position == -1)) eval($h1.position - $h2.position != 1 $h1.position - $h2.position != -1) then System.out.println(抽kools牌的香烟的人与养马(horse)的人是邻居); modify($h1){setCigarette($h3.cigarette)}; modify($h3){setCigarette(Cigarette.kools)}; end In this rule, $h3 and $h1 might be the same house OR $h1 and $h2 might be the same house. I think you need to add extra constraints to make sure that all 3 houses are different. But still, I haven't had a thorough look at all the rules neither did I refresh my knowledge of the zebrapuzzle, so I am not sure whether this is a complete answer (if any). Please let us know. Regards, Frank -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-Can-I-solve-the-Zebra-Puzzle-in-drools-tp3066485p3067138.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 -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-Can-I-solve-the-Zebra-Puzzle-in-drools-tp3066485p3067695.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Smart Templates
Hi, Basically, you have 2 options. 1) You call the function getType() from your .drl file. The function will be executed at runtime. header name value TEMPLATE WHEN blabla THEN $type.setName($service.getType(@{value})); 2) Execute the function before you compile your rules with Rule Templates. I.e. make sure your objects have an attribute whose value will be set by getType() and use this value in the Template. header name value type TEMPLATE WHEN blabla THEN $type.setName(@{type}); Hope this helps. Btw, am I understanding it correctly that you do not want to use a Decision Table because you are worried about manageability of your ruleset? And, in stead, you want to create rules directly from Java objects, using templates. If this is correct, could you tell me how you are going to manage these objects? Regards, Frank ChrisMu wrote: Sorry - you're losing me - could you give an example please? Thanks From: Wolfgang Laun-2 [via Drools] [mailto:ml-node+3010989-1781642469-404...@n3.nabble.com] Sent: 01 June 2011 15:25 To: Mullard, Christopher Subject: Re: [rules-users] Smart Templates It's just like a Java static method. Call JAva code if you don't want to put it all into DRL function, or import from Java in the first place. Both import and function can be used in spreadsheets. -W 2011/6/1 ChrisMu [hidden email] Agreed, but this was just an example - if the function required something more complicated - say a DB lookup, could it be done? From: Wolfgang Laun-2 [via Drools] [mailto:[hidden email] lt;http://user/SendEmail.jtp?type=nodeamp;node=3010490amp;i=0gt; ] Sent: 01 June 2011 12:40 To: Mullard, Christopher Subject: Re: [rules-users] Smart Templates If there are just 2 types (IRDELTA, COMLEASEDELTA) you can add a function that computes this from the 3-letter name. -W 2011/6/1 ChrisMu [hidden email] lt;http://user/SendEmail.jtp?type=nodeamp;node=3010275amp;i=0gt; Possibly. Let me try again with what I'm trying to achieve. Given this excerpt from a decision table: Basically I want to be able to specify a template that says 'If Arg0 is a currency, output RiskType IRDELTA (and currency), if Arg0 is a commodity (begins with 'X') then output RiskType COMLEASEDELTA (and commodity). When fed with data, this would generate the rules: when Arg0 = USD, output RiskType IRDELTA, USD when Arg0 = GBP, output RiskType IRDELTA, GBP etc when Arg0 = XAU, output RiskType COMLEASEDELTA, XAU etc In this way theRiskType name is inferred from the data when the rules are generated. It can be done by explicitly stating all possible combinations as in the decision table above but that gets tedious quickly. I wanted to have a more general template that could generate all the specific rules instances. Does that make more sense? Thanks Chris From: Wolfgang Laun-2 [via Drools] [mailto:[hidden email] lt;http://user/SendEmail.jtp?type=nodeamp;node=3010119amp;i=0gt; ] Sent: 01 June 2011 11:21 To: Mullard, Christopher Subject: Re: [rules-users] Smart Templates I don't want to confuse you, but have you considered not using templates at all? If you can generate N rules from N objects containing different literals for matching a fact or for updating a fact field, then you can achieve the same thing with a single rule and additional facts containing those literal values. rule one 4 all when   Service( $name: name, $value: value )   $sb: ServiceBean( name == $name, value == $value ) then   # RiskType ... is what?   ...$value..., ...$sb.getType()... end -W ___ rules-users mailing list [hidden email] lt;http://user/SendEmail.jtp?type=nodeamp;node=3010097amp;i=0gt; https://lists.jboss.org/mailman/listinfo/rules-users If you reply to this email, your message will be added to the discussion below: http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3010097.html To
Re: [rules-users] Smart Templates
Load the data from a DB and instantiate Java objects with that. Then generate the rule set using a template. = OK, in this case, I would call the function getType() during the instantiation of the java objects. On the manageability topic: I have no knowledge of your data model, but I can indeed imagine cases where a decision table would be less manageable than a database. Regards, Frank ChrisMu wrote: Ideally: Load the data from a DB and instantiate Java objects with that. Then generate the rule set using a template. The DB data would provide the list of permitted values per field. The rule results are generated based on the inputs. This avoids users having to enter one rule for every single currency and commodity type (using the example below) when there are only 2 underlying 'rules'. If another currency is then added to the data in the DB, the new rule will be automatically generated. From: FrankVhh [via Drools] [mailto:ml-node+3011148-1318721408-404...@n3.nabble.com] Sent: 01 June 2011 15:57 To: Mullard, Christopher Subject: RE: [rules-users] Smart Templates Hi, Basically, you have 2 options. 1) You call the function getType() from your .drl file. The function will be executed at runtime. header name value TEMPLATE WHEN blabla THEN $type.setName($service.getType(@{value})); 2) Execute the function before you compile your rules with Rule Templates. I.e. make sure your objects have an attribute whose value will be set by getType() and use this value in the Template. header name value type TEMPLATE WHEN blabla THEN $type.setName(@{type}); Hope this helps. Btw, am I understanding it correctly that you do not want to use a Decision Table because you are worried about manageability of your ruleset? And, in stead, you want to create rules directly from Java objects, using templates. If this is correct, could you tell me how you are going to manage these objects? Regards, Frank ChrisMu wrote: Sorry - you're losing me - could you give an example please? Thanks From: Wolfgang Laun-2 [via Drools] [mailto:[hidden email]] Sent: 01 June 2011 15:25 To: Mullard, Christopher Subject: Re: [rules-users] Smart Templates It's just like a Java static method. Call JAva code if you don't want to put it all into DRL function, or import from Java in the first place. Both import and function can be used in spreadsheets. -W 2011/6/1 ChrisMu [hidden email] Agreed, but this was just an example - if the function required something more complicated - say a DB lookup, could it be done? From: Wolfgang Laun-2 [via Drools] [mailto:[hidden email] lt;http://user/SendEmail.jtp?type=nodeamp;node=3010490amp;i=0gt; ] Sent: 01 June 2011 12:40 To: Mullard, Christopher Subject: Re: [rules-users] Smart Templates If there are just 2 types (IRDELTA, COMLEASEDELTA) you can add a function that computes this from the 3-letter name. -W 2011/6/1 ChrisMu [hidden email] lt;http://user/SendEmail.jtp?type=nodeamp;node=3010275amp;i=0gt; Possibly. Let me try again with what I'm trying to achieve. Given this excerpt from a decision table: Basically I want to be able to specify a template that says 'If Arg0 is a currency, output RiskType IRDELTA (and currency), if Arg0 is a commodity (begins with 'X') then output RiskType COMLEASEDELTA (and commodity). When fed with data, this would generate the rules: when Arg0 = USD, output RiskType IRDELTA, USD when Arg0 = GBP, output RiskType IRDELTA, GBP etc when Arg0 = XAU, output RiskType COMLEASEDELTA, XAU etc In this way theRiskType name is inferred from the data when the rules are generated. It can be done by explicitly stating all possible combinations as in the decision table above but that gets tedious quickly. I wanted to have a more general template that could generate all the specific rules instances. Does that make more sense? Thanks Chris
Re: [rules-users] Smart Templates
Hi, The way I see it, this is the way your template should look like. I do not see the need to use eval() at all. rule DC_0 when $service: Service(name == @{service}, value == @{value}) $riskType: RiskType() then $riskType.setName($service.getType(@{value})); $riskType.setAtt(0,@{value}); end I am assuming that RiskType is already inserted in WM, but you could just as well create a new object in the then-part of the rule. In stead of using the java-function to determine the name, you might actually just as well create an other rule that sets the name according to the value, thus putting the entire decision logic in rules. Hope this helps. Regards, Frank ChrisMu wrote: Hi, I'm trying to get a template (.drt) to generate 2 rules (.drl) from 2 datasets but by doing a little bit more work than direct substitution. Data (service,value): DC, AAA DC, XYZ Idea for the template - if value is of type1 then create Type object with 'Type1' as name. If value is of type2, use 'Type2' as name: rule DC_@{row.rowNumber} when Service(name == DC) then Type.setName(eval(Service.getType(@{value}))) Type.setAtt(0,@{value}) end template eval(Service.getType(@{arg0})) should take 'AAA' or 'XYZ' etc as arg and return a string Type1/Type2 etc. This would then generate 2 rules that look like: rule DC_0 when Service(name == DC, value == AAA) then RiskType.setName(Type1) RiskType.setAtt(0,AAA) rule DC_1 when Service(name == DC, value == XYZ) then RiskType.setName(Type2) RiskType.setAtt(0,XYZ) ...is this possible at all? I'm trying to avoid the eval step being done in the actual rule (.drl) . Thanks Chris -- View this message in context: http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3006589.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to convert and use JAVA drools 5.1 in .net
Hi, I remember implementing Drools in .net, using IKVM, but I am not able to retrieve the code (nor retrieve my memory) at the moment. When I read my short explanation of the way I implemented it, I am not convinced that I used IKVM to convert any native drools libraries. In stead, it appears as if only my original Java-implementation is converted (with all desired functions present). At least, that would explain why you would be able to disregard all warnings (as Drools engine still runs in java). If you would like to use an Object from the Drools-jars, then you probably cannot disregard the warnings when converting the jars. However, I have never tried to fully achieve this. Imo, there are a number of ways forward from here (choose as you prefer) 1) Try to ikvmc the entire drools library, carefully adding all dependancies and fixing wrong convertions 2) Try to contact an other member of this community: Corneil (du Plessis?), who achieved a drools implementation with IKVM. I am not sure to what extent he converted all the jars. 3) Try using jni4net Regards, Frank rahultechie wrote: Hi, I am trying to access JAVA drools 5.1 in .net. To convert binary files of JAVA drools 5.1 in .net, I use ikvm-0.46.0.1 tool. I referred these dlls in my .net application and tried to write JAVA code (referring to http://techgrafitti.wordpress.com/2011/02/21/drools-%E2%80%93-getting-started-hello-world-example/ link ) in my .net application. But not able to refer StatefulSession class from org.drools.StatefulSession namespace. Actually not able to find org.drools.StatefulSession namespace from drools-core-5.1.1.dll. While converting jar to dlls I got lots of warning, after Googling I found that we have to neglect these warnings. Have any body already wrote such code? Please share the dlls if you are able to run the rules in .net using latest drools 5.1. If possible please share me the code (if your code is not similar to the code referred in above link). -- View this message in context: http://drools.46999.n3.nabble.com/How-to-convert-and-use-JAVA-drools-5-1-in-net-tp3005775p3006664.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Smart Templates
But then that would call the service.getType() method when the rule is run wouldn't it? - Yes I'm trying create explicit, simple rules to avoid doing extra work when running data through them. - OK, in essence, I like that :-) How would you use a rule to set the value within another rule? - I am not sure that I follow you here... If you want to avoid to execute the getType()-service at rule execution, then you would need to add an attribute name to your object, and call getType() before creating the rules. Alternatively, you can insert an intermediate value whose value will be set by another rule and then use this intermediate value in your DC rules. When Service(value = AAA) Then String name = Type1; insert(name); Something like this... but make sure not to create a loop :-) Regards, Frank ChrisMu wrote: But then that would call the service.getType() method when the rule is run wouldn't it? I'm trying create explicit, simple rules to avoid doing extra work when running data through them. How would you use a rule to set the value within another rule? Thanks Chris From: FrankVhh [via Drools] [mailto:ml-node+3006589-784869490-404...@n3.nabble.com] Sent: 31 May 2011 16:48 To: Mullard, Christopher Subject: Re: Smart Templates Hi, The way I see it, this is the way your template should look like. I do not see the need to use eval() at all. rule DC_0 when $service: Service(name == @{service}, value == @{value}) $riskType: RiskType() then $riskType.setName($service.getType(@{value})); $riskType.setAtt(0,@{value}); end I am assuming that RiskType is already inserted in WM, but you could just as well create a new object in the then-part of the rule. In stead of using the java-function to determine the name, you might actually just as well create an other rule that sets the name according to the value, thus putting the entire decision logic in rules. Hope this helps. Regards, Frank ChrisMu wrote: Hi, I'm trying to get a template (.drt) to generate 2 rules (.drl) from 2 datasets but by doing a little bit more work than direct substitution. Data (service,value): DC, AAA DC, XYZ Idea for the template - if value is of type1 then create Type object with 'Type1' as name. If value is of type2, use 'Type2' as name: rule DC_@{row.rowNumber} when Service(name == DC) then Type.setName(eval(Service.getType(@{value}))) Type.setAtt(0,@{value}) end template eval(Service.getType(@{arg0})) should take 'AAA' or 'XYZ' etc as arg and return a string Type1/Type2 etc. This would then generate 2 rules that look like: rule DC_0 when Service(name == DC, value == AAA) then RiskType.setName(Type1) RiskType.setAtt(0,AAA) rule DC_1 when Service(name == DC, value == XYZ) then RiskType.setName(Type2) RiskType.setAtt(0,XYZ) ...is this possible at all? I'm trying to avoid the eval step being done in the actual rule (.drl) . Thanks Chris If you reply to this email, your message will be added to the discussion below: http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3006589.html To unsubscribe from Smart Templates, click here lt;http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubs cribe_by_codeamp;node=3006479amp;code=Y2hyaXN0b3BoZXIubXVsbGFyZEBjcmVkaXQtc3Vp c3NlLmNvbXwzMDA2NDc5fDE5NzczMDY1MzE=gt; . === Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html === -- View this message in context: http://drools.46999.n3.nabble.com/Smart-Templates-tp3006479p3006773.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Is there any work going on for Drools on .net?
Hi, Besides IKVM, there is also the other option of using jni4net. See: http://jni4net.sourceforge.net/ for info on jni4net Pavel Savara even placed a working Drools example on the web, which is available at: http://jni4net.googlecode.com/svn/trunk/content/samples/ Regards, Frank Wolfgang Laun-2 wrote: This has been discussed previously on the list.http://www.jboss.org/drools/lists A lot of information is in the thread started by Jan 19 Gorantla, Bhaskar (GE Capital) Drools Java and .Net: http://drools.46999.n3.nabble.com/Drools-Java-and-Net-tp2290536p2290536.html -W On 30 May 2011 07:58, rahultechie lt;rahul_vidh...@persistent.co.ingt; wrote: Hi, I am currently working on Drools on .net. What I found that the latest version of drool .net is 3.0 which was developed around 2007. After that there is work no done on Drool .net. On above investigation following are my some of questions, 1. Whatever information I got is correct? 2. I want to use drools in my .net project. Latest version of Drools is 5.0 in JAVA, in future can we see Drools 5.0 in .net? 3. Is there any work around for now to use Drools 5.0 in .net? Any link to above question will be useful. Thanks. -- View this message in context: http://drools.46999.n3.nabble.com/Is-there-any-work-going-on-for-Drools-on-net-tp3000917p3000917.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 -- View this message in context: http://drools.46999.n3.nabble.com/Is-there-any-work-going-on-for-Drools-on-net-tp3000917p3001468.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Question / problem
Hi, On a sidenote, there is also no real need to use the eval statement. rule FirstRule when $testDrools : TestDroolsDto(myValue != ) then System.out.println(Set my value to 1); $testDrools.setMyValue(1); update($testDrools); end rule SecondRule when $testDrools : TestDroolsDto(myValue == ) then System.out.println(My Value : + $testDrools.getMyValue() ); end As you are only calling your getter methods, you do not need to use the eval statement in the second rule. In the first rule, your eval did not really do much, as the condition of the rule was completely dependable on the presence of TestDrools. And, as the others stated, to prevent you from getting in a loop after calling Update(), you can add an extra constraint in the rule. Regards, Frank ino.nicolas wrote: Hi, I've got a little question. I've got a drl file which contains two rules : rule FirstRule salience 99 when $testDrools : TestDroolsDto() eval ( 1 == 1 ) then System.out.println(Set my value to 1); $testDrools.setMyValue(1); end rule SecondRule salience 1 when $testDrools : TestDroolsDto() eval( $testDrools.getMyValue().equals() ) then System.out.println(My Value : + $testDrools.getMyValue() ); end Is it normal that in my second rule is verified ? - eval( $testDrools.getMyValue().equals() ) is true but : System.out.println(My Value : + $testDrools.getMyValue() ); show me that myValue == 1 Perhaps I did something wrong ? Thanks for your helping me. N. PS : Here is me TestDroolsDto : public class TestDroolsDto { private String myValue; public TestDroolsDto() { myValue=; } public String toString() { return -- + myValue; } /** * @return the myValue */ public String getMyValue() { if ( myValue == null ) { myValue = ; } return myValue; } /** * @param myValue the myValue to set */ public void setMyValue( String myValue ) { this.myValue = myValue; } } ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-Question-problem-tp2931057p2931186.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] unable to create field extractor for tickerId
Unable to create FIeld extractor, mostly that is because you did not declare getters and in your java class. Drools uses the getters to extract the needed values. Make sure you use the correct naming conventions as well. I.e. public int getTicketId(){...} Regards, frank sirinath wrote: declare ReqMktData @role( event ) end declare TickPrice @role( event ) @expires( 2m ) end declare TickSize @role( event ) @expires( 2m ) end rule Bids when $req: ReqMktData($tickerId : tickerId) from entry-point IB Events $bidprice: TickPrice(field == 1, tickerId == $tickerId, this after $req) from entry-point IB Events $bidsize: TickSize(field == 0, tickerId == $tickerId, this after $req) from entry-point IB Events then Bid bid = new Bid($tickerId, $req.contract, size, price); insert(bid); end public class ReqMktData { public int tickerId; public Contract contract; public String genericTickList; public boolean snapshot; } -- View this message in context: http://drools.46999.n3.nabble.com/unable-to-create-field-extractor-for-tickerId-tp2846413p2846464.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] And Or Problem
Hi, No, it is indeed not possible to combine the operators that way. To make it work, you will have to replace , with . I believe in the expert documentation there is a section with examples of constraints that can and cannot be used. Regards, Frank -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-And-Or-Problem-tp2846480p2846497.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Decision Table
Hi, One can not stress enough the importance of rule governance. However, in your case, I think there is a quite simple solution to the problem. Why would you want to store decision logic to calculate a value that you already know and that shouldn't change anymore? I think, in stead of storing your rule, you should save the outcome of the rule. I.e. save the calculated price and use this price in further calculations, rule executions, There are possibilities to use datetimes as well, but I don't think that is necessary in this example. Regards, Frank Riyaz Saiyed wrote: Hi, I'm doing a POC on drools decision table. We need to develope pricing engine for few of our products. I created xls with list of products and their price as per drools format. When I load xls and run the rules, the price were picked up correctly against mathing product, customer and quantity criteria. Now I want to save the executed rule so the if there is any modification in quantity (increase/decrease), I can calculate the price again based on earlier executed rule and not from xls. I think to achieve the, I need to store the rule against every order for each product. Can any one suggest me, how I can get the string representation of the executed rule so that I can create .drl file from that string and run the same rule again for any order modification. I've looked at SpreadsheetCompiler and was able to get the string of all the rules as a result of compile method. Note - I can not read xls again for order modification because, if in between the price in xls has changed, the engine should still pick the old price. Thanks, Riyaz ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://drools.46999.n3.nabble.com/Drools-Decision-Table-tp2830218p2833441.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Decision Table
Agreed. I consider tariff id an outcome of the rule execution and thus a value as well. Once you have established your tariff, or tariff id, you do not need to recalculate this. Sorry for that, I will try to be less ambiguous next time. Wolfgang Laun-2 wrote: Never duplicate any derived information while the data object holding the duplicate is still in the system. Given an invoice, you may associate its positions with a tariff id, which lets you recalculate an (old) order repeatedly, guaranteeing stable pricing. Only when this data is removed from the system you actually calculate and use the currency values. -W 2011/4/17 Riyaz Saiyed lt;riyaz.sai...@emirates.comgt; Hi, I'm doing a POC on drools decision table. We need to develope pricing engine for few of our products. I created xls with list of products and their price as per drools format. When I load xls and run the rules, the price were picked up correctly against mathing product, customer and quantity criteria. Now I want to save the executed rule so the if there is any modification in quantity (increase/decrease), I can calculate the price again based on earlier executed rule and not from xls. I think to achieve the, I need to store the rule against every order for each product. Can any one suggest me, how I can get the string representation of the executed rule so that I can create .drl file from that string and run the same rule again for any order modification. I've looked at SpreadsheetCompiler and was able to get the string of all the rules as a result of compile method. Note - I can not read xls again for order modification because, if in between the price in xls has changed, the engine should still pick the old price. Thanks, *Riyaz*** ___ 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 -- View this message in context: http://drools.46999.n3.nabble.com/Drools-Decision-Table-tp2830218p2833522.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Decision Table
In this case, the rule outcomes will change, so you need to redo the reasoning, because there is certain information that couldn't be passed after the first rule execution. This implies that you have to keep your rules somewhere and you would need rule governance to manage versioning problems. You could f.e. make the admin create a new version of the xls, but based on a previous version. Be very careful here that he cannot overwrite the previous files. Alternatively, you could actually save each version of the knowledgebase in a database, with some time attributes attached. At runtime, you create a session based on the knowledgebase that has a creation date closest before the date of the request. This requires a lot of governance as well, as you have to decide when to save a new kbase, which bases will never be used again etc. I would try to avoid the last alternative, but it is the only thing that I can think of to achieve your requirement. Regards, Frank Riyaz Saiyed wrote: The idea is to store these price rules as xls decision table. The admin (non technical guy) will periodically update the xls just to change the price. For example for the same date range - 1-Jan-2011 to 31-Mar-2011, price can be increased of decrease depending on the volume of requests. So creating multiple version (more entries in xls) may be time consuming for him. He will prefer to do find and replace to update the price. -- View this message in context: http://drools.46999.n3.nabble.com/Drools-Decision-Table-tp2830218p2833742.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Decision Table
Technically, this is feasible, but consider the following issues: - You will have to save the entire ruleset as a string - If you only save part of the ruleset as string: how are you going to decide which part and how are you going to combine this with the other rules? - You will have an incredible abundance of duplicate rule strings, most of them exaclty the same as a lot of other rule strings. Riyaz Saiyed wrote: The initial idea was to save a rule string as additional column in database with every booking request (against each product). Next time for any modification (for same product), I can create a .drl file from previously stored string at runtime and execute the rule again. -With best regards, Riyaz -- View this message in context: http://drools.46999.n3.nabble.com/Drools-Decision-Table-tp2830218p2834397.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Decision Table
Sorry, but I forgot an issue: - You will have to create a new knowledgebase, at least for each time an existing order is modified. Kbase creation is not a friend of perfomance. -- View this message in context: http://drools.46999.n3.nabble.com/Drools-Decision-Table-tp2830218p2834407.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] help! rulerule_key failed to predicate
Hi, I thnik you might need to reposition dialect = mvel. The compiling error will go away if you put it inside each of your rules. See example: rule system will execute 'tc' command when dialect mvel eval(Server.Message8388608) then System.out.println(The network is so crowd that it needs repairing.); Runtime.getRuntime().exec(tc);#give the authority and execute the tc command end rule caution dialect mvel when eval(Server.Message==8388608) then System.out.println(caution!The network maybe will get blocked very soon.); end rule fluent network dialect mvel when eval(Server.Message8388608)#conditions then System.out.println(the current network is very good);#actions end Also, mvel is needed to make the eval statement work. In your case, it might not be needed to work with eval at all. WHEN Server.message should work as well. Providing you have an attribute message in Server with a getter defined. Regards, Frank 赵慧 wrote: hello,everyone! I wrote a rule with Drools, I compile the program and get the errors as follows: [3,0]: [ERR 103] Line 3:0 rule 'rule_key' failed predicate: {(validateIdentifierKey(DroolsSoftKeywords.RULE))}? in rule [3,9]: [ERR 101] Line 3:9 no viable alternative at input 'com' in rule package [7,0]: [ERR 101] Line 7:0 no viable alternative at input 'import' in rule package in rule sample I don't know how it happened, looking forward to your reply! thank you !!! PS: My rules are here: dialect mvel package com.sample import com.sample.Server; rule system will execute 'tc' command when eval(Server.Message8388608) then System.out.println(The network is so crowd that it needs repairing.); Runtime.getRuntime().exec(tc);#give the authority and execute the tc command end rule caution when eval(Server.Message==8388608) then System.out.println(caution!The network maybe will get blocked very soon.); end rule fluent network when eval(Server.Message8388608)#conditions then System.out.println(the current network is very good);#actions end ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://drools.46999.n3.nabble.com/rules-users-help-rule-rule-key-failed-to-predicate-tp2823695p2823722.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] How to use KnowledgeBase
Hi, In theory, you can do it both ways. Depending on your situation, you will have to assess which approach will be the best solution. Regarding the fact that creation of a kbase takes some time, you will probably want to avoid doing it multiple times per transaction or, at least, cache them. Also, when your rules are part of a continupus flow, you probably want only 1 kbase. In your situation, mortgages, I assume your rules are following eachother with no or very little interaction from the user. In that case, I think one would normally use 1 knowledgebase. Theoretically, multiple knowledgebases should be used when dealing with completely different rulesets, with one ruleset not influencing the other (or execution of ruleset one happening in a totally different timeframe as to justify the use of another kbase). I hope this makes it clear. Regards, Frank ismaximum wrote: Hi I am new to Drools and just want to start developing our app with Drools. I have some questions regarding KnowledgeBase instantiation. Can we create a single instance of KB across the application and use it to create any stateful or stateless session? In this case, do we need to add all the rules available in our application or we need to create one instance for each set of rules? In other words, consider we have many rules including mortgage calculation/ validation, auditing process, interest rate calculation and many others, do we need to create one instance of KB for each rule or just one KB and add all the rules to it? -- View this message in context: http://drools.46999.n3.nabble.com/How-to-use-KnowledgeBase-tp2819308p2819374.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Rule Templates
Hi all, In the Expert Guide and on some places on the internet, I read about Rule Templates. I think this is a very interesting feature. However, the expert manual states to use it with caution as it is still an experimental feature. Also, there isn't that much information on the web either. Is it already encouraged to use it in production, or is it still very much in a development phase and should it only be used for educational purposes? Thanks a lot lots of regards, Frank -- View this message in context: http://drools.46999.n3.nabble.com/Rule-Templates-tp2820139p2820139.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Rule Templates
Hi W., Thanks for the fast reply. Meanwhile, I have been trying to play with the templates. Unfortunately, I run into a nullpointerexception in the problems view of Eclipse. At first, I hoped it was the same error as in http://lists.jboss.org/pipermail/rules-users/2010-November/017229.html but that does not seem to be the case. Underneath, you can find my drl file. This is the only artifact that I am having right now. There is no Java code yet, apart from the Price object. This shouldn't be necessary to fix the problem either. I tried to comment out some pieces of code to narrow down on the problem. The nullpointerexception persists even if you comment everything from package to the bottom of the file. This should indicate the problem has to be in the template header, but I do not have a clue. Could anyone help with this? Thanks in advance. == template header minimumValue maximumValue precision startlevel endlevel roundingvalue package rounding import rounding.Price; template Determine evaluated decimals rule Determine evaluated decimals @{row.rowNumber} salience 25 lock-on-active true when $price: Price(integerpart = @{minimumValue} integerpart @{maximumValue} evaluateddecimals == 999) then $price.setRoundedPrecision(@{precision}); $price.calculateNumberOfRoundedDecimals(); $price.calculateEvaluatedDecimals(); $price.calculateBasenumber(); update($price); end end template template Determine rounding value rule Determine rounding value @{row.rowNumber} salience 0 no-loop true when $price: Price(integerpart = @{minimumValue} integerpart @{maximumValue} evaluateddecimals = @{startlevel} evaluateddecimals @{endlevel}) then $price.setRoundedPrice($price.getBasenumber() + @{roundingvalue}); System.out.println($price.getPrice() + = + (double) $price.getRoundedPrice() / Math.pow(10,$price.getNumberofroundeddecimals()) ); end end template -- View this message in context: http://drools.46999.n3.nabble.com/Rule-Templates-tp2820139p2820343.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Rule Templates
Hi, After trying the example from the documentation, eclipse returned the same error. So, I got the same idea and just worked further ignoring eclipse. I saw what I saw and that was that it works fine now, even with the error still displayed in the problems view. Thanks for the help ;-) Regards, Frank Wolfgang Laun-2 wrote: Not that I can see any problem. Disregard the Eclipse error, expand the template as documented, and then we'll see what we'll see... -W On 14 April 2011 15:36, FrankVhh lt;frank.vanhoensho...@agserv.eugt; wrote: Hi W., Thanks for the fast reply. Meanwhile, I have been trying to play with the templates. Unfortunately, I run into a nullpointerexception in the problems view of Eclipse. At first, I hoped it was the same error as in http://lists.jboss.org/pipermail/rules-users/2010-November/017229.html but that does not seem to be the case. Underneath, you can find my drl file. This is the only artifact that I am having right now. There is no Java code yet, apart from the Price object. This shouldn't be necessary to fix the problem either. I tried to comment out some pieces of code to narrow down on the problem. The nullpointerexception persists even if you comment everything from package to the bottom of the file. This should indicate the problem has to be in the template header, but I do not have a clue. Could anyone help with this? Thanks in advance. == template header minimumValue maximumValue precision startlevel endlevel roundingvalue package rounding import rounding.Price; template Determine evaluated decimals rule Determine evaluated decimals @{row.rowNumber} salience 25 lock-on-active true when $price: Price(integerpart = @{minimumValue} integerpart @{maximumValue} evaluateddecimals == 999) then $price.setRoundedPrecision(@{precision}); $price.calculateNumberOfRoundedDecimals(); $price.calculateEvaluatedDecimals(); $price.calculateBasenumber(); update($price); end end template template Determine rounding value rule Determine rounding value @{row.rowNumber} salience 0 no-loop true when $price: Price(integerpart = @{minimumValue} integerpart @{maximumValue} evaluateddecimals = @{startlevel} evaluateddecimals @{endlevel}) then $price.setRoundedPrice($price.getBasenumber() + @{roundingvalue}); System.out.println($price.getPrice() + = + (double) $price.getRoundedPrice() / Math.pow(10,$price.getNumberofroundeddecimals()) ); end end template -- View this message in context: http://drools.46999.n3.nabble.com/Rule-Templates-tp2820139p2820343.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 -- View this message in context: http://drools.46999.n3.nabble.com/Rule-Templates-tp2820139p2820731.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Combination of conditions doesn't work
Hi Sariman, The trick with from entry-point, is quite unfamiliar to me. There might be some problem with that, but I cannot tell by looking at it. However, there are a few problems with the rules that you have printed out for us. 1) The way I understand it, they do not do what they should be doing. You said you do NOT want an action when all sensors evaluate to true. In your case, you are evaluateing whether all sensors are false. This is pretty useless if you already have a rule which evaluates the existence of at least 1 true sensor. The way I would put this is like this: rule Myrule when #conditions sensorEvent1: SensorEvent(booleanValue == true) exists( SensorEvent(booleanValue == false) ) then #actions end 2) There are some errors in your rule. No idea whether this is a copy/paste or a read/type, so I will just point them out. - ; is usually not needed in a LHS, I am not familiar with the from entry-point syntax, but I assume it wouldn't be needed - There is a ) in excess in one of your conditions 3) I don't think it makes sense to put your rules as you did in the second example. Even if you are trying to examine whether those three sensors are false. On a personal note: what does from entry-point do? I must have overlooked it in the documentation. Regards, Frank sariman wrote: To keep it short, I have three sensors providing me some values every x seconds. I am running an algorithm over those values and getting at the end a single value for each sensor. Next I check if this value is greater/less than a threshold value and creating an object and setting its booelan value to true/false. The last part looks like this: SensorEvent sensorEvent = new SensorEvent (); sensorEvent.setBoolean(booleanValue); sensorEvent.setSensorID(sensorID); I want to do some actions if one of the sensors has true and this works. But I want no action if all sensors have true. And this part doens't work. If I only check one of the sensors if it is false it is ok but the combination doesn't work. It means this case seems naver to happen. No exception or error but no system print either. Here is the code snippet from my rules file: declare SensorEvent @role(event) end rule All false when #conditions sensorEvent1: SensorEvent(sensorID == 1 , booleanValue == false)from entry-point Default; sensorEvent2: SensorEvent(sensorID == 5 , booleanValue == false) ) from entry-point Default; sensorEvent3: SensorEvent(sensorID == 6 , booleanValue == false)from entry-point Default; then #actions System.out.println( All false!! - ); end I run the engine in stream mode and every single value (or object) is being inserted after I receieved the value. I also tried this variant but it didn't work either: rule All false when #conditions sensorEvent1: SensorEvent(sensorID == 1 ) from entry-point Default; sensorEvent2: SensorEvent(sensorID == 5 ) from entry-point Default; sensorEvent3: SensorEvent(sensorID == 6 , booleanValue == false sensorEvent1.booleanValue == false sensorEvent2.booleanValue == false)) from entry-point Default; then #actions System.out.println( All false!! - ); end Any suggestions? -- View this message in context: http://drools-drools-expert-drools-fusion-guvnor-drools-planner.46999.n3.nabble.com/Combination-of-conditions-doesn-t-work-tp2789735p2790446.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Combination of conditions doesn't work
Yes, thanks Manstis. I am already informing myself as we speak :-). manstis wrote: @FrankVhh Entry-points are used with CEP; you'll find details in the Fusion documetation. With kind regards, Mike On 7 April 2011 15:21, FrankVhh lt;frank.vanhoensho...@agserv.eugt; wrote: Hi Sariman, The trick with from entry-point, is quite unfamiliar to me. There might be some problem with that, but I cannot tell by looking at it. However, there are a few problems with the rules that you have printed out for us. 1) The way I understand it, they do not do what they should be doing. You said you do NOT want an action when all sensors evaluate to true. In your case, you are evaluateing whether all sensors are false. This is pretty useless if you already have a rule which evaluates the existence of at least 1 true sensor. The way I would put this is like this: rule Myrule when #conditions sensorEvent1: SensorEvent(booleanValue == true) exists( SensorEvent(booleanValue == false) ) then #actions end 2) There are some errors in your rule. No idea whether this is a copy/paste or a read/type, so I will just point them out. - ; is usually not needed in a LHS, I am not familiar with the from entry-point syntax, but I assume it wouldn't be needed - There is a ) in excess in one of your conditions 3) I don't think it makes sense to put your rules as you did in the second example. Even if you are trying to examine whether those three sensors are false. On a personal note: what does from entry-point do? I must have overlooked it in the documentation. Regards, Frank sariman wrote: To keep it short, I have three sensors providing me some values every x seconds. I am running an algorithm over those values and getting at the end a single value for each sensor. Next I check if this value is greater/less than a threshold value and creating an object and setting its booelan value to true/false. The last part looks like this: SensorEvent sensorEvent = new SensorEvent (); sensorEvent.setBoolean(booleanValue); sensorEvent.setSensorID(sensorID); I want to do some actions if one of the sensors has true and this works. But I want no action if all sensors have true. And this part doens't work. If I only check one of the sensors if it is false it is ok but the combination doesn't work. It means this case seems naver to happen. No exception or error but no system print either. Here is the code snippet from my rules file: declare SensorEvent @role(event) end rule All false when #conditions sensorEvent1: SensorEvent(sensorID == 1 , booleanValue == false)from entry-point Default; sensorEvent2: SensorEvent(sensorID == 5 , booleanValue == false) ) from entry-point Default; sensorEvent3: SensorEvent(sensorID == 6 , booleanValue == false)from entry-point Default; then #actions System.out.println( All false!! - ); end I run the engine in stream mode and every single value (or object) is being inserted after I receieved the value. I also tried this variant but it didn't work either: rule All false when #conditions sensorEvent1: SensorEvent(sensorID == 1 ) from entry-point Default; sensorEvent2: SensorEvent(sensorID == 5 ) from entry-point Default; sensorEvent3: SensorEvent(sensorID == 6 , booleanValue == false sensorEvent1.booleanValue == false sensorEvent2.booleanValue == false)) from entry-point Default; then #actions System.out.println( All false!! - ); end Any suggestions? -- View this message in context: http://drools-drools-expert-drools-fusion-guvnor-drools-planner.46999.n3.nabble.com/Combination-of-conditions-doesn-t-work-tp2789735p2790446.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 -- View this message in context: http://drools-drools-expert-drools-fusion-guvnor-drools-planner.46999.n3.nabble.com/Combination-of-conditions-doesn-t-work-tp2789735p2790527.html Sent from the Drools: User forum mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] The update function inside a rule
There might be some conceptual problem going on here. Calling a ruleset with just (one of- those rules would indeed not produce the desired results (leaving the timer aside). Here is what happens: 1) The rule matches because endtime currenttime 2) Rule is put on agenda 3) As the only rule in the agenda, it is executed and sets the endtime to a couple of seconds in the future 4) WM is updated and rules are re-evaluated 5) No more matching rules because endtime currenttime 6) Rule execution stops I do not know exactly what Marc is doing, but I assume he is trying to keep the engine alive by calling fireAllrules time after time. Part of the problem may be lying here. Could you show us the all parts of your code where you have fireAllRules() coded? Additionally, we can be hoping, but the issue with the timer will probably remain. Did you try to System.out the values of endtime and currenttime after each rule execution? Regards, Frank Wolfgang Laun-2 wrote: On 29 March 2011 19:04, marc lt;marc.stra...@gmail.comgt; wrote: gt; Thanks, gt; The JBRULES-2825 seems to be a similar issue indeed ! gt; gt; The timer is necessary: When change the value of SimpleClock and I only do gt; an update (obj), without calling fireAllRules(). That way the rule doesn't gt; fire... Is-it an other problem ?? gt; gt; If I do a update + fireAllRulles() when I change the timer, the rule_b fire gt; fine every 10 seconds. (without timer in the rule..) gt; gt; Sorry, but I do not understand what you mean by any of these two scenarios. -W gt; gt; I think there is an open JIRA for a very similar issue: gt; gt; JBRULES-2825 amp;quot;rule with timer and CE not keeps firing after turning gt; falseamp;quot; gt; gt; I have added these two rules as a comment. gt; gt; However, the timer isn't necessary in this here case. Since the SimpleClock gt; fact is updated periodically, the engine will fire the rule as soon as gt; dateInMillisec exceeds the clock value in the Message fact. gt; gt; Both rules work correctly, if written without the timer. gt; gt; Actuallay, the timer doesn't have any effect (except wasting a few cycles). gt; If the LHS becomes true, it delays the first firing by 1s, and then the LHS gt; is made false by changing the Message object. This stops the timer! But gt; then, eventually, the LHS becomes true again, and *another timer *is gt; started, delays 1s, fires, and terminates. gt; gt; -W gt; gt; gt; gt; -- gt; View this message in context: gt; http://drools-java-rules-engine.46999.n3.nabble.com/The-update-function-inside-a-rule-tp2747484p2749346.html gt; Sent from the Drools - User mailing list archive at Nabble.com. gt; ___ gt; rules-users mailing list gt; rules-users@lists.jboss.org gt; https://lists.jboss.org/mailman/listinfo/rules-users gt; ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/The-update-function-inside-a-rule-tp2747484p2752845.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] The update function inside a rule
Not entirely, Wolfgang could probably explain this a lot better than me, but I will give it a try. 1) Rule execution stops -or it should stop- as soon as there are no more rules with conditions that are true. Therefor, the rules should only be executed once. 2) You would not need your timer because the only thing it does, is to slow down rule execution 1 sec. And, as wolfgang pointed out, the timer stops, or should stop, once the condition becomes false. Now, in your case, it appears the only job the timer does, is to keep the session alive, which appears to be a bug. What you need, is not a timer. You need something to keep your session alive during the time your conditions are false. Preferably something that is not buggy. This could be achieved by f.e. fireUntilHalt(), or whatever intelligent design you can come up with. About adding log to trace the values of endDate, the traces show correct values. But it doesn't trace the value viewed by the drools engine itself wich could be different (just as if I don't do an update() after a modification) If you rpint the value that is evaluated in the condition, that should be the value drools sees... But I am not an expert in JVM, so I could be wrong. Regards, Frank marc wrote: I was using only one fireAllRules() after insert(message) and not fireUntilHalt(). But is should be enough : as the rule change update the fact, the rule is applied again (10 seconds later, and not 1second). With fireUntilHalt() the rule work fine (and without timer)... but it burns the CPU (the java process reach 50% on a bi-proc) while a simple call to fireAllRues() after the timer update use nothing... This doesn't make sense to me because the drools engine is only notified of a fact modification only 1 time per second (the timer update), so it should only fire all rules a this moment and that all (just like a fireAllRules() after the update(SimpleClock) does), so why does it takes so much CPU ? I can post the code but I should open a other thread because it not the same problem ? About adding log to trace the values of endDate, the traces show correct values. But it doesn't trace the value viewed by the drools engine itself wich could be different (just as if I don't do an update() after a modification) Marc -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/The-update-function-inside-a-rule-tp2747484p2753173.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Rule storage
Hi all, Thanks for your inputs Manstis and Mister X. Out of pure gratitude, I will make sure your name remains unspoken :-). This is my second attempt to write a reply, some weird thing happened during the previous one. I hope it does not suddenly show up on the message board. There surely is something in the DSL approach. Using DSL that way, you copuld actually replace variables by a possibly more flexible alternative. However, there are some drawbacks as well, as there will still be some manageablility issues. Suppose prices go up by 5% in year X and by another 2% in year Y. This would mean you have to do some calculations in order to get your DSL straight. Also, you would need to know which groups could be bulk updated in the future. If there are some corss-overs, that might complicate things as well. Providing you can control versioning, I guess a more direct approach might be the way to go. But no need to worry about that, you helped me a lot gaining more insight, especially the silent one. Thanks, Frank -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Rule-storage-tp2742515p2747204.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] The update function inside a rule
Hi Marc, Your rules do not immediately reveal anything remarkable to me, so I do not have an explanation or solution just yet. Here is what I would do to narrow down on the problem: Add an output in your rules that print the internal end date and the current date in each RHS of the rules. It is unlikely that the WM is not updated at all, that would cause internalEndDate to remain unchanged and rules wouldn't be fired anymore. Regards, Frank Marc Strabin wrote: Hello, I've 2 rules which should be similar but the result is different and I can't understand why : I insert an object Message() into drools with the following rule : rule quot;rule_aquot; timer (int:1s 1s) when SimpleClock ( d : dateInMillisec != 0 ) // SimpleClock give the current time (set by a java timer and an update) m : Message ( internalEndDate lt; d ) then System.out.println( quot;rule aquot;); m.setInternalEndDate (d + 1); * retract (m);* * insert (m);* end gt; the result is fine : a message every 10. If I replace the rule_a by the rule_b : (because an update should be better than an retract/insert I guess) rule quot;rule_bquot; timer (int:1s 1s) when SimpleClock ( d : dateInMillisec != 0 ) // Simple slock give the current time (set by a java timer and an update) m : Message ( internalEndDate lt; d ) then System.out.println( quot;rule bquot;); m.setInternalEndDate (d + 1); * update (m);* end gt; the result is bad : a message every 1 second. It act as if the attibute message.internalEndDate wasn't updated in the drools engine. Could someone explain me if/why this behaviour is normal ? Thanks in advance Marc ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/The-update-function-inside-a-rule-tp2747484p2747740.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] The update function inside a rule
I'm sorry, that didn't make any sense. An un-updated internal enddate would indeed cause the LHS condition to remain true, and the timer will cause it to fire each second. My bad... FrankVhh wrote: Hi Marc, Your rules do not immediately reveal anything remarkable to me, so I do not have an explanation or solution just yet. Here is what I would do to narrow down on the problem: Add an output in your rules that print the internal end date and the current date in each RHS of the rules. It is unlikely that the WM is not updated at all, that would cause internalEndDate to remain unchanged and rules wouldn't be fired anymore. Regards, Frank Marc Strabin wrote: Hello, I've 2 rules which should be similar but the result is different and I can't understand why : I insert an object Message() into drools with the following rule : rule quot;rule_aquot; timer (int:1s 1s) when SimpleClock ( d : dateInMillisec != 0 ) // SimpleClock give the current time (set by a java timer and an update) m : Message ( internalEndDate lt; d ) then System.out.println( quot;rule aquot;); m.setInternalEndDate (d + 1); * retract (m);* * insert (m);* end gt; the result is fine : a message every 10. If I replace the rule_a by the rule_b : (because an update should be better than an retract/insert I guess) rule quot;rule_bquot; timer (int:1s 1s) when SimpleClock ( d : dateInMillisec != 0 ) // Simple slock give the current time (set by a java timer and an update) m : Message ( internalEndDate lt; d ) then System.out.println( quot;rule bquot;); m.setInternalEndDate (d + 1); * update (m);* end gt; the result is bad : a message every 1 second. It act as if the attibute message.internalEndDate wasn't updated in the drools engine. Could someone explain me if/why this behaviour is normal ? Thanks in advance Marc ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/The-update-function-inside-a-rule-tp2747484p2747755.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Rule storage
Hi all, This may be a stupid question, but is there a way to see your Guvnor-rules outside Guvnor in some kind of readable file? I noticed jackrabbit is used as a repository, so I would like to have a look in there, but I am not able to find it in the expanded guvnor.war folder. The version I am using is Guvnor 5.1.1, with standard configuration. A look in the Guvnor documentation did not help me out. Feel free to burn me if I missed it :-) Thanks and regards, Frank -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Rule-storage-tp2742515p2742515.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Rule storage
Hi, Thanks for your quick reply, Salaboy. Webdav indeed allow me to browse through the packages and I was able to locate a file mortgage-sample-repository.xml in the folder WEB-INF/classes of drools-fuvnor.war. However, changes in the xml did not show up in Guvnor and vice versa. So, jackrabbit has to store its contents somewhere else. The folder repository only consists of class-files. The reason I am looking for this file, is because I am looking for ways to simultaneously update multiple rule parameters, without adding a new rule to the ruleset. F.e. we want all base prices of our beverages to increase by 5%. It would be as if you run an sql update statement on a rule database. You'll probably need to parse the drl to achieve this. Regards, Frank -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Rule-storage-tp2742515p2743044.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Rule storage
Hi, Tx agaiin for the clarification on the .xml file. It makes a lot more sense, now. Bulk update is indeed not provided, I was hoping to have a look at the way the rules were stored (probably plain drl, or isn't it?) to assess what effort a bulk update would take. If you mean by your last statement to have rules that set the initial base price, and afterwards add rules to modify the base price (when beverage(), then b.augmentBasePrice(5)), I absolutely agree it is the best solution, implementation-wise. Regarding rule management and governance, there are a few issues that might arise. 1) It is more difficult to get a view on your base prices 2) What if base prices are adapted manually to the desired level? Which adaptation rules need to be deleted or changed? I am not saying that this should be basic functionality of a brms, neither am I very fond of the requirement myself. As it shifts the burden of work from the business to the more technical people :-) Regards, Frank manstis wrote: mortgage-sample-repository.xml is the example repository installed into Guvnor when you first deploy (and answer quot;yesquot; to the install examples prompt). Changing this XML will therefore have no effect, unless you re-import the XML too using the Administration functions in Guvnor. In order to achieve what you state you'd need to (a) use the JCR API to query the underlying datastore, (b) re-build your binary rule package. We don't provide a bulk update facility. Given your example would it be not best to have Beverages themselves as Facts and have rules that set their prices? Think of the Rules Engine as a RDBMS and the Facts as records. With kind regards, Mike On 28 March 2011 14:09, FrankVhh lt;frank.vanhoensho...@agserv.eugt; wrote: gt; Hi, gt; gt; Thanks for your quick reply, Salaboy. gt; gt; Webdav indeed allow me to browse through the packages and I was able to gt; locate a file mortgage-sample-repository.xml in the folder WEB-INF/classes gt; of drools-fuvnor.war. gt; gt; However, changes in the xml did not show up in Guvnor and vice versa. So, gt; jackrabbit has to store its contents somewhere else. The folder gt; quot;repositoryquot; gt; only consists of class-files. gt; gt; The reason I am looking for this file, is because I am looking for ways to gt; simultaneously update multiple rule parameters, without adding a new rule gt; to gt; the ruleset. F.e. we want all base prices of our beverages to increase by gt; 5%. gt; gt; It would be as if you run an sql update statement on a quot;rule databasequot;. gt; You'll probably need to parse the drl to achieve this. gt; gt; Regards, gt; Frank gt; gt; -- gt; View this message in context: gt; http://drools-java-rules-engine.46999.n3.nabble.com/Rule-storage-tp2742515p2743044.html gt; Sent from the Drools - User mailing list archive at Nabble.com. gt; ___ gt; rules-users mailing list gt; rules-users@lists.jboss.org gt; https://lists.jboss.org/mailman/listinfo/rules-users gt; ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Rule-storage-tp2742515p2743373.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Rule storage
Mike, Thanks again for your swift reply. I have one more question, though :-) What do you mean by only need to update DSL? I really don't get this. Imo, DSL are just rules with a shirt on. Regards, Frank -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Rule-storage-tp2742515p2743501.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Limiting rule evaluation--not firing
Hi, Having the same questions you had, I played a bit with agenda-groups to see if there was any notable performance effect. I added 200 extra rules which did not fire at all and did two series of rule executions. Once with all rules within the same agenda-group and once with the 200 extra rules in a different agenda-group, while setting focus to the firing rules. Allthough I cannot claim statistical significance, I didn't notice big effects. As I consider it, the reason for still evaluating all rules is because you would need an Update() statement everytime focus is switched to an other agenda-group to make sure Objects are matched to those rules. Maybe ruleflow-groups work a bit different - allthough I doubt it - but I haven't played with them yet. Regards, Frank -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Limiting-rule-evaluation-not-firing-tp2695533p2709697.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Limiting rule evaluation--not firing
Hi all, This is a very interesting discussion, so I re-read the Drools Flow manual. IN section 8.1, it is stated as one of the reasons to use rules in your process: Performance: Rule evaluation is optimized. How do I have to understand this? Does rule evaluation only happens for the rules that are in the current ruleflowgroup? Because the above conversation seems to imply it isn't. Regards, Frank Swindells, Thomas wrote: That's probably the best way to go. I think it's a case of experimentation to work out what runs best (and please report your results). Things to consider are what order you have the conditions in the rules (the control fact first is probably most efficient but may be worth comparing with it at the end) and the order you insert facts - do you insert the control fact first or last. Thomas From: rules-users-boun...@lists.jboss.org [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Vincent Legendre Sent: 21 March 2011 13:47 To: Rules Users List Subject: Re: [rules-users] Limiting rule evaluation--not firing ok. So the only way to do that is to add a control fact, and update it at runtime... Do you think that using the quot;control factquot; method will speed up the execution time for a large ruleset that have different ruleflow-group ? My feeling is yes, especially if quot;firstquot; rules does many updates, but I haven't done any tests. Le 21/03/2011 14:37, Swindells, Thomas a écrit : The thing to remember is that fact evaluation occurs at object insert/update time, not at the point you call fireAllRules. Salience, Agenda and rufeflow control on the other hand are runtime conditions which control which rules are actually activated in what order. Thomas From: rules-users-boun...@lists.jboss.orglt;mailto:rules-users-boun...@lists.jboss.orggt; [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Vincent Legendre Sent: 21 March 2011 13:34 To: Rules Users List Subject: Re: [rules-users] Limiting rule evaluation--not firing And what about ruleflow-group ? There is no network filtering for that too ? The ruleflow-group behaves like an agenda filter, but still evaluate all nodes ? Could we imagine setting quot;tagsquot; to nodes, and stop propagation for node that does not declare the current task tag ? Le 21/03/2011 14:20, Edson Tirelli a écrit : The algorithm as is does eager evaluation, as for the general case that is still better than doing selective evaluation. If, in your case, the decision of which rules to fire is an arbitrary application decision, and not based on the actual constraints of the rules themselves, then the only way would be by creating a control fact: rule 1 when ControlFact( phase == Phase.ONE ) ... rule 2 when ControlFact( phase == Phase.TWO ) ... This way, if the control fact is the first pattern in each rule it effectively disables all the beta evaluations for rules of phases other than the current one. Just be aware that by blocking the eager evaluation this way, phase switches are heavier than without the control fact, where most constraints were already previously evaluated. Obvious, but worth saying out loud... :) There is also a feature that Leonardo is working on that makes the engine automatically unlink and relink parts of the network, based on the existence and possibility of matching the other required facts in a rule LHS. It might achieve similar results to what you are looking for in some cases, but that is totally based on the constraints in there and not on any arbitrary application decision. Edson ** This message is confidential and intended only for the addressee. If you have received this message in error, please immediately notify the postmas...@nds.comlt;mailto:postmas...@nds.comgt; and delete it from your system as well as any copies. The content of e-mails as well as traffic data may be monitored by NDS for employment and security purposes. To protect the environment please do not print this e-mail unless necessary. NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, United Kingdom. A company registered in England and Wales. Registered no. 3080780. VAT no. GB 603 8808 40-00 ** ___ rules-users mailing list rules-users@lists.jboss.orglt;mailto:rules-users@lists.jboss.orggt; 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 -- View this message in context:
Re: [rules-users] .drl(rule)file creation
Hi kedar, Of course, I do not know what you are trying to achieve in the end, but from the limited information that I have, I think I can agree with manstis that there are 2 options. 1) Download and install Guvnor, which is a UI to edit rules and may be exaclty what you want. 2) Write an application that constructs a text file, based on some inputs and save the text file as myveryimportantrules.drl I have never tried option 2, but it doesn't seem very hard. kedar vyawahare wrote: Thanks for reply. yaa i want exactly the same my U.I should generate the DRL file .But I dont know how to generate a DRL file through U.I. Please help me to generate the DRL through U.I. Thanks in Advance. Kedar ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/drl-rule-file-creation-tp2683529p2686047.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools verifier
Hi Wolfgang, I was about to report the fact that using drools-verifier 5.2.0 M1 didn't help, when I saw your comment about checking the error. Apparently there is something wrong: ### Verifier errors ### [ERR 101] Line 1:1 no viable alternative at input ':' Verifier could not form a PackageDescr from the resources that it was trying to verify. I do not understand this completely. When I execute the ruleset, it runs as planned, but this error message seems to imply there is something wrong with the drl. Is it a problem that I feed the verifier with String ruleText = C:\\Users\\Frank\\Documents\\DroolsWorkSpaces\\EmpiricalExperiments\\Financial Rules\\src\\main\\rules\\clearancerules.drl; verifier.addResourcesToVerify( ResourceFactory.newReaderResource( new StringReader( ruleText ) ), ResourceType.DRL ); Do the inputs need to be in another format or is there definitely something wrong in the rules themselves? Regards, Frank -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-verifier-tp2681002p2687184.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools verifier
Hi Wolfgang, Yes, you are absolutely right about the path mistake. Can't believe I missed that. Fixing it removes the errors from the verifier. However, it still does not return the expected outputs... System.out.println(result.getVerifierData().getAll().isEmpty()); = returns false, which is as expected But the following statement still does not return anything. for (VerifierMessageBase base : result .getBySeverity(Severity.WARNING)) { System.out.println(base); } I'm sorry to take so much of your time, I really appreciate your efforts. Regards, Frank -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-verifier-tp2681002p2687459.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools verifier
Hi, Thanks all for your replies. I forgot I had already uncommented the RHS of a rule, whic onviously did not return a warning. When I comment it, this warning is displayed. Sorry to bother you with this trivial problem. Redundancy, however, isn't detected yet. Neither are the gaps [temperature = 0] and [precipitation != snow] I am assuming this has more to do with the rules, than it has to do with drools verfier. These are the redundant rules: = rule Rule 1 salience 200 agenda-group group1 lock-on-active true when $w : Weather( temperature 0 || precipitation == Weather.SNOW ) $a : Assignment( status == Assignment.INACTIVE) then System.out.println(This rule fired); end rule Rule 2 salience 200 agenda-group group1 lock-on-active true when $w : Weather( temperature 0 || precipitation == Weather.SNOW ) $a : Assignment( status == Assignment.INACTIVE) then System.out.println(This rule fired); end rule Rule 3 salience 200 agenda-group group1 lock-on-active true when $w : Weather( temperature 0 || precipitation == Weather.SNOW ) $a : Assignment( status == Assignment.INACTIVE) then System.out.println(This rule fired); end -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-verifier-tp2681002p2688101.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Drools verifier
Hi all, Triggered by a post on this forum, I decided to try a testcase implementation of Drool Verifiier. I manage to write some code that does not produce any errors at runtime, which is good. Unfortunately, it doesn't produce any errors/warnings/notes on my rulefile either, which isn't good. The drl file consists of some duplicate rules, and since the file is only part of a ruleset, there might be some gaps as well. I pasted the java-code below. Does anyone see where I am going wrong? Thanks in advance! Regards, Frank VerifierBuilder vBuilder = VerifierBuilderFactory.newVerifierBuilder(); Verifier verifier = vBuilder.newVerifier(); String ruleText = C:\\Users\\Frank\\Documents\\DroolsWorkSpaces\\EmpiricalExperiments\\Financial Rules\\src\\main\\rules\\clearancerules.drl; verifier.addResourcesToVerify( ResourceFactory.newReaderResource( new StringReader( ruleText ) ), ResourceType.DRL ); verifier.fireAnalysis(); VerifierReport result = verifier.getResult(); for(VerifierMessageBase base: result.getBySeverity( Severity.ERROR ) ){ System.out.println( base ); } for(VerifierMessageBase base: result.getBySeverity( Severity.WARNING ) ){ System.out.println( base ); } for(VerifierMessageBase base: result.getBySeverity( Severity.NOTE ) ){ System.out.println( base ); } -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-verifier-tp2681002p2681002.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Is it possible to Iteriate over a list of string values ?
Hi all, The way I understand your question, you want to evaluate some string value to a list of Strings, and insert an alarm in the form of a new object to notify that these values are present. This is possible. Insert a String into working memory, then call the following rule: #Testing rule rule test when $vals: String(this in (help,support,assist)) not Fact(value == $vals ) then insert ( new Fact ( $vals ) ); System.out.println(This WORKS!); end The rule checks for a String in working memory, and evaluates its contents ( this in ( list ) ) . If a Fact with the corresponding value hasnt been inserted yet, it will be inserted at runtime. Regards, Frank groovenarula wrote: Hello all, In one of my use cases, I need to insert a variable collections of facts into working memory in order to be able to test for those values later : So I was wondering if there's a way to do something like this when $vals : String() from [ A 12345, B 45678, C 8695 ] then insert ( new Fact ( $vals ) ); With the intention that the rule will fire 3 times and insert the 3 new facts with the values A 12345 and B 45678 and C 8695. Is this possible using rules or do I have to resort to using functions. The problem I'm trying to overcome is to see if there's a way to get the A 12345, B 45678, C 8695 from a single cell of a spreadsheet. Thanks in advance, G -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Is-it-possible-to-Iteriate-over-a-list-of-string-values-tp2654135p2654347.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Object insertion on runtime
Hi all, Since yesterday, I am having a problem with reading inserted objects from memory. I don't know why it does not go as planned, because it should be quite straightforward. It is getting boring to stare at the code, so maybe one of you can detect an error. There are 2 kinds of rules. One kind inserts price objects into working memory (as in example 1). THe other kind detects whether the price exists and adapts it to a product (as in example 2). Example 1 seems to work, but the engine does not seem to recognize them as a Price object. All original price attributes of the products remain unchanged unless: - I manually insert a Prce object before calling fireAllRules() or - Checking for an existing price is commented out in the LHS Removing constraints from $price (just checking for existance of a price) does not help. Any idea what has been going wrong? Thanks in advance. ==Example 1= rule Prices_17 lock-on-active true when then Price $price = new Price(); $price.setName(Blue autumn); $price.setPrice(6); insert($price); System.out.println(Price + $price.getName() + inserted); end =Example of usage= rule Products_36 lock-on-active true when $product: Product(colour == Blue) Season(season == Season.AUTUMN) $price: Price(name == Blue autumn) then $product.setPrice($price.getPrice()); update($product); System.out.println(Rule executed); end === -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Object-insertion-on-runtime-tp2650219p2650219.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Object insertion on runtime
I know etiquette stipulates to avoid small talk, but since there is no resolved button, I think this can be useful. You suspected rightly, manstis, removing lock-on-active and replacing it with extra constraints in the LHS indeed solved the problem. Thanks for the quick (and correct) response :-). manstis wrote: I suspect your use of lock-on-active. Expert's documentation states: Whenever ... an agenda-group receives the focus, any rule within that group that has lock-on-active set to true will not be activated any more; irrespective of the origin of the update, the activation of a matching rule is discarded. Both rules are in the default MAIN agenda group so when the first inserts a new Price the update to WM (insert in your case) is not visible to the other rule. Inserting a new Price before calling fireAllRules or commenting out the price constraint in the LHS alters the Facts\Patterns needing to be matched for activation to occur. So, try removing lock-on-active (or making the two rules in different agenda groups). With kind regards, Mike On 8 March 2011 09:53, FrankVhh wrote: Hi all, Since yesterday, I am having a problem with reading inserted objects from memory. I don't know why it does not go as planned, because it should be quite straightforward. It is getting boring to stare at the code, so maybe one of you can detect an error. There are 2 kinds of rules. One kind inserts price objects into working memory (as in example 1). THe other kind detects whether the price exists and adapts it to a product (as in example 2). Example 1 seems to work, but the engine does not seem to recognize them as a Price object. All original price attributes of the products remain unchanged unless: - I manually insert a Prce object before calling fireAllRules() or - Checking for an existing price is commented out in the LHS Removing constraints from $price (just checking for existance of a price) does not help. Any idea what has been going wrong? Thanks in advance. ==Example 1= rule Prices_17 lock-on-active true when then Price $price = new Price(); $price.setName(Blue autumn); $price.setPrice(6); insert($price); System.out.println(Price + $price.getName() + inserted); end =Example of usage= rule Products_36 lock-on-active true when $product: Product(colour == Blue) Season(season == Season.AUTUMN) $price: Price(name == Blue autumn) then $product.setPrice($price.getPrice()); update($product); System.out.println(Rule executed); end === -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Object-insertion-on-runtime-tp2650219p2650219.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Object-insertion-on-runtime-tp2650219p2650454.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Agenda group in excel
Hi all, Let me tune in on this old post. Is AGENDA-GROUP still unavailable in excel decision tables (V5.1)? The user manual suggests it should be possible, but when I try it, it doesn't seem to work. In the same row as CONDITION, PRIORITY and ACTION, I named one of the columns AGENDA-GROUP. Then, I filled up the column with names for the groups. In another decision table, I called drools.setFocus($param); underneath ACTION to switch agendagroups. Moreover, the spreadsheetcompiler returns priority as a salience attribute in each rule, agenda-group can't be found in the outputs. Regards, Frank -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Agenda-group-in-excel-tp49967p2646355.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools.NET active?
Hi, Drools .NET indeed isn't active any more and using it isn't encouraged. However there are some alternatives to use Drools and .NET together. Either use IKVM, which is some sort of conversion tool. On this forum, a person called Corneil has tried it with success. Or use jni4net, which is a bridge between Java and .NET, developed by Pavel Savara. A sample project of drools is available on via his website. http://zamboch.blogspot.com/ I have used both methods and succeeded twice in generating results. Given the choicce, I think a jnibridge is preferable over IKVM. Imo, it allows for a bit more flexibility and it seems to perform a bit faster as well. Caution, these info is based on limited testing :-) Good luck. Regards, Frank ge0ffrey wrote: No one at JBoss works on Drools.NET, as far as I know. It looks indeed like the project is inactive and it's been forked from the java Drools long ago. If you need to connect to Drools from .NET, you might better off looking at the camel integration... or switch to java :) Op 25-02-11 15:01, Sean Su schreef: Does anyone know if Drools.NET is something Drools team in JBoss works on? Or it is maintained by other team which just named the product Drools.NET. The website and document seem to me that the project is not active. Does anyone know? Thanks Sean -- But beware of the Dark Side. Anger, fear, aggression - the Dark Side of the Force are they. -Yoda ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- With kind regards, Geoffrey De Smet ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-NET-active-tp2575350p2594095.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
[rules-users] Strengths of Drools
Hi all, Suppose some kind of annoying manager asks you to list the strengths of Drools, in stead of just letting you play with the tool. What points would you definitely put on te list apart from: - Open source - Low cost of purchase - Lot of flexibility to developer - Performance - Outperforms even commercial tools according to some studies on the internet Why would you use drools in stead of a competitor's tool? Thanks for your involvement. Regards, Frank -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Strengths-of-Drools-tp2559362p2559362.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Java and .Net
Hi all, Thanks for your inputs. As you suggested, this week I tried to use IKVM to make Drools and .NET work together. Converting the Java implementation of drools to dll, importing dll into .NET and calling the java functions isn't that hard, once you are a little bit familiar with ikvm. No syntax errors in Visual Studio when I do this. However, there seems to be going something wrong on execution. It appears to me that the execution environment does not recognize the drools-language. The execution crashes on the first call of Drools code (knowledgebuilderfactory.new KnowledgeBuilder()) with the errors: - IllegalArgumentException : Unable to instantiate service for Class 'org.drools.builder.KnowledgeBuilderFactoryService - ClassNotFoundException: org.drools.builder.impl.KnowledgeBuilderFactoryServiceImpl This means there are some dependancies missing, right? But should I be looking to add some jars to the IKVM-JVM? Or is this definitely a problem of wrong jar to dll conversion? Corneil, could you tell me whether you ran into dependancy problems as well? fyi I also tried to import the drools library as dll into .NET and then rewrite the entire wrapping code in .NET. This didn't return any syntax errors either, but got stuck in execution as well. (With same errors). Regards, Frank Corneil du Plessis wrote: We have successfully used IKVM to create a dlls for our Drools application. The performance was a bit slower on IKVM/.Net as in Sun Java 5. We dynamically load a large number of rules and found the largest impact is to the 'load time' The performance impact was not such that it would make a network call viable; especially with 1000s of clients. Apart from the performance impact the behaviour is exactly the same. On 25/01/2011 17:04, FrankVhh wrote: Hi all, Suppose that you have a rule engine that needs to be embedded on the machine and that there is no way to call the rules as a service from a centralized server, what approach would one have to choose to make Drools and .NET work? The rulke engine will have to be cached to improve performance, so that part, until there is an up-to-date version of Drools.NET, has to be in Java anyway. Then you expose your JAVA code as a (local) service and let .NET call it? Or am I seeing things wrong here? I must stipulate that I am not an expert in .NET at all, and I know only barely enough Java to get Drools working :-). Thanks for your help. Kind regards, Frank salaboy wrote: Yes, and if you want to use the rule engine from .NET you can use the Drools Server that expose the Drools Runtime in REST and SOAP interfaces :) Greetings. 2011/1/19 Michael Anstismichael.ans...@gmail.com Hi, I believe the .NET implementation of Drools is somewhat out dated. However Drools ticks all your other requirements. With kind regards, Mike 2011/1/19 Gorantla, Bhaskar (GE Capital)bhaskar.goran...@ge.com We are looking for a rules engine that has the following characteristics. 1. Supports both Java and .net 2. Provides a business user friendly UI for creating/editing rules 3. Supports versioning 4. The rues in the rules repository are accessible to both Java and .net applications – Nice to have Do you know whether Drools supports all the above? Thanks ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- - CTO @ http://www.plugtree.com - MyJourney @ http://salaboy.wordpress.com - Co-Founder @ http://www.jbug.com.ar - Salatino Salaboy Mauricio - ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Corneil du Plessis - Software Architect TSC Technologies (Pty) Ltd (o) +27 11 431 1666 (f) +27 86 674 2962 (c) +27 82 530 9259 Email: corn...@tsctech.com mailto:corn...@tsctech.com www.tsctech.com http://www.tsctech.com ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Java-and-Net-tp2290536p2403895.html Sent from the Drools - User mailing list archive at Nabble.com. ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Drools Java and .Net
Hi all, Thanks again for your replies. I converted drools-compiler.jar to drools-compiler.dll and imported this into .NET. Problem might be that this compiles with an incredibly long list of warnings. This might explain the malfunctioning. There are 2 main questions that I am posing at this point. 1) Is it necessary to convert those jars into dll or is it also possible to add the jar-files to some kind of path. (I will try to ask this to a IKVM community) 2) If converting is necessary: Suppose I can remove all warnings by referencing other jar files during dll-conversion. Will this be enough to get to rule execution? Because drools-compiler is not the only file that converts with warnings. Thanks regards, Frank salaboy wrote: Are you including drools-compiler as a dependency? Greetings! - CTO @ http://www.plugtree.com - MyJourney @ http://salaboy.wordpress.com - Co-Founder @ http://www.jbug.com.ar - Mauricio Salaboy Salatino - On 02/02/2011, at 05:40, FrankVhh frank.vanhoensho...@agserv.eu wrote: Hi all, Thanks for your inputs. As you suggested, this week I tried to use IKVM to make Drools and .NET work together. Converting the Java implementation of drools to dll, importing dll into .NET and calling the java functions isn't that hard, once you are a little bit familiar with ikvm. No syntax errors in Visual Studio when I do this. However, there seems to be going something wrong on execution. It appears to me that the execution environment does not recognize the drools-language. The execution crashes on the first call of Drools code (knowledgebuilderfactory.new KnowledgeBuilder()) with the errors: - IllegalArgumentException : Unable to instantiate service for Class 'org.drools.builder.KnowledgeBuilderFactoryService - ClassNotFoundException: org.drools.builder.impl.KnowledgeBuilderFactoryServiceImpl This means there are some dependancies missing, right? But should I be looking to add some jars to the IKVM-JVM? Or is this definitely a problem of wrong jar to dll conversion? Corneil, could you tell me whether you ran into dependancy problems as well? fyi I also tried to import the drools library as dll into .NET and then rewrite the entire wrapping code in .NET. This didn't return any syntax errors either, but got stuck in execution as well. (With same errors). Regards, Frank Corneil du Plessis wrote: We have successfully used IKVM to create a dlls for our Drools application. The performance was a bit slower on IKVM/.Net as in Sun Java 5. We dynamically load a large number of rules and found the largest impact is to the 'load time' The performance impact was not such that it would make a network call viable; especially with 1000s of clients. Apart from the performance impact the behaviour is exactly the same. On 25/01/2011 17:04, FrankVhh wrote: Hi all, Suppose that you have a rule engine that needs to be embedded on the machine and that there is no way to call the rules as a service from a centralized server, what approach would one have to choose to make Drools and .NET work? The rulke engine will have to be cached to improve performance, so that part, until there is an up-to-date version of Drools.NET, has to be in Java anyway. Then you expose your JAVA code as a (local) service and let .NET call it? Or am I seeing things wrong here? I must stipulate that I am not an expert in .NET at all, and I know only barely enough Java to get Drools working :-). Thanks for your help. Kind regards, Frank salaboy wrote: Yes, and if you want to use the rule engine from .NET you can use the Drools Server that expose the Drools Runtime in REST and SOAP interfaces :) Greetings. 2011/1/19 Michael Anstismichael.ans...@gmail.com Hi, I believe the .NET implementation of Drools is somewhat out dated. However Drools ticks all your other requirements. With kind regards, Mike 2011/1/19 Gorantla, Bhaskar (GE Capital)bhaskar.goran...@ge.com We are looking for a rules engine that has the following characteristics. 1. Supports both Java and .net 2. Provides a business user friendly UI for creating/editing rules 3. Supports versioning 4. The rues in the rules repository are accessible to both Java and .net applications – Nice to have Do you know whether Drools supports all the above? Thanks ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- - CTO @ http://www.plugtree.com - MyJourney @ http://salaboy.wordpress.com - Co-Founder @ http://www.jbug.com.ar - Salatino Salaboy Mauricio
Re: [rules-users] Drools Java and .Net
Hi all, I figured out how to get it working. This might be interesting to some of the forum visitors, so I will post the brief solution here. 1. Write your Drools application in java as usual (see documentation :-) 2. Export your java code as a runnable jar-file. 3. Using ikvmc from IKVM/bin, convert the .jar to a .dll and (very important) ignore all warnings! ikvmc -target:library droolsapplication.jar 4. Reference this dll in your .net code. 5. Make sure System.dll and IKVM.OpenJDK.Core.dll are referenced as well 6. In your .net code, add a section to reference your drools libraries: System.Environment.SetEnvironmentVariable(CLASSPATH, .;C:/Users/Frank/Documents/Drools runtime/drools-api.jar;C:/Users/Frank/Documents/Drools runtime/drools-core.jar;C:/Users/Frank/Documents/Drools runtime/drools-compiler.jar); 7. Call the (java-)class and invoke the method which calls upon the ruleset to be executed This way, it should work. Any remarks to this brief overview are welcome, of course :-) Regards, Frank FrankVhh wrote: Hi all, Thanks again for your replies. I converted drools-compiler.jar to drools-compiler.dll and imported this into .NET. Problem might be that this compiles with an incredibly long list of warnings. This might explain the malfunctioning. There are 2 main questions that I am posing at this point. 1) Is it necessary to convert those jars into dll or is it also possible to add the jar-files to some kind of path. (I will try to ask this to a IKVM community) 2) If converting is necessary: Suppose I can remove all warnings by referencing other jar files during dll-conversion. Will this be enough to get to rule execution? Because drools-compiler is not the only file that converts with warnings. Thanks regards, Frank salaboy wrote: Are you including drools-compiler as a dependency? Greetings! - CTO @ http://www.plugtree.com - MyJourney @ http://salaboy.wordpress.com - Co-Founder @ http://www.jbug.com.ar - Mauricio Salaboy Salatino - On 02/02/2011, at 05:40, FrankVhh frank.vanhoensho...@agserv.eu wrote: Hi all, Thanks for your inputs. As you suggested, this week I tried to use IKVM to make Drools and .NET work together. Converting the Java implementation of drools to dll, importing dll into .NET and calling the java functions isn't that hard, once you are a little bit familiar with ikvm. No syntax errors in Visual Studio when I do this. However, there seems to be going something wrong on execution. It appears to me that the execution environment does not recognize the drools-language. The execution crashes on the first call of Drools code (knowledgebuilderfactory.new KnowledgeBuilder()) with the errors: - IllegalArgumentException : Unable to instantiate service for Class 'org.drools.builder.KnowledgeBuilderFactoryService - ClassNotFoundException: org.drools.builder.impl.KnowledgeBuilderFactoryServiceImpl This means there are some dependancies missing, right? But should I be looking to add some jars to the IKVM-JVM? Or is this definitely a problem of wrong jar to dll conversion? Corneil, could you tell me whether you ran into dependancy problems as well? fyi I also tried to import the drools library as dll into .NET and then rewrite the entire wrapping code in .NET. This didn't return any syntax errors either, but got stuck in execution as well. (With same errors). Regards, Frank Corneil du Plessis wrote: We have successfully used IKVM to create a dlls for our Drools application. The performance was a bit slower on IKVM/.Net as in Sun Java 5. We dynamically load a large number of rules and found the largest impact is to the 'load time' The performance impact was not such that it would make a network call viable; especially with 1000s of clients. Apart from the performance impact the behaviour is exactly the same. On 25/01/2011 17:04, FrankVhh wrote: Hi all, Suppose that you have a rule engine that needs to be embedded on the machine and that there is no way to call the rules as a service from a centralized server, what approach would one have to choose to make Drools and .NET work? The rulke engine will have to be cached to improve performance, so that part, until there is an up-to-date version of Drools.NET, has to be in Java anyway. Then you expose your JAVA code as a (local) service and let .NET call it? Or am I seeing things wrong here? I must stipulate that I am not an expert in .NET at all, and I know only barely enough Java to get Drools working :-). Thanks for your help. Kind regards, Frank salaboy wrote: Yes, and if you want to use the rule engine from .NET you can use the Drools Server that expose the Drools Runtime in REST and SOAP interfaces :) Greetings. 2011/1/19 Michael Anstismichael.ans...@gmail.com Hi, I believe the .NET implementation of Drools is somewhat out dated. However Drools ticks