Re: [rules-users] Identify Rule on Attributes

2009-03-16 Thread Wolfgang Laun
On Mon, Mar 16, 2009 at 6:24 AM, Nikhil_dev k.nik...@verchaska.com wrote:


 As you guys have suggested to combine all the rule base into one then for
 example(one which i have already mentioned)
 i will combine Rule1 , rule 2 and rule3 into 1 rule base then, when i pass
 the variables to the rulebase who will i come to know which rules were
 executed.


Knowing (as you say) about the execution of rules may be used by the
system you build in several ways. In any case, the right hand side of a
rule (after the when keyword) is the place to program the actions
that preserve the knowledge that this rule has fired. If nothing is done
on the right hand side, then the effect of the execution of a rule is
indeed lost.

The most important ways of making use of the firing of a rule are:

(1) To assert a (new) fact into the Working Memory. This is done if
one expects these new facts to combine with each other or the original
facts in more rule firings.

(2) To modify an existing fact that has been found (matched) by
the rule. This may, in turn, fire other rules.

(3) To make use of some application service to inform the user
of your system that the system has concluded a result. A very
simple way would be to print a message on the terminal; a more
sophisticated way might be to send a message; etc.

Certainly any combination of these basic techniques is to be
considered as well.

You have, so far, shown us examples of very simple rules; it is
not clear to me what the purpose of this system will ultimately be.
Therefore, I cannot advise you about what is best in your case.


 things i would like to know if i am going to execute this idea, the number
 of rules that i will using say around 10, is it advisable to include
 all
 of them in to 1 rulebase!!!
 will there be any performance issues.


Performance is not only a question of the number of rules; it is also
a question of the quality of the conditions, the number of patterns and
the number of facts that are asserted.

10 rules is certainly a big number. Memory consumption will
be high. Loading facts and firing depends on the way patterns are
written, and how many facts you'll have in a session. But for me
the main point is how you'll manage to produce this many rules.
Even if you manage to think up, write and test one rule per minute
then this would take 1666 hours or about 10 months of work!
Moreover, you'll have to make sure that this set of rules is consistent
in their combination, e.g., that it doesn't miss a combination of facts
that it should react upon.

To build a good rule based system isn't easier than building any other
complex software system; perhaps it is even more difficult. There are
some good books around that describe the designs that might be applied
with such systems; some of them are referenced on this page:
http://www.jboss.org/drools/documentation.html

-W





 Anstis, Michael (M.) wrote:
 
  Furthermore a rulebase can contain rules from many resources (e.g.
  DRL's).
 
  So I guess the cause of your pain is why do you need multiple
  rulebases!??!
 
  -Original Message-
  From: rules-users-boun...@lists.jboss.org
  [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Scott Reed
  Sent: 13 March 2009 14:41
  To: Rules Users List
  Subject: Re: [rules-users] Identify Rule on Attributes
 
  A RuleBase can contain many rules, not just one. Generally we take all
  the rules we need for an application and we assemble them into one
  rulebase, so we don't have to figure out which rulebase to use. Does
  that help?
 
  Nikhil_dev [3/13/2009 8:16 AM] wrote:
  Perfect this is the situation but the only difference is the last
  part,
 
  Rulebase for all the 3 Rules are stored in memory.
 
  Now i have is attributes(implemented as bean class), but the issue is
  i dont
  know which Rulebase to use out of the three which is present in the
  memory,
  fetching them one by one and executing it individually is possible but
  a
  long procedure which i want to avoid.(executing 3 Rule is ok what if i
  have
  10 rules it will be very slow process)
 
  ___
  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
 
 


 -
 Regards,
 :working:Nikhil
 --
 View this message in context:
 http://www.nabble.com/Identify-Rule-on-Attributes-tp22471473p22532090.html
 Sent from the drools - user mailing list archive at Nabble.com.

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

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


[rules-users] single binding for or CE flagged by compiler

2009-03-16 Thread Wolfgang Laun
As far as I know, this should work:

package orel;
import orel.Main.Trigger;
rule ror1
when
$t : (or Trigger(fa == 1)
 Trigger(fa == 2))
then
System.out.println( fired  + $t.getName() );
end

This is what Drools-5.0.0 kbuilder.getErrors().toString() returns:

[5,11]: [ERR 102] Line 5:11 mismatched input 'Trigger' expecting '(' in rule
ror1 in pattern or[6,14]: [ERR 102] Line 6:14 mismatched input 'Trigger'
expecting ')' in rule ror1[6,30]: [ERR 102] Line 6:30 mismatched input ')'
expecting 'then' in rule ror1

Shouldn't toString() insert line ends? As it is, the result is pretty much
useless.

This works:
rule ror1
when
(or $t : Trigger(fa == 1)
$t : Trigger(fa == 2))
then
System.out.println( fired  + $t.getName() );
end

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


RE: [rules-users] Identify Rule on Attributes

2009-03-16 Thread Knapp, Barry
You should create a new class that implements AgendaEventListener and
then add it to your execution session.  The snippet below shows how to
add the listener to the session if you create a new class called
ExecutionAgendaEventListener.  This is 4.7, probably pretty similar
concept in 5.


StatelessSession session =
ruleBase.newStatelessSession();

//add agenda event listener to capture the fired rules
session.addEventListener(new
ExecutionAgendaEventListener());






-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Nikhil_dev
Sent: Monday, March 16, 2009 1:25 AM
To: rules-users@lists.jboss.org
Subject: RE: [rules-users] Identify Rule on Attributes


As you guys have suggested to combine all the rule base into one then
for
example(one which i have already mentioned)
i will combine Rule1 , rule 2 and rule3 into 1 rule base then, when i
pass
the variables to the rulebase who will i come to know which rules were
executed.
things i would like to know if i am going to execute this idea, the
number
of rules that i will using say around 10, is it advisable to include
all
of them in to 1 rulebase!!! 
will there be any performance issues.



Anstis, Michael (M.) wrote:
 
 Furthermore a rulebase can contain rules from many resources (e.g.
 DRL's).
 
 So I guess the cause of your pain is why do you need multiple
 rulebases!??! 
 
 -Original Message-
 From: rules-users-boun...@lists.jboss.org
 [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Scott Reed
 Sent: 13 March 2009 14:41
 To: Rules Users List
 Subject: Re: [rules-users] Identify Rule on Attributes
 
 A RuleBase can contain many rules, not just one. Generally we take all

 the rules we need for an application and we assemble them into one 
 rulebase, so we don't have to figure out which rulebase to use. Does 
 that help?
 
 Nikhil_dev [3/13/2009 8:16 AM] wrote:
 Perfect this is the situation but the only difference is the last
 part,

 Rulebase for all the 3 Rules are stored in memory.

 Now i have is attributes(implemented as bean class), but the issue is
 i dont
 know which Rulebase to use out of the three which is present in the
 memory,
 fetching them one by one and executing it individually is possible
but
 a
 long procedure which i want to avoid.(executing 3 Rule is ok what if
i
 have
 10 rules it will be very slow process)
   
 ___
 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
 
 


-
Regards,
:working:Nikhil
-- 
View this message in context:
http://www.nabble.com/Identify-Rule-on-Attributes-tp22471473p22532090.ht
ml
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
This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom they are addressed. If 
you have received this email in error please notify the system manager. This 
message contains confidential information and is intended only for the 
individual named. If you are not the named addressee you should not 
disseminate, distribute or copy this e-mail.

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


RE: [rules-users] single binding for or CE flagged by compiler

2009-03-16 Thread Hehl, Thomas
Not getting into whether this is a bad practice, the only language I've
ever seen support this syntax is COBOL. Every other language I've worked
in (and there are many) do not support this technique, so it seems
reasonable that this syntax should be disallowed in drools as well.

 



From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Edson Tirelli
Sent: Monday, March 16, 2009 9:58 AM
To: Rules Users List
Subject: Re: [rules-users] single binding for or CE flagged by compiler

 


   This is an old discussion. Single binding on or is a non-orthogonal
special case on the language syntax that was introduced in the early
days when we only had infix CEs. When we started to support prefix CE,
the special case was not updated, and as a result, the single binding
works only with infix.

   IMO, this syntax promotes bad practices and should be disallowed.
Although, some people like it and it is still in there. Just to clarify
why I think it promotes bad practice:

* When you have the same object type for all the patterns inside an or
group, you should be using constraint connector ||, not the or CE.
Using your example:

$t : Trigger( fa == 1 || == 2 ) // or any variation of the syntax.

   This keeps the network smaller and prevents unexpected behavior when
the constraints are not mutually exclusive and in some cases people
forget that the rule will fire once for each logical branch when using
or.

* If the object types are different, then you can't use single binding
anyway:

$o  : ( Cheese() or Wine() ) // this will lead to ClassCastExceptions on
the usage of $o.

   So, I really think that the single binding or fulfilled its purpose
on Drools 3, when we didn't had all the flexibility in the language we
have today. But now, the only thing it achieves is promoting bad
practices.

   Just my 0.02c.

   []s
   Edson

2009/3/16 Wolfgang Laun wolfgang.l...@gmail.com

As far as I know, this should work:

package orel;
import orel.Main.Trigger;
rule ror1
when
$t : (or Trigger(fa == 1)
 Trigger(fa == 2))
then
System.out.println( fired  + $t.getName() );
end

This is what Drools-5.0.0 kbuilder.getErrors().toString() returns:

[5,11]: [ERR 102] Line 5:11 mismatched input 'Trigger' expecting '(' in
rule ror1 in pattern or[6,14]: [ERR 102] Line 6:14 mismatched input
'Trigger' expecting ')' in rule ror1[6,30]: [ERR 102] Line 6:30
mismatched input ')' expecting 'then' in rule ror1

Shouldn't toString() insert line ends? As it is, the result is pretty
much useless.

This works:
rule ror1
when
(or $t : Trigger(fa == 1)
$t : Trigger(fa == 2))
then
System.out.println( fired  + $t.getName() );
end

-W


___
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] Drools Boot Camp and San Francisco

2009-03-16 Thread Mark Proctor
I'm still trying to get budget approval. We are looking at the Hilton at 
the moment as expedia have rooms at $103 per day, which is very good 
value. I can get travel and room budget for my team, but not meeting 
room budget. The meeting room is $400 per day, I might be able to 
negotiate a little off that, and we will need sponsors to cover the 
price of the meeting room for the week, if this is to go ahead.


We are looking at a date range of:
arriving - 31 of May
departure - 8th of June

So we'll need a room from the 1st to the 7th, inclusive. If you are able 
to sponsor the meeting room for a day or two, or more :), please do let 
me know as soon as possible.


Thanks

Mark

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


Re: [rules-users] Problem with updated facts

2009-03-16 Thread thomas moncieu
Hi, these are the rules :

Rule A :

rule ID_15202
ruleflow-group RG_A
when
i : Item(name==cheese)
t : Bill(anItem==i);
then
t.setAmount(t.getAmount() - 100);
update(t);
end

Rule B:

rule ID_15203
ruleflow-group RG_T
when
t : Bill($amount : totalAmount,  totalAmount  (new
Double(150.0).doubleValue()));
then
System.out.println(tot :  + $tot);
end

It gives the correct result if shadow proxy is turned on.

But all the rules are re-evaluated with the update(t). Is there another way
that no-loop or lock-on-active that prevents from re-evaluating all the
rules  ?

Thanks for your interest

2009/3/12 surya_n2007 surya_n2...@yahoo.co.in


 Please post the complete rule where you are updating fact.
 --
 View this message in context:
 http://www.nabble.com/Problem-with-updated-facts-tp22458416p22477032.html
 Sent from the drools - user mailing list archive at Nabble.com.

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

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


[rules-users] Null safe MVEL expressions

2009-03-16 Thread Ingomar Otter

Folks,
it seems that since 2.0 MVEL supports null-safe MVEL expressions, ie.
fact.?property.subproperty == foo will evaluate to false (instead of  
failing) if property is null.
I tried this some time ago and  it seems that the drools parser does  
not like the ?.

Is anybody using this?

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


[rules-users] Missing libs for persistence in 5.0.0CR1

2009-03-16 Thread Petersen, Jan (CH Ext)
Hi

I have been trying to get persistence to work in 5.0.0CR1, but I have
noticed that many of libs decribed in the documentation (chapter 5.1.3)
are missing 

As they were present in M5 I'm just wondering why this is the case?

Best regards

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


RE: [rules-users] Identify Rule on Attributes

2009-03-16 Thread Greg Barton

Responses inline below.

--- On Mon, 3/16/09, Nikhil_dev k.nik...@verchaska.com wrote:

 From: Nikhil_dev k.nik...@verchaska.com
 Subject: RE: [rules-users] Identify Rule on Attributes
 To: rules-users@lists.jboss.org
 Date: Monday, March 16, 2009, 12:44 AM
 Greg,
 As of now the solutions that i have got from everyone in
 this forum are
 1. Greg : use a rules engine that implements rete the
 functionality.
 I couldn't any for the same on any drool
 doc that i have (gave you the link that i am referring to.)

If the verb missing in the sentence above is find then I don't think you 
searched hard enough:

http://downloads.jboss.com/drools/docs/4.0.7.19894.GA/html_single/index.html#d0e665

Take a few minutes to read section 2.4 Rete Algorithm which is directly 
linked above.  It specifically addresses how rules are selected to fire based 
on the state of your data.


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


Re: [rules-users] Problem with updated facts

2009-03-16 Thread Greg Barton

Not addressing your stated problem, but I have one question: why are you using 
this expression:  new Double(150.0).doubleValue()

Why not just use 150.0?

--- On Mon, 3/16/09, thomas moncieu thomas.monc...@gmail.com wrote:

 From: thomas moncieu thomas.monc...@gmail.com
 Subject: Re: [rules-users] Problem with updated facts
 To: Rules Users List rules-users@lists.jboss.org
 Date: Monday, March 16, 2009, 9:39 AM
 Hi, these are the rules :
 
 Rule A :
 
 rule ID_15202
 ruleflow-group RG_A
 when
 i : Item(name==cheese)
 t : Bill(anItem==i);
 then
 t.setAmount(t.getAmount() - 100);
 update(t);
 end
 
 Rule B:
 
 rule ID_15203
 ruleflow-group RG_T
 when
 t : Bill($amount : totalAmount,  totalAmount  (new
 Double(150.0).doubleValue()));
 then
 System.out.println(tot :  + $tot);
 end
 
 It gives the correct result if shadow proxy is turned on.
 
 But all the rules are re-evaluated with the update(t). Is
 there another way
 that no-loop or lock-on-active that prevents from
 re-evaluating all the
 rules  ?
 
 Thanks for your interest
 
 2009/3/12 surya_n2007 surya_n2...@yahoo.co.in
 
 
  Please post the complete rule where you are updating
 fact.
  --
  View this message in context:
 
 http://www.nabble.com/Problem-with-updated-facts-tp22458416p22477032.html
  Sent from the drools - user mailing list archive at
 Nabble.com.
 
  ___
  rules-users mailing list
  rules-users@lists.jboss.org
  https://lists.jboss.org/mailman/listinfo/rules-users
 
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


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


RE: [rules-users] Identify Rule on Attributes

2009-03-16 Thread Greg Barton

Of course there will be performance issues. :)  There are always performance 
issues.  But the whole point of the rete algorithm is to address some 
performance issues, specifically those created by needing to select the next 
rule to fire based on how your data changed.  

100k rules is a lot, but certainly within the capabilities of a rete based 
system.  One factor that would make that many rules easier to handle would be 
how homogeneous their conditions are.  Do the rules share many condition 
elements?  But in general systems of that size that need to deal with that many 
rules simultaneously are sequential. (i.e. they don't react to modification of 
the data)

Usually, though, you would not place 100k rules in one set.  As a rule of 
thumb, you place rules in one set if they have tight interaction. i.e. The 
firing of one rule generally triggers the firing of another.  This leads to 
rulesets that are formed around subject area, type of data processing, or stage 
of data processing.  Just from an application architecture standpoint, it 
probably wouldn't make sense to have that many rules all active at once.  

To form sets you basically have to ask this question for each rule: after this 
rule fires, what other rules will most likely fire?  Do that iteratively and 
add the resulting rules to a set.  Once the set stops growing you've probably 
found a good ruleset.

Also, there's no reason why you can't have a set of rules that decides what 
other rulesets should be routed to and/or loaded.  Drools also has many 
constructs not included in the original rete algorithm for deciding whether 
rules should fire: no-loop, agenda-group, etc.

Food for thought...

--- On Mon, 3/16/09, Nikhil_dev k.nik...@verchaska.com wrote:

 From: Nikhil_dev k.nik...@verchaska.com
 Subject: RE: [rules-users] Identify Rule on Attributes
 To: rules-users@lists.jboss.org
 Date: Monday, March 16, 2009, 12:24 AM
 As you guys have suggested to combine all the rule base into
 one then for
 example(one which i have already mentioned)
 i will combine Rule1 , rule 2 and rule3 into 1 rule base
 then, when i pass
 the variables to the rulebase who will i come to know which
 rules were
 executed.
 things i would like to know if i am going to execute this
 idea, the number
 of rules that i will using say around 10, is it
 advisable to include all
 of them in to 1 rulebase!!! 
 will there be any performance issues.
 
 
 
 Anstis, Michael (M.) wrote:
  
  Furthermore a rulebase can contain rules from many
 resources (e.g.
  DRL's).
  
  So I guess the cause of your pain is why do you need
 multiple
  rulebases!??! 
  
  -Original Message-
  From: rules-users-boun...@lists.jboss.org
  [mailto:rules-users-boun...@lists.jboss.org] On Behalf
 Of Scott Reed
  Sent: 13 March 2009 14:41
  To: Rules Users List
  Subject: Re: [rules-users] Identify Rule on Attributes
  
  A RuleBase can contain many rules, not just one.
 Generally we take all 
  the rules we need for an application and we assemble
 them into one 
  rulebase, so we don't have to figure out which
 rulebase to use. Does 
  that help?
  
  Nikhil_dev [3/13/2009 8:16 AM] wrote:
  Perfect this is the situation but the only
 difference is the last
  part,
 
  Rulebase for all the 3 Rules are stored in memory.
 
  Now i have is attributes(implemented as bean
 class), but the issue is
  i dont
  know which Rulebase to use out of the three which
 is present in the
  memory,
  fetching them one by one and executing it
 individually is possible but
  a
  long procedure which i want to avoid.(executing 3
 Rule is ok what if i
  have
  10 rules it will be very slow process)

  ___
  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
  
  
 
 
 -
 Regards,
 :working:Nikhil
 -- 
 View this message in context:
 http://www.nabble.com/Identify-Rule-on-Attributes-tp22471473p22532090.html
 Sent from the drools - user mailing list archive at
 Nabble.com.
 
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users


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


Re: [rules-users] single binding for or CE flagged by compiler

2009-03-16 Thread Wolfgang Laun
2009/3/16 Edson Tirelli tire...@post.com


This is an old discussion. Single binding on or is a non-orthogonal
 special case on the language syntax that was introduced in the early days
 when we only had infix CEs. When we started to support prefix CE, the
 special case was not updated, and as a result, the single binding works only
 with infix.


The example I've posted is practically identical to Example 7.55, or with
binding. So, if it's not in the language, it'd better not be in the
documentation :-)

As for the individual binding, as in
  (or $t : Trigger(fa == 1)
$t : Trigger(fa == 2))
the documentation ought to caution against using different names, at least
when these names are used on the RHS.

I agree that or groups with bindings on patterns are tricky. But is the form
that's now accepted by the compiler less error-prone than the one the
compiler refuses?

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


Re: [rules-users] iterating over objects in a StatelessKnowledgeSession

2009-03-16 Thread Mark Proctor

Michal Bali wrote:

Hi,

I am trying this on trunk. There is currently no way how to iterate 
objects in a StatelessKnowledgeSession.


I've tried to use the GetObjectsCommand, however when it is executes 
the result is lost in the ether :). The collection of objects is not 
handed back to the user.


I guess it should probably be added to the BatchExecutionResults? It 
will then be possible to access this collection of objects.
You have ot specify what it is you want as an out, either as an 'out' on 
an inserted fact or global or a query.


Please let me know if there is a different way how to iterate over 
objects in a StatelessKnowledgeSession. I'd like to use an 
ObjectFilter as well.
Extend the Query interface and use that to filter the iterator on a 
returned query.


Best Regards,
Michal


___
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