[rules-users] Check if a pattern binding exists in the RHS

2008-08-19 Thread hatzlj

Hello everybody,

on the LHS of my rule i connect several Conditions with OR and have
different variable bindings for this Condition. Now - if any of this
conditions does not fire, i assume that the binding variable is not created,
so I can't access it in the RHS. This results in an null pointer exception
when I call the fireAllRules-Command in my Java Application.

A simple rule example:
rule Rule 1
   when
  HKT: Parameter(parameterCode = HKT, value  normalFloor) or
  GGT: Parameter(parameterCode = GGT, value  normalFloor) or
  HSR: Parameter(parameterCode = HSR, value  normalFloor) and
  GOT: Parameter(parameterCode = GOT, value  normalFloor)

   then
  System.out.println(HKT.toString();

end

So my Question is: Is there any way to check in the RHS wheter the pattern
binding has been created or not or do i have to change the way of writing my
rules (which i do not want to)?

thanks,
hatzlj
-- 
View this message in context: 
http://www.nabble.com/Check-if-a-pattern-binding-exists-in-the-RHS-tp19032260p19032260.html
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Sequential mode supports rule flow ??

2008-08-19 Thread raj_drools

Hi , 

i'm using Drools4.0.7 . 

For improving performance of my rule engine ,i want to go for Sequential
mode . 

i want to know whether sequential mode supports Rule Flow . 

if yes how can i do that ? 

thank you 
-- 
View this message in context: 
http://www.nabble.com/Sequential-mode-supports--rule-flow-tp19046672p19046672.html
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] some basic questions to grouping

2008-08-19 Thread psentosa

Hi,

I'm having some difficulty to understand the concept of grouping, but maybe
it's only because of my understanding of the terms, so please apologize for
the silly question
1. when you are saying rules fire, does this mean: matching/checking the
LHS of rule, or executing the RHS of rule

2. I plan to use the grouping features of drools, but still not sure
whether(and how) to use the agenda or activation group (or even the
rule-flow). My problem domain is actually quite simple:
- rules are applied based on e.g age of a person. Now, there are some rules
for 17-year-or older, and some for 30-year-old person, if I'm to use the
agenda group, I'd define the following:

rule1
agenda-group 17 years-old or older
when
 p:Person (Age  17)


rule2
agenda-group 17 years-old or older
when
 p:Person (Age  17)
.

rule3
agenda-group 30 years-old or older
when
 p:Person (Age  30)
..

rule4
agenda-group 30 years-old or older
when
 p:Person (Age  30)
..

If I assert a person into the WM to check his/her age, I want that only the
rules in 30-years-old agenda are CHECKED (and eventually executed when the
other constraints are fulfilled), bcs they are surely older than 17 as well. 
And this is not only for comparing ages. Another example, some rules are
only for Gender.MALE, and some only for Gender.FEMALE. So if a person is
asserted, only the rules with corresponding gender will be checked and no
need of checking/matching the other group
The main purpose is just to skip checking unrelevant rules (imagine if there
is only 1 rule for MALE and 1000 rules for FEMALE with 1000 times WHEN
person (gender == FEMALE) checking for an asserted male-object).
How can I do this effectively? Or will ALL rules checked and only the order
of checking (and eventually exection of their RHS) is defined by the
grouping?

I hope I've described my problem clearly and I'll try to explain this again
in case of difficulty :)
Thanks in advance

Regards


-- 
View this message in context: 
http://www.nabble.com/some-basic-questions-to-grouping-tp19048066p19048066.html
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] some basic questions to grouping

2008-08-19 Thread hatzlj

Hi, 

ad 1)
my understanding of the term a rule fires is: if the LHS of a rule is true
the rule fires (that means roughly: the RHS of the rule is added to the
agenda and executed in a given order).

ad 2)
i  have no detailed knowledge of drools but i assume ruleflow could be the
right thing for you. i would make some ruleflow-groups, for example one for
each gender. in the ruleflow definition you can make a split depending on
the gender of the person, after that you can join again and split depending
on the age of the person and execute the corresponding ruleflow-groups.
you can look up details for creating ruleflows at:
http://downloads.jboss.com/drools/docs/4.0.7.19894.GA/html_single/index.html#d0e4418

regards,
jakob


psentosa wrote:
 
 Hi,
 
 I'm having some difficulty to understand the concept of grouping, but
 maybe it's only because of my understanding of the terms, so please
 apologize for the silly question
 1. when you are saying rules fire, does this mean: matching/checking the
 LHS of rule, or executing the RHS of rule
 
 2. I plan to use the grouping features of drools, but still not sure
 whether(and how) to use the agenda or activation group (or even the
 rule-flow). My problem domain is actually quite simple:
 - rules are applied based on e.g age of a person. Now, there are some
 rules for 17-year-or older, and some for 30-year-old person, if I'm to use
 the agenda group, I'd define the following:
 
 rule1
 agenda-group 17 years-old or older
 when
  p:Person (Age  17)
 
 
 rule2
 agenda-group 17 years-old or older
 when
  p:Person (Age  17)
 .
 
 rule3
 agenda-group 30 years-old or older
 when
  p:Person (Age  30)
 ..
 
 rule4
 agenda-group 30 years-old or older
 when
  p:Person (Age  30)
 ..
 
 If I assert a person into the WM to check his/her age, I want that only
 the rules in 30-years-old agenda are CHECKED (and eventually executed when
 the other constraints are fulfilled), bcs they are surely older than 17 as
 well. 
 And this is not only for comparing ages. Another example, some rules are
 only for Gender.MALE, and some only for Gender.FEMALE. So if a person is
 asserted, only the rules with corresponding gender will be checked and no
 need of checking/matching the other group
 The main purpose is just to skip checking unrelevant rules (imagine if
 there is only 1 rule for MALE and 1000 rules for FEMALE with 1000 times
 WHEN person (gender == FEMALE) checking for an asserted male-object).
 How can I do this effectively? Or will ALL rules checked and only the
 order of checking (and eventually exection of their RHS) is defined by the
 grouping?
 
 I hope I've described my problem clearly and I'll try to explain this
 again in case of difficulty :)
 Thanks in advance
 
 Regards
 
 
 

-- 
View this message in context: 
http://www.nabble.com/some-basic-questions-to-grouping-tp19048066p19048073.html
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] FROM and the working memory

2008-08-19 Thread Edson Tirelli
   David, it will use RETE but the actual data is retrieved on-demand...
meaning no previous processing is made, and if it is a list, it will iterate
the list every-time, so, it is less efficient than when the data is already
in the working memory. It is useful for cases, for instance, when you have a
lot of data outside of the working memory, but you are only interested in a
small subset of the data... asserting all the data would then be a waste.

   []s
   Edson

2008/8/19 David Boaz [EMAIL PROTECTED]


 Hi all,

 in the drools manual (6.5.28): FROM allows the engine to reason over data
 not in the working memory.
 Will drools use rete to evaluate patterns with a FROM source?

 Lets assume the following rule:
 WHEN p:Person(age60), Address(city=NY) FROM p.addresses
 will the rule engine match the Address pattern using rete?

 and, what about the following rule:
 when p:Person(age=m), Person(age60) from p
 1) will it work?
 2) will the age constraint be matched using rete?

 Thanks, David
 --
 View this message in context:
 http://www.nabble.com/FROM-and-the-working-memory-tp19020847p19020847.html
 Sent from the drools - user mailing list archive at Nabble.com.

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
Edson Tirelli
JBoss Drools Core Development
JBoss, a division of Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] CEP functionality

2008-08-19 Thread Edson Tirelli
   Hi David, must have missed your previous e-mail.

* Where can we find a more detailed description of CEP functionality in
drools?
   Unfortunately we don't have proper documentation for CEP in Drools yet.
General documentation about the subject can be found in a lot of places, but
a good starting point is: www.complexevents.com.

* Is it a good idea to use CEP for analyzing historic data (retrieved from
the database)? or is it best for online data.
   Usually CEP is used to match online **events** with historic
**data**, but in the reality, in Drools you can assign event semantics to
any type of fact, so it really depends on your problem domain and how you
are modeling it.

* Can we use CEP in a stateless session?
   Not sure it makes sense. Need to investigate that. CEP is usually about
streams of events and ongoing event pattern detection, and so we are
developing it for Stateful sessions.

* As we understand, CEP attaches to each fact a temporal attribute of the
assertion time. Can we define that a particular attribute (e.g.,
LabResult.samplingDate) will be used as the time stamp? Or, should we assert
the facts by their temporal order, and advance the session-clock
appropriately?
   Yes, just assign event semantics to your fact and declare its timestamp
attribute:

declare LabResult
   @role( event )
   @timestamp( samplingDate )
end

* Can we use CEP to analyze the data in the examples above?
   Well, you can, but is it the best tool for the job? Maybe yes, maybe no.
Look at your case and read the quick list of itens that describe what means
to assign and event semantic to your labresults. They will match I guess,
but just make it sure. Otherwise, maybe what you need is best support for
date constraints, and that is another subject.

   Keep tunned. As the pieces start to come to their places now, we will be
releasing more info on our CEP support.

   Cheers,
   Edson


2008/8/19 David Boaz [EMAIL PROTECTED]


 Dear all,

 We posted this question two weeks ago, but with no replies. please forgive
 me for posting it again.

 In our business, most of the facts have time-stamp attributes. For example,
 each laboratory test (a fact) has the time stamp when the sample was taken,
 and when the machine produced the result value. In our business-logic, we
 often analyze the relation between facts using these attributes.

 For example:
 1) finding two adjacent labResults with an increasing value
 2) checking whether 3 facts are consecutive
 3) counting the number of facts fulfilling a specific constraint within a
 specific time window.

 We were happy to read (in the blog) about the new CEP feature which is
 about
 to be added to drools 5.0.

 * Where can we find a more detailed description of CEP functionality in
 drools?
 * Is it a good idea to use CEP for analyzing historic data (retrieved from
 the database)? or is it best for online data.
 * Can we use CEP in a stateless session?
 * As we understand, CEP attaches to each fact a temporal attribute of the
 assertion time. Can we define that a particular attribute (e.g.,
 LabResult.samplingDate) will be used as the time stamp? Or, should we
 assert
 the facts by their temporal order, and advance the session-clock
 appropriately?
 * Can we use CEP to analyze the data in the examples above?

 Many thanks for the help, David
 --
 View this message in context:
 http://www.nabble.com/CEP-functionality-tp19020709p19020709.html
 Sent from the drools - user mailing list archive at Nabble.com.

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
Edson Tirelli
JBoss Drools Core Development
JBoss, a division of Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Fire rule only when all the fact objects sent during a specific period match the WHEN part

2008-08-19 Thread Edson Tirelli
   Ok, your case seems clearly a case where you need either a
StatefulSession or your application needs to send previous readings to
drools.
   If you are using a StatefulSession AND you always use the same SystemInfo
object (just use update on it), you could use duration on your rule:

rule Start_New_Process_If_System_is_70%_Idle_Continuously_for_60_Seconds
   duration 6
when
SystemInfo (idle = 70)  //Idle continuously for 60 seconds
then
// start new process
end

   Using StatelessSession, you must have an update rule for your object

rule System_is_70%_Idle
salience 10
when
$si : SystemInfo (idle = 70)
then
$si.setIdleCounter( $si.getIdleCounter() + 1 );
end

rule Start_New_Process_If_System_is_70%_Idle_Continuously_for_60_Seconds
when
SystemInfo( idleCounter = 12)
then
// start new process
end

   []s
   Edson

2008/8/19 ganesh.p [EMAIL PROTECTED]


 I need to create a rule with following requirements:

 There is a fact class called SystemInfo which contains idle information of
 a
 sytem

 public class SystemInfo {
private double idle; //System idle percentage

public void setIdle(double idle) {
this.idle = idle;
}

public double getIdle() {
return this.idle;
}
 }


 The SystemInfo objects are continuously sent to DROOLS (StatelessSession)
 with 5 second delay.

 I need to create a rule


 rule Start_New_Process_If_System_is_70%_Idle_Continuously_for_60_Seconds

 when SystemInfo (idle = 70)  //Idle continuously for 60 seconds
 then
  // start new process

 end


 I need to fire this rule only if all the 12 SystemInfo objects which are
 sent with 5 seconds delay for 60 seconds, match the condition idle = 70.
 Even if a single SystemInfo doesn't match this condition then this rule
 shouldn't be fired.

 I am using DROOLS 4.0. Please help me in implementing the WHEN condition.

 Thanks
 -Ganesh
 --
 View this message in context:
 http://www.nabble.com/Fire-rule-only-when-all-the-fact-objects-sent-during-a-specific-period-match-the-WHEN-part-tp19029247p19029247.html
 Sent from the drools - user mailing list archive at Nabble.com.

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
Edson Tirelli
JBoss Drools Core Development
JBoss, a division of Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Check if a pattern binding exists in the RHS

2008-08-19 Thread Edson Tirelli
   This is a surprise for me, because you should get a compilation error for
that. What version of Drools are you using?

   Anyway, you can't do that. When you use or, Drools will internally
create one subrule for each logical branch in your LHS. So, any variable you
use in the RHS must be bound in all possible logical branches.

   []s
   Edson

2008/8/19 hatzlj [EMAIL PROTECTED]


 Hello everybody,

 on the LHS of my rule i connect several Conditions with OR and have
 different variable bindings for this Condition. Now - if any of this
 conditions does not fire, i assume that the binding variable is not
 created,
 so I can't access it in the RHS. This results in an null pointer exception
 when I call the fireAllRules-Command in my Java Application.

 A simple rule example:
 rule Rule 1
   when
  HKT: Parameter(parameterCode = HKT, value  normalFloor) or
  GGT: Parameter(parameterCode = GGT, value  normalFloor) or
  HSR: Parameter(parameterCode = HSR, value  normalFloor) and
  GOT: Parameter(parameterCode = GOT, value  normalFloor)

   then
  System.out.println(HKT.toString();

 end

 So my Question is: Is there any way to check in the RHS wheter the pattern
 binding has been created or not or do i have to change the way of writing
 my
 rules (which i do not want to)?

 thanks,
 hatzlj
 --
 View this message in context:
 http://www.nabble.com/Check-if-a-pattern-binding-exists-in-the-RHS-tp19032260p19032260.html
 Sent from the drools - user mailing list archive at Nabble.com.

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
Edson Tirelli
JBoss Drools Core Development
JBoss, a division of Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] some basic questions to grouping

2008-08-19 Thread Edson Tirelli
1. when you are saying rules fire, does this mean: matching/checking the
LHS of rule, or executing the RHS of rule

Means execute the RHS. The LHS of the rules is evaluated at assert time.
Take a look at the docs for more info on that.

2. I plan to use the grouping features of drools, but still not sure..

First a quick explanation:
* agenda-groups allow you to control in what order rules are **fired**,
because only rules from the active agenda-group are allowed to fire.
* activation-groups allow you to create mutually exclusive rules, because
when a rule in an activation-group **fires**, it cancel all other
activations in the same group.

None of it is what you want. In fact, you should not worry about the cases
you described. Just write your patterns and constraints in the same order as
much as possible, and also always write more constraining patterns  before
the more general patterns and let the engine do its magic.

If you have 1 rule where gender is Gender.MALE, and 1000 rules where it is
Gender.FEMALE and you assert a male (or female, dos not matter) Person, the
engine will execute the condition only twice, because it shares the
Gender.FEMALE constraint among all the rules, assuming you write the
constraints in the same order. An even more interesting situation is:
pretend you have some kind of discriminating attribute for person, like
countryOfBirth, and you have 100 rules for each country that you have to
handle (lets say 100). So, you have 100 x 100 = 1 rules:

Rule x1 when Person( countryOfBirth == Country.CANADA...
...
Rule x500 when Person( countryOfBirth == Country.BRAZIL...
...

Guess how many times that condition will be executed for a Person whose
country is CANADA (or any other country, does not matter)? Only **once**,
because of an optimization called alpha hashing.

Now range conditions are not hashed, but they still have node sharing, so as
long as you write them in the same order, they are still optimized. The only
problem you will have is if you start using accumulate and collect, that are
really expensive in terms of performance. In cases like that, you will need
a manual optimization, but it is still doable.

   Hope it helps.

 Edson


2008/8/19 psentosa [EMAIL PROTECTED]


 Hi,

 I'm having some difficulty to understand the concept of grouping, but maybe
 it's only because of my understanding of the terms, so please apologize for
 the silly question
 1. when you are saying rules fire, does this mean: matching/checking the
 LHS of rule, or executing the RHS of rule

 2. I plan to use the grouping features of drools, but still not sure
 whether(and how) to use the agenda or activation group (or even the
 rule-flow). My problem domain is actually quite simple:
 - rules are applied based on e.g age of a person. Now, there are some rules
 for 17-year-or older, and some for 30-year-old person, if I'm to use the
 agenda group, I'd define the following:

 rule1
 agenda-group 17 years-old or older
 when
 p:Person (Age  17)
 

 rule2
 agenda-group 17 years-old or older
 when
 p:Person (Age  17)
 .

 rule3
 agenda-group 30 years-old or older
 when
 p:Person (Age  30)
 ..

 rule4
 agenda-group 30 years-old or older
 when
 p:Person (Age  30)
 ..

 If I assert a person into the WM to check his/her age, I want that only the
 rules in 30-years-old agenda are CHECKED (and eventually executed when the
 other constraints are fulfilled), bcs they are surely older than 17 as
 well.
 And this is not only for comparing ages. Another example, some rules are
 only for Gender.MALE, and some only for Gender.FEMALE. So if a person is
 asserted, only the rules with corresponding gender will be checked and no
 need of checking/matching the other group
 The main purpose is just to skip checking unrelevant rules (imagine if
 there
 is only 1 rule for MALE and 1000 rules for FEMALE with 1000 times WHEN
 person (gender == FEMALE) checking for an asserted male-object).
 How can I do this effectively? Or will ALL rules checked and only the order
 of checking (and eventually exection of their RHS) is defined by the
 grouping?

 I hope I've described my problem clearly and I'll try to explain this again
 in case of difficulty :)
 Thanks in advance

 Regards


 --
 View this message in context:
 http://www.nabble.com/some-basic-questions-to-grouping-tp19048066p19048066.html
 Sent from the drools - user mailing list archive at Nabble.com.

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
Edson Tirelli
JBoss Drools Core Development
JBoss, a division of Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] some basic questions to grouping

2008-08-19 Thread Kris Nuttycombe
Thanks for your very informative reply, Edson! I hadn't picked up on
the significance of stating conditions in the same order from the
Drools documentation.

Kris

On Tue, Aug 19, 2008 at 7:14 AM, Edson Tirelli [EMAIL PROTECTED] wrote:

 1. when you are saying rules fire, does this mean: matching/checking the
 LHS of rule, or executing the RHS of rule

 Means execute the RHS. The LHS of the rules is evaluated at assert time.
 Take a look at the docs for more info on that.

 2. I plan to use the grouping features of drools, but still not sure..

 First a quick explanation:
 * agenda-groups allow you to control in what order rules are **fired**,
 because only rules from the active agenda-group are allowed to fire.
 * activation-groups allow you to create mutually exclusive rules, because
 when a rule in an activation-group **fires**, it cancel all other
 activations in the same group.

 None of it is what you want. In fact, you should not worry about the cases
 you described. Just write your patterns and constraints in the same order as
 much as possible, and also always write more constraining patterns  before
 the more general patterns and let the engine do its magic.

 If you have 1 rule where gender is Gender.MALE, and 1000 rules where it is
 Gender.FEMALE and you assert a male (or female, dos not matter) Person, the
 engine will execute the condition only twice, because it shares the
 Gender.FEMALE constraint among all the rules, assuming you write the
 constraints in the same order. An even more interesting situation is:
 pretend you have some kind of discriminating attribute for person, like
 countryOfBirth, and you have 100 rules for each country that you have to
 handle (lets say 100). So, you have 100 x 100 = 1 rules:

 Rule x1 when Person( countryOfBirth == Country.CANADA...
 ...
 Rule x500 when Person( countryOfBirth == Country.BRAZIL...
 ...

 Guess how many times that condition will be executed for a Person whose
 country is CANADA (or any other country, does not matter)? Only **once**,
 because of an optimization called alpha hashing.

 Now range conditions are not hashed, but they still have node sharing, so as
 long as you write them in the same order, they are still optimized. The only
 problem you will have is if you start using accumulate and collect, that are
 really expensive in terms of performance. In cases like that, you will need
 a manual optimization, but it is still doable.

Hope it helps.

  Edson


 2008/8/19 psentosa [EMAIL PROTECTED]

 Hi,

 I'm having some difficulty to understand the concept of grouping, but
 maybe
 it's only because of my understanding of the terms, so please apologize
 for
 the silly question
 1. when you are saying rules fire, does this mean: matching/checking the
 LHS of rule, or executing the RHS of rule

 2. I plan to use the grouping features of drools, but still not sure
 whether(and how) to use the agenda or activation group (or even the
 rule-flow). My problem domain is actually quite simple:
 - rules are applied based on e.g age of a person. Now, there are some
 rules
 for 17-year-or older, and some for 30-year-old person, if I'm to use the
 agenda group, I'd define the following:

 rule1
 agenda-group 17 years-old or older
 when
 p:Person (Age  17)
 

 rule2
 agenda-group 17 years-old or older
 when
 p:Person (Age  17)
 .

 rule3
 agenda-group 30 years-old or older
 when
 p:Person (Age  30)
 ..

 rule4
 agenda-group 30 years-old or older
 when
 p:Person (Age  30)
 ..

 If I assert a person into the WM to check his/her age, I want that only
 the
 rules in 30-years-old agenda are CHECKED (and eventually executed when the
 other constraints are fulfilled), bcs they are surely older than 17 as
 well.
 And this is not only for comparing ages. Another example, some rules are
 only for Gender.MALE, and some only for Gender.FEMALE. So if a person is
 asserted, only the rules with corresponding gender will be checked and no
 need of checking/matching the other group
 The main purpose is just to skip checking unrelevant rules (imagine if
 there
 is only 1 rule for MALE and 1000 rules for FEMALE with 1000 times WHEN
 person (gender == FEMALE) checking for an asserted male-object).
 How can I do this effectively? Or will ALL rules checked and only the
 order
 of checking (and eventually exection of their RHS) is defined by the
 grouping?

 I hope I've described my problem clearly and I'll try to explain this
 again
 in case of difficulty :)
 Thanks in advance

 Regards


 --
 View this message in context:
 http://www.nabble.com/some-basic-questions-to-grouping-tp19048066p19048066.html
 Sent from the drools - user mailing list archive at Nabble.com.

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users



 --
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.com

 

Re: [rules-users] Drools 3.0.6 support for enum's on jdk 1.5 ?

2008-08-19 Thread Mark Proctor

Kris Nuttycombe wrote:

It's been a few days since this question was asked, and I am also
interested in the answer. I'm currently using an eval to get around
the problem, but is there any way to check enum equivalence directly
in drools?
  
I beleive it'll work with primitive enums (int), but not enum classes. 
If you tried it and it doesn't work, probably safe to assume it doesn't 
support it :)


Mark

Thanks,

Kris

On Wed, Aug 13, 2008 at 2:42 PM, Maxim Veksler [EMAIL PROTECTED] wrote:
  

Hello list,

I have a rule that generally speaking looks like this :

rule ABC
when
$f : FilteringStateConnector($campaignId : campaignId)


$campaign : Campaign(code == $campaignId
,$limitTypeEnum : limitTypeEnum, $limitByEventType :
limitByEventType)


 // Check Budget limit pass conditions:
(
eval(BooleanLogging.trace(log,DEBUG:  + ($limitTypeEnum ==
ENUM1.BudgetLimitFlag))) and
eval(BooleanLogging.trace(log,DEBUG: Always here, right now))
and
eval(BooleanLogging.trace(log,DEBUG:  + ($limitByEventType ==
ENUM2._2_EXPOSED))) and

Campaign(code == $campaignId, limitTypeEnum ==
ENUM1.BudgetLimitFlag, limitByEventType ==  ENUM2._2_EXPOSED) and

eval(BooleanLogging.trace(log,DEBUG: Right here, right now))

) or (
...
)

then
...
end



The line eval(BooleanLogging.trace(log,DEBUG:  +
($limitTypeEnum == ENUM1.BudgetLimitFlag)))  evaluates to true in the
logs.
The line eval(BooleanLogging.trace(log,DEBUG:  +
($limitByEventType == ENUM2._2_EXPOSED)))  as well. These are java (eval)
checks for truth. If I try to use Drools to gain the rete optimization by
writing :
Campaign(code == $campaignId, limitTypeEnum ==
ENUM1.BudgetLimitFlag, limitByEventType ==  ENUM2._2_EXPOSED)  , It never
reachers past that line. why is that? Can't Drools 3 check for truthness of
Enum conditionals ?


I would love to supply more information if required.



Help is highly appreciated,
Maxim.

--
Cheers,
Maxim Veksler

Free as in Freedom - Do u GNU ?

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users




___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

  


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Drools error messages no very useful.

2008-08-19 Thread samd

Alright so I'm new to Drools and I get this error message.

  [testng] org.drools.rule.InvalidRulePackage: [0,-1]: unknown:0:-1
mismatched token: [EMAIL PROTECTED],0:0='no text
,-1,0:-1]; expecting type RIGHT_PAREN

What is this supposed to mean?

The Drools editor in Eclipse does not show any errors.
-- 
View this message in context: 
http://www.nabble.com/Drools-error-messages-no-very-useful.-tp19054317p19054317.html
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Drools Eclipse Editor

2008-08-19 Thread samd

I find the Editor does not pick up many errors and I need to rely on the
compiler most of the time which can be time consuming. 

Has anyone else experienced this?
-- 
View this message in context: 
http://www.nabble.com/Drools-Eclipse-Editor-tp19054433p19054433.html
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] some basic questions to grouping

2008-08-19 Thread Edson Tirelli
1. Rete network is built at rulebase compile time, i.e., when you add
packages to the Rulebase:

ruleBase.addPackageFromDrl( ... ); // and similar API calls

   At assert time, the facts are propagated and when you call
fireAllRules(), active rules are fired.

2. These are part of the internal optimization algorithms. Let me try to
simplify things, but talking about 2 optimizations we have:

* node sharing: every time you have the same condition (even among different
rules), the engine will try to share them, so that you have it executed only
once. Writing conditions in the same order helps to achieve this. So, for
the first example, when you have the Gender constraints, it will share the
Gender.FEMALE constraints among the 1000 rules and will execute it only
once. The Gender.MALE constraint is also executed once, and then you have 2
executions in total.

* alpha hashing: this is a bit more complicate, but when you have mutually
exclusive constraints on the same field, you know that only one of them is
correct. So, if you have 100 different constraints like this:

Person( countryOfBirth == Country.CANADA...
Person( countryOfBirth == Country.BRAZIL...

You know that only one of them will be true. The engine detects that and
instead of evaluating every constraint, where 99 of them will fail, it will
hash all the constraints.
Then, when a fact is asserted (lets say contryOfBirth is BRAZIL), instead of
going through all the constraints, it applies the hash function on the
attribute value (BRAZIL) and knows where the constraint is. So it will only
evaluate that constraint and forget about the others, since they will fail
anyway.

Having said that, the first example (gender) is also mutually exclusive, but
there are only 2 possible values. What happens is that there is a cost to
calculate the hash value on the alpha hashing optimization and the cost does
not pay off if you have only 2 possible values. In fact, after doing some
research we found that the ideal cardinality to activate the alpha hashing
optimization is 3, but that is a parameter you can configure using
RuleBaseConfiguration (either by API or by a system property). So, by
default, that optimization only kicks in when you have 3 or more possible
values (like the country of birth) and not with 2 or less (like gender).

3. Sorry, I don't see your attachement. But anyway, rule-flow, agenda-groups
and etc are used to control rule firing order, not rule evaluation. Rete
will evaluate your rules eagerly, even if your group is not active. In your
case, with mutually exclusive constraints in your patterns, you should not
worry about that. Let the engine optimize the matching for you. If you find
performance problems, then come back and we can see if there is any
sub-optimal rules in your rule set. Until then, don't worry with it.

[]s
Edson

2008/8/19 psentosa [EMAIL PROTECTED]


 Jakob, Edson, thanks a lot for your replies especially on agenda vs
 activation-group :)

 But please allow me to ask some further questions:
 1. The LHS of the rules is evaluated at assert time.
 When is actually the RETE network built? On assertion, will a fact then be
 propagated over the network?

 2. The example with Gender and countryOfBirth:
For the gender example, you said the condition will be executed only
 twice. So I assumed it's because there are 2 possibilities of gender. But
 the example with countryOfBirth with 100 possibilities, why only once?

 3. Back to my problem I described before:
   Before I read your reply (Edson's), I try to follow the suggestion from
 Jakob, namely using the ruleflow-group. So I came up with a the
 ruleflow-graph I attached (please have a look if you don't mind)
 http://www.nabble.com/file/p19053522/regulation-check.rfm
 regulation-check.rfmhttp://www.nabble.com/file/p19053522/regulation-check.rfmregulation-check.rfm.
  I try to describe the following hierarchy:
 There are certain rules only for young people; if they are older, than it
 will be checked, whether he/she is a male/female. Another group of rules is
 only valid for females, the rest of the rules are valid for both male and
 female. does the graph correspond correctly to the problem I describe? Is
 it
 better to use such grouping or like you said, just write my patterns and
 constraints as much as possible (without the grouping)?
 Again thanks in advance!

 Regards




 Edson Tirelli-3 wrote:
 
  1. when you are saying rules fire, does this mean: matching/checking
 the
  LHS of rule, or executing the RHS of rule
 
  Means execute the RHS. The LHS of the rules is evaluated at assert
 time.
  Take a look at the docs for more info on that.
 
  2. I plan to use the grouping features of drools, but still not sure..
 
  First a quick explanation:
  * agenda-groups allow you to control in what order rules are **fired**,
  because only rules from the active agenda-group are allowed to fire.
  * activation-groups allow you to create mutually exclusive rules, because
  when a rule 

Re: [rules-users] Drools error messages no very useful.

2008-08-19 Thread Edson Tirelli
   Well, for 5.0 we rewrote the parser from scratch with much improved error
messages... :)

   Anyway, in your case, are you using DSL? I saw this error before when
someone was using a DSL, but calling the DRL API. I.e, they were doing:

builder.addPackageFromDrl( drlsource );

   instead of the correct (when using DSL):

builder.addPackageFromDrl( drlsource, dslsource );

   []s
   Edson

2008/8/19 samd [EMAIL PROTECTED]


 Alright so I'm new to Drools and I get this error message.

  [testng] org.drools.rule.InvalidRulePackage: [0,-1]: unknown:0:-1
 mismatched token: [EMAIL PROTECTED],0:0='no text
 ,-1,0:-1]; expecting type RIGHT_PAREN

 What is this supposed to mean?

 The Drools editor in Eclipse does not show any errors.
 --
 View this message in context:
 http://www.nabble.com/Drools-error-messages-no-very-useful.-tp19054317p19054317.html
 Sent from the drools - user mailing list archive at Nabble.com.

 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users




-- 
Edson Tirelli
JBoss Drools Core Development
JBoss, a division of Red Hat @ www.jboss.com
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Using nested properties on guided editor

2008-08-19 Thread Vinicius Carvalho
Hello there! I'm trying Guvnor 5.0M1  (really nice :)) after reading :
http://blog.athico.com/2008/08/machine-learning-and-apache-mahout.html

I thought I could use nested objects in my rules. For instance, I have a
technical rule:

when
$t: Trabalho( situacao.dscSituacao == AGUARDANDO APROVAÇÃO )
Situacao( dscSituacao == EM APROVAÇÃO )
then
$t.setSituacaoValida(true);

But I can't find a way to bind this using guided editor. I add the fact
Trabalho, bind it to $t variable, but when selecting a restriction to a
field, it ends on situacao, not letting me navigate deeper on the graph. Is
this possible? Do I need a latest version on the SVN in order to use this?

Best Regards

-- 
In a world without fences and walls, who needs Gates and Windows?
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] new user - running examples

2008-08-19 Thread Marcin Krol

Hello everyone,

I am totally new to Drools (I have basic exposure to Java, nothing 
more), hope that someone helps me with the following problem:


I have successfully imported Eclipse plugin and ran the DroolTest.java 
example in Eclipse Europa (it worked OK). Then I imported Eclipse 
example (4.0.7) project into Eclipse workspace.



But most of .drl files show error markers with messages like:

Rule 01:Unable to resolve ObjectType 'Cashflow'  (example4.drl)

Now when I try to run Example4.java, I get the error:

The project: drools-compiler which is referenced by the classpath, 
does not exist.



In Eclipse: menu Project | Properties | Java Build Path | Projects tab 
shows drools-core and drools-compiler with yellow warning icons. Button 
Edit is grayed out, there's nothing I can do to fix those items.


I have added drools-core-4.0.7.jar and drools-compiler-4.0.7.jar in Add 
External JARs on Libraries tab, but this does nothing to resolve the 
problem.


How do I fix those problems so I can run examples?

Regards,
Marcin


___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Why can't I filter in my testcases?

2008-08-19 Thread samd

I'm seeing where I do something like this:

 @Test( groups = { submissionTests } )
   public void ifBoWarnOfValidationRules()
   {
  ...
  workingMemory.fireAllRules( new RuleNameStartsWithAgendaFilter(
FIFTEEN ) );
   }

Other rules that do not begin with FIFTEEN also fire. It is really annoying
since it results in my testcases failing.
-- 
View this message in context: 
http://www.nabble.com/Why-can%27t-I-filter-in-my-testcases--tp19059402p19059402.html
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Why can't I filter in my testcases?

2008-08-19 Thread samd

Actually this appears to happen when I'm asserting into memory.

[testng] org.drools.RuntimeDroolsException: java.lang.NullPointerException
[testng] at
org.drools.rule.EvalCondition.isAllowed(EvalCondition.java:75)
[testng] at
org.drools.reteoo.EvalConditionNode.assertTuple(EvalConditionNode.java:141)
[testng] at
org.drools.reteoo.CompositeTupleSinkAdapter.propagateAssertTuple(CompositeTupleSinkAdap
.java:30)
[testng] at org.drools.reteoo.JoinNode.assertTuple(JoinNode.java:120)
[testng] at
org.drools.reteoo.SingleTupleSinkAdapter.createAndPropagateAssertTuple(SingleTupleSinkA
ter.java:55)
[testng] at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.java:131)
[testng] at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObjectSinkAdapter
va:20)
[testng] at
org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:160)
[testng] at org.drools.reteoo.Rete.assertObject(Rete.java:176)
[testng] at
org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:196)
[testng] at
org.drools.reteoo.ReteooWorkingMemory.doInsert(ReteooWorkingMemory.java:70)
[testng] at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:854)
[testng] at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:826)
[testng] at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:627)



samd wrote:
 
 I'm seeing where I do something like this:
 
  @Test( groups = { submissionTests } )
public void ifBoWarnOfValidationRules()
{
   ...
   workingMemory.fireAllRules( new RuleNameStartsWithAgendaFilter(
 FIFTEEN ) );
}
 
 Other rules that do not begin with FIFTEEN also fire. It is really
 annoying since it results in my testcases failing.
 

-- 
View this message in context: 
http://www.nabble.com/Why-can%27t-I-filter-in-my-testcases--tp19059402p19059745.html
Sent from the drools - user mailing list archive at Nabble.com.

___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users