using complex evaluate expressions with DSL
by maverik j
Hi,
We are planning to use DSL/DSRL approach with generic DSL template like say
[condition][]The {object} has valid {field}={object}({field} != null )
[condition][]there is object {*obj*} that = {*obj*}()
[condition][]- has {*attr*} equal {*val*} = {*attr*} == {*val*}
[condition][]- has valid {*attr*} = {*attr*} != null
[condition][]- and has {*attr*} equal {value}= && {*attr*} == {value}
But there are quite few of requirements like to have DSL rules that can
generate expression as follows:
exists Employee(
attribute name not equals "xxx"
&& the attribute subOrdinate is not null
&& eval(
the attribute $dept.getId() is not null
&& attribute $dept.getId() follows pattern "I"
&& ( ! (the attribute $dept.getHeadOfDpt() equals name)
)
)
I am not sure if this is possible with DSL. Using '-' operator we cannot
really add '&&', '||' conditions it by-default expands to ',' separated and
conditions. And wirtting generic rules with and/or is not really dynamic to
allow any number of expressions in evaluation.
i am struggling to get this run since long time so any help/thoughts on this
would be highly appriciable !!!
Thanks & Regards,
-Maverik
13 years, 10 months
Guvnor - No function but rule containing it still validates
by Rob Fisher
Using Guvnor 5.1.1....
I've written a rule utilizing a function that does not exist within the
same package. However, the rule still validates ok. How is this
possible?
Rob Fisher
Systems Analyst, Agency Awards
Desk 309-735-4136
Cell 309-660-4957
13 years, 10 months
KnowledgeAgent exception while trying to deserialize KnowledgeDefinitionsPackage
by John Peterson
This is sort of a repost of an error I've been getting, but I thought
with the new year, I'd give it another shot.
I've been getting the following exception in my code:
[2010:12:361 09:12:910:debug] KnowledgeAgent rebuilding KnowledgeBase
using ChangeSet
[2010:12:361 09:12:972:exception]
***java.lang.RuntimeException*: KnowledgeAgent exception while trying to
deserialize KnowledgeDefinitionsPackage
at
org.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(***Kn
owledgeAgentImpl.java:664*)
at
org.drools.agent.impl.KnowledgeAgentImpl.addResourcesToKnowledgeBase(***
KnowledgeAgentImpl.java:889*)
at
org.drools.agent.impl.KnowledgeAgentImpl.rebuildResources(***KnowledgeAg
entImpl.java:704*)
at
org.drools.agent.impl.KnowledgeAgentImpl.buildKnowledgeBase(***Knowledge
AgentImpl.java:584*)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(***KnowledgeAgen
tImpl.java:185*)
at
org.drools.agent.impl.KnowledgeAgentImpl.applyChangeSet(***KnowledgeAgen
tImpl.java:168*)
at
com.agencyawards2.RuleSessionProviderFactory.getSessionFactory(***RuleSe
ssionProviderFactory.java:95*)
at
com.agencyawards2.RuleSessionProviderFactory.getProvider(***RuleSessionP
roviderFactory.java:35*)
at com.agencyawards2.RunRules.runRules(***RunRules.java:27*)
at com.agencyawards2.DroolsTest.main(***DroolsTest.java:40*)
Caused by:*** java.io.StreamCorruptedException*: invalid stream header:
7061636B
at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
at java.io.ObjectInputStream.<init>(Unknown Source)
at
org.drools.common.DroolsObjectInputStream.<init>(***DroolsObjectInputStr
eam.java:71*)
at
org.drools.core.util.DroolsStreamUtils.streamIn(***DroolsStreamUtils.jav
a:205*)
at
org.drools.core.util.DroolsStreamUtils.streamIn(***DroolsStreamUtils.jav
a:174*)
at
org.drools.agent.impl.KnowledgeAgentImpl.createPackageFromResource(***Kn
owledgeAgentImpl.java:653*)
... 9 more
I'm running Drools 5.1.1 on my workstation in Eclipse. When I run it
against Guvnor locally using version 5.1.1 installed as the "Guvnor
Standalone" downloaded at the same time as Drools 5.1.1 was downloaded
from the JBoss.org site, it works fine.
When I run it against the server, which was from the 5.0.1 "Guvnor
Standalone" installation, but I updated the drools-guvnor.war file to
use the new 5.1.1 version, I get the error listed above. Based on my
research into the "KnowledgeAgent exception while trying to deserialize
KnowledgeDefinitionsPackage" error, it seems to stem from an
incompatibility between versions of Drools.
Do I need to install the 5.1.1 Guvnor Standalone to my server to bring
the versions into synch, or am I experiencing some other sort of
problem?
13 years, 10 months
Does Drools Fusion support "Group By" clause ?
by Kiran Ananthpur Bacche (kbacche)
Hi,
I have a event processing rule as follows
declare Sale
@role(event)
end
rule "StoreABC"
when
#conditions
Number( $TotalSalesAmount : intValue,
intValue > 100)
from accumulate ( Sale($amount : amount,
$quantity : quantity)
from entry-point StoreABC,sum($amount *
$quantity))
then
System.out.println("StoreABC sale
exceeds 100...");
End
The POJO Sale has a attribute "String type;". The above rule actually
ignores the type, and does the accumulation for all types put together.
Now I want the rule to fire successfully only when the TotalSalesAmount
for _any_ given type exceeds 100.
And is it possible to access the "type" of Sale whose sales exceeded
100, in the "Then" clause ?
Example:
Lets say the input events are as below (Triplets - Type, Quantity and
Amount)
1. Apple , 10, 5
2. Orange, 10, 6
3. Banana, 20, 4
4. Orange, 10, 5
5. Apple, 2, 5
Now in the above rule, the event fires after Event 2 since the total
sales is > 100. However I want the rule to fire after Event 4 since at
that point the sale of one particular item, viz. "Orange" exceeds 100 in
this store. In the "THEN" clause of the rules, I also want access to a
variable that indicates that it was "Orange" whose sale exceeded 100 in
this store.
Is this possible in Drools Fusion ? If yes, can you please let me know
the changes to be made to the above rule ?
Thanks
Kiran
13 years, 10 months
Drools Flow within Stateless Session in Drools 5.1
by JeffMax
I am seeing some odd behavior where it seems that inference is not working
when trying to use a flow process within a stateless knowledge session. I
have tried to do the same thing in both stateful and stateless, and the
behavior is different. It appears that if one rule inserts a fact in its
right hand side that causes another rule in a different flow-group to become
activated, the rule-flow (which should progress to the next flow group) will
not allow that rule to fire if the session is stateless. It is possible I am
confused about how a rule-flow evaluates or the order in which it evaluates
with respect to inference, but it is working as I expected in a stateful
session.
An example:
I have a simple rule flow with two flow-groups, group1 and group2. They are
connected one after the other
in a file with id TestFlow
start->group1 -> group2 -> end
I then have a simple rules file:
declare Fact1
num: int
end
declare Fact2
num: int
end
rule "Rule1"
ruleflow-group "group1"
when
Fact1()
then
System.out.print("FIRING 1");
insert(new Fact2());
end
rule "Your Second Rule"
ruleflow-group "group2"
when
Fact2()
then
System.out.print("FIRING 2");
end
When used in a stateful session, both rules will fire and print their
respective output. In a stateless, the second rule will never fire. To
execute this test, I am using the same code against both a stateless and
stateful session:
FactType fact = kbase.getFactType("org.test", "Fact1");
Object one = fact.newInstance();
List cmds = new ArrayList();
cmds.add(CommandFactory.newInsert(one));
cmds.add(CommandFactory.newStartProcess("TestFlow"));
cmds.add(CommandFactory.newFireAllRules()); // Only need this in stateful
ksession.execute(CommandFactory.newBatchExecution(cmds));
Does anyone have any suggestions?
Thanks,
Jeff
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Drools-Flow-within-St...
Sent from the Drools - User mailing list archive at Nabble.com.
13 years, 10 months
Writting generic DSL to have complex evaluate expression on exists
by maverik
Hi,
We are planning to use DSL/DSRL approach with generic DSL template like say
[condition][]The {object} has valid {field}={object}({field} != null )
[condition][]there is object {obj} that = {obj}()
[condition][]- has {attr} equal {val} = {attr} == {val}
[condition][]- has valid {attr} = {attr} != null
[condition][]- and has {attr} equal {value}= && {attr} == {value}
But there are quite few of requirements like to have DSL rules that can
generate expression as follows:
exists Employee(
attribute name not equals "xxx"
&& the attribute subOrdinate is not null
&& eval(
the attribute $dept.getId() is not null
&& attribute $dept.getId() follows pattern "I"
&& ( ! (the attribute $dept.getHeadOfDpt() equals name)
)
)
I am not sure if this is possible with DSL. Using '-' operator we cannot
really add '&&', '||' conditions it by-default expands to ',' separated and
conditions. And wirtting generic rules with and/or is not really dynamic to
allow any number of expressions in evaluation.
i am struggling to get this run since long time so any help/thoughts on this
would be highly appriciable !!!
Thanks & Regards,
-Maverik
--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Writting-generic-DSL-...
Sent from the Drools - User mailing list archive at Nabble.com.
13 years, 10 months
QA features in BRMS
by Benson Fung
Hi,
Can anyone know whether QA features can provide the rule conflict checks?
Thanks
13 years, 10 months
Re: [rules-users] JESS: Hello To Jess User Group and How Is Jess Doing?
by James Owen
Ernest et al:
Sorry for the confusion on my part - which is why I included all of the email lists. However, at one time (unless I have a really faulty memory chip) programmers outside of the USA used to complain because they could not get the source code (and sometimes the binary) because of the BATF regulations that considered computer source code as some kind of "munitions."
Also, I personally did have to pay $100 for the source code way back when (about 2001 or 2002) unless I just wanted the binary version. But, I have been allowed to download all of the upgrades since that time for free.
However, thanks for clarifying today's pricing options and showing that Jess is available world-wide, even with source. That's great news! Thanks,
Rose Bowl Results
TCU Horned Frogs, 21
Michigan Badgers, 19
TCU, a small private university, is located in little old Fort Worth, Texas - where the West begins. :-)
SDG
jco
jco(a)kbsc.com
CoFounder DRG 2000
CoFounder ORF-2008/ORF-2009
CoFounder and Speaker (O)RF 2010
http://www.DallasRulesGroup.org
http://www.RulesFest.org
On Jan 2, 2011, at 5:45 PM, Ernest Friedman-Hill wrote:
>
> Jess is available under one of four main licensing agreements. Three of these options are available worldwide -- it is not true that Jess is unavailable outside the US. Source code is indeed available as part of many agreements, but in no case is it specifically available for $100.
13 years, 10 months
Re: [rules-users] JESS: Hello To Jess User Group and How Is Jess Doing?
by James Owen
Edson et al:
I rarely get involved with this kind of thing but since there are more than 10 emails on the same subject and since Mark Proctor, Edson Tirelli and Dr. Friedman-Hill really shouldn't be drawn into the discussion due to a "conflict of interest" matter, and my friend and fellow instigator PL/ (woolfel) has not commented, may I be so bold as to interject these few thoughts:
1. There are about 25 or more BRMS/rulebased systems presently being used throughout the world. In this space they seem to be grouped into commercial and free, or almost free for personal use. Commercial systems can range from a few thousand to a few million US Dollars. Free (or almost free systems - no such thing as a free lunch) systems will require lots of time and study to learn what the commercial guys can provide in a short period of time. Also, most commercial vendors usually have schools for training purposes.
2a. EJFH has frequently mentioned that Jess is for programmers. But, he has written a book, "Jess In Action", (a bit out of date by now but still spot-on applicable in most cases) and the on-line user's manual that is kept up to date really is quite good. Read it! Also, the Jess email list is quite as active as the Drools Users list and you can normally get a response within a few hours there. In addition, there is a 3rd party Fuzzy Jess for those who want a bit "more" expert system approach to their system. Jess comes with source code for an extra $100 but commercial applications have to be worked out with Sandia Labs. Unfortunately, Jess is NOT available (legally) outside the USA but is totally free (with source code) to military, government and/or students/teachers at approved universities.
2b. If you are using C/C++ as your main system, then CLIPS (C Language Interface to Production Systems) is quite good and could be considered a superset of Jess. In addition to the quite-excellent on-line manuals, they also have a book out by Dr. Joseph Girratano (University of Houston) and Gary Riley (formerly NASA but now independent) that is updated frequently and is on version 4 at the time of this email - I use the book for teaching CLIPS, CLIPS/R2 and, sometimes, to supplement the "Jess In Action" book By Dr. Friedman-Hill. Unfortunately, I haven't found a similar email list to the ones maintained by Drools or Jess. The latest version of CLIPS 6.3 compares quite favorably with OPSJ using Rete-2 on my performance testing. CLIPS also allows various optimization conflict resolution strategies and comes with source code if you want to change things up a bit.
3. Mark Proctor et cie developed Drools for the past few years and it was (years ago) a programmers-only language as well. Recently however they are moving more toward the BRMS space with Guvnor and other tools to make it easier for the business user to use, create and/or modify the rules; and to compete with ILOG and Advisor. They also have an active users email list and a developers email list. (PLEASE - do not take user questions to the developer list.) They still lack factory consulting but you can purchase factory phone-in tech support from Red Hat, their parent company, or advertise for a Drools consultant on their home page. In addition, there are two books on Drools (in addition to their on-line manual) available through Amazon, Barnes & Noble, Nerd Books, etc.
4 Commercial, Rete-based systems normally have an evaluation copy (usually a full working version that is time-bombed to quit working after an appropriate period of time.) The biggies here are FICO Blaze Advisor (COBOL and .NET as well), IBM/ILOG JRules (COBOL and .NET as well), Pega Rules as part of the PegaSystems, MindBox for Mortgage Systems, and many others. In addition to some kind of text rules, these tools usually employ highly sophisticated Decision Tables (spreadsheets), Decision Trees, Reporting tools, Trouble Shooting tools, Professional Services (Consulting), Factory technical support (of various levels), etc. They are not cheap (usually $25K per developer seat) but, then, nobody ever got fired for using one of them. Most use some form of enhanced Rete and Blaze Advisor uses Rete 2 licensed from Dr. Forgy discussed below.
5. Non-Rete Commercial systems that might be considered could be Rule Burst (now owned by Oracle that also owns the Rete-based Haley Expert Systems), Visual Rules or Corticon (and others) that are, more or less, spreadsheet-based rule maintenance tools. All of them have some kind of rule optimization in place. These eye-catching models are far more familiar to the business users - and probably to your IT group and would compare to the Decision Tables from FICO, ILOG or Drools. In addition, these companies also have Professional Services and/or telephone technical support available for a cost. I have found that 75% or more of most business applications do not actually need Rete but Rete is better for large, enterprise rulebased systems that need a high performance factor.
6. Prolog tools are abundantly available, usually free, and VisiRules (not Visual Rules) is a great commercial modeling tool if you are considering an expert system rather than just a gathering of rules. My experience is that Prolog doesn't scale well to massive numbers of problems but is much better for extremely complicated and/or complex problems. But, then, my experience with Prolog is limited to smaller problems so maybe I didn't approach it the right way.
7. For high-performance applications I always recommend that companies take a look at OPSJ from Production System Technologies (the company founded and still owned by Dr. Charles L. Forgy, the inventor of Rete.) OPSJ (Java) uses, a proprietary algorithm from Dr. Fory that is from 50 - 100 times faster than most simple Rete systems and usually 10 - 20 times faster than most of today's improved Java-based Rete systems. The cost of OPSJ was less than $10K about a year or so ago and has no run-time fees. Also, Dr. Forgy recently announced Rete-NT that is about 10-12 times faster than Rete-2 but is priced based on the number of CPUs being used, usually about $5K per CPU. Rete-NT is best for systems (such as Homeland Security, NASA or Military application) that need a rulebased system AND that need extremely high performance. PST also has the C/C++ based CLIPS/R2 and other systems available for certain situations. If you think that you need the performance from Rete-NT, (warning: personal plug here) give me a call, or email, and let's talk about it first.
8. May I suggest that if your firm is considering using one or the other of those discussed above, or any other BRMS / Rulebased System, that you call in a trusted, independent consultant, of which there are some walking the streets in these hard time, who has experience not only with these rulebased systems but maybe with many others as well. That consultant (not myself but I could recommend several) would be able to listen to the requirements and advise as to which system might be the best for your situation. Beware of those who are partners with only one or two major vendors because, right or wrong, that is the recommendation that you will get. Be prepared to pay for their services - they have spent 10 to 20 years (or more) working with most of these systems and they are well aware of the benefits and pitfalls of most of them.
Hmmm... Just a few thoughts. But, this should be sufficient to explain that selecting the appropriate tool depends on the problem and the capabilities of the tools. Most times I have found that the company didn't need a rulebased system (sometimes erroneously call Business Rule Management System - BRMS) at all. Rather, it probably should have been coded in Java or C/C++; or even BASIC, FORTRAN or COBOL. But using a BRMS / Rulebased System / Expert System would look cool on a CV so the IT guys (or the business guys) recommended it as a stepping stone for their next position.
Above all, once a tool has been selected, RTFM!! Read The Fabulous Manual!!! Before calling in or writing the email list.
I have CC'd both the Drools email list and the Drools Developers email list in the event that I misspoke anything about their (or another) product. The very LAST thing that I want to do is start an email flurry (sometimes called a "flame war") on any of the lists. These are my own personal opinions and do not reflect the positions of any of the trade-marked companies above nor of my own company, KnowledgeBased Systems Corporation, in any way, shape, form nor fashion.
SDG
jco
On Jan 1, 2011, at 7:14 PM, Edson Tirelli wrote:
> Hi,
>
> I will abstain myself from discussing Drools specific features in
> this list, in respect to the other users and due to my involvement
> with the other project, but I can tell you that if your bias is
> towards Jess, go for it. As we all know it is an excellent engine, and
> if we look at the rules engine alone, the choice between Jess and
> Drools Expert IMHO is purely a matter of taste (syntax and API). The
> differences between the 2 products will be more salient when you start
> throwing into your analysis all other requirements, both functional
> and non-functional, for your use case, as well as looking at the
> ecosystem and other modules/products developed around them.
>
> Feel free to ask the Drools specific questions at the Drools
> mailing list. Community there is also very friendly and active.
>
> Cheers,
> Edson
>
>
> 2011/1/1 dc tech <dctech1000(a)gmail.com>:
>> Thank's Edson. Will check it out.
>> Drools seems to have come a long compared to when I last looked at it -
>> given that you have a foot in both camps, any wisdom and guidance would much
>> appreciated. My bias is towards Jess, perhaps since I got introduced to
>> rules engines with the excellent Jess book but is it worth looking at
>> Drools? I like the interactive 'protype'ability with Jess using the shell
>> (still on 6.1). Does Drools have similar intractivity? We are developing
>> using j
>> jRuby (RoR) or Java.
>> Thanks!
>> On Fri, Dec 31, 2010 at 3:58 PM, Edson Tirelli <ed.tirelli(a)gmail.com> wrote:
>>>
>>> May I suggest you take a look at Tohu?
>>>
>>> http://community.jboss.org/wiki/Tohu
>>>
>>> It is a small framework to do, it seems, exactly what you
>>> described. It is built on top of Drools, but even if you prefer to
>>> write your own framework on top of Jess, it can probably give you
>>> ideas for your own design. Need to say, though, that I never used it
>>> myself, so not sure how good/bad it is, but the video demo is nice.
>>>
>>>> Lets not forget, even the Drools reference area (and JBoss Rules /
>>>> Drools Developer Book) recommends you read: "Jess in Action: Java Rule-based
>>>> Systems"
>>>
>>> It is an excellent book for people that want to learn about
>>> Rule-based Systems, so why not recommend it? :) Being a Drools
>>> developer, I can tell you that we always had a good relationship with
>>> the Jess community, and we have much more to gain by cooperating than
>>> competing. That is not to detract from one engine or the other, it is
>>> just the open source way of promoting innovation and education and
>>> building upwards from the shoulders of the giants that came first...
>>> :)
>>>
>>> Cheers and Happy New Year!
>>>
>>> Edson
>>>
>>>
>>> 2010/12/31 dc tech <dctech1000(a)gmail.com>:
>>>>>> Perhaps a little, but not greatly. ....
>>>> Am happy to hear. Jess was my first introduction to rules engines 4-5
>>>> years
>>>> back but did not use it for a production system. Now we are looking to
>>>> build
>>>> a 'guided navigation' type of app using Jess where the rules determine
>>>> what
>>>> steps does a user need to do. I am really excited to be able to use a
>>>> rules
>>>> engine for that type of application; I am sure many of you have built
>>>> similar things. Will keep you posted on questions/findings/lessons.
>>>> Not having done real development for many years, I really enjoyed using
>>>> the
>>>> Jess shell (still v6, from the book) and actually build small prototypes
>>>> with rules.
>>>> Agree on the Drools making rules more accessible.
>>>>
>>>> On Thu, Dec 30, 2010 at 3:17 PM, Socrates Frangis
>>>> <soc.frangis(a)gmail.com>
>>>> wrote:
>>>>>
>>>>> Agree with Donald, were on holiday.
>>>>>
>>>>> "Any impact from things like jBoss rules or other engines?"
>>>>> -Perhaps a little, but not greatly. I will applaud Red Hat for
>>>>> exposing more and more people to rule engines through open source
>>>>> however.
>>>>>
>>>>> With that said, I think the many users of Jess stick with it due to
>>>>> it's maturity and 'rule engine features' as apposed to the convenient
>>>>> bundling of open source middle-ware. I have the feeling that many will
>>>>> get introduced to rule engines through Drools now, but when searching
>>>>> for something that gets the job done they will sway elsewhere.
>>>>>
>>>>> Lets not forget, even the Drools reference area (and JBoss Rules /
>>>>> Drools Developer Book) recommends you read:
>>>>> "Jess in Action: Java Rule-based Systems"
>>>>>
>>>>>
>>>>> On Thu, Dec 30, 2010 at 8:26 AM, dc tech <dctech1000(a)gmail.com> wrote:
>>>>>> Rejoining the Jess community after a multi-year hiatus and notice
>>>>>> that
>>>>>> the
>>>>>> mailing list has been very quiet. I am curious to see how Jess is
>>>>>> doing
>>>>>> now
>>>>>> a days? Any impact from things like jBoss rules or other engines? Is
>>>>>> the
>>>>>> community still pretty active?
>>>>>> Happy Holidays to everyone !
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> V/R
>>>>> -Socrates Frangis
>>>>> -Mathematician & Software Engineer
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --------------------------------------------------------------------
>>>>> To unsubscribe, send the words 'unsubscribe jess-users you(a)address.com'
>>>>> in the BODY of a message to majordomo(a)sandia.gov, NOT to the list
>>>>> (use your own address!) List problems? Notify
>>>>> owner-jess-users(a)sandia.gov.
>>>>> --------------------------------------------------------------------
>>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>> --------------------------------------------------------------------
>>> To unsubscribe, send the words 'unsubscribe jess-users you(a)address.com'
>>> in the BODY of a message to majordomo(a)sandia.gov, NOT to the list
>>> (use your own address!) List problems? Notify owner-jess-users(a)sandia.gov.
>>> --------------------------------------------------------------------
>>>
>>
>>
>
>
>
> --
> Edson Tirelli
> JBoss Drools Core Development
> JBoss by Red Hat @ www.jboss.com
>
>
>
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users you(a)address.com'
> in the BODY of a message to majordomo(a)sandia.gov, NOT to the list
> (use your own address!) List problems? Notify owner-jess-users(a)sandia.gov.
> --------------------------------------------------------------------
>
13 years, 10 months