Re: [rules-users] Simple JBoss Rules Sample

2007-08-02 Thread Fernando Meyer

Hi Robert,

	Have you tried the drools 4.0.0 examples ? http://labs.jboss.com/ 
drools/downloads

regards

Fernando Meyer http://fmeyer.org
[EMAIL PROTECTED]
PGP: 0xD804DDFB



On Aug 3, 2007, at 1:33 AM, Robert Burdick wrote:


Hello All:



I am brand new to JBoss Rules / Drools development.  I have found  
the examples with the version 3.0.6 download extremely  
unenlightening.  Can anyone point me to a simple starter  
application to get a feel for how all of this works?  A simple  
thick client GUI or command line application would be great.   
Preferably not just a collection og JUnit TestCases, but a real  
application, no matter how simple, that shows how to exercise the  
rules engine from Java would be very helpful to me.




Thanks, Robert



___
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] Simple JBoss Rules Sample

2007-08-02 Thread Dr. Gernot Starke
Try rbs.gernotstarke.de, I tried to clarify things a little.

feedback welcome, it's just a start,

regards,
Gernot


> Hello All:
>
>
>
> I am brand new to JBoss Rules / Drools development.  I have found the
> examples with the version 3.0.6 download extremely unenlightening.  Can
> anyone point me to a simple starter application to get a feel for how all
> of
> this works?  A simple thick client GUI or command line application would
> be
> great.  Preferably not just a collection og JUnit TestCases, but a real
> application, no matter how simple, that shows how to exercise the rules
> engine from Java would be very helpful to me.
>
>
>
> Thanks, Robert
>
>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


-- 
Dr. Gernot Starke
Willi-Lauf Allee 43, D-50858 Köln
Tel. +49 (0) 177 - 728 2570
Mail: [EMAIL PROTECTED]
http://www.gernotstarke.de
http://www.arc42.de
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Golfer Example: Why will the example get two equal result ?

2007-08-02 Thread Dr. Gernot Starke
a half answer: I behaved the same in 3.0.6...

imho it's the "unknown" variables that get instantiated differently...
but I did not investigate much further...

suggestion: ignore - make your own rules behave better :-)
Gernot


>
>
> When I test the Golfer example in Drools4.0 environment. I found the rule
> was matched twice but print same result. I try to override equals() and
> hashCode() method in Golfer Object, but no change happen. Who can tell me
> the reason that happened?
>
>
>
> Thanks.
>
> Jason Wang
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>


-- 
Dr. Gernot Starke
Willi-Lauf Allee 43, D-50858 Köln
Tel. +49 (0) 177 - 728 2570
Mail: [EMAIL PROTECTED]
http://www.gernotstarke.de
http://www.arc42.de
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Simple JBoss Rules Sample

2007-08-02 Thread Robert Burdick
Hello All:

 

I am brand new to JBoss Rules / Drools development.  I have found the
examples with the version 3.0.6 download extremely unenlightening.  Can
anyone point me to a simple starter application to get a feel for how all of
this works?  A simple thick client GUI or command line application would be
great.  Preferably not just a collection og JUnit TestCases, but a real
application, no matter how simple, that shows how to exercise the rules
engine from Java would be very helpful to me.

 

Thanks, Robert

 

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


[rules-users] Golfer Example: Why will the example get two equal result ?

2007-08-02 Thread jason
 

When I test the Golfer example in Drools4.0 environment. I found the rule
was matched twice but print same result. I try to override equals() and
hashCode() method in Golfer Object, but no change happen. Who can tell me
the reason that happened? 

 

Thanks.

Jason Wang

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


Re: [rules-users] How to accumulate from objects in a collection?

2007-08-02 Thread Edson Tirelli
   Felipe,

   I think you were very close to doing it right. What about this:

rule "remove used vacation days"
no-loop
when
 vr: VacationRequestVO($days: availableDays , $iniDate: initDate )
 $u: UserVO( $vacReqList: vacationRequestList )
 Number ($usedDays : intValue > 1) from accumulate ( VacationRequestVO(
isAproved == true, endDate < $iniDate, $uDays: usedDays)
from $vacReqList, sum($uDays))
then
 vr.setAvailableDays($days - $usedDays);
end

So, basically, what we are trying to do from a language perspective is
to allow users to optionally provide a source for each pattern. So, if you
simply write a pattern without a source, it comes from the working memory:

MyClass( ... )

   If you want him to come from another source, you use the "from" CE.  As
you did, it is possible to nest the "from CE" inside the "accumulate CE".

Number(...) from accumulate( VacationRequestVO(...) from $vacRequeList ... )

   The other change you needed in your rule is that as you are adding up
quantities, you want to use the "sum" function instead of "count" function
that is used to count occurrences.

   Try out and let us know... this is a nice rule to show language
expressiveness.

   []s
   Edson

2007/8/2, Felipe Piccolini <[EMAIL PROTECTED]>:
>
> Hi,
>this is just a dumb question for drools-languaje gurus... like Edson :)
>
> How ca I write a rule (CE in LHS) for accumulate atributes inside an
> object, but this objects are not facts,
> they are inside a collection which is an attribute from a fact... pretty
> messy right?...lol..
>
> well, the business problem is this.
>
> I need to count (accumulate) vacation days used on previous vacation
> requests.
> I have an User (which is one fact) having a collection of
> oldVacationRequests
> and an actual VacationRequest (the another fact).
> So the rules is like this: discount to the available days for vacation
> those used in previous
> vacation request, and those days are the days between initDate and endDate
> in each
> old vacation request with isAproved seted true and having endDate before
> the actual
> vacation request initDate.
>
> did I explain myself?...
>
>
>
> so I need to know if this is possible I was trying to do something like
> this...but is obviously wrong...:)
> rule "remove used vacation days"
> no-loop
> when
>  vr: VacationRequestVO($days: availableDays , $iniDate: initDate )
>  $u: UserVO( $vacReqList: vacationRequestList )
>  $usedDays : Number (intValue > 1) from accumulate ( $ovr:
> VacationRequestVO( isAproved == true, endDate < $iniDate, $uDays: usedDays),
> from $vacReqList, count($uDays))
> then
>  vr.setAvailableDays($days - $usedDays);
> end
>
> Thanks...
> 
> *Felipe
> Piccolini M.*
> [EMAIL PROTECTED]
>
>
>
>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>


-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  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] How to accumulate from objects in a collection?

2007-08-02 Thread Felipe Piccolini

Hi,

   this is just a dumb question for drools-languaje gurus... like  
Edson :)


How ca I write a rule (CE in LHS) for accumulate atributes inside an  
object, but this objects are not facts,
they are inside a collection which is an attribute from a fact...  
pretty messy right?...lol..


well, the business problem is this.

I need to count (accumulate) vacation days used on previous vacation  
requests.
I have an User (which is one fact) having a collection of  
oldVacationRequests

and an actual VacationRequest (the another fact).
So the rules is like this: discount to the available days for  
vacation those used in previous
vacation request, and those days are the days between initDate and  
endDate in each
old vacation request with isAproved seted true and having endDate  
before the actual

vacation request initDate.

did I explain myself?...



so I need to know if this is possible I was trying to do something  
like this...but is obviously wrong...:)

rule "remove used vacation days"
no-loop
when
vr: VacationRequestVO($days: availableDays , $iniDate: initDate 
)
$u: UserVO( $vacReqList: vacationRequestList )
		$usedDays: Number (intValue > 1) from accumulate ( $ovr:  
VacationRequestVO( isAproved == true, endDate < $iniDate, $uDays:  
usedDays),


from $vacReqList, count($uDays))
then
vr.setAvailableDays($days - $usedDays);
end

Thanks...

Felipe Piccolini M.
[EMAIL PROTECTED]




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


Re: [rules-users] on update

2007-08-02 Thread Edson Tirelli
   Sergey,

   I don't think you will get the behavior you described, out of the box.
What you can do, is delegate to the engine the actual update work.

rule "on updated cost write to archive old value"
when
$cost : Cost( $oldAmount : amount )
$event : CostUpdateEvent( $newAmount : amount, object ==
$cost )
then
//... write to archive $oldAmount
$cost.setAmount( $newAmount );
update( $cost );
retract( $event );
end

   Right now, shadow facts don't expose it's cache for use in rules in a
safe way. So, I believe something like the above is the best approach.

[]s
Edson

2007/8/2, Manukyan, Sergey <[EMAIL PROTECTED]>:
>
>
> Folks,
>
> I need a rule that will track changes to cost amount and do something
> with his old value.
>
> Like that :
>
> rule "on updated cost write to archive old value"
> when
> cost : Cost()
> old_cost : Cost(amount != cost.amount)  // how can I
> specify the OLD cost object before it was updated???
> then
> ... write to archive $old_cost.amount
> end
>
>
> Is it possible at all?
>
> Something like in database system triggers, when you have "on update"
> and then you have OLD value and NEW values available...?
>
> Thanks a lot!
>
> -Sergey
>
>
>
> **
> ** LEGAL DISCLAIMER **
> **
>
> This E-mail message and any attachments may contain
> legally privileged, confidential or proprietary
> information. If you are not the intended recipient(s),
> or the employee or agent responsible for delivery of
> this message to the intended recipient(s), you are
> hereby notified that any dissemination, distribution
> or copying of this E-mail message is strictly
> prohibited. If you have received this message in
> error, please immediately notify the sender and
> delete this E-mail message from your computer.
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  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] nested accessors with Sets

2007-08-02 Thread Edson Tirelli
Mark,

Hmmm, something is going on with mvel integration... bellow must work.
There are work arounds (like using plain java code, or using multiple
patterns), but I think we need to fix that. Can you please include this info
in the ticket.

Thanks,

 []s
 Edson

2007/8/2, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
> Edson,
>
> Thank you for the response. I tried writing the in-line eval as suggested
> but get this Exception:
>
> org.drools.rule.InvalidRulePackage: Unable to determine the used
> declarations : [Rule name=State, agendaGroup=MAIN, salience=0,
> no-loop=false]
>at org.drools.rule.Package.checkValidity(Package.java:408)
>at org.drools.common.AbstractRuleBase.addPackage(
> AbstractRuleBase.java:288)
>at [...]
>
> This is my rule:
>
> rule State
>dialect "mvel"
>when
>$ca:CandidateAssociation( eval ( !
> nurseDetails.stateLicensures.contains( patientDetails.state ) ) )
>then
>retract( $ca );
> end
>
> I haven't yet but, plan to open an issue in JIRA as requested
>
> Thanks for your help.
> Mark
>
>
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] on update

2007-08-02 Thread Manukyan, Sergey

Folks,

I need a rule that will track changes to cost amount and do something
with his old value.

Like that :

rule "on updated cost write to archive old value"
when
cost : Cost()
old_cost : Cost(amount != cost.amount)  // how can I
specify the OLD cost object before it was updated???
then
... write to archive $old_cost.amount
end


Is it possible at all?

Something like in database system triggers, when you have "on update"
and then you have OLD value and NEW values available...?

Thanks a lot!

-Sergey



**
** LEGAL DISCLAIMER **
**

This E-mail message and any attachments may contain 
legally privileged, confidential or proprietary 
information. If you are not the intended recipient(s),
or the employee or agent responsible for delivery of 
this message to the intended recipient(s), you are 
hereby notified that any dissemination, distribution 
or copying of this E-mail message is strictly 
prohibited. If you have received this message in 
error, please immediately notify the sender and 
delete this E-mail message from your computer.

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


[rules-users] RuleML-2007 Challenge - Extended Deadlines, 7th/17th August

2007-08-02 Thread Adrian Paschke


  [Apologies for multiple postings]

-- Extended Deadlines: August 7th/17th --

RuleML-2007 Challenge: Rule Technology Showcase

October, 25th, 2007 - Orlando, Florida

  http://2007.ruleml.org/index-Dateien/Page787.htm

With its unique emphasis on the practical use of rule technologies in
distributed Web-based environments, RuleML-2007 will feature a Challenge
with a focus on rule applications and rule-based tools. The challenge
offers participants a unique possibility to demonstrate their commercial
or open source tools, use cases, and applications.

Those demo paper submissions that are received by August 7th, and
accepted, will participate in the Challenge and be published in the
Springer LNCS Proceedings.
Those that are received a little later, but by August 17th very latest,
and accepted, will participate in the Challenge and may be considered
for publication in the Proceedings.

Submissions of demo papers (3-5 pages) for the RuleML-2007 Challenge can

be sent to

ruleml2007 AT easychair.org.

The RuleML-2007 Challenge is being held as part of the International
RuleML Symposium on Rule Interchange and Applications (RuleML-2007:
http://2007.ruleml.org/) - to be held in Orlando, Florida, on 25th/26th
October, in co-location with the 10th Business Rules Forum.

RuleML-2007 is devoted to practical distributed rule technologies and
rule-based applications which need language standards for rules
operating in the context of, e.g., the Semantic Web, Web 2.0/3.0,
Intelligent Multi-Agent Systems, Event-Driven Architectures and
Service-Oriented Computing Applications.

For more information please visit:
http://2007.ruleml.org/

Sincerely Yours,

Adrian Paschke
(RuleML-2007 Co-Chair)






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


RE: [rules-users] Why does Drools' RuleBase.addPackage() Behave ThisWay?

2007-08-02 Thread Jin, Ming
Mark,
 
Thanks for the prompt response.  I will certainly create a simplified
program to demonstrate this problem and open a JIRA.
 
As for the "non-optimized test rule set", I meant that I did not even
using the new syntax in 4.0GA, such as "in" and "not in", when
converting IRL to DRL.  I converted all the in conditions to
concatenated or's or "!=" for negations.  All the rules also created
without one condition that has been showing greatly improved performance
in JRules.  But Drools seems not needing it.  The data set is exactly
the same.
 
By the way, I also like DRL a lot.
 
-Ming
 




From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mark Proctor
Sent: Thursday, August 02, 2007 2:06 PM
To: Rules Users List
Cc: Shtarkman, Daniel
Subject: Re: [rules-users] Why does Drools'
RuleBase.addPackage() Behave ThisWay?


Thanks for the feedback, glad it's working out faster for you.
Btw have you tried our sequentail mode, thats even faster, especially
for large data sets and where as JRule's sequential/fastpath modes limit
the rule langauge available to you, we still allow you access to the
full language. Also notice how we don't need to pool rule contexts like
JRules, our single rulebase can be shared amount working memory
sessions, making the management of sessions very light weight which
simplifies your over all infrastructure.

On the increasing times, that doesn't look good. Probably a bad
loop or cache somewhere. Could you make a self contained project showing
this behaviour and upload it as a jira, and we will track and hopefully
move the bottlebeck. Hopefully JProfiler can shed some light.

Btw what do you mean by "non-optimized test rule set and data" -
just trying to understand so I can compare apples to apples.

Mark
Jin, Ming wrote: 

I am benchmarking Drools 4.0 and received excellent
results in rule execution.  With our non-optimized test rule set and
data, Drools out performed ILOG/JRules by quite a bit.  Congratulations
to Drools' team for a job well done.
 
I encountered a strange behavior when trying to test the
performance of rule registration, meaning to add Package's to a new
instance of RuleBase.  I ran the same test 5 times in a sequence, and
the RuleBase instance was discarded right away.  The test ran with
different different number of packages, 20, 50, 100, and 200.  The
results are as the followings:
 
Added 20 packages to rulebase in 0:00:0.15
Added 20 packages to rulebase in 0:00:0.21
Added 20 packages to rulebase in 0:00:0.21
Added 20 packages to rulebase in 0:00:0.301
Added 20 packages to rulebase in 0:00:0.18
Added 20 packages to rulebase 5 times in 0:00:1.051
 
Added 50 packages to rulebase in 0:00:0.17
Added 50 packages to rulebase in 0:00:1.422
Added 50 packages to rulebase in 0:00:1.252
Added 50 packages to rulebase in 0:00:1.322
Added 50 packages to rulebase in 0:00:1.331
Added 50 packages to rulebase 5 times in 0:00:5.497
 
Added 100 packages to rulebase in 0:00:0.19
Added 100 packages to rulebase in 0:00:5.278
Added 100 packages to rulebase in 0:00:5.297
Added 100 packages to rulebase in 0:00:5.228
Added 100 packages to rulebase in 0:00:5.327
Added 100 packages to rulebase 5 times in 0:00:21.32
 
Added 200 packages to rulebase in 0:00:0.22
Added 200 packages to rulebase in 0:00:21.691
Added 200 packages to rulebase in 0:00:21.481
Added 200 packages to rulebase in 0:00:21.642
Added 200 packages to rulebase in 0:00:21.341
Added 200 packages to rulebase 5 times in 0:01:26.385
 
As you can see, the timing of creating first RuleBase
instance is always good, while the subsequent one's were very bad.  Is
there an attribute I could adjust in configuration to improve the
performance for this scenario?  Please advise if there is other
alternatives.  I would be glad to provide details if needed.
 
Your help is greatly appreciated!
-Ming




___
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/li

Re: [rules-users] Why does Drools' RuleBase.addPackage() Behave This Way?

2007-08-02 Thread Mark Proctor
Thanks for the feedback, glad it's working out faster for you. Btw have 
you tried our sequentail mode, thats even faster, especially for large 
data sets and where as JRule's sequential/fastpath modes limit the rule 
langauge available to you, we still allow you access to the full 
language. Also notice how we don't need to pool rule contexts like 
JRules, our single rulebase can be shared amount working memory 
sessions, making the management of sessions very light weight which 
simplifies your over all infrastructure.


On the increasing times, that doesn't look good. Probably a bad loop or 
cache somewhere. Could you make a self contained project showing this 
behaviour and upload it as a jira, and we will track and hopefully move 
the bottlebeck. Hopefully JProfiler can shed some light.


Btw what do you mean by "non-optimized test rule set and data" - just 
trying to understand so I can compare apples to apples.


Mark
Jin, Ming wrote:
I am benchmarking Drools 4.0 and received excellent results in rule 
execution.  With our non-optimized test rule set and data, Drools out 
performed ILOG/JRules by quite a bit.  Congratulations to Drools' team 
for a job well done.
 
I encountered a strange behavior when trying to test the performance 
of rule registration, meaning to add Package's to a new instance of 
RuleBase.  I ran the same test 5 times in a sequence, and the RuleBase 
instance was discarded right away.  The test ran with different 
different number of packages, 20, 50, 100, and 200.  The results are 
as the followings:
 
Added 20 packages to rulebase in 0:00:0.15

Added 20 packages to rulebase in 0:00:0.21
Added 20 packages to rulebase in 0:00:0.21
Added 20 packages to rulebase in 0:00:0.301
Added 20 packages to rulebase in 0:00:0.18
Added 20 packages to rulebase 5 times in 0:00:1.051
 
Added 50 packages to rulebase in 0:00:0.17

Added 50 packages to rulebase in 0:00:1.422
Added 50 packages to rulebase in 0:00:1.252
Added 50 packages to rulebase in 0:00:1.322
Added 50 packages to rulebase in 0:00:1.331
Added 50 packages to rulebase 5 times in 0:00:5.497
 
Added 100 packages to rulebase in 0:00:0.19

Added 100 packages to rulebase in 0:00:5.278
Added 100 packages to rulebase in 0:00:5.297
Added 100 packages to rulebase in 0:00:5.228
Added 100 packages to rulebase in 0:00:5.327
Added 100 packages to rulebase 5 times in 0:00:21.32
 
Added 200 packages to rulebase in 0:00:0.22

Added 200 packages to rulebase in 0:00:21.691
Added 200 packages to rulebase in 0:00:21.481
Added 200 packages to rulebase in 0:00:21.642
Added 200 packages to rulebase in 0:00:21.341
Added 200 packages to rulebase 5 times in 0:01:26.385
 
As you can see, the timing of creating first RuleBase instance is 
always good, while the subsequent one's were very bad.  Is there an 
attribute I could adjust in configuration to improve the performance 
for this scenario?  Please advise if there is other alternatives.  I 
would be glad to provide details if needed.
 
Your help is greatly appreciated!

-Ming


___
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] nested accessors with Sets

2007-08-02 Thread mark . mcnally
Edson,

Thank you for the response. I tried writing the in-line eval as suggested but 
get this Exception:

org.drools.rule.InvalidRulePackage: Unable to determine the used declarations : 
[Rule name=State, agendaGroup=MAIN, salience=0, no-loop=false]
at org.drools.rule.Package.checkValidity(Package.java:408)
at 
org.drools.common.AbstractRuleBase.addPackage(AbstractRuleBase.java:288)
at [...]

This is my rule:

rule State
dialect "mvel"
when
$ca:CandidateAssociation( eval ( ! 
nurseDetails.stateLicensures.contains( patientDetails.state ) ) )
then
retract( $ca );
end

I haven't yet but, plan to open an issue in JIRA as requested

Thanks for your help.
Mark

 -- Original message --
From: "Edson Tirelli" <[EMAIL PROTECTED]>
>Mark,
> 
>Sorry for not answering before. I was doing some research.
>What you found is a bug. Contains and not contains are supported
> operations in Drools, but the case you are facing is that you are using
> these operators with accessors expressions (e.g.
> nurseDetails.stateLicensures ). When an accessor expression is used, the
> engine converts the whole expression in an inline-eval. So what you are
> doing will be interpreted by the engine as:
> 
>$ca:CandidateAssociation( eval ( nurseDetails.stateLicensures not
> contains patientDetails.state  ) )
> 
> Problem is that "not contains" is not a valid operator for MVEL. May I
> ask you please to open a JIRA for that? I will fix it asap.
> 
> Meanwhile, to work around the problem you can either avoid the accessor
> path expression when using "contains/memberOf/matches" and their
> corresponding negations, or write the inline eval yourself, avoid a
> mistranslation by the engine. So, if you are using mvel dialect for your
> rule, you could write:
> 
> rule XXX
> dialect "mvel"
> when
>$ca:CandidateAssociation( eval ( ! nurseDetails.stateLicensures.contains(
> patientDetails.state ) ) )
> then
>// do something
> end
> 
>   Please not that as you are explicitly declaring the mvel dialect for your
> rule, your consequence will also be an MVEL block.
> 
>   Sorry for the inconvenience. I will fix that for 4.0.1.
> 
>   Thanks,
>   Edson
> 
> 2007/8/1, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
> >
> >
> > Actually, it is still broken.
> >
> > This does not complain but it always executes the consequence, even when
> > the stateLicensures includes the state that in patientDetails.state
> >
> >$ca:CandidateAssociation(nurseDetails.stateLicensures not contains
> > patientDetails.state  )
> >
> >
> > I also tried the following but it complains with an Exception
> >
> >   $ca:CandidateAssignment(participantDetails.state not memberof
> > nurseDetails.stateLicensures  )
> >
> >
> > org.drools.rule.InvalidRulePackage: [13,50]: unknown:13:50 Unexpected
> > token 'not'[13,93]: unknown:13:93 mismatched token:
> > [EMAIL PROTECTED],574:574=')',<13>,13:93]; expecting type LEFT_PAREN
> > at org.drools.rule.Package.checkValidity(Package.java:408)
> > at org.drools.common.AbstractRuleBase.addPackage(
> > AbstractRuleBase.java:288)
> >
> >
> > Is what I am trying to do supported by Drools?
> >
> > Thank you,
> > Mark
> >
> >
> > -- Original message --
> > From: [EMAIL PROTECTED]
> > > My rule now appears to be working after switching from the
> > "excludes"  operator
> > > to the newer "not contains".
> > >
> > > This works:
> > > $ca:CandidateAssociation(nurseDetails.stateLicensures not contains
> > > patientDetails.state  )
> > >
> > > This does not:
> > > $ca:CandidateAssociation(nurseDetails.stateLicensures excludes
> > > patientDetails.state  )
> > >
> > >
> > > Mark
> > >
> > >  -- Original message --
> > > From: [EMAIL PROTECTED]
> > > > Hello,
> > > >
> > > > Please excuse me if I have double posted - my first did not seem to
> > appear.
> > > >
> > > > I am wondering if the following is valid rule syntax. I am getting  a
> > > stacktrace
> > > > when the rules fire that points to a ClassCastException on a HashSet
> > > >
> > > > I am using v4.0 GA.
> > > >
> > > > Thank you, Mark
> > > >
> > > >
> > > > rule StateMatch
> > > > when
> > > > $ca:CandidateAssociation(nurseDetails.stateLicensures excludes
> > > > patientDetails.state  )
> > > > then
> > > > retract( $ca );
> > > > end
> > > >
> > > >
> > > > public class CandidateAssociation {
> > > > private PatientDetails patientDetails;
> > > > private NurseDetails   nurseDetails;
> > > > private int overlapHours;
> > > >
> > > > public CandidateAssociation( PatientDetails patientDetails,
> > NurseDetails
> > > > nurseDetails) {
> > > > super();
> > > > this.patientDetails = patientDetails;
> > > > this.nurseDetails = nurseDetails;
> > > > overlapHours =
> > > > participantDetails.get

[rules-users] Why does Drools' RuleBase.addPackage() Behave This Way?

2007-08-02 Thread Jin, Ming
I am benchmarking Drools 4.0 and received excellent results in rule
execution.  With our non-optimized test rule set and data, Drools out
performed ILOG/JRules by quite a bit.  Congratulations to Drools' team
for a job well done.
 
I encountered a strange behavior when trying to test the performance of
rule registration, meaning to add Package's to a new instance of
RuleBase.  I ran the same test 5 times in a sequence, and the RuleBase
instance was discarded right away.  The test ran with different
different number of packages, 20, 50, 100, and 200.  The results are as
the followings:
 
Added 20 packages to rulebase in 0:00:0.15
Added 20 packages to rulebase in 0:00:0.21
Added 20 packages to rulebase in 0:00:0.21
Added 20 packages to rulebase in 0:00:0.301
Added 20 packages to rulebase in 0:00:0.18
Added 20 packages to rulebase 5 times in 0:00:1.051
 
Added 50 packages to rulebase in 0:00:0.17
Added 50 packages to rulebase in 0:00:1.422
Added 50 packages to rulebase in 0:00:1.252
Added 50 packages to rulebase in 0:00:1.322
Added 50 packages to rulebase in 0:00:1.331
Added 50 packages to rulebase 5 times in 0:00:5.497
 
Added 100 packages to rulebase in 0:00:0.19
Added 100 packages to rulebase in 0:00:5.278
Added 100 packages to rulebase in 0:00:5.297
Added 100 packages to rulebase in 0:00:5.228
Added 100 packages to rulebase in 0:00:5.327
Added 100 packages to rulebase 5 times in 0:00:21.32
 
Added 200 packages to rulebase in 0:00:0.22
Added 200 packages to rulebase in 0:00:21.691
Added 200 packages to rulebase in 0:00:21.481
Added 200 packages to rulebase in 0:00:21.642
Added 200 packages to rulebase in 0:00:21.341
Added 200 packages to rulebase 5 times in 0:01:26.385
 
As you can see, the timing of creating first RuleBase instance is always
good, while the subsequent one's were very bad.  Is there an attribute I
could adjust in configuration to improve the performance for this
scenario?  Please advise if there is other alternatives.  I would be
glad to provide details if needed.
 
Your help is greatly appreciated!
-Ming
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Drools 4.0 StateExampleWithDynamicRules Question

2007-08-02 Thread Daren Chylinski
Hello,

 

I am a new Drools user working my way through the examples.  To test my
understanding of how the rules work, I modified the
StateExampleUsingSalience.drl file used in the
StateExampleWithDynamicRules example.  The result of my change
conflicted with my understanding of how the rules should work.

 

I made two modifications in the StateExampleUsingSalience.drl file.  The
two modifications (shown below) are the commenting out of the two lines
in the RHS portion of the "B to D" rule.  My understanding of how this
would affect the result was:  because the "D" State object never changes
state to "State.FINISHED" the RHS portion of the "D to E" rule (shown
below) would not execute because the first pattern in the LHS would fail
to find a State object in working memory that met the criteria of the
constraint groups defined within it.

 

My question is:  Why does the "D to E" rule in the
StateExampleDynamicRules.drl execute the statements in the RHS portion
of the rule?

 

>From StateExampleUsingSalience.drl:  My changes in this file are the two
lines commented out in the RHS portion.

 

rule "B to D"

  when

State(name == "B", state == State.FINISHED )

d : State(name == "D", state == State.NOTRUN )

  then

//System.out.println(d.getName() + " finished" );

//d.setState( State.FINISHED );

end

 

 

>From StateExampleDynamicRules.drl:  This is the rule where I expected
the RHS portion to NOT get executed because there aren't any State
objects in working memory that have their name == "D" and its state ==
State.FINISHED because the setState( State.FINISHED ) was never executed
on the "D" state object.

 

rule "D to E"

  when

State(name == "D", state == State.FINISHED )

e : State(name == "E", state == State.NOTRUN )

  then

System.out.println(e.getName() + " finished" );

e.setState( State.FINISHED );

end

 

After my modifications, the output was:

 

A finished

B finished

C finished

E finished

 

I did not expect the "E finished" message to be printed.

 

 

Regards,

Daren

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


Re: [rules-users] Update error: handle not found for object

2007-08-02 Thread Edson Tirelli
   Hi,

   Please note that java.lang.Integer is an immutable class. So, what is
happening when you do:

unEntier++;
update(unEntier);

   is that java is actually doing is creating another, different
java.lang.Integer object (using auto-boxing/unboxing).
   What you need to do is:

rule "incrementation"
no-loop
when
unEntier : java.lang.Integer()
then
retract( unEntier );
unEntier++;
System.out.println("incrementation firing...");
insert(unEntier);
end


[]s
Edson

2007/8/2, hypnosat7 <[EMAIL PROTECTED]>:
>
>
> hi I have an exception after using an update
>
>   This is my rule :
>
> package packageDrlTest
>
> #list any import classes here.
> import java.lang.Integer;
>
>
> #declare any global variables here
>
> rule "incrementation"
> no-loop
> when
> unEntier : java.lang.Integer()
> then
> unEntier++;
> System.out.println("incrementation firing...");
> update(unEntier);
>
> end
>
>
> when I execute my rule on this list of facts :
>
> List integerList = new ArrayList();
> integerList.add(Integer.valueOf(1));
> for (Object fact : integerList )
> {
> session.insert(fact);  // session is a StatefulMemory
> }
>
> Update error: handle not found for object: 2. Is it in the working memory?
>
> détails :
>
> incrementation firing...
> org.drools.FactException: Update error: handle not found for object: 2. Is
> it in the working memory?
> at
> org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java
> :93)
> at
> packageDrlTest.Rule_incrementation_0.consequence
> (Rule_incrementation_0.java:9)
> at
> packageDrlTest.Rule_incrementation_0ConsequenceInvoker.evaluate
> (Rule_incrementation_0ConsequenceInvoker.java:22)
> at org.drools.common.DefaultAgenda.fireActivation(
> DefaultAgenda.java:545)
> at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java
> :509)
> at
> org.drools.common.AbstractWorkingMemory.fireAllRules(
> AbstractWorkingMemory.java:430)
> at
> org.drools.common.AbstractWorkingMemory.fireAllRules(
> AbstractWorkingMemory.java:392)
> --
> View this message in context:
> http://www.nabble.com/Update-error%3A-handle-not-found-for-object-tf4206369.html#a11965297
> 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
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  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] correlating two collects

2007-08-02 Thread Edson Tirelli
Yury,

Correlation can happen in many ways, but I would say your general
approach is correct. Answering your questions:

1. Both collect and accumulate work (as it is today) on single patterns.
This means whenever you are using collect, you could be using accumulate.
Just have in mind that accumulate is more powerful and flexible that
collect, but it is also heavier. So, if collect does what you need, go with
collect, otherwise fall back to accumulate.

3. Collect is incremental (on 4.0 GA) for all working memory operations:
insert/update/retract. Accumulate is always incremental for insert, but for
modify and retract it is incremental only if you provide the "reverse"
action in case you are using adhoc operations. If you are using accumulate
functions, modify and retract are incremental if the function supports
reverse calculation.

[]s
Edson

2007/8/1, Yuri de Wit <[EMAIL PROTECTED]>:
>
> I am finally having some time to use collects. What I basically need
> to do is to collect items from a list using a specific criteria, then
> collect items from a diff list using another criteria, and finally
> compare the groups collected using a 3rd criteria
>
> Here is what I am thinking:
>
> i : Item(type==A)
> ig : ItemGroup(size>1)
>  collect Item(a==i.a, b==i.b, ... n==i.n)
>
> i2: Item(type==B)
> ig2 : ItemGroup( size>1,
>  ga==ig.ga, gb==i.gb,  )
>  collect Item(a==i.a, b==i.b, ... n==i.n)
>
> 1) It is quite nice that any implementation of java.util.Collection
> can be the resut of collect. ItemGroup here not only keeps hold of all
> Items returned but has some aggregate properties (afaik, I cannot use
> the aggregate functions with accumulate since I have multiple column
> aggregation).
>
> 2) Am I on the right track? Or is there a better way?
>
> 3) Is the collect recomputed from scratch or incrementally every time
> a new fact is asserted or updated?
>
> thanks
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  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] Update error: handle not found for object

2007-08-02 Thread hypnosat7

hi I have an exception after using an update

  This is my rule :

package packageDrlTest

#list any import classes here.
import java.lang.Integer;


#declare any global variables here

rule "incrementation"
no-loop 
when
unEntier : java.lang.Integer()
then 
unEntier++;
System.out.println("incrementation firing...");
update(unEntier);

end


when I execute my rule on this list of facts :

List integerList = new ArrayList();
integerList.add(Integer.valueOf(1));
for (Object fact : integerList )
{
session.insert(fact);  // session is a StatefulMemory
}

Update error: handle not found for object: 2. Is it in the working memory?

détails :

incrementation firing...
org.drools.FactException: Update error: handle not found for object: 2. Is
it in the working memory?
at
org.drools.base.DefaultKnowledgeHelper.update(DefaultKnowledgeHelper.java:93)
at
packageDrlTest.Rule_incrementation_0.consequence(Rule_incrementation_0.java:9)
at
packageDrlTest.Rule_incrementation_0ConsequenceInvoker.evaluate(Rule_incrementation_0ConsequenceInvoker.java:22)
at 
org.drools.common.DefaultAgenda.fireActivation(DefaultAgenda.java:545)
at org.drools.common.DefaultAgenda.fireNextItem(DefaultAgenda.java:509)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:430)
at
org.drools.common.AbstractWorkingMemory.fireAllRules(AbstractWorkingMemory.java:392)
-- 
View this message in context: 
http://www.nabble.com/Update-error%3A-handle-not-found-for-object-tf4206369.html#a11965297
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] High Performance Rules Environment

2007-08-02 Thread Edson Tirelli
Robert,

This is a very complex evaluation to do, since most of the published
benchmarks will give you different results for the same rules engine. :)
Also, the first and third links you listed bellow, all refer to Drools
2.xseries that were not Rete complete implementations. Just to show
you the
difference between drools 2.x and 3.x, check this:

http://blog.athico.com/2006/11/rush-hour-and-content-based-routing.html

Drools 4.x is even faster for complex rules scenarios with lots of
partial matches.

The testimonies though are good for you to check out as they are recent
testimonies.

Best thing to do would be, if possible, to build a prototype with a use
case closer to what you need and check the numbers out. We are sure that on
a face to face performance comparison, you will be pleasant surprised with
the power of the Drools rules engine.

If you need help on the prototype, just mail the list, or if you want
official support for it, just contact Red Hat.

Regards,
   Edson


2007/8/1, Robert Mertens <[EMAIL PROTECTED]>:
>
>
> I would be interested in any feedback from users who have used / are using
> the JBoss Rules engine in a high performance environment.
>
> In order to justify the use of JBoss Rules / Drools, I need to be able to
> reference implementations that are using this rule engine in a production
> environment.
>
> The BRMS components that form part of release 4.0 allow it to be evaluated
> alongside Ilog Rules and Blaze Advisor; however, I really need some case
> studies that detail the numbers of facts and rules that are in production
> use, and any related stability issues.
>
> To date, I have come across the following links :
>
> http://legacy.drools.codehaus.org/Testimonies
> http://lists.jboss.org/pipermail/rules-users/2007-July/002097.html
> http://geekswithblogs.net/cyoung/articles/54022.aspx - Microsoft's Rule
> Engine Scalability Results - A comparison with Jess and Drools
>
> Does anybody know of any links to case studies, or performance
> /scalability
> tests?
>
> Thanks
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  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] rule name regular expression

2007-08-02 Thread Edson Tirelli
Hi, yes, close to that:

name returns [String name]
: ID { $name = $ID.text; }
| STRING { $name = getString( $STRING.text ); }
;

So, a rule name can be either an ID or a STRING. ID is what you got
already:

ID
:
('a'..'z'|'A'..'Z'|'_'|'$'|'\u00c0'..'\u00ff')('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'\u00c0'..'\u00ff')*

;

A String is a valid Java string... so pretty much anything enclosed in
either " or '.

STRING
:  ('"' ( EscapeSequence | ~('\\'|'"') )* '"')
 | ('\'' ( EscapeSequence | ~('\\'|'\'') )* '\'')
;

In other words, if you want to allow the user to write rule names and
don't want to bother in validating it, just enclose the rule name in " and
be done with it. The only thing that may be good is to limit the length of
the string... you may want to use a hard limit around 60 characters I guess.

[]s
Edson

[]s
Edson

2007/8/2, hypnosat7 <[EMAIL PROTECTED]>:
>
>
> No I mean how can I check the validity of the rule names before put it in
> a
> DB, maybe I have to look to DRL.g grammar file ?
> is it this :
>
> ID
> :
>
> ('a'..'z'|'A'..'Z'|'_'|'$'|'\u00c0'..'\u00ff')('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'\u00c0'..'\u00ff')*
>
> thanks
>
>
>
> Mark Proctor wrote:
> >
> > There is no regexp for this. Easiest thing to do is make a package with
> > a single rule in it and pass it into a packagebuilder session.
> >
> > Mark
> > hypnosat7 wrote:
> >> Hi,
> >>   When can I find the regular expression to check the validity of a
> rule
> >> name ?
> >> thanks
> >>
> >
> > ___
> > rules-users mailing list
> > rules-users@lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/rule-name-regular-expression-tf4201280.html#a11959690
> 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
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  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] Inheritance

2007-08-02 Thread Mark Proctor

yes.

In that Collect(...) will match anything that implements Collection, be 
it List, ArrayList etc.


Mark
Heyns, Juan wrote:


If I have two objects asserted into working memory and the one is 
inherited from the other will a rule such as the following fire on 
both objects (Person and Employee):


 


Rule

When

Person( property == "bla" )

Then

[...]

End

 


Juan

 


"Employees of Lonmin Platinum ("Lonplats") are not authorised to conclude
electronic transactions or to enter into electronic agreements on behalf
of Lonplats. Any electronic signature (other than an advanced electronic
signature as defined in the Electronic Communications and Transactions
Act of 2003) added to a data message (such as an email or an attachment
to an (email) ostensibly on behalf of Lonplats by a Lonplats employee 
shall
not be legally binding on Lonplats and Lonplats shall incur no 
liability of
any nature whatsoever, directly or indirectly, arising from such act 
on the

part of it's employee. It is further recorded that nothing (other than an
advanced electronic signature) inserted into any data message
emanating from Lonplats shall be construed as constituting an electronic
signature"



___
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] Re: nested accessors with Sets

2007-08-02 Thread Edson Tirelli
Arjun,

I guess your questions are about 2 different subjects.

1. The non-existence of an object is handled by the NOT CE. So, if you want
to say: there is no Bus asserted into working memory, you simply say:

not Bus()

If you want to say: there is no red bus asserted into working memory, you
simply say:

not Bus( color == "red" )

In the above case, even if there is a blue bus asserted, but not a red one,
the CE will evaluate to true.
If you want to say: there is a MyComposedObject whose active attribute is
false or none MyComposedObject at all, you could say something like:

when
MyComposedObject(active == false) or
not MyComposedObject()
Then
  //Action
End

http://labs.jboss.com/file-access/default/members/drools/freezone/docs/4.0.0.13773GA/html/ch06s05.html#d0e3622

2. The use of contains and memberOf constraints. They both work on
collections and arrays. The "in" operator only works on explicit lists of
values:

Composer( this contains "abc" ) // valid
Composer( this contains $anotherObject ) // valid
Component( this memberOf $composer.components )  // valid
Cheese( type in ( "stilton", $muzzarela, Cheese.PROVOLONE ) ) // valid

The negation of all of these operators works the same.

http://labs.jboss.com/file-access/default/members/drools/freezone/docs/4.0.0.13773GA/html/ch06s05.html#d0e2992

Please, read the docs and suggest improvements for everything that is
not clear there.

Thanks,
 Edson


2007/8/2, Arjun Dhar <[EMAIL PROTECTED]>:
>
>  comcast.net> writes:
>
> >
> > My rule now appears to be working after switching from the "excludes"
> operator to the newer "not contains".
> >
> > This works:
> > $ca:CandidateAssociation(nurseDetails.stateLicensures not contains
> patientDetails.state  )
> >
> > This does not:
> > $ca:CandidateAssociation(nurseDetails.stateLicensures excludes
> patientDetails.state  )
> >
> > Mark
>
>
> I was just about to post a question and I think this may be the answer to
> my
> problem as well. So let me confirm.
>
> Question) I hvae a rule
>
> When
> obj: MyComposedObject(active == false)
> Then
>   //Action
> End
>
> .. the problem is, if the above object was never asserted; I still want it
> to
> execute. Luckily MyComposedObject is  composend inside another object, so
> can i
> use the technique above as>
>
> When
> obj: Composer( this not contains MyComposedObject)
> End
>
> or even obj: Composer( this not in MyComposedObject)
>
>
> ... My Composer simply composes the object and does not contain it in a
> list.
>
> Q1) So would either or both "not contains" or "not in" work?
> Q2) Or is "not contains" only for List or Collection type? what about
> HashMaps
> then?
> Q3) Stretching my actual use case to its limits; if I want to write
> conditions
> over objects that were never asserted into the working memory (need to OR
> them
> with existing) ones, how do I do that? I understand technically it does
> not
> make sense to want conditions over objects one never asserted; ... but
> please
> think a moment. A person asserts Objects and due to some external factor
> some
> objects do not get asserted. Since he is aware of it, can he trap that
> conidtion in the rule itself?
> Example: Assertions --> (Object Type) A1, A2, A4
>
> RULES: I never got Object type A3 so Do Notify Admin <-- How to write such
> a
> rule?
>
> I hope I'm able to express my use case.
>
>
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  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] nested accessors with Sets

2007-08-02 Thread Edson Tirelli
   Mark,

   Sorry for not answering before. I was doing some research.
   What you found is a bug. Contains and not contains are supported
operations in Drools, but the case you are facing is that you are using
these operators with accessors expressions (e.g.
nurseDetails.stateLicensures ). When an accessor expression is used, the
engine converts the whole expression in an inline-eval. So what you are
doing will be interpreted by the engine as:

   $ca:CandidateAssociation( eval ( nurseDetails.stateLicensures not
contains patientDetails.state  ) )

Problem is that "not contains" is not a valid operator for MVEL. May I
ask you please to open a JIRA for that? I will fix it asap.

Meanwhile, to work around the problem you can either avoid the accessor
path expression when using "contains/memberOf/matches" and their
corresponding negations, or write the inline eval yourself, avoid a
mistranslation by the engine. So, if you are using mvel dialect for your
rule, you could write:

rule XXX
dialect "mvel"
when
   $ca:CandidateAssociation( eval ( ! nurseDetails.stateLicensures.contains(
patientDetails.state ) ) )
then
   // do something
end

  Please not that as you are explicitly declaring the mvel dialect for your
rule, your consequence will also be an MVEL block.

  Sorry for the inconvenience. I will fix that for 4.0.1.

  Thanks,
  Edson

2007/8/1, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
>
> Actually, it is still broken.
>
> This does not complain but it always executes the consequence, even when
> the stateLicensures includes the state that in patientDetails.state
>
>$ca:CandidateAssociation(nurseDetails.stateLicensures not contains
> patientDetails.state  )
>
>
> I also tried the following but it complains with an Exception
>
>   $ca:CandidateAssignment(participantDetails.state not memberof
> nurseDetails.stateLicensures  )
>
>
> org.drools.rule.InvalidRulePackage: [13,50]: unknown:13:50 Unexpected
> token 'not'[13,93]: unknown:13:93 mismatched token:
> [EMAIL PROTECTED],574:574=')',<13>,13:93]; expecting type LEFT_PAREN
> at org.drools.rule.Package.checkValidity(Package.java:408)
> at org.drools.common.AbstractRuleBase.addPackage(
> AbstractRuleBase.java:288)
>
>
> Is what I am trying to do supported by Drools?
>
> Thank you,
> Mark
>
>
> -- Original message --
> From: [EMAIL PROTECTED]
> > My rule now appears to be working after switching from the
> "excludes"  operator
> > to the newer "not contains".
> >
> > This works:
> > $ca:CandidateAssociation(nurseDetails.stateLicensures not contains
> > patientDetails.state  )
> >
> > This does not:
> > $ca:CandidateAssociation(nurseDetails.stateLicensures excludes
> > patientDetails.state  )
> >
> >
> > Mark
> >
> >  -- Original message --
> > From: [EMAIL PROTECTED]
> > > Hello,
> > >
> > > Please excuse me if I have double posted - my first did not seem to
> appear.
> > >
> > > I am wondering if the following is valid rule syntax. I am getting  a
> > stacktrace
> > > when the rules fire that points to a ClassCastException on a HashSet
> > >
> > > I am using v4.0 GA.
> > >
> > > Thank you, Mark
> > >
> > >
> > > rule StateMatch
> > > when
> > > $ca:CandidateAssociation(nurseDetails.stateLicensures excludes
> > > patientDetails.state  )
> > > then
> > > retract( $ca );
> > > end
> > >
> > >
> > > public class CandidateAssociation {
> > > private PatientDetails patientDetails;
> > > private NurseDetails   nurseDetails;
> > > private int overlapHours;
> > >
> > > public CandidateAssociation( PatientDetails patientDetails,
> NurseDetails
> > > nurseDetails) {
> > > super();
> > > this.patientDetails = patientDetails;
> > > this.nurseDetails = nurseDetails;
> > > overlapHours =
> > > participantDetails.getNumberOverlapHourCnt(nurseDetails);
> > > }
> > > [...]
> > > }
> > >
> > > public class NurseDetails {
> > > private Set stateLicensures = new HashSet();
> > > [...]
> > > }
> > > public class PatientDetails {
> > > private String state;
> > > [...]
> > > }
> > >
> > > --
> > > Firing Rules
> > > **
> > > org.drools.RuntimeDroolsException: Exception executing predicate
> > > [EMAIL PROTECTED]
> > > at
> > > org.drools.rule.PredicateConstraint.isAllowed(PredicateConstraint.java
> :197)
> > > at org.drools.reteoo.AlphaNode.assertObject(AlphaNode.java:121)
> > > at
> > >
> > org.drools.reteoo.CompositeObjectSinkAdapter.propagateAssertObject
> (CompositeObje
> > > ctSinkAdapter.java:317)
> > > at
> > > org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:159)
> > > at org.drools.reteoo.Rete.assertObject(Rete.java:175)
> > > at
> > > org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:190)
> > > at
> > > org.drools.reteoo.ReteooWorkingMemory.d

[rules-users] Inheritance

2007-08-02 Thread Heyns, Juan

If I have two objects asserted into working memory and the one is
inherited from the other will a rule such as the following fire on both
objects (Person and Employee):



Rule

When

Person( property == "bla" )

Then

[...]

End



Juan





"Employees of Lonmin Platinum ("Lonplats") are not authorised to conclude
electronic transactions or to enter into electronic agreements on behalf
of Lonplats. Any electronic signature (other than an advanced electronic
signature as defined in the Electronic Communications and Transactions
Act of 2003) added to a data message (such as an email or an attachment
to an (email) ostensibly on behalf of Lonplats by a Lonplats employee shall
not be legally binding on Lonplats and Lonplats shall incur no liability of
any nature whatsoever, directly or indirectly, arising from such act on the
part of it's employee. It is further recorded that nothing (other than an
advanced electronic signature) inserted into any data message
emanating from Lonplats shall be construed as constituting an electronic
signature"___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] LHS use of from with a static method

2007-08-02 Thread Mark Proctor
turns out for static fields there was an MVEL regression, this has been 
picked up and fixed  and will be part of 4.0.1 There where a number of 
MVEL regressions, in both the MVEL engine and Tooling. 4.0.1 aims to fix 
all of this, which will be out next week.


Mark
Heyns, Juan wrote:


Hello everyone

 


I have a rule:

 


rule "my rule name"

no-loop

when

Object1( $property1: property1 );

Object2( testvalue == "Test String" ) 
from StaticClass.aMethod($property1)


then

aFunction();

end

 

 

I cannot seem to get the StaticClass.aMethod to return anything but 
null. I have a test case for this method somewhere else and it seems 
to work fine. Is this a legal operation? Could it be that the version 
I am using (jbossrules-4.0.0.11754MR2-bin) still does not have support 
for this?


 


Regards

Juan

 


"Employees of Lonmin Platinum ("Lonplats") are not authorised to conclude
electronic transactions or to enter into electronic agreements on behalf
of Lonplats. Any electronic signature (other than an advanced electronic
signature as defined in the Electronic Communications and Transactions
Act of 2003) added to a data message (such as an email or an attachment
to an (email) ostensibly on behalf of Lonplats by a Lonplats employee 
shall
not be legally binding on Lonplats and Lonplats shall incur no 
liability of
any nature whatsoever, directly or indirectly, arising from such act 
on the

part of it's employee. It is further recorded that nothing (other than an
advanced electronic signature) inserted into any data message
emanating from Lonplats shall be construed as constituting an electronic
signature"



___
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] Re: Production rules vs. ECA Rules

2007-08-02 Thread Mark Proctor
If anyone is interestined in creating a drools-eca extension module, to 
allow for ECA style event creation and handling, let me know, as its 
definitely something we would like to support.


Mark
Tomas Olsson wrote:

Hi,

I think one can say that in ECA there is a conceptually difference 
between events and conditions. Events are modeled explicitly as a 
separate concept outside the condition part. This can be

a nice for modeling since you can separate the "event" that triggers
rule execution from the internal conditions that governs what rules to
execute. I have a paper that describes an SLA evaluator in terms of ECA
implemented with Drools 2:
http://www.sics.se/spot/document/QoS_using_SLA.pdf (see page 8). In
short: the evaluator receives notifications and scheduled executions as
events and reacts to them.

Thus you can use JBoss Drools to implement ECA but you have to create
the event model yourself. In an ECA engine this is already done for you
and you get a language to somehow express the events.

/Tomas

[EMAIL PROTECTED] wrote:

Hi Mark,

in which constellations i should select ECAs? What is the difference 
between events in ECAs and the occurrence of a certain set of facts 
in WorkingMemory in case of production rules?


In following document they classify ECAs and production rules both as 
reactive rules, but they state they are somehow different:


http://www.pms.ifi.lmu.de/publikationen/PMS-FB/PMS-FB-2007-8/PMS-FB-2007-8-reactive-rules-on-the-web.pdf 



And they state that JBoss Rules is only for production rules.  So can 
I use JBoss Rules for implementing ECAs?

Thanks and best regards,

Kioumars


Date: Mon, 30 Jul 2007 19:20:51 +0100
From: Mark Proctor <[EMAIL PROTECTED]>
Subject: Re: [rules-users] Production rules vs. ECA Rules
To: Rules Users List 
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=UTF-8; format=flowed

ECA is really a specialised subset of Product Rules; focusing more on
generic event generation and event handling.

Mark
[EMAIL PROTECTED] wrote:
 

Dear List,

In JBoss Rules documentation it is written that they can be used for 
production rules. But I frequently read also in other sources about 
ECA rules.


Is there any significant difference between “ECA† and 
“Production† Rules?

If yes, what?

Thanks in advance for your feedback and best Regards,

Kioumars





  




___
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] Re: Production rules vs. ECA Rules

2007-08-02 Thread Tomas Olsson

Hi,

I think one can say that in ECA there is a conceptually difference 
between events and conditions. Events are modeled explicitly as a 
separate concept outside the condition part. This can be

a nice for modeling since you can separate the "event" that triggers
rule execution from the internal conditions that governs what rules to
execute. I have a paper that describes an SLA evaluator in terms of ECA
implemented with Drools 2:
http://www.sics.se/spot/document/QoS_using_SLA.pdf (see page 8). In
short: the evaluator receives notifications and scheduled executions as
events and reacts to them.

Thus you can use JBoss Drools to implement ECA but you have to create
the event model yourself. In an ECA engine this is already done for you
and you get a language to somehow express the events.

/Tomas

[EMAIL PROTECTED] wrote:

Hi Mark,

in which constellations i should select ECAs? What is the difference between 
events in ECAs and the occurrence of a certain set of facts in WorkingMemory in 
case of production rules?

In following document they classify ECAs and production rules both as reactive 
rules, but they state they are somehow different:

http://www.pms.ifi.lmu.de/publikationen/PMS-FB/PMS-FB-2007-8/PMS-FB-2007-8-reactive-rules-on-the-web.pdf

And they state that JBoss Rules is only for production rules.  
So can I use JBoss Rules for implementing ECAs? 


Thanks and best regards,

Kioumars


Date: Mon, 30 Jul 2007 19:20:51 +0100
From: Mark Proctor <[EMAIL PROTECTED]>
Subject: Re: [rules-users] Production rules vs. ECA Rules
To: Rules Users List 
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=UTF-8; format=flowed

ECA is really a specialised subset of Product Rules; focusing more on
generic event generation and event handling.

Mark
[EMAIL PROTECTED] wrote:
  

Dear List,

In JBoss Rules documentation it is written that they can be used for production 
rules. But I frequently read also in other sources about ECA rules.

Is there any significant difference between “ECA† and “Production† 
Rules?
If yes, what?

Thanks in advance for your feedback and best Regards,

Kioumars





  




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


[rules-users] LHS use of from with a static method

2007-08-02 Thread Heyns, Juan

Hello everyone



I have a rule:



rule "my rule name"

no-loop

when

Object1( $property1: property1 );

Object2( testvalue == "Test String" )
from StaticClass.aMethod($property1)

then

aFunction();

end





I cannot seem to get the StaticClass.aMethod to return anything but
null. I have a test case for this method somewhere else and it seems to
work fine. Is this a legal operation? Could it be that the version I am
using (jbossrules-4.0.0.11754MR2-bin) still does not have support for
this?



Regards

Juan





"Employees of Lonmin Platinum ("Lonplats") are not authorised to conclude
electronic transactions or to enter into electronic agreements on behalf
of Lonplats. Any electronic signature (other than an advanced electronic
signature as defined in the Electronic Communications and Transactions
Act of 2003) added to a data message (such as an email or an attachment
to an (email) ostensibly on behalf of Lonplats by a Lonplats employee shall
not be legally binding on Lonplats and Lonplats shall incur no liability of
any nature whatsoever, directly or indirectly, arising from such act on the
part of it's employee. It is further recorded that nothing (other than an
advanced electronic signature) inserted into any data message
emanating from Lonplats shall be construed as constituting an electronic
signature"___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Fwd: correlating two collects

2007-08-02 Thread Yuri de Wit
second try... (this is actually happenning too often)

-- Forwarded message --
From: Yuri de Wit <[EMAIL PROTECTED]>
Date: Aug 1, 2007 9:38 PM
Subject: correlating two collects
To: Rules Users List 


I am finally having some time to use collects. What I basically need
to do is to collect items from a list using a specific criteria, then
collect items from a diff list using another criteria, and finally
compare the groups collected using a 3rd criteria

Here is what I am thinking:

i : Item(type==A)
ig : ItemGroup(size>1)
 collect Item(a==i.a, b==i.b, ... n==i.n)

i2: Item(type==B)
ig2 : ItemGroup( size>1,
 ga==ig.ga, gb==i.gb,  )
 collect Item(a==i.a, b==i.b, ... n==i.n)

1) It is quite nice that any implementation of java.util.Collection
can be the resut of collect. ItemGroup here not only keeps hold of all
Items returned but has some aggregate properties (afaik, I cannot use
the aggregate functions with accumulate since I have multiple column
aggregation).

2) Am I on the right track? Or is there a better way?

3) Is the collect recomputed from scratch or incrementally every time
a new fact is asserted or updated?

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


Re: [rules-users] drools 4.0 compilation

2007-08-02 Thread Mark Proctor
While drools 2.x was limited to XML, 4.0 preference is for the DRL, 
which is a none xml format. It doesn't produce a jar at the moment just 
a binary Packaage instance, which you can serialise.


Mark
fuadhamidov wrote:
hi, 


i developed my project using drools 2.5. now i want to upgrade to drools
4.0. in my project i 

(1) create xml file, 
(2) compile xml file & get jar file, 
(3) save jar file 
(4) and load jar file when i need to run rules


i was able to upgrade xml file to drools 4.0 xml format, but i can not do
necessary modification in code to compile xml and get "jar or any reloadable
file".
There is my code that is developed for drools 2.5. Can you help me to
upgrade it for drools 4.0?




void compile() throws Exception {
// read xml file, returns data in xml format
	String rulecontent = readRuleFromFile(); 
	byte[] bytes = null;


// codes for drools 2.5. i want to develop corresponding code for 4
statement bellow that runs with drools 4.0
// RuleSetReader reader = new RuleSetReader();
// RuleSet ruleSet = reader.read(new BufferedReader(new
StringReader(rulecontent)));
// RuleSetCompiler compiler = new RuleSetCompiler(ruleSet, "com.sample",
"knowledgeHelper");
// bytes = compiler.getBinaryDeploymentJar();

// some codes for drools 4.0, but it is not finilized
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromXml(new BufferedReader(new
StringReader(rulecontent)));
Package pkg = builder.getPackage();
	//... and then what? how do it get bytecode from package? 
	//may be 3 statements are not necessary for compilation	


// save to disk as a jar file
	writeRuleToJar(bytes); 
}



void runrule(Object usg) throws Exception {
// runs both, drools 2.5 and drools 4.0
ConflictResolver[] conflictResolvers = new ConflictResolver[] {
SalienceConflictResolver.getInstance(),
ComplexityConflictResolver.getInstance(),
FifoConflictResolver.getInstance() };
CompositeConflictResolver compositeConflictResolver = new
CompositeConflictResolver(conflictResolvers);
byte[] bytecode = readRuleFromJar();

// i can not develope this part also
// RuleBaseLoader loader = new 
RuleBaseLoader(compositeConflictResolver);
// loader.addFromByteArray(bytecode);
// RuleBase ruleBase = loader.buildRuleBase();

// modification in code for drools 4.0
// WorkingMemory workingMemory = ruleBase.newWorkingMemory();
WorkingMemory workingMemory = ruleBase.newStatefulSession();
// workingMemory.assertObject(usg);
workingMemory.insert(usg);
workingMemory.fireAllRules();
}
  


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


[rules-users] drools 4.0 compilation

2007-08-02 Thread fuadhamidov

hi, 

i developed my project using drools 2.5. now i want to upgrade to drools
4.0. in my project i 

(1) create xml file, 
(2) compile xml file & get jar file, 
(3) save jar file 
(4) and load jar file when i need to run rules

i was able to upgrade xml file to drools 4.0 xml format, but i can not do
necessary modification in code to compile xml and get "jar or any reloadable
file".
There is my code that is developed for drools 2.5. Can you help me to
upgrade it for drools 4.0?




void compile() throws Exception {
// read xml file, returns data in xml format
String rulecontent = readRuleFromFile(); 
byte[] bytes = null;

// codes for drools 2.5. i want to develop corresponding code for 4
statement bellow that runs with drools 4.0
// RuleSetReader reader = new RuleSetReader();
// RuleSet ruleSet = reader.read(new BufferedReader(new
StringReader(rulecontent)));
// RuleSetCompiler compiler = new RuleSetCompiler(ruleSet, "com.sample",
"knowledgeHelper");
// bytes = compiler.getBinaryDeploymentJar();

// some codes for drools 4.0, but it is not finilized
PackageBuilder builder = new PackageBuilder();
builder.addPackageFromXml(new BufferedReader(new
StringReader(rulecontent)));
Package pkg = builder.getPackage();
//... and then what? how do it get bytecode from package? 
//may be 3 statements are not necessary for compilation 

// save to disk as a jar file
writeRuleToJar(bytes); 
}


void runrule(Object usg) throws Exception {
// runs both, drools 2.5 and drools 4.0
ConflictResolver[] conflictResolvers = new ConflictResolver[] {
SalienceConflictResolver.getInstance(),
ComplexityConflictResolver.getInstance(),
FifoConflictResolver.getInstance() };
CompositeConflictResolver compositeConflictResolver = new
CompositeConflictResolver(conflictResolvers);
byte[] bytecode = readRuleFromJar();

// i can not develope this part also
// RuleBaseLoader loader = new 
RuleBaseLoader(compositeConflictResolver);
// loader.addFromByteArray(bytecode);
// RuleBase ruleBase = loader.buildRuleBase();

// modification in code for drools 4.0
// WorkingMemory workingMemory = ruleBase.newWorkingMemory();
WorkingMemory workingMemory = ruleBase.newStatefulSession();
// workingMemory.assertObject(usg);
workingMemory.insert(usg);
workingMemory.fireAllRules();
}
-- 
View this message in context: 
http://www.nabble.com/drools-4.0-compilation-tf4204509.html#a11959523
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] rule name regular expression

2007-08-02 Thread hypnosat7

No I mean how can I check the validity of the rule names before put it in a
DB, maybe I have to look to DRL.g grammar file ?
is it this :

ID  
:
('a'..'z'|'A'..'Z'|'_'|'$'|'\u00c0'..'\u00ff')('a'..'z'|'A'..'Z'|'_'|'0'..'9'|'\u00c0'..'\u00ff')*
 

thanks



Mark Proctor wrote:
> 
> There is no regexp for this. Easiest thing to do is make a package with 
> a single rule in it and pass it into a packagebuilder session.
> 
> Mark
> hypnosat7 wrote:
>> Hi,
>>   When can I find the regular expression to check the validity of a rule
>> name ?
>> thanks
>>   
> 
> ___
> rules-users mailing list
> rules-users@lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/rule-name-regular-expression-tf4201280.html#a11959690
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