Re: [rules-users] Trouble getting Dynamic Salience working

2009-09-02 Thread James Owen
Just a quick observance, but this is also an excellent example of  
subsumption of rules (almost).  The first rule conditions elements are  
all contained in the second rule.  However, the action items are  
different.  Therefore the first rule should say that the topping does  
not contain sausage nor pepperoni...  Or, the objects could be written  
so that there would be something to flag a cheese-only pizza otherwise  
both rules would fire as written.  :-(


SDG
James Owen
Founder October Rules Fest
Senior Consultant / Architect KBSC
http://www.kbsc.com
http://www.OctoberRulesFest.org
Twitter: OctRulesFest
Blogs:
http://JavaRules.blogspot.com [Rulebased Systems Blog]
http://ORF2009.blogspot.com [October Rules Fest Blog]
http://exscg.blogspot.com/ [Expert Systems Consulting Group Blog]

If I have seen a little further it is by standing on the shoulders of  
giants.

Sir Isaac Newton in a letter to Robert Hooke, 5 Feb 1676

Come to October Rules Fest and stand on the shoulders of the Giants of  
the industry; if only for a week.




On Sep 1, 2009, at 9:29 PM, Greg Barton wrote:

I hope you're not going through all of that trouble just to get the  
functionality from that concrete example.  You get that for free  
with Drools' default conflict resolution, which includes  
specificity.  Specificity means that rules with the more specific  
conditions, and all else equal, are fired first.  So between these  
two rules, only the CheeseSausagePepperoniPepper one fires:


rule CheeseOnly
when
p : Pizza( )
t1: Topping( pizza == p, name == cheese )
then
System.out.println( Eating cheese pizza );
retract( t1 );
retract( p );
end

rule CheeseSausagePepperoniPepper
when
p : Pizza( )
t1: Topping( pizza == p, name == cheese )
t2: Topping( pizza == p, name == sausage )
t3: Topping( pizza == p, name == pepperoni )
t4: Topping( pizza == p, name == pepper )
then
		System.out.println( Eating cheese sausage pepperoni pepper  
pizza );

retract( t4 );
retract( t3 );
retract( t2 );
retract( t1 );
retract( p );
end

See the attached project.

--- On Tue, 9/1/09, Bill Tarr javatestc...@yahoo.com wrote:


From: Bill Tarr javatestc...@yahoo.com
Subject: [rules-users]  Trouble getting Dynamic Salience working
To: rules-users@lists.jboss.org
Date: Tuesday, September 1, 2009, 7:28 PM
We have a winner!  Many thanks
Michal, hope I can return the favor one day.

salience ( return getSalience4() )

for the record, my function looks something like (after
tempate evaluation):

pre
function int getSalience4(){
int salience = 0;
if(VALUE==VALUE) salience += 1000;

return salience;
}
/pre

I think the combination activation-group and dynamic
salience for rule-template projects are pretty useful.

Just for anyone interested, the tempate code looks
something like this:

pre
rule Some ru...@{row.rownumber}

activation-group @{param...@{param2}
salience ( return getsalie...@{row.rownumber}() )
/pre

where PARAM1 and PARAM2 make up a kind of key. I only want
to execute one rule that matches that key, no matter how
many options there are.

Rules that have additional parameters get higher salience
than rules with less parameters, so here is my function.

pre
function int getsalie...@{row.rownumber}(){
int salience = 0;
if(@{PARAM3}==@{PARAM3}) salience += 1000;
if(@{PARAM4}==@{PARAM4}) salience += 1000;
return salience;
}
/pre

A concrete example could be pizza.  So there are 3 types
of pizza, all are grouped in the same activation-group.

cheese, pepperoni
cheese, pepperoni, sausage
cheese, pepperoni, meatball, pepper

Any cheese and pepperoni pizza should could match all these
rules, but more toppings is always better for me.

So cheese, pepperoni, onion, pepper getts a salience of
2000, and is the only rule evaluated.



On Tue Sep 1 18:39:13 EDT 2009, Michal Bali michalbali at
gmail.com  wrote:

does this work?
salience ( return getSalience() )

or this:

salience ( getSalience();)


On Tue, Sep 1, 2009 at 6:50 PM, Bill Tarr javatestcase
at yahoo.com wrote:


Possibily just a simple MVEL error, but I've been

struggling for a while

and thought I'd see if anyone could help.

I just want to run a logic test to determine salience

for some rules I am

generating with rules-templates.  Even after making

the logical test true

I can't get any of variation to compile.

(true ? 1000 : 0)
**produces**
Unable to build expression for 'salience' : not a

statement, or badly

formed structure

( true ? 1000 : 0)
**produces**
Unable to build expression for 'salience' : invalid

number literal: 1000


salience ( getSalience() )
...
function int getSalience(){return 0;}
**produces**
Unable to build expression for 'salience' :

org.mvel2.util.MethodStub

[rules-users] DRools 5 with spring 2.5.6

2009-09-02 Thread Damien Feugas
Hi Everyone.

I'm new to Drools 5, and I'd like to use it in a spring project.
Basically, I want to load a knowledge base in a Service Spring object, and
use it as a dependency in others treatment objects.

Google serves me several sites on how to use Spring and previous Drools
releases, but nothing really up to date.
Spring-modules, a kind of Spring extension wich provided a Drools
integration is deprecated.

Is there any simple way to use both Spring 2.5.6 and Drools 5.0.1 ?

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


Re: [rules-users] question on drools and method calls on facts

2009-09-02 Thread Wolfgang Laun
It depends whether you are a purist, a pragmatist, or a maverick. A few
random thoughts, and note that I consider myself a repenting pragmatist ;-)

Having fact classes with methods that modify the object in addition to the
usual setters is dangerous; a toString() according to the convention is
harmless.

Even from a purist's point of view your list could be extended by calls of
methods to global objects, e.g., for communicating results to some GUI or
whatever.

What is usually frowned at it the use of conditional statements on the RHS
as going against the spirit of rule based programming.

If complex processing is required, hide it in some static methods of an
utility class. It will make your rule code trimmer and slimmer, avoiding
needless binding between the business logic part and implementation details.

-W


On Tue, Sep 1, 2009 at 11:02 PM, Garner, Shawn
garner.sh...@principal.comwrote:

 I'm under the impression that in the action clause of a rule you should
 only do one of the following:
 1) Set a property on a Fact
 2) Retract a Fact
 3) Insert (Assert) a new Fact
 4) Modify an existing Fact

 However in some of the examples in the documentation it shows calling
 methods other than bean property getters and setters.
 I was wondering if what other peoples opinions are on whether you should be
 doing more than the 4 things I listed above in a then clause of a rule.

 Thanks,
 SG


 -Message Disclaimer-

 This e-mail message is intended only for the use of the individual or
 entity to which it is addressed, and may contain information that is
 privileged, confidential and exempt from disclosure under applicable law.
 If you are not the intended recipient, any dissemination, distribution or
 copying of this communication is strictly prohibited. If you have
 received this communication in error, please notify us immediately by
 reply email to conn...@principal.com and delete or destroy all copies of
 the original message and attachments thereto. Email sent to or from the
 Principal Financial Group or any of its member companies may be retained
 as required by law or regulation.

 Nothing in this message is intended to constitute an Electronic signature
 for purposes of the Uniform Electronic Transactions Act (UETA) or the
 Electronic Signatures in Global and National Commerce Act (E-Sign)
 unless a specific statement to the contrary is included in this message.

 While this communication may be used to promote or market a transaction
 or an idea that is discussed in the publication, it is intended to provide
 general information about the subject matter covered and is provided with
 the understanding that The Principal is not rendering legal, accounting,
 or tax advice. It is not a marketed opinion and may not be used to avoid
 penalties under the Internal Revenue Code. You should consult with
 appropriate counsel or other advisors on all matters pertaining to legal,
 tax, or accounting obligations and requirements.


 ___
 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] When MinaTaskClient.complete throw NullPointerException

2009-09-02 Thread liuzhikun
Hi.
   I use human task in JPA,when i call MinaTaskClient.complete throw below 
error:
java.lang.NullPointerException
 at 
org.drools.persistence.processinstance.JPAWorkItemManager.completeWorkItem(JPAWorkItemManager.java:83)
 at 
org.drools.process.workitem.wsht.WSHumanTaskHandler$GetCompletedTaskResponseHandler.execute(WSHumanTaskHandler.java:282)
 at 
org.drools.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:67)
 at 
org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:752)
 at 
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)2009-9-2
 13:50:26 org.apache.mina.filter.logging.LogLevel$4 log
 at 
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:49)
 at 
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:832)
 at 
org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:379)
 at 
org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:173)
 at 
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
 at 
org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:49)
 at 
org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:832)
 at 
org.apache.mina.core.filterchain.DefaultIoFilterChain$HeadFilter.messageReceived(DefaultIoFilterChain.java:616)
 at 
org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
 at 
org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:408)
 at 
org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:578)
 at 
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:540)
 at 
org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:532)
 at 
org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:58)
 at 
org.apache.mina.core.polling.AbstractPollingIoProcessor$Worker.run(AbstractPollingIoProcessor.java:857)
 at 
org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
 at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 at java.lang.Thread.run(Unknown Source)
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Trouble getting Dynamic Salience working - add in rules-templates

2009-09-02 Thread Bill Tarr
Thank you for the response Greg.  For starters, I did NOT know about 
specificity...  very helpful to know, and I feel certain I will be using it in 
the future.  I don't feel any of the documentation I've read on Drools really 
got this subject across for me, I not sure the the Drools developer book really 
covers it at all.

Back to my actual implementation.  We are using rules-templates, which have a 
unique behavior I've been calling a feature, but some might consider a bug... 
or have found a way to work around.  Templates do not render rule lines which 
contains NULL parameters.  This hasn't bit my too badly to this point, but MAY 
pose an interesting issue for specificity (now that I know about it!)

My real world example is a good bit more complicated.  My LH includes:

PARAMETERS
--
Product  - NOT NULL
Start Date
End State
Price Group - NOT NULL
State Group

Some of the info is coming from a single instance of an object I'm calling 
transporter I use to gather info from other rules.  It will have a list of 
state groups and price groups.  So psuedocode for my template LH will look 
something like:

template.pricegroups.contains( @{PRICE_GROUP} )
template.stategroups.contains( @{STATE_GROUP} )
policy ( 
    startDate  @{START_DATE}
                endDate  @{END_DATE}
                product = @{PRODUCT}
)

The problem I run into here, is that in any given rule, only a subset of these 
will appear.  So one rule may produce:

// this rules parameters have a NULL STATE_GROUP
template.pricegroups.contains( pg1 )

policy ( 
    startDate  2009-01-01
                endDate  2010-01-10}
                product = prod1
)

and another might produce

// this rule has a STATE_GROUP, but no START_DATE and END_DATE
template.pricegroups.contains( pg1 )
template.stategroups.contains( NY ) 
policy ( 


                product = prod2
)

In this example, I actually want the SECOND rule to win the conflict.  It is 
more specific for our business rule, a policy for NY should match, but 
the the first rule should not.  In reality, the first rule has more facts, so 
which one will actually fire first by rules of specificity?

My activation-group and salience hack was one workaround for this condition.  I 
set the second rule with a higher salience, and add them both to the same 
activation-group.

I will try different combinations of rule-templates and specificity when I am 
in the office tomorrow (midnight here in San Diego.)  If you have any further 
feedback on this, I do appreciate your taking the time to show a Drools newbie 
some very useful stuff.

Thanks!

Bill



Message: 2
Date: Tue, 1 Sep 2009 19:29:40 -0700 (PDT)
From: Greg Barton greg_bar...@yahoo.com
Subject: Re: [rules-users] Trouble getting Dynamic Salience working
To: Rules Users List rules-users@lists.jboss.org
Message-ID: 52492.42683...@web81501.mail.mud.yahoo.com
Content-Type: text/plain; charset=iso-8859-1

I hope you're not going through all of that trouble just to get the 
functionality from that concrete example.  You get that for free with Drools' 
default conflict resolution, which includes specificity.  Specificity means 
that rules with the more specific conditions, and all else equal, are fired 
first.  So between these two rules, only the CheeseSausagePepperoniPepper one 
fires: 

rule CheeseOnly
    when
        p : Pizza( )
        t1: Topping( pizza == p, name == cheese )
    then
        System.out.println( Eating cheese pizza ); 
        retract( t1 );
        retract( p );
end

rule CheeseSausagePepperoniPepper
    when
        p : Pizza( )
        t1: Topping( pizza == p, name == cheese )
        t2: Topping( pizza == p, name == sausage )
        t3: Topping( pizza == p, name == pepperoni )
        t4: Topping( pizza == p, name == pepper )
    then
        System.out.println( Eating cheese sausage pepperoni pepper pizza ); 
        retract( t4 ); 
        retract( t3 ); 
        retract( t2 );
        retract( t1 );
        retract( p );
end

See the attached project.

--- On Tue, 9/1/09, Bill Tarr javatestc...@yahoo.com wrote:

 From: Bill Tarr javatestc...@yahoo.com
 Subject: [rules-users]  Trouble getting Dynamic Salience working
 To: rules-users@lists.jboss.org
 Date: Tuesday, September 1, 2009, 7:28 PM
 We have a winner!? Many thanks
 Michal, hope I can return the favor one day.
 
 salience ( return getSalience4() )
 
 for the record, my function looks something like (after
 tempate evaluation):
 
 pre
 function int getSalience4(){
 ??? int salience = 0;
 ??? if(VALUE==VALUE) salience += 1000;
 
 ??? return salience;
 }
 /pre
 
 I think the combination activation-group and dynamic
 salience for rule-template projects are pretty useful. 
 
 Just for anyone interested,?the tempate code looks
 something like this:
 
 pre
 rule Some ru...@{row.rownumber}
 
 ??? activation-group @{param...@{param2}
 ??? salience ( return getsalie...@{row.rownumber}() )
 /pre
 
 where PARAM1 and 

[rules-users] KnowledgeAgent with BRL Files

2009-09-02 Thread David
Hi!

I did a lot of searching aroung the web, drools doc and this mailing 
list but could not solve my problem.
I want to monitor a folder for BRL File so i used the Agent.

Java Code:
KnowledgeAgent kbAgent = KnowledgeAgentFactory.newKnowledgeAgent(kbAgent);
Resource resource = ResourceFactory.newUrlResource(ChangeSet.xml);
kbAgent.applyChangeSet(resource);
ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();

ChangeSet.xml:
change-set
add
resource
source='file:/Z:/rules'
type='BRL' /
/add
/change-set

Result:
When i execute the code, the agent starts up, finds the brl file in the 
folder and parses them.
But:
* It tries to parse the drools.package file with the imports for the brl 
files as BRL file as well
* So i tried to work around and tweaked the implementation of 
KnowledgeAgentImpl, so it skips the drools.package file when scanning 
the folder for brl files. But now i get:
com.thoughtworks.xstream.io.StreamException:  : Content is not allowed 
in prolog. plus [Fatal Error] :1:1: Content is not allowed in prolog. 
in the console. As far as i could trace the error, the problem is that 
the imports are not added to the internally generated drl (package).

So how do i use the agent properly to use brl files?
Any ideas on this?

Thank you for reading,
Dave

-- 
===
This mail account will accept only Mails from jboss mailing lists. If you like 
to send me an email, delete the .drools_user_list in the sender address.

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


[rules-users] how to use 'extend' keyword in Rule Engine

2009-09-02 Thread Pardeep . Ruhil
Hi,
I want to use the condition of Rule 1 in Rule 2.
So for this I got to know that extend keyword will be used.
But in the documentation I have not get any details of the same.

So can you please tell me how to use extends keyword in Rule.


Thanks  Regards

Pardeep Ruhil
LT Infotech Ltd
Mumbai
Ph: +919820283884

Larsen  Toubro Infotech Ltd.
www.Lntinfotech.com

This Document is classified as: 

LT Infotech Proprietary   LT Infotech Confidential   LT Infotech 
Internal Use Only   LT 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@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Maven Plugin to build pkg files

2009-09-02 Thread Bernd Rücker
Hi Eric.



Thanks for the answer. Basically I developed that code yesterday, yes. I
did it somehow similar to the Ant Task. But I had some serious
serialization issues as posted yesterday. Maybe you have an idea about
that?



 If one doesn’t exist and there’s enough interest, we

 could use what I have as a starting point as an open source plugin for
it.



You mean in the drools codebase? Basically, yes, sure. Should be no
problem to contribute it. Just tell me how to progress in that area.



Cheers

Bernd



Von: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] Im Auftrag von Miles, Eric
Gesendet: Mittwoch, 2. September 2009 14:27
An: Rules Users List
Betreff: Re: [rules-users] Maven Plugin to build pkg files



Bernd,



Something didn’t exist as of Drools 4.x (at least nothing official).  With
the latest release of Drools, the amount of code needed to be written to
compile is actually pretty small.  Making a Maven plugin would not be that
difficult.  I’ve made one that is just a couple of hundred lines long and
most of that is the Maven framework glue.



If one doesn’t exist and there’s enough interest, we could use what I have
as a starting point as an open source plugin for it.



Eric



  _

From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Bernd Rücker
Sent: Monday, August 31, 2009 10:57 AM
To: rules-users@lists.jboss.org
Subject: [rules-users] Maven Plugin to build pkg files



Hi all.



I wonder if there exists a maven plugin to build pkg files out of the rule
base during the maven packaging. Because we don’t use the Guvnor
repository in this project and I want to package the pkg files with the
overall ear.



I searched a bit, but didn’t found anything… Okay, not hard to write
ourself, but would be nicer to reuse existing stuff…



Thanks

Bernd



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


Re: [rules-users] When MinaTaskClient.complete throw NullPointerException

2009-09-02 Thread Kris Verlaenen
When using the human task service in combination with JPA, you should
use the CommandBasedWSHumanTaskHandler, not the default WSHumanTaskHandler:
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-process/drools-process-task/src/main/java/org/drools/process/workitem/wsht/CommandBasedWSHumanTaskHandler.java

The reason is that in that case, the completion of a human task should
also be executed as part of a JPA transaction, hence the slightly
modified handler.

Kris

Quoting liuzhikun liuzhi...@viewhigh.com.cn:

 Hi.
I use human task in JPA,when i call MinaTaskClient.complete throw
 below error:
 java.lang.NullPointerException
  at

org.drools.persistence.processinstance.JPAWorkItemManager.completeWorkItem(JPAWorkItemManager.java:83)
  at

org.drools.process.workitem.wsht.WSHumanTaskHandler$GetCompletedTaskResponseHandler.execute(WSHumanTaskHandler.java:282)
  at

org.drools.task.service.TaskClientHandler.messageReceived(TaskClientHandler.java:67)
  at

org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:752)
  at

org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)2009-9-2
 13:50:26 org.apache.mina.filter.logging.LogLevel$4 log
  at

org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:49)
  at

org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:832)
  at

org.apache.mina.filter.codec.ProtocolCodecFilter$ProtocolDecoderOutputImpl.flush(ProtocolCodecFilter.java:379)
  at

org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(ProtocolCodecFilter.java:173)
  at

org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
  at

org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:49)
  at

org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:832)
  at

org.apache.mina.core.filterchain.DefaultIoFilterChain$HeadFilter.messageReceived(DefaultIoFilterChain.java:616)
  at

org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:414)
  at

org.apache.mina.core.filterchain.DefaultIoFilterChain.fireMessageReceived(DefaultIoFilterChain.java:408)
  at

org.apache.mina.core.polling.AbstractPollingIoProcessor.read(AbstractPollingIoProcessor.java:578)
  at

org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:540)
  at

org.apache.mina.core.polling.AbstractPollingIoProcessor.process(AbstractPollingIoProcessor.java:532)
  at

org.apache.mina.core.polling.AbstractPollingIoProcessor.access$400(AbstractPollingIoProcessor.java:58)
  at

org.apache.mina.core.polling.AbstractPollingIoProcessor$Worker.run(AbstractPollingIoProcessor.java:857)
  at

org.apache.mina.util.NamePreservingRunnable.run(NamePreservingRunnable.java:51)
  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown
 Source)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown
 Source)
  at java.lang.Thread.run(Unknown Source)
 




Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] forall/from/eval/contains: odd DRL syntax error

2009-09-02 Thread Wolfgang Laun
A rule has to ascertain that all elements in a ListElemBoxStatusin a
Collector occur in the matching BoxResponse's  SetElemBoxStatus. There is
just one BoxResponse per Collector.

This here works fine:

rule matchCollectorResponse
 when
$c : Collector( $ebsList : elemBoxStatusList, $gsSet :
globalStatusSet )
$b : BoxResponse( collector == $c, globalStatusSet == $gsSet,
$ebsSet : elemBoxStatusSet  )
forall( $ebs : ElemBoxStatus() from $ebsList
BoxResponse( collector == $c, elemBoxStatusSet contains $ebs
) )
then
...
end

Thinking that $ebs is already available from the second pattern ($b:...), I
tried

rule matchCollectorResponse
when
$c : Collector( $ms : message, $ebsList : elemBoxStatusList, $gsSet
: globalStatusSet )
$b : BoxResponse( collector == $c, globalStatusSet == $gsSet,
$ebsSet : elemBoxStatusSet  )
forall( $ebs : ElemBoxStatus() from $ebsList
   eval( $ebsSet.contains( $ebs ) ) )
then
...
end

but the compiler came back with

Line ...:55 no viable alternative at input '$ebs' in rule
matchCollectorResponse in pattern eval

Defining a suitable function isIn(...) and using this within eval() produces
the same result. This
and other experiments seems to indicate that bindings in the first pattern
of forall() are not
passed in to an eval() later in the forall.

JIRA?

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


Re: [rules-users] question on drools and method calls on facts

2009-09-02 Thread Greg Barton
I have to disagree on one point.  Having fact classes with methods that modify 
the object in addition to the usual setters is not dangerous, it's called 
encapsulation or information hiding and is a common OO pattern.  Now, in 
the rules context, you have to inform the engine that the object has changed, 
but that's necessary when you call a setter as well.  In fact I think it's an 
advantage of Drools that you can use pojos in working memory and take advantage 
of OO design.

--- On Wed, 9/2/09, Wolfgang Laun wolfgang.l...@gmail.com wrote:

 From: Wolfgang Laun wolfgang.l...@gmail.com
 Subject: Re: [rules-users] question on drools and method calls on facts
 To: Rules Users List rules-users@lists.jboss.org
 Date: Wednesday, September 2, 2009, 1:30 AM
 It depends whether you are a purist, a
 pragmatist, or a maverick. A few random thoughts, and note
 that I consider myself a repenting pragmatist ;-)
 
 Having fact classes with methods that modify the object in
 addition to
 the usual setters is dangerous; a toString() according to
 the
 convention is harmless.
 
 
 Even from a purist's point of view your list could be
 extended by calls of methods to global objects,
 e.g., for communicating results to some GUI or whatever.
 
 What is usually frowned at it the use of conditional
 statements on the RHS as going against the spirit of rule
 based programming.  
 
 
 If complex processing is required, hide it in some static
 methods of an utility class. It will make your rule code
 trimmer and slimmer, avoiding needless binding between the
 business logic part and implementation details.
 
 
 -W
 
 
 On Tue, Sep 1, 2009 at 11:02 PM,
 Garner, Shawn garner.sh...@principal.com
 wrote:
 
 I'm under the impression that in the action clause of a
 rule you should only do one of the following:
 
 1) Set a property on a Fact
 
 2) Retract a Fact
 
 3) Insert (Assert) a new Fact
 
 4) Modify an existing Fact
 
 
 
 However in some of the examples in the documentation it
 shows calling methods other than bean property getters and
 setters.
 
 I was wondering if what other peoples opinions are on
 whether you should be doing more than the 4 things I listed
 above in a then clause of a rule.
 
 
 
 Thanks,
 
 SG
 
 
 
 
 
 -Message Disclaimer-
 
 
 
 This e-mail message is intended only for the use of the
 individual or
 
 entity to which it is addressed, and may contain
 information that is
 
 privileged, confidential and exempt from disclosure under
 applicable law.
 
 If you are not the intended recipient, any dissemination,
 distribution or
 
 copying of this communication is strictly prohibited. If
 you have
 
 received this communication in error, please notify us
 immediately by
 
 reply email to conn...@principal.com
 and delete or destroy all copies of
 
 the original message and attachments thereto. Email sent to
 or from the
 
 Principal Financial Group or any of its member companies
 may be retained
 
 as required by law or regulation.
 
 
 
 Nothing in this message is intended to constitute an
 Electronic signature
 
 for purposes of the Uniform Electronic Transactions Act
 (UETA) or the
 
 Electronic Signatures in Global and National Commerce Act
 (E-Sign)
 
 unless a specific statement to the contrary is included in
 this message.
 
 
 
 While this communication may be used to promote or market a
 transaction
 
 or an idea that is discussed in the publication, it is
 intended to provide
 
 general information about the subject matter covered and is
 provided with
 
 the understanding that The Principal is not rendering
 legal, accounting,
 
 or tax advice. It is not a marketed opinion and may not be
 used to avoid
 
 penalties under the Internal Revenue Code. You should
 consult with
 
 appropriate counsel or other advisors on all matters
 pertaining to legal,
 
 tax, or accounting obligations and requirements.
 
 
 
 
 
 ___
 
 rules-users mailing list
 
 rules-users@lists.jboss.org
 
 https://lists.jboss.org/mailman/listinfo/rules-users
 
 
 
 
 -Inline Attachment Follows-
 
 ___
 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] forall/from/eval/contains: odd DRL syntax error

2009-09-02 Thread Greg Barton
Is Collection.containsAll() an option?

--- On Wed, 9/2/09, Wolfgang Laun wolfgang.l...@gmail.com wrote:

 From: Wolfgang Laun wolfgang.l...@gmail.com
 Subject: [rules-users] forall/from/eval/contains: odd DRL syntax error
 To: Rules Users List rules-users@lists.jboss.org
 Date: Wednesday, September 2, 2009, 9:58 AM
 A rule has to ascertain that all elements in
 a ListElemBoxStatusin a
 Collector occur in the matching BoxResponse's 
 SetElemBoxStatus. There is
 just one BoxResponse per Collector.
 
 This here works fine:
 
 
 rule matchCollectorResponse
  when
     $c : Collector( $ebsList :
 elemBoxStatusList, $gsSet : globalStatusSet )
     $b : BoxResponse( collector == $c,
 globalStatusSet == $gsSet, $ebsSet : elemBoxStatusSet  )
 
     forall( $ebs : ElemBoxStatus() from
 $ebsList
     BoxResponse( collector ==
 $c, elemBoxStatusSet contains $ebs ) )
     then
 ...
 end
 
 Thinking that $ebs is already available from the second
 pattern ($b:...), I tried
 
 
 rule matchCollectorResponse
     when
     $c : Collector( $ms : message, $ebsList :
 elemBoxStatusList, $gsSet : globalStatusSet )
     $b : BoxResponse( collector == $c,
 globalStatusSet == $gsSet, $ebsSet : elemBoxStatusSet  )
 
     forall( $ebs : ElemBoxStatus() from
 $ebsList
        eval( $ebsSet.contains(
 $ebs ) ) )
     then
 ...
 end
 
 but the compiler came back with
 
 Line ...:55 no viable alternative at input '$ebs'
 in rule matchCollectorResponse in pattern eval
 
 
 Defining a suitable function isIn(...) and using this
 within eval() produces the same result. This
 and other experiments seems to indicate that bindings in
 the first pattern of forall() are not
 passed in to an eval() later in the forall.
 
 
 JIRA?
 
 -W
 
 
 
 -Inline Attachment Follows-
 
 ___
 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] Doubt regarding extend keyword in Rule Engine

2009-09-02 Thread Pardeep . Ruhil
Hi Users,Please help me to clear my doubt of using 'extend' keyword in Rules.I tried using this keyword to use the condition of rule 1 in rule 2 asRule "first rule" when condition then actionRule "second rule" extends "first rule"when condition then actionBut whenI tried to use it,it gives meerror for compilation error in drool file.Kindly help me over this, If I am wrongly using the keyword as I have not found anything about it in Rule engine documentation. Thanks  RegardsPardeep RuhilThis 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. Thanks

__

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


[rules-users] Drools as Lexer / Parser (sequential data processing)

2009-09-02 Thread André Thieme
Hello group, I recently had the idea:
A rule system (like Drools) is ideal for making programs with complex
  rules simpler. Writing a lexer or parser can be non-trivial. So, is it
  possible and also meaningful to express such a task with rules?

Anyone here who maybe tried that already?
The two big questions for me are:
1) how easy is it to express a lexer with rules?
2) how bad (good?) will it perform?

If you happen to have a good idea of how to do it, could you please give
me an example for a simple lexer?
Let's say it will get natural language (a string, such as this email) as
input and should return a sequence (say, ArrayList) of Tokens, which may
look like this:

public class Token {
   public String value;
   public String category;

   Token(String value, String category) {
 this.value = value;
 this.category = category;
   }
}

We could have three categories:
word,  numeric  and  whitespace.

An input String could be:
We can   see 500 cars
And it should produce an ArrayList with the contents:
[
  Token(We, word),
  Token( , whitespace),
  Token(can, word),
  Token(   , whitespace),
  Token(see, word),
  Token( , whitespace),
  Token(500, numeric),
  Token( , whitespace),
  Token(cars, word)
]

At the moment I have difficulties to see if/how this could be achieved.
If you find this easy, please post a solution.
I am aware that JavaCC is really good for such tasks and will also
perform extremly well.


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


[rules-users] Scaling to large numbers of rules

2009-09-02 Thread Adam Sussman

I am hoping that I am doing something wrong here and that one of you can
point me in the right direction.

Can anyone provide some advice on scaling up the number of rules in a
single KnowledgeBase?  While I have seen all sorts of reports on having
lots of facts, I have not seen anything about having lots of rules.

I need to get to about 200K rules in a single KnowledgeBase, and also
to run several of these side by side in the same system.

The problem:

As the number of rules increases, the time to compile and load them
into memory skyrockets.  Now while I realize that the Rete algorithm
complexity is about the number of rules, the times I am seeing are
pretty scary.  Also, at about 30k rules, things just fall apart.

On a 64 bit Linux OS with 2 2.4Ghz processors using a 64bit JVM from
OpenJDK (1.6.1) with 1 Gig of memory allocated to the JVM, loading
from .drl files:

1000 rules:
KnowledgeBuilder.add:   7 seconds
KnowledgeBase.addKnowledgePackages: .8 seconds

1 rules:
KnowledgeBuilder.add:   79 seconds
KnowledgeBase.addKnowledgePackages: 23 seconds

15000 rules:
KnowledgeBuilder.add:   138 seconds
KnowledgeBase.addKnowledgePackages:  55 seconds

2 rules:
KnowledgeBuilder.add:   488 seconds
KnowledgeBase.addKnowledgePackages: 100 seconds

3 rules:
KnowledgeBuilder.add:   out of memory
KnowledgeBase.addKnowledgePackages: never runs

At this rate, 200k rules will take 13-14 hours to compile
and 2-3 hours to load into RAM, assuming I can even get
to that many rules.  This just is not usable.

Time to fire all rules is negligible (fortunately!).

The rules I am testing on are very simple 1-3 variable equality whens
with a simple System.out.println then clause.

The benchmark code I am running is as follows:

KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

kbuilder.add( ResourceFactory.newClassPathResource( drlFile, 
RuleRunner.class ), ResourceType.DRL );

CollectionKnowledgePackage pkgs = kbuilder.getKnowledgePackages();
kbase.addKnowledgePackages( pkgs );


Sample rule:

rule 0005 - random rule
when
Transaction(someId == 35156  someOtherId == 
'79F81FB8134A129F'  someCollection contains 'EC3F2A1DCA88')
then
System.out.println(match rule 0005 - random rule);
end

Any help would be appreciated.

Regards,

Adam Sussman
CONFIDENTIALITY NOTICE:

This message contains information which may be confidential or privileged.  If 
you are not the intended recipient, be aware that any disclosure, copying, 
distribution or use of the contents of this information is prohibited.  If you 
have received this transmission in error, please notify me immediately by 
telephone.
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] not able to debug drools flow

2009-09-02 Thread Justin King
Hi,

I'm afraid I downloaded the new plugin from the link you have and it still
wont allow me to debug on eclipse 3.5. Anyone else had any luck?

Cheers,

Justin

On Thu, Aug 27, 2009 at 11:05 PM, Kris Verlaenen 
kris.verlae...@cs.kuleuven.be wrote:

 Ok, sorry, it took me a while but I found the issue.  The code works
 fine for both Eclipse 3.4.x and 3.5.x, but apparently there is an issue
 when you build the plugin for 3.4.x and try to use that in 3.5.x.

 I managed to work around the problem and the fix is committed on trunk.
  You can download the latest version of the plugin here:

 https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/

 Kris

 Quoting Justin King justin.matthew.k...@gmail.com:

  I'm also using eclipse galileo, Java 1.5, and XP SP3 and I'm having
  the same
  problem
 
  2009/8/24 Jakob Marovt jmar...@gmail.com
 
   Hi,
  
   I am using Eclipse 3.5.0, jdk 1.6.0_13-b03 and Drools 5.0 all on
  Windows XP
   Professional SP3.
  
   Jakob
  
  
   On Sat, Aug 22, 2009 at 11:47 PM, Kris Verlaenen 
   kris.verlae...@cs.kuleuven.be wrote:
  
   I just tried using Eclipse 3.5.0, jdk 1.6.0_06 and the latest
  Drools
   5.1.0.SNAPSHOT on RHEL and everything seems to be working fine
  ...
  
   Could you specify the exact environment you are getting this error
  in,
   so I can at least try to reproduce?
  
   Kris
  
   Quoting Maximiliano Batelli maxibate...@gmail.com:
  
Hello
I have the same problem when debuging rules using eclipse 3.5,
  drools
5.0 and jdk 1.6.
I downgraded to eclipse 3.4 and worked for me.
Is there a solution to let me debug using eclipse 3.5?
   
Thanks
Max
   
   
   
   
Hi,
   
I`m experiencing the same problems as Vishal. I am using Eclipse
  3.5
and newest Drools. I am only able to debug project as Java
application, but when I want to debug it as Drools application
  all I
get is this problem. I also tried disabling firewall and
  changing
its
settings but as it seems it does not help.
So if anyone has figured out a solution to this problem, I
  would
really appreciate an answer.
   
Thanks,
Jakob
   
probably related to your personal firewall:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6303969
http://www.techienuggets.com/Comments?tx=3786
   
I don't think this is a Drools specific issue.
   
Mark
   
   
Vishal Anand wrote:

*** Hi,*

*** *

*** I am using Drools 5.0 and have create a simple application
  using
*
* drools flow, it runs perfectly but when trying to debug it as
  n
drools *
* application I get the following error:*

*** *

*** FATAL ERROR in native method: JDWP No transports
  initialized, *
* jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)*

*** ERROR: transport error 202: connect failed: Connection
  refused*

*** ERROR: JDWP Transport dt_socket failed to initialize,
TRANSPORT_INIT(510)*

*** JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No
  transports
*
* initialized [../../../src/share/back/debugInit.c:690]*

*** *

*** *

*** While stack trace shows the following:*

*** *

*** *

*** java.lang.IncompatibleClassChangeError: Expected static
  method
*
   
  
  
 

 *org.drools.eclipse.launching.DroolsVMDebugger.renderCommandLine([Ljava/lang/String;)Ljava/lang/String;
*

*** at
  org.drools.eclipse.launching.DroolsVMDebugger.run(Unknown
Source)*

*** at *
   
  
  
 

 *org.eclipse.jdt.launching.JavaLaunchDelegate.launch(JavaLaunchDelegate.java:101)
*

*** at *
   
  
  
 

 *org.drools.eclipse.launching.DroolsLaunchConfigurationDelegate.launch(Unknown
*
* Source)*

*** at *
   
  
  
 

 *org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:853)
*

*** at *
   
  
  
 

 *org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:703)
*

*** at *
   
  
  
 

 *org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:866)
*

*** at *
   
  
  
 

 *org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1069)
*

*** at
  org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)*

*** *

*** *

*** I am using eclipse 3.4*

*** *

*** What could be the issue ?*

*** *

*** Thanks*

*** Vishal*
   
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
   
  
  
  
  
   Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
   ___
   rules-users mailing list
   rules-users@lists.jboss.org
   https://lists.jboss.org/mailman/listinfo/rules-users
  
  
  
   

[rules-users] immediate vs path bound variables wrt performance?

2009-09-02 Thread Barry Kaplan

The docs state that == with bound variables is very fast due to hashing. The
example only shows a simple bound value, eg

   Person( likes : favouriteCheese )
   Cheese( type == likes )

In the following will drools create an implicit hashed variable for
'$p.likes' and yield the same performance?

   $p : Person( )
   Cheese( type == $p.likes )

 
-- 
View this message in context: 
http://www.nabble.com/immediate-vs-path-bound-variables-wrt-performance--tp25269900p25269900.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] immediate vs path bound variables wrt performance?

2009-09-02 Thread Barry Kaplan

Ok, I think I just found my answer, from 4.8.2.1

'Note: Nested accessors have a much greater performance cost than direct
field accesses, so use them carefully.

But is the simple case in the previous post considered nested?


-- 
View this message in context: 
http://www.nabble.com/immediate-vs-path-bound-variables-wrt-performance--tp25269900p25269967.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