Re: [rules-users] Convert logic to DRL rules
Hi Steven, Yes I thought of that but our business user says this is unacceptable unless I can write a parser to automatically generate all these combinations. The example I use is quite simple. Our business user have quite complex logic expressions (imagin my example plus a lot of parenthesis to build up multiple level logic) already built using Pascal like language and it is not easy to do. Thanks, Ye On 2/19/07, Steven Williams [EMAIL PROTECTED] wrote: Hi Bill, To implement your rules in 3.0.5 you would need to implement a rule for each combination of age and zipCode. $a : Person(age 35 zipCode == 23546) then $a.setStatus(KT); $a : Person(age 25, zipCode == 23546 ) then $a.setStatus(KT); $a : Person(age 35, zipCode == 68590) then $a.setStatus(KT); etc.. Steve On 2/19/07, Bill Zhang [EMAIL PROTECTED] wrote: So Alex, if I only want to use the old syntax that is in production, there is no way to implement my seemingly simple logic conditioning? Thanks for your help. On 2/18/07, Alexander Varakin [EMAIL PROTECTED] wrote: As far as I know this syntax is new and is available in SVN only, you will have to wait till 3.1 is released or take source from SVN and build it. Bill Zhang wrote: Hi Steven, Thank you very much for your help. Really appreciate. I still got the same error, Unexpected token '|'. I did not see | in the document, only saw ||, which is supposed to be used with columns. Ye On 2/18/07, Steven Williams [EMAIL PROTECTED] wrote: Hi Bill, I think it should be: $a : Person(age 35 | 25, zipCode == 23546 | == 68590) Edson, Mark or Michael can probably confirm or correct the above syntax. Make sure you are running of the latest trunk. cheers Steve On 2/18/07, Bill Zhang [EMAIL PROTECTED] wrote: I tried: $a : Person(age 35 || age 25, zipCode == 23546 || == 68590) Errors: org.drools.rule.InvalidRulePackage : unknown:39:30 Unexpected token '||' unknown:39:40 mismatched token: [EMAIL PROTECTED],1040:1041='=',47,39:40]; expecting type '(' unknown:39:92 mismatched token: [EMAIL PROTECTED],1092:1092='',46,39:92]; expecting type '(' I also tried $a : Person(age 35 | age 25, zipCode == 23546 | == 68590) Pretty much the same error. Based on the document, || is only valid for columns... On 2/17/07, Bill Zhang [EMAIL PROTECTED] wrote: Thank you Steve. But I got syntax error using the following. On 2/17/07, Steven Williams [EMAIL PROTECTED] wrote: In trunk I think you can use connective constraints: $a : Person(age 35 | 25, zipCode == 23546 | == 68590) then $a.setStatus(KT); On 2/18/07, Bill Zhang [EMAIL PROTECTED] wrote: Hello, I am a new Drools user trying to convert the following simple logic into DRL: IF (Person.Age 35 OR Person.Age 25) AND (Person.ZipCode = 23546 or Person.ZipCode = 68590) THEN Person.Status = KT; I found that it is not easy to convert the above logic into ONE DRL rule. I tried something like this when $a: Person(age35) or Person (age25) $b: Person(Zipcode==23456) or Person (ZipCode == 68590) $c: $a and $b Then $c.setStatus(KT) But looks like I can not use $c: $a and $b becaue in Drools, you can only bind variable to column, not to other varaibles. Please advise how to do this. I would imagine this should be quite simple, maybe I missed something quite obvious. I know that I can write custom Java method to do this, but if I do that, I suppose I lose the power of RETEOO pattern matching (pattern resuing, etc.). So I prefer not to do that. I also understand I can break the above logic into 4 rules and that would be quite easy, but our business user is not used to think in that way. Also, we have more complex logic than the above. So what I want is to see if there is a way to convert this kind of logic in ONE DRL rule. Thanks in advance. Bill ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Steven Williams Supervising Consultant Object Consulting Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501 [EMAIL PROTECTED] www.objectconsulting.com.au consulting | development | training | support our experience makes the difference ___ rules-users mailing list rules-users@lists.jboss.org
Re: [rules-users] Convert logic to DRL rules
Hi Alex, Thank you for confirming this. Writing such a builder may take us a lot of time because our business user is used to free style Pascal-like authoring using quite complex logic. For example, IF ( ( (Person.Age 35 OR Person.Age 25) AND (Person.ZipCode =23546 or Person.ZipCode = 68590) ) and ( (Person.LastOrderPrice 300 OR (Person.TotalOrderNumber 2) ) ) OR ( ( (Person.LastOrderCategory in (098, 109) ) AND (Person.ZipCode =74567 or Person.ZipCode = 23765) ) and ( (Person.LastOrderPrice 1000 OR (Person.TotalOrderNumber 1) ) ) ... THEN Person.Status = KT; Before I set out to write the builder, I would like to know whether the new syntax can handle the above logic? Also, where can I find document for the new syntax? I am also trying to find some existing open source Java library to flatten out these complex logic - to break these complex logic to atomic ones that can be handled by Drools. Do you have any recommendation? Thanks a lot for your help. Bill Y. On 2/19/07, Alexander Varakin [EMAIL PROTECTED] wrote: We built a Rule Builder which creates drl with all possible combinations. In any case, drl syntax is not exactly business user friendly, so having such builder is not a bad idea. Simple Rule Builder can be implemented as an Excel spreadsheet, which can be easily parsed using POI library and then drl file produced. Steven Williams wrote: Hi Bill, To implement your rules in 3.0.5 you would need to implement a rule for each combination of age and zipCode. $a : Person(age 35 zipCode == 23546) then $a.setStatus(KT); $a : Person(age 25, zipCode == 23546 ) then $a.setStatus(KT); $a : Person(age 35, zipCode == 68590) then $a.setStatus(KT); etc.. Steve On 2/19/07, *Bill Zhang* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: So Alex, if I only want to use the old syntax that is in production, there is no way to implement my seemingly simple logic conditioning? Thanks for your help. On 2/18/07, Alexander Varakin [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: As far as I know this syntax is new and is available in SVN only, you will have to wait till 3.1 is released or take source from SVN and build it. Bill Zhang wrote: Hi Steven, Thank you very much for your help. Really appreciate. I still got the same error, Unexpected token '|'. I did not see | in the document, only saw ||, which is supposed to be used with columns. Ye On 2/18/07, Steven Williams [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi Bill, I think it should be: $a : Person(age 35 | 25, zipCode == 23546 | == 68590) Edson, Mark or Michael can probably confirm or correct the above syntax. Make sure you are running of the latest trunk. cheers Steve On 2/18/07, Bill Zhang [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I tried: $a : Person(age 35 || age 25, zipCode == 23546 || == 68590) Errors: org.drools.rule.InvalidRulePackage : unknown:39:30 Unexpected token '||' unknown:39:40 mismatched token: [EMAIL PROTECTED],1040:1041='=',47,39:40]; expecting type '(' unknown:39:92 mismatched token: [EMAIL PROTECTED],1092:1092='',46,39:92]; expecting type '(' I also tried $a : Person(age 35 | age 25, zipCode == 23546 | == 68590) Pretty much the same error. Based on the document, || is only valid for columns... On 2/17/07, Bill Zhang [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Thank you Steve. But I got syntax error using the following. On 2/17/07, Steven Williams [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: In trunk I think you can use connective constraints: $a : Person(age 35 | 25, zipCode == 23546 | == 68590) then $a.setStatus(KT); On 2/18/07, Bill Zhang [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hello, I am a new Drools user trying to convert the following simple logic into DRL: IF (Person.Age 35 OR Person.Age 25) AND (Person.ZipCode = 23546 or Person.ZipCode = 68590) THEN Person.Status = KT; I found that it is not easy to convert the above logic into ONE DRL rule. I tried something like this when $a: Person(age35) or Person (age25) $b: Person(Zipcode==23456) or Person (ZipCode == 68590) $c: $a and $b
Re: [rules-users] Convert logic to DRL rules
Bill, The way of doing that is using connective constraints as explained by Steven previously: $a : Person(age 35 | 25, zipCode == 23546 | == 68590) This is a new feature that only works in 3.1M1 and later versions. []s Edson Bill Zhang wrote: Hi Steven, Yes I thought of that but our business user says this is unacceptable unless I can write a parser to automatically generate all these combinations. The example I use is quite simple. Our business user have quite complex logic expressions (imagin my example plus a lot of parenthesis to build up multiple level logic) already built using Pascal like language and it is not easy to do. Thanks, Ye On 2/19/07, Steven Williams [EMAIL PROTECTED] wrote: Hi Bill, To implement your rules in 3.0.5 you would need to implement a rule for each combination of age and zipCode. $a : Person(age 35 zipCode == 23546) then $a.setStatus(KT); $a : Person(age 25, zipCode == 23546 ) then $a.setStatus(KT); $a : Person(age 35, zipCode == 68590) then $a.setStatus(KT); etc.. Steve On 2/19/07, Bill Zhang [EMAIL PROTECTED] wrote: So Alex, if I only want to use the old syntax that is in production, there is no way to implement my seemingly simple logic conditioning? Thanks for your help. On 2/18/07, Alexander Varakin [EMAIL PROTECTED] wrote: As far as I know this syntax is new and is available in SVN only, you will have to wait till 3.1 is released or take source from SVN and build it. Bill Zhang wrote: Hi Steven, Thank you very much for your help. Really appreciate. I still got the same error, Unexpected token '|'. I did not see | in the document, only saw ||, which is supposed to be used with columns. Ye On 2/18/07, Steven Williams [EMAIL PROTECTED] wrote: Hi Bill, I think it should be: $a : Person(age 35 | 25, zipCode == 23546 | == 68590) Edson, Mark or Michael can probably confirm or correct the above syntax. Make sure you are running of the latest trunk. cheers Steve On 2/18/07, Bill Zhang [EMAIL PROTECTED] wrote: I tried: $a : Person(age 35 || age 25, zipCode == 23546 || == 68590) Errors: org.drools.rule.InvalidRulePackage : unknown:39:30 Unexpected token '||' unknown:39:40 mismatched token: [EMAIL PROTECTED],1040:1041='=',47,39:40]; expecting type '(' unknown:39:92 mismatched token: [EMAIL PROTECTED],1092:1092='',46,39:92]; expecting type '(' I also tried $a : Person(age 35 | age 25, zipCode == 23546 | == 68590) Pretty much the same error. Based on the document, || is only valid for columns... On 2/17/07, Bill Zhang [EMAIL PROTECTED] wrote: Thank you Steve. But I got syntax error using the following. On 2/17/07, Steven Williams [EMAIL PROTECTED] wrote: In trunk I think you can use connective constraints: $a : Person(age 35 | 25, zipCode == 23546 | == 68590) then $a.setStatus(KT); On 2/18/07, Bill Zhang [EMAIL PROTECTED] wrote: Hello, I am a new Drools user trying to convert the following simple logic into DRL: IF (Person.Age 35 OR Person.Age 25) AND (Person.ZipCode = 23546 or Person.ZipCode = 68590) THEN Person.Status = KT; I found that it is not easy to convert the above logic into ONE DRL rule. I tried something like this when $a: Person(age35) or Person (age25) $b: Person(Zipcode==23456) or Person (ZipCode == 68590) $c: $a and $b Then $c.setStatus(KT) But looks like I can not use $c: $a and $b becaue in Drools, you can only bind variable to column, not to other varaibles. Please advise how to do this. I would imagine this should be quite simple, maybe I missed something quite obvious. I know that I can write custom Java method to do this, but if I do that, I suppose I lose the power of RETEOO pattern matching (pattern resuing, etc.). So I prefer not to do that. I also understand I can break the above logic into 4 rules and that would be quite easy, but our business user is not used to think in that way. Also, we have more complex logic than the above. So what I want is to see if there is a way to convert this kind of logic in ONE DRL rule. Thanks in advance. Bill ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Steven Williams Supervising Consultant Object Consulting Office: 8615 4500 Mob: 0439 898 668
Re: [rules-users] Convert logic to DRL rules
Bill, Your statement bellow can be written in 3.1M1 as: rule ... when $person : ( Person( age 35 | 25, zipCode == 23546 | == 68570, $lop: lastOrderPrice, $ton: totalOrderNumber, ( $lop 300 || $ton 2 )) or Person( lastOrderCategory == 098 | == 109, zipCode == 74567 | == 23756 ) ) then $person.setStatus( KT ); end []s Edson Bill Zhang wrote: Hi Alex, Thank you for confirming this. Writing such a builder may take us a lot of time because our business user is used to free style Pascal-like authoring using quite complex logic. For example, IF ( ( (Person.Age 35 OR Person.Age 25) AND (Person.ZipCode =23546 or Person.ZipCode = 68590) ) and ( (Person.LastOrderPrice 300 OR (Person.TotalOrderNumber 2) ) ) OR ( ( (Person.LastOrderCategory in (098, 109) ) AND (Person.ZipCode =74567 or Person.ZipCode = 23765) ) and ( (Person.LastOrderPrice 1000 OR (Person.TotalOrderNumber 1) ) ) ... THEN Person.Status = KT; Before I set out to write the builder, I would like to know whether the new syntax can handle the above logic? Also, where can I find document for the new syntax? I am also trying to find some existing open source Java library to flatten out these complex logic - to break these complex logic to atomic ones that can be handled by Drools. Do you have any recommendation? Thanks a lot for your help. Bill Y. On 2/19/07, Alexander Varakin [EMAIL PROTECTED] wrote: We built a Rule Builder which creates drl with all possible combinations. In any case, drl syntax is not exactly business user friendly, so having such builder is not a bad idea. Simple Rule Builder can be implemented as an Excel spreadsheet, which can be easily parsed using POI library and then drl file produced. Steven Williams wrote: Hi Bill, To implement your rules in 3.0.5 you would need to implement a rule for each combination of age and zipCode. $a : Person(age 35 zipCode == 23546) then $a.setStatus(KT); $a : Person(age 25, zipCode == 23546 ) then $a.setStatus(KT); $a : Person(age 35, zipCode == 68590) then $a.setStatus(KT); etc.. Steve On 2/19/07, *Bill Zhang* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: So Alex, if I only want to use the old syntax that is in production, there is no way to implement my seemingly simple logic conditioning? Thanks for your help. On 2/18/07, Alexander Varakin [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: As far as I know this syntax is new and is available in SVN only, you will have to wait till 3.1 is released or take source from SVN and build it. Bill Zhang wrote: Hi Steven, Thank you very much for your help. Really appreciate. I still got the same error, Unexpected token '|'. I did not see | in the document, only saw ||, which is supposed to be used with columns. Ye On 2/18/07, Steven Williams [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi Bill, I think it should be: $a : Person(age 35 | 25, zipCode == 23546 | == 68590) Edson, Mark or Michael can probably confirm or correct the above syntax. Make sure you are running of the latest trunk. cheers Steve On 2/18/07, Bill Zhang [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I tried: $a : Person(age 35 || age 25, zipCode == 23546 || == 68590) Errors: org.drools.rule.InvalidRulePackage : unknown:39:30 Unexpected token '||' unknown:39:40 mismatched token: [EMAIL PROTECTED],1040:1041='=',47,39:40]; expecting type '(' unknown:39:92 mismatched token: [EMAIL PROTECTED],1092:1092='',46,39:92]; expecting type '(' I also tried $a : Person(age 35 | age 25, zipCode == 23546 | == 68590) Pretty much the same error. Based on the document, || is only valid for columns... On 2/17/07, Bill Zhang [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Thank you Steve. But I got syntax error using the following. On 2/17/07, Steven Williams [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: In trunk I think you can use connective constraints: $a : Person(age 35 | 25, zipCode == 23546 | == 68590) then $a.setStatus(KT); On 2/18/07, Bill Zhang [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hello, I am a new Drools user trying to convert the following
Re: [rules-users] Convert logic to DRL rules
Vlad, I think that for Bill's case, the object structure is flatten already (what is good for rules). Creating nested objects will actually make it more difficult to write the rules... Just my 0.02c []s Edson Olenin, Vladimir (MOH) wrote: I guess if you modify the business objects a bit (in quite weird way - I think it would be rather a shortcut than a solution) you can implement this kind of logic: you need to swap property (zipcode, age, etc) and 'property ownner' (Person) objects, so that you'll have: Person (id) ZipCode (id, code) Age (id, age) Etc In this case you should be able to write: Rule X When $p: Person($id: id) ( ZipCode(id == $id, code == 23456) or ZipCode(id == $id, code == 68590) ) And ( Age(id == $id, age 25) Or Age(id == $id, age 34) ) Then // do smth using $p End Or smth along those lines... Would that work?. Vlad -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bill Zhang Sent: 19 February 2007 09:14 To: Rules Users List Subject: Re: [rules-users] Convert logic to DRL rules Hi Alex, Thank you for confirming this. Writing such a builder may take us a lot of time because our business user is used to free style Pascal-like authoring using quite complex logic. For example, IF ( ( (Person.Age 35 OR Person.Age 25) AND (Person.ZipCode =23546 or Person.ZipCode = 68590) ) and ( (Person.LastOrderPrice 300 OR (Person.TotalOrderNumber 2) ) ) OR ( ( (Person.LastOrderCategory in (098, 109) ) AND (Person.ZipCode =74567 or Person.ZipCode = 23765) ) and ( (Person.LastOrderPrice 1000 OR (Person.TotalOrderNumber 1) ) ) ... THEN Person.Status = KT; Before I set out to write the builder, I would like to know whether the new syntax can handle the above logic? Also, where can I find document for the new syntax? I am also trying to find some existing open source Java library to flatten out these complex logic - to break these complex logic to atomic ones that can be handled by Drools. Do you have any recommendation? Thanks a lot for your help. Bill Y. On 2/19/07, Alexander Varakin [EMAIL PROTECTED] wrote: We built a Rule Builder which creates drl with all possible combinations. In any case, drl syntax is not exactly business user friendly, so having such builder is not a bad idea. Simple Rule Builder can be implemented as an Excel spreadsheet, which can be easily parsed using POI library and then drl file produced. Steven Williams wrote: Hi Bill, To implement your rules in 3.0.5 you would need to implement a rule for each combination of age and zipCode. $a : Person(age 35 zipCode == 23546) then $a.setStatus(KT); $a : Person(age 25, zipCode == 23546 ) then $a.setStatus(KT); $a : Person(age 35, zipCode == 68590) then $a.setStatus(KT); etc.. Steve On 2/19/07, *Bill Zhang* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: So Alex, if I only want to use the old syntax that is in production, there is no way to implement my seemingly simple logic conditioning? Thanks for your help. On 2/18/07, Alexander Varakin [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: As far as I know this syntax is new and is available in SVN only, you will have to wait till 3.1 is released or take source from SVN and build it. Bill Zhang wrote: Hi Steven, Thank you very much for your help. Really appreciate. I still got the same error, Unexpected token '|'. I did not see | in the document, only saw ||, which is supposed to be used with columns. Ye On 2/18/07, Steven Williams [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi Bill, I think it should be: $a : Person(age 35 | 25, zipCode == 23546 | == 68590) Edson, Mark or Michael can probably confirm or correct the above syntax. Make sure you are running of the latest trunk. cheers Steve On 2/18/07, Bill Zhang [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I tried: $a : Person(age 35 || age 25, zipCode == 23546 || == 68590) Errors: org.drools.rule.InvalidRulePackage : unknown:39:30 Unexpected token '||' unknown:39:40 mismatched token: [EMAIL PROTECTED],1040:1041='=',47,39:40]; expecting type '(' unknown:39:92 mismatched token: [EMAIL PROTECTED],1092:1092='',46,39:92]; expecting type '(' I also tried $a : Person(age 35 | age 25, zipCode == 23546 | == 68590) Pretty much the same error. Based on the document, || is only valid for columns... On 2/17/07, Bill Zhang [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Thank you Steve. But I got syntax error using the following
Re: [rules-users] Convert logic to DRL rules
Hi Vlad, Thank you for the help. Unfortunately I can not change the Object Model as these POJOs are not used only by myself. Bill Y. On 2/19/07, Olenin, Vladimir (MOH) [EMAIL PROTECTED] wrote: I guess if you modify the business objects a bit (in quite weird way - I think it would be rather a shortcut than a solution) you can implement this kind of logic: you need to swap property (zipcode, age, etc) and 'property ownner' (Person) objects, so that you'll have: Person (id) ZipCode (id, code) Age (id, age) Etc In this case you should be able to write: Rule X When $p: Person($id: id) ( ZipCode(id == $id, code == 23456) or ZipCode(id == $id, code == 68590) ) And ( Age(id == $id, age 25) Or Age(id == $id, age 34) ) Then // do smth using $p End Or smth along those lines... Would that work?. Vlad -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bill Zhang Sent: 19 February 2007 09:14 To: Rules Users List Subject: Re: [rules-users] Convert logic to DRL rules Hi Alex, Thank you for confirming this. Writing such a builder may take us a lot of time because our business user is used to free style Pascal-like authoring using quite complex logic. For example, IF ( ( (Person.Age 35 OR Person.Age 25) AND (Person.ZipCode =23546 or Person.ZipCode = 68590) ) and ( (Person.LastOrderPrice 300 OR (Person.TotalOrderNumber 2) ) ) OR ( ( (Person.LastOrderCategory in (098, 109) ) AND (Person.ZipCode =74567 or Person.ZipCode = 23765) ) and ( (Person.LastOrderPrice 1000 OR (Person.TotalOrderNumber 1) ) ) ... THEN Person.Status = KT; Before I set out to write the builder, I would like to know whether the new syntax can handle the above logic? Also, where can I find document for the new syntax? I am also trying to find some existing open source Java library to flatten out these complex logic - to break these complex logic to atomic ones that can be handled by Drools. Do you have any recommendation? Thanks a lot for your help. Bill Y. On 2/19/07, Alexander Varakin [EMAIL PROTECTED] wrote: We built a Rule Builder which creates drl with all possible combinations. In any case, drl syntax is not exactly business user friendly, so having such builder is not a bad idea. Simple Rule Builder can be implemented as an Excel spreadsheet, which can be easily parsed using POI library and then drl file produced. Steven Williams wrote: Hi Bill, To implement your rules in 3.0.5 you would need to implement a rule for each combination of age and zipCode. $a : Person(age 35 zipCode == 23546) then $a.setStatus(KT); $a : Person(age 25, zipCode == 23546 ) then $a.setStatus(KT); $a : Person(age 35, zipCode == 68590) then $a.setStatus(KT); etc.. Steve On 2/19/07, *Bill Zhang* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: So Alex, if I only want to use the old syntax that is in production, there is no way to implement my seemingly simple logic conditioning? Thanks for your help. On 2/18/07, Alexander Varakin [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: As far as I know this syntax is new and is available in SVN only, you will have to wait till 3.1 is released or take source from SVN and build it. Bill Zhang wrote: Hi Steven, Thank you very much for your help. Really appreciate. I still got the same error, Unexpected token '|'. I did not see | in the document, only saw ||, which is supposed to be used with columns. Ye On 2/18/07, Steven Williams [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi Bill, I think it should be: $a : Person(age 35 | 25, zipCode == 23546 | == 68590) Edson, Mark or Michael can probably confirm or correct the above syntax. Make sure you are running of the latest trunk. cheers Steve On 2/18/07, Bill Zhang [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I tried: $a : Person(age 35 || age 25, zipCode == 23546 || == 68590) Errors: org.drools.rule.InvalidRulePackage : unknown:39:30 Unexpected token '||' unknown:39:40 mismatched token: [EMAIL PROTECTED],1040:1041='=',47,39:40]; expecting type '(' unknown:39:92 mismatched token: [EMAIL PROTECTED],1092:1092='',46,39:92]; expecting type '(' I also tried $a : Person(age 35 | age 25, zipCode == 23546 | == 68590) Pretty much the same error. Based on the document, || is only valid for columns... On 2/17/07
Re: [rules-users] Convert logic to DRL rules
Bill, The new version works fine with nested conditional elements and allow for any level of nesting. You simply must be very careful with OR as the semantics of OR in a rules engine are not exactly the same as most people are used to in imperative programming. Also, the syntax you showed bellow is not correct (but maybe it was simply a typo in the e-mail). Maybe if you can write your intent or a sample rule (in english) you are trying to implement it is easier to help. []s Edson Bill Zhang wrote: Edson, Thanks for the reply. The rule you authored worked fine on my new Drools build from SVN. However, I did notice that the following pattern matching is not working: $p: Person( (Person(some comparison logic) or Person(some comparison logic) ) and (Person(some comparison logic) or Person(some comparison logic) ) ) Looks like althugh or is allowed, the new version does not use and within pattern matching. Am I right or did I do something wrong? Thanks, Bill On 2/19/07, Edson Tirelli [EMAIL PROTECTED] wrote: Bill, Unfortunatelly we are working hard to get all features finished in time for the release and the documentation will only be done right before release unless we get some help from community. So, maybe if you (or anyone else) think you can help with that, we would gladly provide you with info that when written down would be usefull both for your users/team and to other drools users. You need to use bound variables when you want to do an OR (||) between constraints of different fields inside a single Pattern. So, in your example, as you want to do: lastOrderPrice 300 OR totalOrderNumber 2 For the same Person object, it means you need to do either: Person( $lop: lastOrderPrice, $ton: totalOrderNumber, ( $lop 300 || $ton 2 )) Or using a predicate without the bound variables: $p: Person( ($p.getLastOrderPrice() 300 || $p.getTotalOrderNumber() 2 ) ) Or use an eval (that I think is the least efficient way): $p: Person() eval( $p.getLastOrderPrice() 300 || $p.getTotalOrderNumber() 2 ) From the above options, I would go with the first. Unfortunatelly, there is no semantics currently defined for the syntax you used: Person( lastOrderPrice 300 || totalOrderNumber 2 ) We may eventually do it in the future, but for now (Mark can confirm that), we don't have resources to add it to the next major release (again, unless community comes in to help). []s Edson Bill Zhang wrote: That's it, Edson. I'll give it a try and I'll let you know whether I make it. Edson, I will appreciate if you can point to me where is the most recent syntax document. Thanks. I am not sure why I need to use bound variables ($lop: lastOrderPrice). Can I write it in the following: rule ... when $person : ( Person( age 35 | 25, zipCode == 23546 | == 68570, ( lastOrderPrice 300 || totalOrderNumber 2 )) or Person( lastOrderCategory == 098 | == 109, zipCode == 74567 | == 23756 ) ) then $person.setStatus( KT ); end Thanks to everyone helping me. This is really a great community. On 2/19/07, Edson Tirelli [EMAIL PROTECTED] wrote: Bill, Your statement bellow can be written in 3.1M1 as: rule ... when $person : ( Person( age 35 | 25, zipCode == 23546 | == 68570, $lop: lastOrderPrice, $ton: totalOrderNumber, ( $lop 300 || $ton 2 )) or Person( lastOrderCategory == 098 | == 109, zipCode == 74567 | == 23756 ) ) then $person.setStatus( KT ); end []s Edson Bill Zhang wrote: Hi Alex, Thank you for confirming this. Writing such a builder may take us a lot of time because our business user is used to free style Pascal-like authoring using quite complex logic. For example, IF ( ( (Person.Age 35 OR Person.Age 25) AND (Person.ZipCode =23546 or Person.ZipCode = 68590) ) and ( (Person.LastOrderPrice 300 OR (Person.TotalOrderNumber 2) ) ) OR ( ( (Person.LastOrderCategory in (098, 109) ) AND (Person.ZipCode =74567 or Person.ZipCode = 23765) ) and ( (Person.LastOrderPrice 1000 OR (Person.TotalOrderNumber 1) ) ) ... THEN Person.Status = KT; Before I set out to write the builder, I would like to know whether the new syntax can handle the above logic? Also, where can I find document for the new syntax? I am also trying to find some existing open source Java library to flatten out these complex logic - to break these complex logic to atomic ones that can be handled by Drools. Do you have any recommendation? Thanks a lot for your help. Bill Y. On 2/19/07, Alexander Varakin
Re: [rules-users] Convert logic to DRL rules
'and' is not needed at top level, it is implicitely assumed that all patters are under an 'and' CE. Mark Bill Zhang wrote: Edson, Thanks for the reply. The rule you authored worked fine on my new Drools build from SVN. However, I did notice that the following pattern matching is not working: $p: Person( (Person(some comparison logic) or Person(some comparison logic) ) and (Person(some comparison logic) or Person(some comparison logic) ) ) Looks like althugh or is allowed, the new version does not use and within pattern matching. Am I right or did I do something wrong? Thanks, Bill On 2/19/07, Edson Tirelli [EMAIL PROTECTED] wrote: Bill, Unfortunatelly we are working hard to get all features finished in time for the release and the documentation will only be done right before release unless we get some help from community. So, maybe if you (or anyone else) think you can help with that, we would gladly provide you with info that when written down would be usefull both for your users/team and to other drools users. You need to use bound variables when you want to do an OR (||) between constraints of different fields inside a single Pattern. So, in your example, as you want to do: lastOrderPrice 300 OR totalOrderNumber 2 For the same Person object, it means you need to do either: Person( $lop: lastOrderPrice, $ton: totalOrderNumber, ( $lop 300 || $ton 2 )) Or using a predicate without the bound variables: $p: Person( ($p.getLastOrderPrice() 300 || $p.getTotalOrderNumber() 2 ) ) Or use an eval (that I think is the least efficient way): $p: Person() eval( $p.getLastOrderPrice() 300 || $p.getTotalOrderNumber() 2 ) From the above options, I would go with the first. Unfortunatelly, there is no semantics currently defined for the syntax you used: Person( lastOrderPrice 300 || totalOrderNumber 2 ) We may eventually do it in the future, but for now (Mark can confirm that), we don't have resources to add it to the next major release (again, unless community comes in to help). []s Edson Bill Zhang wrote: That's it, Edson. I'll give it a try and I'll let you know whether I make it. Edson, I will appreciate if you can point to me where is the most recent syntax document. Thanks. I am not sure why I need to use bound variables ($lop: lastOrderPrice). Can I write it in the following: rule ... when $person : ( Person( age 35 | 25, zipCode == 23546 | == 68570, ( lastOrderPrice 300 || totalOrderNumber 2 )) or Person( lastOrderCategory == 098 | == 109, zipCode == 74567 | == 23756 ) ) then $person.setStatus( KT ); end Thanks to everyone helping me. This is really a great community. On 2/19/07, Edson Tirelli [EMAIL PROTECTED] wrote: Bill, Your statement bellow can be written in 3.1M1 as: rule ... when $person : ( Person( age 35 | 25, zipCode == 23546 | == 68570, $lop: lastOrderPrice, $ton: totalOrderNumber, ( $lop 300 || $ton 2 )) or Person( lastOrderCategory == 098 | == 109, zipCode == 74567 | == 23756 ) ) then $person.setStatus( KT ); end []s Edson Bill Zhang wrote: Hi Alex, Thank you for confirming this. Writing such a builder may take us a lot of time because our business user is used to free style Pascal-like authoring using quite complex logic. For example, IF ( ( (Person.Age 35 OR Person.Age 25) AND (Person.ZipCode =23546 or Person.ZipCode = 68590) ) and ( (Person.LastOrderPrice 300 OR (Person.TotalOrderNumber 2) ) ) OR ( ( (Person.LastOrderCategory in (098, 109) ) AND (Person.ZipCode =74567 or Person.ZipCode = 23765) ) and ( (Person.LastOrderPrice 1000 OR (Person.TotalOrderNumber 1) ) ) ... THEN Person.Status = KT; Before I set out to write the builder, I would like to know whether the new syntax can handle the above logic? Also, where can I find document for the new syntax? I am also trying to find some existing open source Java library to flatten out these complex logic - to break these complex logic to atomic ones that can be handled by Drools. Do you have any recommendation? Thanks a lot for your help. Bill Y. On 2/19/07, Alexander Varakin [EMAIL PROTECTED] wrote: We built a Rule Builder which creates drl with all possible combinations. In any case, drl syntax is not exactly business user friendly, so having such builder is not a bad idea. Simple Rule Builder can be implemented as an Excel spreadsheet, which can be easily parsed using POI library and then drl file produced. Steven Williams wrote: Hi Bill, To
Re: [rules-users] Convert logic to DRL rules
Edson and Mark, Thank you for your help. I have the complete rule expressed in PASCAL-like language in the following. Mark mentioned that and is not needed at top level but I am not sure what syntax I can use to express the top-level and in the following rule when the top-level and is used to connect Person objects with complex matching logic. Thank you for pointing out the diffrence between and in a rules engine vs. normal programming language - I will do some more experiments on that. IF ( ( ( (Person.Age 35 OR Person.Age 25) AND (Person.ZipCode =23546 OR Person.ZipCode = 68590) ) and ( (Person.LastOrderPrice 300) OR (Person.TotalOrderNumber 2) ) ) OR ( ( (Person.LastOrderCategory in (098, 109) ) AND (Person.ZipCode =74567 or Person.ZipCode = 23765) ) and ( (Person.LastOrderPrice 1000 OR (Person.TotalOrderNumber 1) ) ) ) AND // Top Level AND ( (Person.Status=K AND Person.IsDelinquent = true) OR (Person.Status=T AND Person.IsDelinquent = true AND Person.DelinquentBucket = 3) ) THEN Person.Status = KT; On 2/19/07, Edson Tirelli [EMAIL PROTECTED] wrote: Bill, The new version works fine with nested conditional elements and allow for any level of nesting. You simply must be very careful with OR as the semantics of OR in a rules engine are not exactly the same as most people are used to in imperative programming. Also, the syntax you showed bellow is not correct (but maybe it was simply a typo in the e-mail). Maybe if you can write your intent or a sample rule (in english) you are trying to implement it is easier to help. []s Edson Bill Zhang wrote: Edson, Thanks for the reply. The rule you authored worked fine on my new Drools build from SVN. However, I did notice that the following pattern matching is not working: $p: Person( (Person(some comparison logic) or Person(some comparison logic) ) and (Person(some comparison logic) or Person(some comparison logic) ) ) Looks like althugh or is allowed, the new version does not use and within pattern matching. Am I right or did I do something wrong? Thanks, Bill On 2/19/07, Edson Tirelli [EMAIL PROTECTED] wrote: Bill, Unfortunatelly we are working hard to get all features finished in time for the release and the documentation will only be done right before release unless we get some help from community. So, maybe if you (or anyone else) think you can help with that, we would gladly provide you with info that when written down would be usefull both for your users/team and to other drools users. You need to use bound variables when you want to do an OR (||) between constraints of different fields inside a single Pattern. So, in your example, as you want to do: lastOrderPrice 300 OR totalOrderNumber 2 For the same Person object, it means you need to do either: Person( $lop: lastOrderPrice, $ton: totalOrderNumber, ( $lop 300 || $ton 2 )) Or using a predicate without the bound variables: $p: Person( ($p.getLastOrderPrice() 300 || $p.getTotalOrderNumber() 2 ) ) Or use an eval (that I think is the least efficient way): $p: Person() eval( $p.getLastOrderPrice() 300 || $p.getTotalOrderNumber() 2 ) From the above options, I would go with the first. Unfortunatelly, there is no semantics currently defined for the syntax you used: Person( lastOrderPrice 300 || totalOrderNumber 2 ) We may eventually do it in the future, but for now (Mark can confirm that), we don't have resources to add it to the next major release (again, unless community comes in to help). []s Edson Bill Zhang wrote: That's it, Edson. I'll give it a try and I'll let you know whether I make it. Edson, I will appreciate if you can point to me where is the most recent syntax document. Thanks. I am not sure why I need to use bound variables ($lop: lastOrderPrice). Can I write it in the following: rule ... when $person : ( Person( age 35 | 25, zipCode == 23546 | == 68570, ( lastOrderPrice 300 || totalOrderNumber 2 )) or Person( lastOrderCategory == 098 | == 109, zipCode == 74567 | == 23756 ) ) then $person.setStatus( KT ); end Thanks to everyone helping me. This is really a great community. On 2/19/07, Edson Tirelli [EMAIL PROTECTED] wrote: Bill, Your statement bellow can be written in 3.1M1 as: rule ... when $person : ( Person( age 35 | 25, zipCode == 23546 | == 68570, $lop: lastOrderPrice, $ton: totalOrderNumber, ( $lop 300 || $ton 2 )) or Person( lastOrderCategory == 098 | == 109, zipCode == 74567 | == 23756 ) )
RE: [rules-users] Convert logic to DRL rules
To improve my understanding of DROOLS a bit, just a small follow up question. If the modification of the business domain model is correct and will result in the correct behavior, I wonder what kind of performance implications such modification will bring (to compare with 'flatten' model)? Would the performance become worse, better or remain approximately the same (for a significant number of rules fact objects)? Currently I'm at the cross roads whether to create such artificial 'inverted index' for my application or not (I didn't know that the connective constraints are available in 3.1M...). Thanks, Vlad -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli Sent: 19 February 2007 11:05 To: Rules Users List Subject: Re: [rules-users] Convert logic to DRL rules Vlad, I think that for Bill's case, the object structure is flatten already (what is good for rules). Creating nested objects will actually make it more difficult to write the rules... Just my 0.02c []s Edson Olenin, Vladimir (MOH) wrote: I guess if you modify the business objects a bit (in quite weird way - I think it would be rather a shortcut than a solution) you can implement this kind of logic: you need to swap property (zipcode, age, etc) and 'property ownner' (Person) objects, so that you'll have: Person (id) ZipCode (id, code) Age (id, age) Etc In this case you should be able to write: Rule X When $p: Person($id: id) ( ZipCode(id == $id, code == 23456) or ZipCode(id == $id, code == 68590) ) And ( Age(id == $id, age 25) Or Age(id == $id, age 34) ) Then // do smth using $p End Or smth along those lines... Would that work?. Vlad -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Bill Zhang Sent: 19 February 2007 09:14 To: Rules Users List Subject: Re: [rules-users] Convert logic to DRL rules Hi Alex, Thank you for confirming this. Writing such a builder may take us a lot of time because our business user is used to free style Pascal-like authoring using quite complex logic. For example, IF ( ( (Person.Age 35 OR Person.Age 25) AND (Person.ZipCode =23546 or Person.ZipCode = 68590) ) and ( (Person.LastOrderPrice 300 OR (Person.TotalOrderNumber 2) ) ) OR ( ( (Person.LastOrderCategory in (098, 109) ) AND (Person.ZipCode =74567 or Person.ZipCode = 23765) ) and ( (Person.LastOrderPrice 1000 OR (Person.TotalOrderNumber 1) ) ) ... THEN Person.Status = KT; Before I set out to write the builder, I would like to know whether the new syntax can handle the above logic? Also, where can I find document for the new syntax? I am also trying to find some existing open source Java library to flatten out these complex logic - to break these complex logic to atomic ones that can be handled by Drools. Do you have any recommendation? Thanks a lot for your help. Bill Y. On 2/19/07, Alexander Varakin [EMAIL PROTECTED] wrote: We built a Rule Builder which creates drl with all possible combinations. In any case, drl syntax is not exactly business user friendly, so having such builder is not a bad idea. Simple Rule Builder can be implemented as an Excel spreadsheet, which can be easily parsed using POI library and then drl file produced. Steven Williams wrote: Hi Bill, To implement your rules in 3.0.5 you would need to implement a rule for each combination of age and zipCode. $a : Person(age 35 zipCode == 23546) then $a.setStatus(KT); $a : Person(age 25, zipCode == 23546 ) then $a.setStatus(KT); $a : Person(age 35, zipCode == 68590) then $a.setStatus(KT); etc.. Steve On 2/19/07, *Bill Zhang* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: So Alex, if I only want to use the old syntax that is in production, there is no way to implement my seemingly simple logic conditioning? Thanks for your help. On 2/18/07, Alexander Varakin [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: As far as I know this syntax is new and is available in SVN only, you will have to wait till 3.1 is released or take source from SVN and build it. Bill Zhang wrote: Hi Steven, Thank you very much for your help. Really appreciate. I still got the same error, Unexpected token '|'. I did not see | in the document, only saw ||, which is supposed to be used with columns. Ye On 2/18/07, Steven Williams [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi Bill, I think it should be: $a : Person(age 35 | 25, zipCode == 23546 | == 68590) Edson, Mark or Michael can probably confirm or correct the above syntax. Make sure you are running of the latest trunk. cheers Steve On 2/18/07, Bill Zhang
Re: [rules-users] Convert logic to DRL rules
Hi Steven, Thank you very much for your help. Really appreciate. I still got the same error, Unexpected token '|'. I did not see | in the document, only saw ||, which is supposed to be used with columns. Ye On 2/18/07, Steven Williams [EMAIL PROTECTED] wrote: Hi Bill, I think it should be: $a : Person(age 35 | 25, zipCode == 23546 | == 68590) Edson, Mark or Michael can probably confirm or correct the above syntax. Make sure you are running of the latest trunk. cheers Steve On 2/18/07, Bill Zhang [EMAIL PROTECTED] wrote: I tried: $a : Person(age 35 || age 25, zipCode == 23546 || == 68590) Errors: org.drools.rule.InvalidRulePackage: unknown:39:30 Unexpected token '||' unknown:39:40 mismatched token: [EMAIL PROTECTED],1040:1041='=',47,39:40]; expecting type '(' unknown:39:92 mismatched token: [EMAIL PROTECTED],1092:1092='',46,39:92]; expecting type '(' I also tried $a : Person(age 35 | age 25, zipCode == 23546 | == 68590) Pretty much the same error. Based on the document, || is only valid for columns... On 2/17/07, Bill Zhang [EMAIL PROTECTED] wrote: Thank you Steve. But I got syntax error using the following. On 2/17/07, Steven Williams [EMAIL PROTECTED] wrote: In trunk I think you can use connective constraints: $a : Person(age 35 | 25, zipCode == 23546 | == 68590) then $a.setStatus(KT); On 2/18/07, Bill Zhang [EMAIL PROTECTED] wrote: Hello, I am a new Drools user trying to convert the following simple logic into DRL: IF (Person.Age 35 OR Person.Age 25) AND (Person.ZipCode = 23546 or Person.ZipCode = 68590) THEN Person.Status = KT; I found that it is not easy to convert the above logic into ONE DRL rule. I tried something like this when $a: Person(age35) or Person (age25) $b: Person(Zipcode==23456) or Person (ZipCode == 68590) $c: $a and $b Then $c.setStatus(KT) But looks like I can not use $c: $a and $b becaue in Drools, you can only bind variable to column, not to other varaibles. Please advise how to do this. I would imagine this should be quite simple, maybe I missed something quite obvious. I know that I can write custom Java method to do this, but if I do that, I suppose I lose the power of RETEOO pattern matching (pattern resuing, etc.). So I prefer not to do that. I also understand I can break the above logic into 4 rules and that would be quite easy, but our business user is not used to think in that way. Also, we have more complex logic than the above. So what I want is to see if there is a way to convert this kind of logic in ONE DRL rule. Thanks in advance. Bill ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Steven Williams Supervising Consultant Object Consulting Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501 [EMAIL PROTECTED] www.objectconsulting.com.au consulting | development | training | support our experience makes the difference ___ 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 -- Steven Williams Supervising Consultant Object Consulting Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501 [EMAIL PROTECTED] www.objectconsulting.com.au consulting | development | training | support our experience makes the difference ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Convert logic to DRL rules
As far as I know this syntax is new and is available in SVN only, you will have to wait till 3.1 is released or take source from SVN and build it. Bill Zhang wrote: Hi Steven, Thank you very much for your help. Really appreciate. I still got the same error, Unexpected token '|'. I did not see | in the document, only saw ||, which is supposed to be used with columns. Ye On 2/18/07, Steven Williams [EMAIL PROTECTED] wrote: Hi Bill, I think it should be: $a : Person(age 35 | 25, zipCode == 23546 | == 68590) Edson, Mark or Michael can probably confirm or correct the above syntax. Make sure you are running of the latest trunk. cheers Steve On 2/18/07, Bill Zhang [EMAIL PROTECTED] wrote: I tried: $a : Person(age 35 || age 25, zipCode == 23546 || == 68590) Errors: org.drools.rule.InvalidRulePackage: unknown:39:30 Unexpected token '||' unknown:39:40 mismatched token: [EMAIL PROTECTED],1040:1041='=',47,39:40]; expecting type '(' unknown:39:92 mismatched token: [EMAIL PROTECTED],1092:1092='',46,39:92]; expecting type '(' I also tried $a : Person(age 35 | age 25, zipCode == 23546 | == 68590) Pretty much the same error. Based on the document, || is only valid for columns... On 2/17/07, Bill Zhang [EMAIL PROTECTED] wrote: Thank you Steve. But I got syntax error using the following. On 2/17/07, Steven Williams [EMAIL PROTECTED] wrote: In trunk I think you can use connective constraints: $a : Person(age 35 | 25, zipCode == 23546 | == 68590) then $a.setStatus(KT); On 2/18/07, Bill Zhang [EMAIL PROTECTED] wrote: Hello, I am a new Drools user trying to convert the following simple logic into DRL: IF (Person.Age 35 OR Person.Age 25) AND (Person.ZipCode = 23546 or Person.ZipCode = 68590) THEN Person.Status = KT; I found that it is not easy to convert the above logic into ONE DRL rule. I tried something like this when $a: Person(age35) or Person (age25) $b: Person(Zipcode==23456) or Person (ZipCode == 68590) $c: $a and $b Then $c.setStatus(KT) But looks like I can not use $c: $a and $b becaue in Drools, you can only bind variable to column, not to other varaibles. Please advise how to do this. I would imagine this should be quite simple, maybe I missed something quite obvious. I know that I can write custom Java method to do this, but if I do that, I suppose I lose the power of RETEOO pattern matching (pattern resuing, etc.). So I prefer not to do that. I also understand I can break the above logic into 4 rules and that would be quite easy, but our business user is not used to think in that way. Also, we have more complex logic than the above. So what I want is to see if there is a way to convert this kind of logic in ONE DRL rule. Thanks in advance. Bill ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Steven Williams Supervising Consultant Object Consulting Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501 [EMAIL PROTECTED] www.objectconsulting.com.au consulting | development | training | support our experience makes the difference ___ 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 -- Steven Williams Supervising Consultant Object Consulting Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501 [EMAIL PROTECTED] www.objectconsulting.com.au consulting | development | training | support our experience makes the difference ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Convert logic to DRL rules
We built a Rule Builder which creates drl with all possible combinations. In any case, drl syntax is not exactly business user friendly, so having such builder is not a bad idea. Simple Rule Builder can be implemented as an Excel spreadsheet, which can be easily parsed using POI library and then drl file produced. Steven Williams wrote: Hi Bill, To implement your rules in 3.0.5 you would need to implement a rule for each combination of age and zipCode. $a : Person(age 35 zipCode == 23546) then $a.setStatus(KT); $a : Person(age 25, zipCode == 23546 ) then $a.setStatus(KT); $a : Person(age 35, zipCode == 68590) then $a.setStatus(KT); etc.. Steve On 2/19/07, *Bill Zhang* [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: So Alex, if I only want to use the old syntax that is in production, there is no way to implement my seemingly simple logic conditioning? Thanks for your help. On 2/18/07, Alexander Varakin [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: As far as I know this syntax is new and is available in SVN only, you will have to wait till 3.1 is released or take source from SVN and build it. Bill Zhang wrote: Hi Steven, Thank you very much for your help. Really appreciate. I still got the same error, Unexpected token '|'. I did not see | in the document, only saw ||, which is supposed to be used with columns. Ye On 2/18/07, Steven Williams [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi Bill, I think it should be: $a : Person(age 35 | 25, zipCode == 23546 | == 68590) Edson, Mark or Michael can probably confirm or correct the above syntax. Make sure you are running of the latest trunk. cheers Steve On 2/18/07, Bill Zhang [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I tried: $a : Person(age 35 || age 25, zipCode == 23546 || == 68590) Errors: org.drools.rule.InvalidRulePackage : unknown:39:30 Unexpected token '||' unknown:39:40 mismatched token: [EMAIL PROTECTED],1040:1041='=',47,39:40]; expecting type '(' unknown:39:92 mismatched token: [EMAIL PROTECTED],1092:1092='',46,39:92]; expecting type '(' I also tried $a : Person(age 35 | age 25, zipCode == 23546 | == 68590) Pretty much the same error. Based on the document, || is only valid for columns... On 2/17/07, Bill Zhang [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Thank you Steve. But I got syntax error using the following. On 2/17/07, Steven Williams [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: In trunk I think you can use connective constraints: $a : Person(age 35 | 25, zipCode == 23546 | == 68590) then $a.setStatus(KT); On 2/18/07, Bill Zhang [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hello, I am a new Drools user trying to convert the following simple logic into DRL: IF (Person.Age 35 OR Person.Age 25) AND (Person.ZipCode = 23546 or Person.ZipCode = 68590) THEN Person.Status = KT; I found that it is not easy to convert the above logic into ONE DRL rule. I tried something like this when $a: Person(age35) or Person (age25) $b: Person(Zipcode==23456) or Person (ZipCode == 68590) $c: $a and $b Then $c.setStatus(KT) But looks like I can not use $c: $a and $b becaue in Drools, you can only bind variable to column, not to other varaibles. Please advise how to do this. I would imagine this should be quite simple, maybe I missed something quite obvious. I know that I can write custom Java method to do this, but if I do that, I suppose I lose the power of RETEOO pattern matching (pattern resuing, etc.). So I prefer not to do that. I also understand I can break the above logic into 4 rules and that would be quite easy, but our business user is not used to think in that way. Also, we have more complex logic than the above. So what I want is to see if there is a way to convert this kind of logic in ONE DRL rule.
[rules-users] Convert logic to DRL rules
Hello, I am a new Drools user trying to convert the following simple logic into DRL: IF (Person.Age 35 OR Person.Age 25) AND (Person.ZipCode = 23546 or Person.ZipCode = 68590) THEN Person.Status = KT; I found that it is not easy to convert the above logic into ONE DRL rule. I tried something like this when $a: Person(age35) or Person (age25) $b: Person(Zipcode==23456) or Person (ZipCode == 68590) $c: $a and $b Then $c.setStatus(KT) But looks like I can not use $c: $a and $b becaue in Drools, you can only bind variable to column, not to other varaibles. Please advise how to do this. I would imagine this should be quite simple, maybe I missed something quite obvious. I know that I can write custom Java method to do this, but if I do that, I suppose I lose the power of RETEOO pattern matching (pattern resuing, etc.). So I prefer not to do that. I also understand I can break the above logic into 4 rules and that would be quite easy, but our business user is not used to think in that way. Also, we have more complex logic than the above. So what I want is to see if there is a way to convert this kind of logic in ONE DRL rule. Thanks in advance. Bill ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users
Re: [rules-users] Convert logic to DRL rules
In trunk I think you can use connective constraints: $a : Person(age 35 | 25, zipCode == 23546 | == 68590) then $a.setStatus(KT); On 2/18/07, Bill Zhang [EMAIL PROTECTED] wrote: Hello, I am a new Drools user trying to convert the following simple logic into DRL: IF (Person.Age 35 OR Person.Age 25) AND (Person.ZipCode = 23546 or Person.ZipCode = 68590) THEN Person.Status = KT; I found that it is not easy to convert the above logic into ONE DRL rule. I tried something like this when $a: Person(age35) or Person (age25) $b: Person(Zipcode==23456) or Person (ZipCode == 68590) $c: $a and $b Then $c.setStatus(KT) But looks like I can not use $c: $a and $b becaue in Drools, you can only bind variable to column, not to other varaibles. Please advise how to do this. I would imagine this should be quite simple, maybe I missed something quite obvious. I know that I can write custom Java method to do this, but if I do that, I suppose I lose the power of RETEOO pattern matching (pattern resuing, etc.). So I prefer not to do that. I also understand I can break the above logic into 4 rules and that would be quite easy, but our business user is not used to think in that way. Also, we have more complex logic than the above. So what I want is to see if there is a way to convert this kind of logic in ONE DRL rule. Thanks in advance. Bill ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users -- Steven Williams Supervising Consultant Object Consulting Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501 [EMAIL PROTECTED] www.objectconsulting.com.au consulting | development | training | support our experience makes the difference ___ rules-users mailing list rules-users@lists.jboss.org https://lists.jboss.org/mailman/listinfo/rules-users