Re: [rules-users] Java code Vs Drools
by Tomas Olsson
See this previous email
/Tomas
-------- Original Message --------
Subject: RE: [rules-users] Drools vs Business Logic
Date: Fri, 8 Aug 2008 09:06:57 +0100
From: Anstis, Michael (M.) <manstis1(a)ford.com>
Reply-To: Rules Users List <rules-users(a)lists.jboss.org>
To: Rules Users List <rules-users(a)lists.jboss.org>
References:
<OF379C05EC.BC44AE12-ON6525749F.00276A32-6525749F.00281306(a)lntinfotech.com>
Well, IMO, common sense suggests highly specialised hand crafted code
optimised to a particular problem domain *should* be faster than a
generic algorithm (taking this further why not dump the high level
languages all together and opt for C++ or assembler, if you really
really want you squeeze performance?!?). However should your problem
domain change you have the burden of changing and re-optimising your
code. Lots of hassle. IMO, rule engines are great where your problem
domain is likely to change or you want to externalise your rule
definitions for whatever reason (maintainability, exposure to user
definitions etc). You'd be better off comparing the performance of a
prototype hand-crafted solution to generic rule engine solution - I
think you'd be surprised as to just how fast the generic solution is -
there have been quite a few postings to this group where people have
done performance tests of Drools. Only you can make these decisions as
you know your requirements best.
-----Original Message-----
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Harsh Jetly
Sent: 08 August 2008 08:18
To: rules-users(a)lists.jboss.org
Subject: [rules-users] Drools vs Business Logic
Hi ,
Firstly I would like to apologize for sending the same question to both
the
mailing lists and sending it multiple number of times. I assure you , it
shall not happen again .
I am using version 4.0.4 of drools . I have a basic question :
If we compare a rule engine to code written within the application ,
which
would prove to be faster .
I know about the rete algorithm and concepts of node sharing and caching
.
Another question that I have is , in which situation will Drools be best
suited ?
Thanks a ton
Harsh Jetly
Larsen & Toubro Infotech Ltd.
www.Lntinfotech.com
This Document is classified as:
|------|
| [X] |
|------|L&T Infotech Proprietary |------|
| [ ] |
|------|L&T Infotech Confidential
|------|
|
[ ] |
|------|
L&T Infotech Internal Use Only |------|
| [ ] |
|------|L&T Infotech General Business
This Email may contain confidential or privileged information for the
intended recipient (s) If you are not the intended recipient, please do
not
use or disseminate the information, notify the sender and delete it from
your system.
______________________________________________________________________
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
16 years, 4 months
Fetching values of an object's attribute set by different rules
by psentosa
Hi,
I have the following problems:
I need to prove an object based on certain rules, where the parts of the
rules should be kept to be used in further process within my application.
In order to fetch those parts, my idea was to insert an additional object as
value holder for the rule's parts,
put values on them when the corresponding rule is fired, so that later on I
can process those value holder after my appl gets the control back from
Ruleengine.
The example below:
Shirt shirt = new Shirt(...)
WashRuleValueHolder holder = new WashRuleValueHolder();
session.insert(shirt);
session.insert(holder);
......
session.dispose()
System.out.println(holder.getTemperature());
System.out.println(holder.getDetergent());
=======================
rule A
when
Shirt (dirtinessLevel == high)
$holder : WashRuleValueHolder()
then
System.out.println ("this cloth should be washed in 60 degree water
with 1 spoon of detergent")
$holder.temperature = 60;
$holder.detergent = 1;
rule B
when
Shirt(material == satin)
$holder : WashRuleValueHolder()
then
System.out.println ("this cloth should be washed in 30 degree water
with 0,5 spoon of detergent")
$holder.temperature = 30;
$holder.detergent = 0,5;
Now, in case both rules evaluate to true, I'd have problem with my
valueholder, bcs depending on which one of the rules was fired latest,
that'd be the value I got from the holder, and I need both of them.
So, my questions:
- Is using such a value holder a good solution to fetch the rules' value? Or
is there any better solution?
- How to handle this problem of multiple value association to the holder, so
I still can get all the values without one overwriting the other and they
are still connected?
Any idea highly appreciated, thanks in advance!
--
View this message in context: http://www.nabble.com/Fetching-values-of-an-object%27s-attribute-set-by-d...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 4 months
"or" not working
by Yu Wang
Hi, I need help in making the "or" work. I have the following rule:
rule
when
(
or
Condition_clause_1
Condition_clause_2
)
then
Consequence_clause_1
end
-------------
It gives me the following compilation error:
org.drools.rule.InvalidRulePackage: [4] Unable to expand: ( [5]
Unable to expand: or [8] Unable to expand: )
Seems it doesn't recognize "(", "or", and ")". But I totally follow
the documentation on section 6.5.2.3 of version 4.0.7.
Any help is highly appreciated.
16 years, 4 months
Composition of Fact Templates
by Stephen Kestle
I'm trying to make some fact templates in the form of
template "Address"
String line1
String line2
end
template "Person"
String name
int age
Address address
end
It complains that it is "Unable to resolve class "Address""
1. Is there any way around this - am I just getting syntax wrong?
2. Is this being fixed in 5.0 or > 4.0.7 (which I have)
3. Am I able to modify the class loader to grab the FactTemplate
class types and infer the correct object? e.g. is this something
that's ridiculously hard, and so hasn't already been included?
4. Am I going about this entirely the wrong way?
1. Are nested types at all useful in the rules?
2. Is it possible to even have a rule like:
p: Person( age == 5, Address(line1 == "My address))
? (given a java object schema)
3. Should I be using variables and other rules to assert facts?
4. Off topic: Is rules composition achieved by the assertion of
facts for other rules to use?
What I want to do:
I am dealing with (xml) schemas and ontologies, and need to be able to
create Fact Templates from these definitions. While I can do this
easily enough in java side, I believe I need to create the templates to
match my java objects so that the rules can be compiled.
Thanks heaps
Stephen
16 years, 4 months
How do I assign a value to a variable using a method call.
by samd
Hello,
I'm very new to drools and am trying to do something like the following:
rule "test"
when
$x: X( );
$y: Y( ) from someAction.getY( x.getId() );
eval( hasSomethingChanged( $x, $y ) );
then
$x.warnSombody("some message");
end
The problem is when I load the rule it gives me an error when it hits the
from line.
[testng] FAILED CONFIGURATION: @BeforeClass setUp("/test.drl")
[testng] org.drools.rule.InvalidRulePackage: Unable to build expression
for 'from' node 'someAction.getY( x.getId() )' : [Rule name=test,
agendaGroup=MA
IN, salience=0, no-loop=false]
I'm a bit stuck on this so any help would be great.
--
View this message in context: http://www.nabble.com/How-do-I-assign-a-value-to-a-variable-using-a-metho...
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 4 months
Caching RuleBase in Drools
by raj_drools
Hi ,
i'm trying to implement caching of rules .
in the manual there is a statement as follows :
" Typically, a rulebase would be generated and cached on first use; to save
on the continually re-generation of the Rule Base; which is expensive."
how does rule base caches rules ? is there any method to cache the rules ?
how can i implement caching in Drools in order to avoid loading rules all
the times ?
--
View this message in context: http://www.nabble.com/Caching-RuleBase-in-Drools-tp18924137p18924137.html
Sent from the drools - user mailing list archive at Nabble.com.
16 years, 4 months
Salience not being considered in DSL
by Harsh Jetly
Hi ,
I am using Drools version 4.0.4.
I have created a dsl file for my drl ,I have set a salience for each rule .
The problem I am facing is that the salience specified in the drl is not
being used.
Now when I use the drl without the dsl . Things work just fine and the
salience is used .
What should be done ?
Regards
Harsh Jetly
SOA
Center of Excellence
Larsen & Toubro Infotech Ltd.
www.Lntinfotech.com
This Document is classified as:
|------|
| [X] |
|------|L&T Infotech Proprietary |------|
| [ ] |
|------|L&T Infotech Confidential |------|
| [ ] |
|------|
L&T Infotech Internal Use Only |------|
| [ ] |
|------|L&T Infotech General Business
This Email may contain confidential or privileged information for the
intended recipient (s) If you are not the intended recipient, please do not
use or disseminate the information, notify the sender and delete it from
your system.
______________________________________________________________________
16 years, 4 months
Use of a DAO in LHS
by BINET JEAN-BAPTISTE
Hello,
I have a DRL file in which I have a global variable representing a DAO.
So, I succeed in writting a rule which uses this DAO to run a SQL query
on the database from the RHS part.
But now, I would like to use my DAO in the LHS, I mean I want to fire my
rule only if a condition is ok on the result of my SQL query.
Is it possible to call a method of my DAO in the LHS part ?
I have not found an example.
Thanks.
Regards,
Jean-Baptiste
16 years, 4 months
Re: How to create DSL template that produces rules based on arbitrary user's input?
by Matt Geis
You can do this. Keep in mind that the DSL engine will try to match each dsl mapping entry into the LHS of the rule, one by one, in the order they are declared in the mapping file. This means you can have one mapping that substitutes the word "and" for a comma, and so on. It may take some clever mapping, and multiple entries to get the flexible effect you're looking for, but it's doable (I've done it).
You might find the typed variable support in Drools 5 helpful. There's a blog post about it, and a few weeks ago I posted a more detailed answer to essentially the same question to the list, if you want to go through the archives to find it.
This may help...
http://article.gmane.org/gmane.comp.java.drools.user/11020/match=geis
Matt Geis
16 years, 4 months
Performance issues with using RuleFlow with StatelessSession
by Amit Mhatre
Hi,
this might either be a java-users questions or a drools-users, but I'd like
to try here to see if somebody has any suggestions for me.
I have observed that the ruleFlow that I am using gets slower and slower
since its initial deployment. It initially started taking like 30mins to
evaluate all the rules, but the run-time goes up to about 4hours in about 4
days.
I am using a statelessSession. I do a RuleBaseFactory().newRuleBase() and
ruleBase.newStatelessSession() each time I begin an evaluation (I evaluate
about 50k objects, once a day). I have the ruleBase as a private instance in
an EvaluationHandler which does other evaluations as well and is a singleton
which is obtained from a factory.
Has anyone else too on this forum faced this issue? I found this archive,
but no reply to it:
http://www.nabble.com/Performance-Question-with-Stateless-Session-to14704...
Could it be that a new ruleBase is being created each time I do an
evaluation (it obviously is), but a reference to the old ruleBase still
hangs around (and hence the entire WorkingMemory)? I checked the RuleBase
apis and I couldn't find anything that could help me clear the workingMemory
once I am done with evaluating all the rules.
Would be great if somebody could ched some light into this issue that I am
facing and/or let me know the path I must follow to find the root-cause of
the slowing down of the evaluations.
Thanks,
- am
16 years, 4 months