Re: [rules-users] Guvnor Test Scenario - value equality

2009-11-13 Thread Anstis, Michael (M.)
Please attach your (rule) source.
 
You don't provide much for the community to go on.




From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Libor Nenadál
Sent: 13 November 2009 13:59
To: rules-users@lists.jboss.org
Subject: [rules-users] Guvnor Test Scenario - value equality


Hello, I came to a problem when scenario fails because field values do 
not equal to those expected although they actually do. Here is the result after 
scenario run: 
[TransactionBatch] field [otherPartyAccountNumber] was [12345678] 
expected [12345678].
[TransactionBatch] field [otherPartyAccountSuffix] was [1234].
Both fields are of int type and the first does not match although it 
should. Can you please point me to where the problem can be? Thank you, Libor 



View this message in context: Guvnor Test Scenario - value equality 
http://old.nabble.com/Guvnor-Test-Scenario---value-equality-tp26336990p26336990.html
 
Sent from the drools - user mailing list archive 
http://old.nabble.com/drools---user-f11823.html  at Nabble.com.


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


Re: [rules-users] Java beans inheritance

2009-11-12 Thread Anstis, Michael (M.)
If you are checking for class in the LHS would it not be better to
define a separate rule for the subclass?
 
I assume you're doing something like:-
 
rule current
when
MyClass(class == MySubClassOfMyClass.class)
then
//Something specific to the subclass
end
 
When something like this might be more suited?
 
rule super
when   
MyClass()
then
//Do generic stuff
end
 
rule sub
when
MySubClassOfMyClass()
then
//Do something more specific
end
 
I don't know whether this would cause two activations or whether the
more generic would swallow the Fact in the first ObjectType node in the
RETE network; Edson?



From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wolfgang Laun
Sent: 12 November 2009 16:48
To: Rules Users List
Subject: Re: [rules-users] Java beans inheritance


Are you using MVEL at all in this rule?

Anyway, better would be

   class == SomeClass.class

which avoids string handling.

-W



On Thu, Nov 12, 2009 at 3:25 PM, Zohar Etzioni
zohar.etzi...@gmail.com wrote:


Hi,

I have a class hierarchy of objects that I'm inserting
as facts. Lets
say X, Y extends X and Z extends Y. I have a rule that
is defined on X
and therefore applies to all of them, however in the
rule I want to
ask about the class name and I'm referring to it as
class.name==some.class. This should work as far as I
understand coz
it keeps the java beans format, however it is not
directly defined in
the class X but rather in Object. The error I'm getting
is Error:
could not access: name. Any idea what I'm doing wrong?

Thanks,
Dawg
___
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] Specific Agenda strategy to control which rulesto fire

2009-10-29 Thread Anstis, Michael (M.)
Hi Wolfgang,
 
I'm interested with your reply and am trying to better understand it (although 
the use-case has nothing to do with what I do!)
 
The Score class has a constructor taking Deal and level (assume to be akin to 
priority in the original post); however your example Fact insertions exclude 
level for the Score Fact. 
 
I assume Score's level should be initially set to the highest (most granular) 
level; e.g. 2 in the example cited (ranging from 0-2)?
 
It's good to see and understand other's approaches.
 
Cheers,
 
Mike



From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Wolfgang Laun
Sent: 29 October 2009 07:09
To: Rules Users List
Subject: Re: [rules-users] Specific Agenda strategy to control which 
rulesto fire


I don't think you should consider an agenda strategy for this.

Add a simple class:
   class Score{
 int level; int coun; Deal deal; Book book; 
 Score( Deal deal, int level ){...} 
  }

and insert an instance along with the Deal to be classified:

insert( deal );
insert( new Score( deal ) );

Rules for level 2 would be written according to:

rule trader and product
salience 10
when
   $s : Score( level == 2, $d : deal )
Deal( this == $d, trader==Alex, product == GOOG )
then
   $s.setCount( $s.getCount() + 1 );
   $s.setBook( B2 );
end

Then you'll need a couple of rules handling success and failure:

rule post level success
salience 5
when
   $s : Score( $l : level, count == 1, $d : deal, $b : book )
then
   assign $d to $b, retract $d
   retract( $s );
end 

rule post level failure
salience 5
when
   $s : Score( $l : level, count != 1 )
then
   modify( $s ){
   setLevel( $l - 1 );
   }
end 

Rules for level 1 would also be at salience 10.

A rule for level == 0 should catch Deals gone down through all levels.

-W




2009/10/28 Costigliola Joel (EXT) joel.costigliola-...@natixis.com


Hello all,

 

I need some help to to set a specific Agenda strategy in order 
to control finely which activated rules will be fired.

 

Problem context :

-

My company is a bank where traders are making deals on markets, 
these deals must be classified in book, this is what we call booking process.

Booking is done according to booking criteria : which trader 
has made the deal ? on which product ? wich market ? etc ... 

A booking rule defines a set of criteria and the target book 
where the deal will classified, it also has a priority, note that it is ok that 
two booking rule have same priority. 

I want to implement booking rule as Drools rule.

Several booking rule can be applied to a deal, in that case 
choosing the right booking rule to fire depends on the following algorithm : 

- look all the activated booking rule of the highest priority, 

--- if there is a unique rule apply it

--- if there is no unique rule (0 rule or more than one), look 
at rules of a lesser priority and apply the same logic.

 

Next section is an example that will clear things (I hope).

 

Example :

-

A deal D1 has been done by Alex on NY market to buy Google 
stocks.

We have 3 booking rules : 

- BR1 : criteria = trader=Alex / book = B1

- BR2 : criteria = trader=Alex and product = google stock / 
book = B2

As BR2 is more precise than BR1, il will matches the deal and 
book it in B1

If the deal was on another product, BR1 would have been applied.

 

Things gets more complicated when 2 rules of same priority can 
be applied. 

Let's imagine we add the following booking rule 

- BR3 : criteria = trader=Alex and market = NY / book = B3

We have a problem to book D1 since BR2 and BR3 can be applied 
but have same priority. 

We can't choose one over the other thus we must apply a less 
precise/prioritary rule (if unique at its own precision level).

In my example, that would lead to apply BR1.

 

Question :

--

If I 

Re: [rules-users] Better way to run each rule once?

2009-10-09 Thread Anstis, Michael (M.)
You could look into using a sequential RETE network

http://blog.athico.com/2007/07/sequential-rete.html 

http://www.redhat.com/docs/manuals/jboss/jboss-soa-4.2/html/JBoss_Rules_
Manual/ch02s05s10.html

But as Greg suggests, better understanding your use-case might furnish
other ideas.

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Greg Barton
Sent: 08 October 2009 23:08
To: Rules Users List
Subject: Re: [rules-users] Better way to run each rule once?

Could you give some sample rules and the nature of the problem you're
solving?  Maybe you don't need to update all of the time with a
different approach.



- Original Message 
From: Dave Schweisguth d...@schweisguth.org
To: rules-users@lists.jboss.org
Sent: Thu, October 8, 2009 4:43:34 PM
Subject: [rules-users] Better way to run each rule once?

Greetings fellow Droolers,

Each of our rules modifies the fact it matches. We'd like to run each of
those rules exactly once, not reactivating them when a fact changes. I
see
from the archives that I'm not the first person to discover that no-loop
is
too weak and lock-on-activate too strong for my purposes.

I implemented our requirement with an AgendaListener that remembers
hashes
of rules + facts. This works but requires each fact to implement an
interface with a method that returns the hash, and means TWO casts each
time
I examine a FactHandle. The whole AgendaFilter is below so you can see
what
I mean.

Can anyone suggest a better way? I'm looking more for a better approach
altogether than I am for critique of the implementation of my current
approach, although the latter would not be unwelcome.

private static class Once
implements AgendaFilter {

private final SetInteger alreadyActivatedRules = new
HashSetInteger();

public boolean accept(Activation activation) {
int hash = activation.getRule().getName().hashCode();
for (FactHandle handle: activation.getFactHandles()) {
Object object = ((DefaultFactHandle) handle).getObject();
hash *= 31;
if (object instanceof Identifiable) {
hash += ((Identifiable) object).getIdentity();
} else if (object instanceof String) {
// We get here when a rule uses from on a string collection
hash += object.hashCode();
} else {
throw new IllegalStateException(
Don't know what to do with fact class 
+ object.getClass() + , value  + object);
}
}
boolean accept = !alreadyActivatedRules.contains(hash);
alreadyActivatedRules.add(hash);
 return accept;
}

}

Thanks  cheers,

-- 
| Dave Schweisguth
http://schweisguth.org/~dave/ |
| Home: dave at schweisguth.orgWork:
http://www.nileguide.com/ |
| For compliance with the NJ Right to Know Act: Contents partially
unknown |
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



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

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


Re: [rules-users] How to prevent activation list creation onretracts

2009-09-17 Thread Anstis, Michael (M.)
Can I just clarify that you *need* truth maintenance on the inserts but not on 
the retractions?
 

-Original Message-
From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Greg Barton
Sent: 16 September 2009 21:28
To: Rules Users List
Subject: Re: [rules-users] How to prevent activation list creation onretracts

You can't have concurrent threads, each with a session?  

Or do you need all transactions processed serially?  Also, can you process 
simultaneous transactions in the same working memory without retracting objects 
from the previous one?  Objects from previous transactions could then be 
cleaned up by low priority rules that ran between transactions. (Of course, 
there's potential memory build up problems involved with that, but that can be 
mediated.  A high priority rule could kick in if there are too many completed 
transactions hanging around.)

You could call halt() then clearAgenda() on the session when you're done with a 
transaction, then retract all objects.  Maybe that will be faster.  Having the 
agenda clear might make it faster because there would be no activations to 
check against the retracted objects. (Though it would still have to remove them 
from the rete node memories.)  That's just a guess, though.

--- On Wed, 9/16/09, Scott Burrows scottjburr...@gmail.com wrote:

 From: Scott Burrows scottjburr...@gmail.com
 Subject: Re: [rules-users] How to prevent activation list creation on retracts
 To: Rules Users List rules-users@lists.jboss.org
 Date: Wednesday, September 16, 2009, 2:00 PM
 Thanks Greg but I have tried that, creating
 a newstatefulsession is slowish, taking around 800
 milliseconds to do.  When milliseconds count 800 is too
 long.  It's faster to do the retracts, they take about
 400 millis.
 
 
 Someone showed a command or configuration recently that
 tells workingmemory not to re-eval the rules.  I'm
 looking for that switch or something equivalent.
 
 Our system is a live transaction system.  The trans need
 to be  completed and ready for the next one in under a
 second.
 
 
 Scott
 
 
 
 On Wed, Sep 16, 2009 at 2:06 PM,
 Greg Barton greg_bar...@yahoo.com
 wrote:
 
 Dispose of your session and create another.
 
 
 
 --- On Wed, 9/16/09, Scott Burrows scottjburr...@gmail.com
 wrote:
 
 
 
  From: Scott Burrows scottjburr...@gmail.com
 
  Subject: [rules-users] How to prevent activation list
 creation on retracts
 
  To: Rules Users List rules-users@lists.jboss.org
 
  Date: Wednesday, September 16, 2009, 12:50 PM
 
  I think this question
 was asked recently
 
  but I cant seem to find it.
 
 
 
  Using 4.0.7
 
 
 
  I have a large number of facts I need to retract from
 
  working memory after all rules have been processed
 
  (transaction is completed) so I can insert new facts
 for the
 
  next transaction.  Milliseconds count.
 
 
 
 
 
  I know that drools recalc's which rules are
 eligible to
 
  be run after each retraction.  Since all facts are
 being
 
  removed its unneeded processing and time that could
 be
 
  saved.
 
 
 
  How can I tell drools that until I tell it otherwise
 do not
 
  re-evaluate the rules to save time?
 
 
 
 
 
  Scott
 
 
 
 
 
 
 
 
 
  -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
 
 
 
 
 -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 mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Re: [rules-users] Applying rules on xml data

2009-09-16 Thread Anstis, Michael (M.)
Hi Nilima,
 
This might be of interest
http://www.theserverside.com/discussions/thread.tss?thread_id=46708
although I don't know whether it is supported with Drools 5.x.
 
Otherwise I believe your only option is to use JAXB to map the XML into
POJO's. I am unsure whether there is a native channel in the Drools API
or whether you will need to bake your own.
 
With kind regards,
 
Mike




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Nilima R
Sent: 16 September 2009 09:20
To: rules-users@lists.jboss.org
Subject: [rules-users] Applying rules on xml data



Hi All,
 
I have a wb service which returns me xml and I need to apply
rules on that xml data and not pOJO.
Can someone point me some refrence link.
I am using Guvnor.


Thanks
Nilima Rajendra Raichandani
Sub Focus Area Lead - BPM/BAM/BRE
TEG - Open Source Platform
Tata Consultancy Services
Ph:- 9322108518
Cell:- +91 20 6608 7184
Mailto: nilim...@tcs.com
Website: http://www.tcs.com http://www.tcs.com/ 

Experience certainty. IT Services
Business Solutions
Outsourcing


=-=-=
Notice: The information contained in this e-mail
message and/or attachments to it may contain 
confidential or privileged information. If you are 
not the intended recipient, any dissemination, use, 
review, distribution, printing or copying of the 
information contained in this e-mail message 
and/or attachments to it are strictly prohibited. If 
you have received this communication in error, 
please notify us by reply e-mail or telephone and 
immediately and permanently delete the message 
and any attachments. Thank you



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


Re: [rules-users] Applying rules on xml data

2009-09-16 Thread Anstis, Michael (M.)
crawling back under my stone - to spend the weekend R'ingTFM

;-)

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Jaroslaw
Kijanowski
Sent: 16 September 2009 09:41
To: Rules Users List
Subject: Re: [rules-users] Applying rules on xml data

Hi,
  you will need to create POJOs out of your XML. Drools Pipeline and 
smooks transformer are your friends.

https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/
trunk/target/docs/drools-expert/html_single/index.html#d0e2004

http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-pipelin
e/drools-transformer-smooks/src/test/java/org/drools/runtime/pipeline/im
pl/SmookStatefulSessionTest.java

Cheers,
  Jarek



Nilima R wrote:
 Hi All,
  
 I have a wb service which returns me xml and I need to apply rules on 
 that xml data and not pOJO.
 Can someone point me some refrence link.
 I am using Guvnor.
 
 Thanks
 Nilima Rajendra Raichandani
 Sub Focus Area Lead - BPM/BAM/BRE
 TEG - Open Source Platform
 Tata Consultancy Services
 Ph:- 9322108518
 Cell:- +91 20 6608 7184
 Mailto: nilim...@tcs.com mailto:nilim...@tcs.com
 Website: http://www.tcs.com http://www.tcs.com/
 
 Experience certainty. IT Services
 Business Solutions
 Outsourcing
 
 
 =-=-=
 Notice: The information contained in this e-mail
 message and/or attachments to it may contain 
 confidential or privileged information. If you are 
 not the intended recipient, any dissemination, use, 
 review, distribution, printing or copying of the 
 information contained in this e-mail message 
 and/or attachments to it are strictly prohibited. If 
 you have received this communication in error, 
 please notify us by reply e-mail or telephone and 
 immediately and permanently delete the message 
 and any attachments. Thank you
 
 
 
 


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

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


Re: [rules-users] Drools Fuson and Deltas (differences)

2009-09-14 Thread Anstis, Michael (M.)
Let me understand you better.

The events do not contain any information about source other than what
can be implied from their temporal position?
Source 1 : 0s, 15s, 30s, 35s etc
Source 2: 5s, 20s, 35s, 40s etc

What if the period between events for a specific source were greater
than 15s (as you state) which caused an overlap with another source?
Source 1: 0s, 15s, 35s, 40s etc
Source 2: 5s, 20s, 35s, 40s etc

I would have thought without being able to ascertain source from the
event Fact it would be almost impossible to achieve your use-case.

With kind regards,

Mike

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of skasab2s
Sent: 12 September 2009 11:54
To: rules-users@lists.jboss.org
Subject: [rules-users] Drools Fuson and Deltas (differences)


Hi guys,

I have the following problem, which I'm trying to solve with
Drools-Fusion:

Every 15 seconds(or more) happens an event, that contains an unique
number.
For example every 15 seconds(or more) comes a Temperature of a patient
with
a new different value as an event. The problem is, that it is possible,
that
between two of those Temperatures other Temperatures from a differrent
source appear:

Second 0: Nothing
...
Second: 15: Temperature: 37.5 
...
Second: 20 Temperature 38.8
...
Second: 30 Temperature: 36.5 

Is it possible with Drools Fuzion to detect that Temperature 38.8 is
from
other source (because it has happended between the 15th and 30th second)
and
calculate the difference between the temperature 38.8 and 37.5 (in this
case)?

Thanks a lot! 

Svetlomir. 
-- 
View this message in context:
http://www.nabble.com/Drools-Fuson-and-Deltas-%28differences%29-tp254134
21p25413421.html
Sent from the drools - user mailing list archive at Nabble.com.

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

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


Re: [rules-users] modify facts problem

2009-08-27 Thread Anstis, Michael (M.)
what version of Drools are you using?




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Vikram
Pancholi
Sent: 27 August 2009 15:30
To: rules-users@lists.jboss.org
Subject: [rules-users] modify facts problem


Hi,  
  I am having problem about modifying certain fact. 
 
  For example 
  1) I have User status when inserted  set to value 1.
  2) in the modify in a rule block i m changing this  to 5.
  3)Now i have a flow where i have a wait which waits this user
status is not value 1.
 After the rule is fired ans the status is changed to false,
in the next step i am checking this status of user status in an XOR
split constraints
but i still get the status in the constraint as 1. I have
got no clues whts going on. I tried printing this value in the getting
the objects using classobjectfilter and then specyfing the class again,
the value is still shown as 1. I am very much confused about this. Is
this some effect of Shadow facts. 
  awaiting your response.
 
Regards
Vikram Pancholi
 
 

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


RE: [rules-users] Hibernate Query delivers wrong values

2009-07-10 Thread Anstis, Michael (M.)
I assume ...but when I change a field of a db-record manually... means you go 
into the database and tweak a field?

In which case this is definitely a hibernate session usage issue and I'd 
suggest you read up on the latter.

With kind regards,

Mike 

-Original Message-
From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Thomas Zwifl
Sent: 10 July 2009 11:46
To: rules-users@lists.jboss.org
Subject: [rules-users] Hibernate Query delivers wrong values

Hi there!

I'm working with the latest snapshot-releas of v5.1 
(build3098-rev27324-20090630-0403).
My application consists of two independent processes, 
both are repeated periodically (timer-node).
the processes both have ruleset-nodes. some rules are
querying a database with hibernate in the rule condition (LHS).
the queried objects are then inserted into workinmemory (insert(object)), 
then some computation follows, the objects are modified and written
back to db, and then the objects are retracted (retract(object)).

Now to the problem: when I start the application, everything works 
correct, and leads to the right results. But when I change a field of a
db-record manually, the hibernate-query delivers the old values!!
(of course the changes are committed.)

Anyone has an idea whats going wrong here? Is there some kind of 
caching mechanism that delivers the old objects instead of querying
the database?

greetz!
tom 
-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
___
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] How execute a Single rule from rule file or rulepackage

2009-07-06 Thread Anstis, Michael (M.)
If each rule is held within a unique agenda, you could use agenda
filters.
 
How would you determine which rule needs to be activated though? You'd
need some criteria hard-coded elsewhere in your application. Why not
make this part of the rules too?




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Amila Silva
Sent: 03 July 2009 07:17
To: rules-users@lists.jboss.org
Subject: [rules-users] How execute a Single rule from rule file
or rulepackage


hi everyone,

  I have a requirement like execute a single rule from set of
loaded rule files or single rule from single drl file.
 when i execute fireAllRules() it executes the all the rules in
the files. even that overloaded method that take int as agrs also
 seems doesnt help much. 
 let me know if any body gone thru this kind of senarios.






-- 
Thanks,
Regrads,

Amila Silva,
Associate Software Engineer

hSenid Mobile Solutions

Phone : 
+94-77-9983894
Fax : 
+94-11-2673 845

Web: 
http://www.hSenid.com

Make it Happen


http://www.hSenidMobile.com

Enabling the Mobile World


Disclaimer: This email and any files transmitted with it are
confidential and intended solely for the use of the individual or entity
to which they are addressed. The content and opinions contained in this
email are not necessarily those of hSenid Software International. If you
have received this email in error please contact the sender.



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


RE: [rules-users] Formula value assginment in LHS

2009-07-05 Thread Anstis, Michael (M.)
Why not simply use something like this:-
 
rule TaxCalc
when
 $i : Invoice($st : salesTax, $gst : gstRate, $sa : salesAmount,
$id : importDuty, $gr : govtRebate)
then
 $i.setTotalTax(round($st + ($gst * $sa / 100) + $id - $gr, 2));
 update($i);
end

What do you gain by checking whether the Total Tax is different from the
value of the calculation? I must be missing something from your
simplified example?!?
 
(I think, big disclaimer!!) you could achieve your requirement using
eval and a tax value function that uses a cache under the hood, much
like the following:-
 
rule TaxCalc
when
 $i : Invoice($tt : totalTax, $st : salesTax, $gst : gstRate,
$sa : salesAmount, $id : importDuty, $gr : govtRebate)
 eval(Invoice($tt != taxFunction($st, $gst, $sa, Sid, $gr))
then
 $i.setTotalTax(taxFunction($st, $gst, $sa, Sid, $gr);
 update($i);
end

Evals cannot be indexed so you take a performance hit.
 
With kind regards,
 
Mike





From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Shabbir Dhari
Sent: 03 July 2009 01:24
To: rules-users@lists.jboss.org
Subject: [rules-users] Formula value assginment in LHS


Dear all

We are developing a financial business application that contains
hundreds of business rules for validations and calculations. In the
calculation rules we change the value of attribute if values past in the
request is incorrect e.g.  

rule TaxCalc
when
 $i : Invoice()
 Invoice (totalTax != (round(salesTax + (gstRate *
salesAmount / 100) + importDuty - govtRebate, 2)))
then
 i.setTotalTax(round(salesTax + (gstRate * salesAmount /
100) + importDuty - govtRebate, 2));
end

The above code works perfectly fine. Only problem is the perform
calculation twice. What I was looking if possible I can store calculated
tax in a variable and simply assign variable to attribute if rule
condiation fails. Some thing like:

rule TaxCalc
when
$i : Invoice() 
Invoice (totalTax != calTax : (round(salesTax + (gstRate
* salesAmount / 100)+ importDuty - govtRebate, 2)))
then
i.setTotalTax(calTax);
end

But this does not work - shows system error at calculated value
assignment. Is there any work around?





Click here to find out more POP access for Hotmail is here!
http://windowslive.ninemsn.com.au/article.aspx?id=802246  

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


RE: [rules-users] How to call a another drl file from one drl file

2009-07-02 Thread Anstis, Michael (M.)
I believe you will need to add each DRL file into a single RuleBase
(Drools 4.x terminology; I think KnowledgeBase in 5.0 but I'm a little
rusty).
 
Don't forget rules aren't evaluated when fireAllRules is called but as
objects are inserted into WorkingMemory, so all rules need to be
compiled into a RuleBase before object insertion.




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Amila Silva
Sent: 02 July 2009 11:07
To: rules-users@lists.jboss.org
Subject: [rules-users] How to call a another drl file from one
drl file


hi,
   I have requirement to execute a chain of rules. One rule
after another and they are reusable.I need to know how to call another
drl file from a drl file. or in a then part of the 
   a rule.

thanks
Amila Silva



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


RE: [rules-users] forEach node Clarification

2009-06-23 Thread Anstis, Michael (M.)
Your jpg was not visible at the enclosed URL. 

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of rajakanthan
Sent: 23 June 2009 02:24
To: rules-users@lists.jboss.org
Subject: [rules-users] forEach node Clarification


Hey guys,
I'm doing a POC using drools and drools flow.I have inserted a image
here
after modifying some of ruleflow groups. There are more ruleflow groups.
The
rules belong to each ruleset in a composite node is perfectly
working.Ok.
fine. the problem is, when it comes to 'child service', a list of
ChildService Object will be returned by POJO(let me say, ). For each
object,
the rules belong to Service 1,2 and 3 has to executed before coming out
of
this composite node 'Level Child'. 

I dont have any clue on this. what i have to be given in
CollectionExpression and variableName property in forEach node? How to
work
on this forEach?
http://www.nabble.com/file/p24150374/ServiceForEach.jpg 

-- 
View this message in context:
http://www.nabble.com/forEach-node-Clarification-tp24150374p24150374.htm
l
Sent from the drools - user mailing list archive at Nabble.com.

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

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


RE: [rules-users] How to execute the SQL query using drools

2009-06-23 Thread Anstis, Michael (M.)
You have not clearly defined when you want to execute SQL queries.
 
If you want to access a DB from the LHS you can use the from keyword.
Note the results need to be time-constant i.e. not change on successive
calls.
 
If you want to access a DB from the RHS it is plain Java (or MVEL
depending upon your rule dialect).
 
See the documentation for more information.




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Amila Silva
Sent: 23 June 2009 07:55
To: rules-users@lists.jboss.org
Subject: [rules-users] How to execute the SQL query using drools




hi All,

I have requirement like to execute the sql queries through
drools. is there are way to do it?
please let me know asap.

thanks
amila silva


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


RE: [rules-users] help

2009-06-23 Thread Anstis, Michael (M.)
You need to provide more information.

Your question is like me replying with I don't have any problems.

Not very helpful.
 

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of SHIMI
Abdelouahad ( Prestataire )
Sent: 22 June 2009 16:54
To: rules-users@lists.jboss.org
Subject: [rules-users] help

Effectivly by using the version 4 and plugin 4 of drools, the
application Works without any problem, but with version 5 and plugin 5
of drooos i have allwise the exception.

Is the first time that I use Drools, I don't undurtand why don't work, I
need the help. Please please help



This e-mail and/or attachment(s) is (are) confidential and may be
legally
protected. This message is addressed to the intended recipient only. If
you
are not the intended recipient of the message, please notify the sender
immediately. Its contents do not constitute a commitment by the sender's
company except where provided for in a written and signed agreement
between
you and sender's company. Any disclosure, use or dissemination, either
in
whole or in partial, shall be prior authorized by the sender's company
by
written and signed agreement. E-mail and/or attachment(s) cannot be
guaranteed
to be secured or error-free as information can be intercepted,
corrupted,
lost, destroyed, arrive late or incomplete, or contain viruses. The
sender.s
company has taken all reasonable precautions to ensure that any
attachment to
this message does not contain a virus. However, the sender.s company
(and not
any of its Officers, Directors, Employees or Agents) cannot be held
liable for
any damages resulting from or linked to the existence of a virus. You
are
therefore strongly advised to carry out all your own anti-virus checks
before
opening any and all attachments to this message.


___
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] Link for drools-server module

2009-06-23 Thread Anstis, Michael (M.)
Did you replace the EL jar with that available from JBOSS?

You will still need an EL jar somewhere if you are using JSF.

Do you have Java security enabled in your Tomcat instance? I've
previously had to put the EL jar in Tomcat's lib folder to fix other
issues relating to the use of JSF and EL on Tomcat (not when trying to
use Drools on Tomcat, but other standalone applications).

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of tanzu
Sent: 22 June 2009 12:28
To: rules-users@lists.jboss.org
Subject: [rules-users] Link for drools-server module


Hi
 
Can anyone please provide me with the following

Tutorials about the detailed working and usage of the drools execution
server.

I have exported the drools-server in the drools 5 download, as a war and
deployed on the application server to be used in conjuction with
guvnor.But
I am getting the following errrors.


java.lang.IllegalStateException: Attempted to invoke a Seam component
outside an initialized application
at
org.jboss.seam.contexts.Lifecycle.getApplication(Lifecycle.java:36)
at
org.jboss.seam.contexts.Lifecycle.mockApplication(Lifecycle.java:111)
at org.jboss.seam.Seam.componentForName(Seam.java:298)
at
org.jboss.seam.intercept.RootInterceptor.getComponent(RootInterceptor.ja
va:224)
at
org.jboss.seam.intercept.JavaBeanInterceptor.callPostActivate(JavaBeanIn
terceptor.java:151)
at
org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.
java:72)
at
org.drools.guvnor.server.security.RoleBasedPermissionManager_$$_javassis
t_0.sessionDidActivate(RoleBasedPermissionManager_$$_javassist_0.java)
at
org.apache.catalina.session.StandardSession.activate(StandardSession.jav
a:804)
at
org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:
397)
at
org.apache.catalina.session.StandardManager.load(StandardManager.java:32
1)..

and

java.lang.NoClassDefFoundError: javax/el/ExpressionFactory
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown
Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.j
ava:3713)
at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4216
)
at
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.ja
va:760)
at
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
at
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
at
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:831)
at
org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:720)..
. 
 

I am working on tomcat 5.5.7  and eclipse 3.4.  I have guvnor 5.0
runnning
with this configuration.I have already copied the jsf jars in tomcat lib
folder.As it is tomcat 5.5.7 and not 6.x , I havent removed el-api jar
from
drools-guvnor.war for depolyment.

Please help I need the drools-server up and working.



Thanks 
tanzu
-- 
View this message in context:
http://www.nabble.com/Link-for-drools-server-module-tp24142668p24142668.
html
Sent from the drools - user mailing list archive at Nabble.com.

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

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


RE: [rules-users] How to execute the SQL query using drools

2009-06-23 Thread Anstis, Michael (M.)
Let me see if I understand correctly.
 
You want the user to be able to define the SQL query (table, field list,
predicates) and have the resulting SQL executed within Drools?
 
Is this your only requirement for the rules engine; if so have you
thought a rules engine might not be your best option.




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Amila Silva
Sent: 23 June 2009 09:49
To: rules-users@lists.jboss.org
Subject: [rules-users] How to execute the SQL query using drools



Hi Anstis,
  I'm creating a rule engine which is basically a SQL query
executor. for that i need to have a drool
  file where i can add new rules to build the different query
criteria.  user should be able to create new selection criteria.

is there any way that i can define sql queries in side the drool
files.

thanks

  







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


RE: [rules-users] How to execute the SQL query using drools

2009-06-23 Thread Anstis, Michael (M.)
The best I think you could achieve would be something like this...
 
Global ExecuterService es; 
 
rule execute some SQL
when
$q : Query()
$f : Fields(query == $q)
$t : Tables(query == $q)
$p : Predicates(query == $q)
then
es.execute($f, $t, $p);
end
 
Still not sure if a rules engine is your best option, if I understand
your use case correctly.




From: Anstis, Michael (M.) 
Sent: 23 June 2009 10:00
To: 'ami...@hsenidmobile.com'; 'Rules Users List'
Subject: RE: [rules-users] How to execute the SQL query using
drools


Let me see if I understand correctly.
 
You want the user to be able to define the SQL query (table,
field list, predicates) and have the resulting SQL executed within
Drools?
 
Is this your only requirement for the rules engine; if so have
you thought a rules engine might not be your best option.




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Amila Silva
Sent: 23 June 2009 09:49
To: rules-users@lists.jboss.org
Subject: [rules-users] How to execute the SQL query
using drools



Hi Anstis,
  I'm creating a rule engine which is basically a SQL
query executor. for that i need to have a drool
  file where i can add new rules to build the different
query criteria.  user should be able to create new selection criteria.

is there any way that i can define sql queries in side
the drool files.

thanks

  







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


RE: [rules-users] Link for drools-server module

2009-06-23 Thread Anstis, Michael (M.)
Sounds like you found a solution!

It could be worth you posting your configuration (including version of
Tomcat, Drools components and EL) back to the forum to help others.
Something showing the folder hierarchy and location of JARS would be
good. You could even dig out the wiki page relating to Drools and Tomcat
if you feel adventurous.

I don't know anything about the REST api etc. Sorry.
 

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of tanzu
Sent: 23 June 2009 10:15
To: rules-users@lists.jboss.org
Subject: RE: [rules-users] Link for drools-server module


Hi Michael


I added the el-api 1.2  to tomcat 5.5.7/common/lib  ,and then the
drools-server started working.But then my web-client ,built on struts
and
using jsp not jsf ,started giving the same el-api error.

I am also working with tomcat 6.0.3  .I had added the jsf jars from
jboss
,but drools server and later my web - client application started to work
,but guvnor gave el-api version error.Because tomcat 6.0.3 had el-api
and
guvnor contained el-api 1.2  .So at last i removed the el-api 1.2 from
guvnor ,and replaced it in tomcat lib with el-api.

Bingo now all 3 guvnor ,drools-server ,and my web-client application are
deployed in tomcat 6 and working fine.

Still in need of a document describing ,the complete working of the rest
api
along with the web client to call drools server.

Thanks

Tanzu

Anstis, Michael (M.) wrote:
 
 Did you replace the EL jar with that available from JBOSS?
 
 You will still need an EL jar somewhere if you are using JSF.
 
 Do you have Java security enabled in your Tomcat instance? I've
 previously had to put the EL jar in Tomcat's lib folder to fix other
 issues relating to the use of JSF and EL on Tomcat (not when trying to
 use Drools on Tomcat, but other standalone applications).
 
 -Original Message-
 From: rules-users-boun...@lists.jboss.org
 [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of tanzu
 Sent: 22 June 2009 12:28
 To: rules-users@lists.jboss.org
 Subject: [rules-users] Link for drools-server module
 
 
 Hi
  
 Can anyone please provide me with the following
 
 Tutorials about the detailed working and usage of the drools execution
 server.
 
 I have exported the drools-server in the drools 5 download, as a war
and
 deployed on the application server to be used in conjuction with
 guvnor.But
 I am getting the following errrors.
 
 
 java.lang.IllegalStateException: Attempted to invoke a Seam component
 outside an initialized application
   at
 org.jboss.seam.contexts.Lifecycle.getApplication(Lifecycle.java:36)
   at
 org.jboss.seam.contexts.Lifecycle.mockApplication(Lifecycle.java:111)
   at org.jboss.seam.Seam.componentForName(Seam.java:298)
   at

org.jboss.seam.intercept.RootInterceptor.getComponent(RootInterceptor.ja
 va:224)
   at

org.jboss.seam.intercept.JavaBeanInterceptor.callPostActivate(JavaBeanIn
 terceptor.java:151)
   at

org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.
 java:72)
   at

org.drools.guvnor.server.security.RoleBasedPermissionManager_$$_javassis
 t_0.sessionDidActivate(RoleBasedPermissionManager_$$_javassist_0.java)
   at

org.apache.catalina.session.StandardSession.activate(StandardSession.jav
 a:804)
   at

org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:
 397)
   at

org.apache.catalina.session.StandardManager.load(StandardManager.java:32
 1)..
 
 and
 
 java.lang.NoClassDefFoundError: javax/el/ExpressionFactory
   at java.lang.Class.getDeclaredConstructors0(Native Method)
   at java.lang.Class.privateGetDeclaredConstructors(Unknown
 Source)
   at java.lang.Class.getConstructor0(Unknown Source)
   at java.lang.Class.newInstance0(Unknown Source)
   at java.lang.Class.newInstance(Unknown Source)
   at

org.apache.catalina.core.StandardContext.listenerStart(StandardContext.j
 ava:3713)
   at

org.apache.catalina.core.StandardContext.start(StandardContext.java:4216
 )
   at

org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.ja
 va:760)
   at

org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
   at
 org.apache.catalina.core.StandardHost.addChild(StandardHost.java:544)
   at
 org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:831)
   at

org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:720)..
 . 
  
 
 I am working on tomcat 5.5.7  and eclipse 3.4.  I have guvnor 5.0
 runnning
 with this configuration.I have already copied the jsf jars in tomcat
lib
 folder.As it is tomcat 5.5.7 and not 6.x , I havent removed el-api jar
 from
 drools-guvnor.war for depolyment.
 
 Please help I need the drools-server up and working.
 
 
 
 Thanks 
 tanzu
 -- 
 View this message in context:

http://www.nabble.com/Link-for-drools-server-module-tp24142668p24142668.
 html
 Sent

RE: [rules-users] How to execute the SQL query using drools

2009-06-23 Thread Anstis, Michael (M.)
Your requirement isn't that clear however here's a few thoughts:-
 
Data can be inserted into the Rule Engine either externally (i.e.
WorkingMemory.insert) or internally (using from).
 
If you use DSL you can make DRL more human readable; although neither
are binary format in the first place.
 
Drools will fit your requirement, but without knowing your use-cases
better I can't say whether it would be the best fit.
 
Perhaps if you can give a more detailed use-case the group would be
better able to comment further.
 
Please also ensure your emails go to the group
http://www.jboss.org/drools/lists.html
 
Finally, do read the documentation, you would probably be able to answer
your own questions.
 
With kind regards,
 
Mike




From: Amila Silva [mailto:ami...@hsenidmobile.com] 
Sent: 23 June 2009 10:58
To: Anstis, Michael (M.)
Subject: Re: [rules-users] How to execute the SQL query using
drools



Thanks Michael,
   another thing can you tell me how can select data set or
execute some queries using the drools ?
  can we have method to store rules as humand readable format
instead of binary format?

 My requirement is to have rule engine , basically there are
some set of rules which used to execute some queries and populate some
tables depend on the situations, other than that need have every
flexible rule engine instead of hard coded rule in java?
what you think,is it possible to use drools for my requirement.

thank you very much
amila





On Tue, Jun 23, 2009 at 2:29 PM, Anstis, Michael (M.)
manst...@ford.com wrote:


Let me see if I understand correctly.
 
You want the user to be able to define the SQL query
(table, field list, predicates) and have the resulting SQL executed
within Drools?
 
Is this your only requirement for the rules engine; if
so have you thought a rules engine might not be your best option.




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Amila Silva
Sent: 23 June 2009 09:49
To: rules-users@lists.jboss.org
Subject: [rules-users] How to execute the SQL
query using drools



Hi Anstis,
  I'm creating a rule engine which is basically
a SQL query executor. for that i need to have a drool
  file where i can add new rules to build the
different query criteria.  user should be able to create new selection
criteria.

is there any way that i can define sql queries
in side the drool files.

thanks

  










-- 
Thanks,
Regrads,

Amila Silva,
Associate Software Engineer

hSenid Mobile Solutions

Phone : 
+94-77-9983894
Fax : 
+94-11-2673 845

Web: 
http://www.hSenid.com

Make it Happen


http://www.hSenidMobile.com

Enabling the Mobile World


Disclaimer: This email and any files transmitted with it are
confidential and intended solely for the use of the individual or entity
to which they are addressed. The content and opinions contained in this
email are not necessarily those of hSenid Software International. If you
have received this email in error please contact the sender.



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


RE: [rules-users] Inserting Collection into WorkingMemory

2009-06-11 Thread Anstis, Michael (M.)
Correct me if I misunderstand:-

(1) You have a list of Strings accessible using a generic businessData
property.

(2) Nestled within the list *you happen to know* one of the values
represents a SSN and another the loan amount.

(3) You expect Drools to read your mind and workout how to determine the
meaning of individual items in the list.

You can check whether the businessData contains a value using the
contains operator. Whether the value is however a SSN or a loan amount
is anyones guess as demonstrated below. If you don't have discrete
accessors for individual businessData items then I believe a map is your
best option.

Rule read my mind
When
$p : ProcessRequest(businessData contains 1234)
Then
System.println(ProcessRequest contains '1234' however I have no
idea whether it is a SSN or loan amount);
End

With kind regards,

Mike 

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of VinuJay
Sent: 11 June 2009 07:39
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Inserting Collection into WorkingMemory


Hi Andrew,

Thanks for the reply.

My problem is i don't have any input values for businessdata, i need to
evaluate only on the key (name) of business data.  Like if SSN == 1234

LoanAmount  5 assign to jcooper 

So ListString,String businessData in my Fact object would not be
useful. I
need the values for the business data to be picked up from the rules
file
(.drl) itself.

-- 
View this message in context:
http://www.nabble.com/Inserting-Collection-into-WorkingMemory-tp23975474
p23976147.html
Sent from the drools - user mailing list archive at Nabble.com.

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

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


RE: [rules-users] OR operator affects how many times Rule's actionis executed

2009-06-08 Thread Anstis, Michael (M.)
I believe the answer is that Drools implements sub-rule compilation for
rules containing or.

So in essence your rulebase contains the following once compiled:-

rule fire_twice_a
no-loop true
when
eval(true)
then
System.out.println(word);
end

rule fire_twice_b
no-loop true
when
eval(true)
then
System.out.println(word);
end


-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of
sergey.olifirenko
Sent: 08 June 2009 13:39
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] OR operator affects how many times Rule's
actionis executed


More simple example:


package continuated_rules

dialect mvel

rule fire_twice
no-loop true
when
eval(true) or eval(true)
then
System.out.println(word);
end

output is:

word
word

why does it happens ? 

-- 
View this message in context:
http://www.nabble.com/OR-operator-affects-how-many-times-Rule%27s-action
-is-executed-tp23910106p23923259.html
Sent from the drools - user mailing list archive at Nabble.com.

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

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


RE: [rules-users] A relational SQL Database as RuleBase

2009-06-04 Thread Anstis, Michael (M.)
Perhaps, as Otter suggested, you provide a little more information about
what you are trying to achieve?

quote
Rene,
mhhm, what are your trying to do (besides storing rules in a rdbms)?
What's the use-case?
/quote 

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of
r.r.neum...@freenet.de
Sent: 04 June 2009 08:32
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] A relational SQL Database as RuleBase


It's just a question still now :) ... 
-- 
View this message in context:
http://www.nabble.com/A-relational-SQL-Database-as-RuleBase-tp2383p2
3865137.html
Sent from the drools - user mailing list archive at Nabble.com.

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

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


RE: [rules-users] high cpu usage

2009-03-25 Thread Anstis, Michael (M.)
Lets think about your new question logically.

A CPU cannot give more than 100% utilisation. If Drools is consuming 80% and 
other applications require less than 20% then the other applications 
performance will not degrade. If however the other applications require more 
than 20% CPU utilisation then one of the process's performance will degrade - 
whether it is Drools or the other applications depends upon the thread 
scheduler and which threads have higher priority.

-Original Message-
From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of techy
Sent: 25 March 2009 11:17
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] high cpu usage


Thanks for your valuable input.

I did further testing in TEST solaris machine where other apps too are
running. 

1.In the consumer, I launched 5-10 threads of parallel execution with drools
stateless session. It did performed well with more cpu usage. it maintained
avg cpu usage of 65-70%. occasional spikes went to 85-90%.
while I was doing this, Other apps contacted me about this and showed their
concern too.

So this brings up another question.  Will drools high cpu usage degrade
other app performance when they are running in same machine  same time? 

Thanks again!


nheron wrote:
 
 Hello,
 Yes, when running drools, the cpu usages goes high.
 It is one of the main caracteristic with rule engine : the more cpu you
 have the quickler it is !!
 It is normal because all the rete graph  Co are in ram and drools work
 on it. 
 So there is not wait for database, IO and co so CPU goes very high very
 quicly but is is normal !
 All my customers have this surprise : a 4 CPU machine instead one one
 makes it able to have 4 concurrent drools sessions to work in parallele
 with the same performance as one session on one CPU  !
 Regards
 Nicolas Heron
 
 Regards 
 Nicolas
 Le mercredi 25 mars 2009 à 10:05 +0100, Wolfgang Laun a écrit :
 
 The figures you gave just indicate that you have a good balance
 between I/O
 and CPU load. The increase between no rules and ~60 rules is to be
 expected
 as all the work is being done during fact insertion. Of course, adding
 more and
 more rules will, eventually, push the CPU load factor to the natural
 upper limit.
 
 If the overall throughput is good, why do you worry?
 
 -W
 
 
 
 On Tue, Mar 24, 2009 at 11:20 PM, techy techluver...@gmail.com
 wrote:
 
 
 Hello
 My app is functioning consumer/producer model.
 1.Producer reads the data from DB and inserts to blocking
 queue
 2.Consumer reads the data from queue and execute the rules
 using drools
 stateless session.
 Both producer and consumer run asynchronously.
 
 in my testing I found the following
 
 1. for 1000 facts at a time and no rules in drl, cpu usage is
 maintained at
 25-30% in my PC(Intel core 2 CPU,2.13 GH,2G RAM)  - with no
 rules in drl, Is
 this cpu usage  acceptable?
 2. for 1000 facts at a time and ~60 rules in drl, cpu usage is
 maintained at
 50-60% on the same PC.
 3. If I have 1 sec wait between each execution of rules in
 consumer, then
 cpu usage is maintained  5%
 
 high CPU usage is being big concern to me. Is this expected
 while using
 drools? Do others see same cpu usage too?  Please share your
 thoughts.
 appreciate your input.
 
 Thanks
 
 --
 View this message in context:
 http://www.nabble.com/high-cpu-usage-tp22691131p22691131.html
 Sent from the drools - user mailing list archive at
 Nabble.com.
 
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users
 
 
 
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users
 
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users
 
 

-- 
View this message in context: 
http://www.nabble.com/high-cpu-usage-tp22691131p22699498.html
Sent from the drools - user mailing list archive at Nabble.com.


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

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


RE: [rules-users] Inserting a JRuby object via Spring JRubyScriptFactory in Drools

2009-03-20 Thread Anstis, Michael (M.)
I read that JBoss AS supports JRuby classes running in the JVM...
 
http://oddthesis.org/posts/2009-03-jboss-rails-1-0-0-beta4-in-time-for-t
he-weekend
 
Whilst I haven't used it nor read about it in detail perhaps this is
something that might be of interest.
 
With kind regards,
 
Mike




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Edson Tirelli
Sent: 19 March 2009 16:06
To: Rules Users List
Subject: Re: [rules-users] Inserting a JRuby object via Spring
JRubyScriptFactory in Drools



   Drools always looks for getters/setters, never for the actual
internal attribute. 

   As long as you have an instance of a given interface and your
rules are written against the interface you should be fine in Drools 5.

   Drools 4 used shadow facts, so, there would be more
considerations to make on drools 4.

   []s
   Edson


2009/3/19 Premkumar Stephen pre...@gmail.com


Hello Folks, 

I have been looking at options of using ruby objects as
fact objects in Drool's working memory.

One obvious way is using services.

Another path that I have been researching about is to
use Spring as outlined here
http://www.jroller.com/habuma/entry/spring_meet_ruby 

Now, in this example, if the Lime ruby object were like
a POJO, (contains fields), will I be able to insert this object into the
workingMemory?  My Lime interface would have getters and setters. Will
the engine look for the fields themselves in an object or can it work
with just getters and setters ( as would be declared in the Lime.java
interface and defined in the Lime.rb ruby class? 

Are there any drawbacks in doing it this way?

Any comments/pointers will be appreciated.

Thanks!!

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






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


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


RE: [rules-users] Identify Rule on Attributes

2009-03-13 Thread Anstis, Michael (M.)
I concur everybody's statements fully.

The purpose of a rules engine is to remove the need for the application
developer to code algorithms to determine which of a set of rules should
execute given a set of facts\properties\objects. Drools implements the
RETE algorithm. Writing your own code to determine which rule should be
executed would be like writing your own video driver so you can display
an image. 

Of course we all assume you plan on using Drools as a rule engine; a
black box to drive the execution of consequences based upon rule
definitions and domain objects. As you state in your last post below;
your point is that [you] want to use rule engine in [your] application
at it's fullest. Without a clearer description of your use-case it
might be impossible for anybody to give an answer that helps with your
particular issue.

These forums are an excellent place to find solutions. Everybody has
always been extremely helpful to me.

I hope you are not discouraged by the responses received to date and am
sure everybody is genuinely trying to help.

With kind regards,

Mike

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Nikhil_dev
Sent: 13 March 2009 06:44
To: rules-users@lists.jboss.org
Subject: RE: [rules-users] Identify Rule on Attributes


Hi Vikrant,

Please go through all the post and try understand what i am trying to
get
from rule engine please do not post just for the namesake.
My point is that i want to use rule engine in my application at its
fullest,
if something is possible in Rule engine i would like to experiment on
it. 

Cheers,
Nikhil.




Vikrant Yagnick wrote:
 
 Hi Nikhil,
 
 Drools implements the RETE algorithm. The average rules user does
not
 need to bother or even care about it. All you need to do is use the
rule
 engine(for which you do not need to design or write your own
algorithm)
 and it will automatically do the work for you.
 
 Cheers,
 Vikrant
 
 -Original Message-
 From: rules-users-boun...@lists.jboss.org
 [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Nikhil_dev
 Sent: Friday, March 13, 2009 11:35 AM
 To: rules-users@lists.jboss.org
 Subject: Re: [rules-users] Identify Rule on Attributes
 
 
 
 from the doc i got what is Rete algo ... but not getting the way to
 implement it using drools
 
 
 Nikhil_dev wrote:


 if this is the doc

http://downloads.jboss.com/drools/docs/4.0.4.17825.GA/html_single/index.
html
 u are talking about then i coudl'nt  find much help.
 It will be very helpful if u can give me a kick start on the
same...
 since i am just an average rule engine user.some helpful doc on
the
 same



 Greg Barton wrote:


 Yes, if you use a rules engine that implements rete the
functionality
 you
 need is available.

 Read the Drools docs.

 Carefully.

 GreG

 On Mar 12, 2009, at 23:40, Nikhil_dev k.nik...@verchaska.com
wrote:


 thank u Scott and Greg for u'r reply..

 by the way Greg is it possible for me to use this rete algo through
rule
 engine as this functionality already available in the core of Rule
 Enigne
 or
 should i implement this out side rule engine.


 Greg Barton wrote:


 That's the core functionality of a rule engine.  The rete algorithm
does
 this, and drools implements rete.

 --- On Thu, 3/12/09, Nikhil_dev k.nik...@verchaska.com wrote:

 so now is there
 any way with the help of drools we can identify which rule
 to execute with
 out executing all of them one after the another



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




 -
 Regards,
 :working:Nikhil
 --
 View this message in context:

http://www.nabble.com/Identify-Rule-on-Attributes-tp22471473p22490126.ht
ml
 Sent from the drools - user mailing list archive at Nabble.com.

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




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




 
 
 -
 Regards,
 :working:Nikhil
 --
 View this message in context:

http://www.nabble.com/Identify-Rule-on-Attributes-tp22471473p22490776.ht
ml
 Sent from the drools - user mailing list archive at Nabble.com.
 
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users
 
 
 MASTEK LTD.
 Mastek is in NASSCOM's 'India Top 20' Software Service Exporters List.
 In the US, we're called MAJESCOMASTEK
 


~~
 Opinions expressed in this e-mail are those of the individual and not
that
 of Mastek Limited, unless specifically indicated to that effect.

RE: [rules-users] Identify Rule on Attributes

2009-03-13 Thread Anstis, Michael (M.)
Hi Nikhil,

Let's break down what you have said into pseudo Drools terms:-

Rule 1
AdultFare(value==3000)
ChildFare(value==2500)
Then
//Do what you want to do
End

Rule 2
ChildFare(value==2000) or 
InfantFare(value==1500)
Then
//Do what you want to do
End

Rule 3
AdultFare($f1 : value)
InfantFare($f2 : value)
eval($f1 + $f2  4000)
Then
//Do what you want to do
End

You suggest you have a RuleBase that has been successfully loaded. 

You state you have some attributes (I assume these to be implemented as
Classes).

StatefulSession ss = rulebase.newStatefulSession();
ss.insert( new AdultFare(1000) );//-- Causes object to be compared
to ALL rules. This is how RETE works
ss.insert( new InfantFare(1000) );   //-- Causes object to be compared
to ALL rules. This is how RETE works
ss.fireAllRules();   //-- Causes the then part of
Rule 3 to execute

It sounds like you are trying to hard.

With kind regards,

Mike

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Nikhil_dev
Sent: 13 March 2009 11:19
To: rules-users@lists.jboss.org
Subject: RE: [rules-users] Identify Rule on Attributes


Thank you Michael, 
Following is the use-case/example/Situation that i trying to make it
work
Consider Example 
Rule 1: requires attributes/Values  adultFare == 3000 and
ChildFare
== 2500
Rule 2: requires attributes/Values  ChildFare == 2000 or
InfantFare 
== 1500
Rule 3: requires attributes/Values  AdultFare + InfantFare 
4000

Above said rules is complied and its Rulebase is stored in the
memory..

Now i have adultFare and InfantFare Attribute in hand... so now is
there
any way with the help of drools we can identify which rule to execute
with
out executing all of them one after the another...as per the example
Rule3 should be executedand will give right output...

I hope u got what i am trying to do. let me know weather it is
possible  through RETE algo used inside drools or should i do it
on
my own of identifying the rules...


Anstis, Michael (M.) wrote:
 
 I concur everybody's statements fully.
 
 The purpose of a rules engine is to remove the need for the
application
 developer to code algorithms to determine which of a set of rules
should
 execute given a set of facts\properties\objects. Drools implements the
 RETE algorithm. Writing your own code to determine which rule should
be
 executed would be like writing your own video driver so you can
display
 an image. 
 
 Of course we all assume you plan on using Drools as a rule engine; a
 black box to drive the execution of consequences based upon rule
 definitions and domain objects. As you state in your last post below;
 your point is that [you] want to use rule engine in [your]
application
 at it's fullest. Without a clearer description of your use-case it
 might be impossible for anybody to give an answer that helps with your
 particular issue.
 
 These forums are an excellent place to find solutions. Everybody has
 always been extremely helpful to me.
 
 I hope you are not discouraged by the responses received to date and
am
 sure everybody is genuinely trying to help.
 
 With kind regards,
 
 Mike
 
 -Original Message-
 From: rules-users-boun...@lists.jboss.org
 [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Nikhil_dev
 Sent: 13 March 2009 06:44
 To: rules-users@lists.jboss.org
 Subject: RE: [rules-users] Identify Rule on Attributes
 
 
 Hi Vikrant,
 
 Please go through all the post and try understand what i am trying to
 get
 from rule engine please do not post just for the namesake.
 My point is that i want to use rule engine in my application at its
 fullest,
 if something is possible in Rule engine i would like to experiment on
 it. 
 
 Cheers,
 Nikhil.
 
 
 
 
 Vikrant Yagnick wrote:
 
 Hi Nikhil,
 
 Drools implements the RETE algorithm. The average rules user does
 not
 need to bother or even care about it. All you need to do is use the
 rule
 engine(for which you do not need to design or write your own
 algorithm)
 and it will automatically do the work for you.
 
 Cheers,
 Vikrant
 
 -Original Message-
 From: rules-users-boun...@lists.jboss.org
 [mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Nikhil_dev
 Sent: Friday, March 13, 2009 11:35 AM
 To: rules-users@lists.jboss.org
 Subject: Re: [rules-users] Identify Rule on Attributes
 
 
 
 from the doc i got what is Rete algo ... but not getting the way to
 implement it using drools
 
 
 Nikhil_dev wrote:


 if this is the doc


http://downloads.jboss.com/drools/docs/4.0.4.17825.GA/html_single/index.
 html
 u are talking about then i coudl'nt  find much help.
 It will be very helpful if u can give me a kick start on the
 same...
 since i am just an average rule engine user.some helpful doc on
 the
 same



 Greg Barton

RE: [rules-users] Identify Rule on Attributes

2009-03-13 Thread Anstis, Michael (M.)
Furthermore a rulebase can contain rules from many resources (e.g.
DRL's).

So I guess the cause of your pain is why do you need multiple
rulebases!??! 

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Scott Reed
Sent: 13 March 2009 14:41
To: Rules Users List
Subject: Re: [rules-users] Identify Rule on Attributes

A RuleBase can contain many rules, not just one. Generally we take all 
the rules we need for an application and we assemble them into one 
rulebase, so we don't have to figure out which rulebase to use. Does 
that help?

Nikhil_dev [3/13/2009 8:16 AM] wrote:
 Perfect this is the situation but the only difference is the last
part,

 Rulebase for all the 3 Rules are stored in memory.

 Now i have is attributes(implemented as bean class), but the issue is
i dont
 know which Rulebase to use out of the three which is present in the
memory,
 fetching them one by one and executing it individually is possible but
a
 long procedure which i want to avoid.(executing 3 Rule is ok what if i
have
 10 rules it will be very slow process)
   
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

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


RE: [rules-users] Inserting collection of facts in rule Consequence

2009-02-09 Thread Anstis, Michael (M.)
The RHS is just a block of Java, do what you like.

There is an implicit variable drools available in the RHS that equates
to an instance of KnowledgeHelper.

(This was 4.x - Hundson doesn't show a KnowledgeHelper for 5 so I'm
guessing things have changed). 

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of techy
Sent: 09 February 2009 15:14
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Inserting collection of facts in rule
Consequence


I would appreciate If someone can clarify this.

Thanks in advance


techy wrote:
 
 Hello,
 
 Is there way to insert all facts from collection (similar to
 session.execute(collection)) in the rule consequence ? 
 
 Thanks!
 

-- 
View this message in context:
http://www.nabble.com/Inserting-collection-of-facts-in-rule-Consequence-
tp21814308p21914860.html
Sent from the drools - user mailing list archive at Nabble.com.

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

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


RE: [rules-users] Java Bean dependency

2009-02-06 Thread Anstis, Michael (M.)
Do you mean object classes that represent DRL or objects that DRL
operate upon (i.e. Facts)? 
 
Facts are simply POJO's and therefore IMO any mechanism that can
deserialise into a POJO should suffice.
 
You could also look into the use of JNI for the interface between C++
and Drools.
 
With kind regards,
 
Mike




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Sachin Mangal
Sent: 06 February 2009 07:13
To: rules-users@lists.jboss.org
Subject: [rules-users] Java Bean dependency


Hi,
 
I want to use Drools as a part of a classification system which
consist of Machine Learning based classification (semi supervised)
followed by an expert system (rule based classification). The issue is
that ML part and the framework is in C++ and Drools supports Java. So, I
will use some IPC mechanism for sending data objects from framework to
the rule system (I have my own serialization and deserialization modules
for that). I just want to know that the object classes correspoding to
DRLs need to be in some special format or any format with getter and
setter methods will do?
 
Thanks in advance,
 
Sachin Mangal
Member of Research Staff,
Guavus Network Systems Pvt Ltd

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


RE: [rules-users] one question about asserting facts

2009-02-06 Thread Anstis, Michael (M.)
Hello,

Unless the Drools team have a secret optimisation *I think* there is
no other way to insert large numbers of facts.

Think about it; every fact you insert will need to be propagated through
the RETE network in order for the correct rules to be activated.

You could however optimise your rules to ensure the facts are processed
as efficiently as possible. For example if you are interested in
DataClasses where line is not empty you should have the RHS pattern
that checks for this before other RHS patterns in rules. This should
ensure the fact is not propagated through the network further than is
really necessary. I believe Drools does this itself when the RETE
network is built by have specialised Object nodes that filter out
classes you have not consumed in RHS patters (so if you insert a Foo
class into WM and your rules only use Bar classes the Foo class does not
propagate further).

With kind regards,

Mike


-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Senlin Liang
Sent: 05 February 2009 20:06
To: rules-users@lists.jboss.org
Subject: [rules-users] one question about asserting facts

Hi all,

I am trying to assert (or insert) a large number of facts (or
DataClass objects) in to a session, what i am doing right now is to
insert them one by one as
-
   while (line != null) {
   str = bufRead.readLine();
   session.insert(new DataClass(line, str));
   line = bufRead.readLine();
   }
-

My question: is there an efficient way to insert all facts at once, so
that it takes less time?

Thanks,
Senlin
___
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] Parsing XML using Drools

2009-01-29 Thread Anstis, Michael (M.)
It is not clear how you want to use the XML?
 
If the XML represents Facts then you could use a worker Fact and FROM
to deserialise them and make them available to WM. For example:-
 
rule get some XML facts
when
$w : Worker()
Cheese( ) from $w.getCheesesFromXML();
then
//Do something with cheese
end
 
Obviously the XML need not be true serialised objects (in a JAXB sense)
but simply the properties that getCheeseFromXML rehydrates.
 
Drools is not exposing any of the XML libraries; they are merely used by
your code. The above would be (partially) equivalent to:-
 
Worker w = new Worker();
ListCheese cheeses = w.getCheesesFromXML();
for(Cheese c : cheeses) {
wm.insert(c);
}
 
rule Cheese pre-loaded
when
Cheese( )
then
//Do something with cheese
end
 
Partially equivalent as you could retract Cheese( ) in the second way
which would affect truth maintenance whereas the first way would (I
believe) not.
 
With kind regards,
 
Mike




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Gupta, Ankit
(Ankit)
Sent: 29 January 2009 07:22
To: rules-users@lists.jboss.org
Subject: [rules-users] Parsing XML using Drools


Hi All,
  How can we read and parse a XML file using drools ?
 
Does Drools support the SAX or DOM parsing .
 
 
Regards
 
Ankit

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


RE: [rules-users] Working with dates in rules

2009-01-29 Thread Anstis, Michael (M.)
Hi,
 
I wonder whether Drools 5 Complex Event Processing Support (Temporal
Reasoning) might be what you're looking for?
 
http://blog.athico.com/2008/07/drools-50-m1-new-and-noteworthy.html
 
With kind regards,
 
Mike




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of David Siefert
Sent: 29 January 2009 09:40
To: Rules Users List
Subject: [rules-users] Working with dates in rules


Hi-
 
I'm wondering how it would be possible to compare a part of a
date in the lhs condition of a rule in a Drool.  In other words, I need
to compare a date to see if it is x days from the current date, n hours
from current time, etc.  Would anyone be kind enough to provide an
example?  I'm thinking I may have to implement something of my own to
offer that functionality?
 
Big thanks,
David

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


FW: [rules-users] Parsing XML using Drools

2009-01-29 Thread Anstis, Michael (M.)
Received from Anit, which might help others comment




From: Gupta, Ankit (Ankit) [mailto:gupt...@avaya.com] 
Sent: 29 January 2009 10:04
To: Anstis, Michael (M.)
Subject: RE: [rules-users] Parsing XML using Drools


Hi Mike,
Thanks for prompt reply ,
Actually right now I am streaming the xml 

BenchmarkResultsFor



   BenchmarkDataProcessing/Benchmark



   Workload1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16/Workload



   Memory4, 4, 4, 8, 8, 12, 12, 16, 24, 24, 24, 24, 24, 24,
24, 24/Memory



/BenchmarkResultsFor

 

here we are using apache math api for interpolation 

 

public MemoryBenchmarkResult(String name, double[] x, double[]
y) {

this.hostFunction = name;



// Create the interpolation function

SplineInterpolator i1 = new SplineInterpolator();

this.workload = x;

this.memory = y;

this.interpolator = i1.interpolate(this.workload, this.memory);

}

 

here we are passing the values of X Axis (Workload) and we get
the values of Y Axis (Memory ). Reading or Streaming of this XML are
doing using SAX .

This thing I want to do with Drools .. as I know XML
Streaming is possible in Drools  .

 

 

Regards

Ankit

 

 

 




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Anstis,
Michael (M.)
Sent: Thursday, January 29, 2009 2:48 PM
To: Rules Users List
Subject: RE: [rules-users] Parsing XML using Drools


It is not clear how you want to use the XML?
 
If the XML represents Facts then you could use a worker Fact and
FROM to deserialise them and make them available to WM. For example:-
 
rule get some XML facts
when
$w : Worker()
Cheese( ) from $w.getCheesesFromXML();
then
//Do something with cheese
end
 
Obviously the XML need not be true serialised objects (in a JAXB
sense) but simply the properties that getCheeseFromXML rehydrates.
 
Drools is not exposing any of the XML libraries; they are merely
used by your code. The above would be (partially) equivalent to:-
 
Worker w = new Worker();
ListCheese cheeses = w.getCheesesFromXML();
for(Cheese c : cheeses) {
wm.insert(c);
}
 
rule Cheese pre-loaded
when
Cheese( )
then
//Do something with cheese
end
 
Partially equivalent as you could retract Cheese( ) in the
second way which would affect truth maintenance whereas the first way
would (I believe) not.
 
With kind regards,
 
Mike




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Gupta, Ankit
(Ankit)
Sent: 29 January 2009 07:22
To: rules-users@lists.jboss.org
Subject: [rules-users] Parsing XML using Drools


Hi All,
  How can we read and parse a XML file using
drools ?
 
Does Drools support the SAX or DOM parsing .
 
 
Regards
 
Ankit

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


RE: [rules-users] Parsing XML using Drools

2009-01-29 Thread Anstis, Michael (M.)
I am not sure on what you are trying to achieve.
 
Drools is a Rule Engine and not a XML parser; the nearest I could find
to what you are reporting (I know XML Streaming is possible in Drools)
is the following. 
 
http://netzooid.com/blog/2007/03/16/sxc-simple-xml-compiler-jaxb-runtime
-streaming-xpath-implementation-and-more/
 
Can you enlighten me with your knowledge of XML Streaming in Drools?




From: Gupta, Ankit (Ankit) [mailto:gupt...@avaya.com] 
Sent: 29 January 2009 10:04
To: Anstis, Michael (M.)
Subject: RE: [rules-users] Parsing XML using Drools


Hi Mike,
Thanks for prompt reply ,
Actually right now I am streaming the xml 

BenchmarkResultsFor



   BenchmarkDataProcessing/Benchmark



   Workload1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16/Workload



   Memory4, 4, 4, 8, 8, 12, 12, 16, 24, 24, 24, 24, 24, 24,
24, 24/Memory



/BenchmarkResultsFor

 

here we are using apache math api for interpolation 

 

public MemoryBenchmarkResult(String name, double[] x, double[]
y) {

this.hostFunction = name;



// Create the interpolation function

SplineInterpolator i1 = new SplineInterpolator();

this.workload = x;

this.memory = y;

this.interpolator = i1.interpolate(this.workload, this.memory);

}

 

here we are passing the values of X Axis (Workload) and we get
the values of Y Axis (Memory ). Reading or Streaming of this XML are
doing using SAX .

This thing I want to do with Drools .. as I know XML
Streaming is possible in Drools  .

 

 

Regards

Ankit

 

 

 




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Anstis,
Michael (M.)
Sent: Thursday, January 29, 2009 2:48 PM
To: Rules Users List
Subject: RE: [rules-users] Parsing XML using Drools


It is not clear how you want to use the XML?
 
If the XML represents Facts then you could use a worker Fact and
FROM to deserialise them and make them available to WM. For example:-
 
rule get some XML facts
when
$w : Worker()
Cheese( ) from $w.getCheesesFromXML();
then
//Do something with cheese
end
 
Obviously the XML need not be true serialised objects (in a JAXB
sense) but simply the properties that getCheeseFromXML rehydrates.
 
Drools is not exposing any of the XML libraries; they are merely
used by your code. The above would be (partially) equivalent to:-
 
Worker w = new Worker();
ListCheese cheeses = w.getCheesesFromXML();
for(Cheese c : cheeses) {
wm.insert(c);
}
 
rule Cheese pre-loaded
when
Cheese( )
then
//Do something with cheese
end
 
Partially equivalent as you could retract Cheese( ) in the
second way which would affect truth maintenance whereas the first way
would (I believe) not.
 
With kind regards,
 
Mike




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Gupta, Ankit
(Ankit)
Sent: 29 January 2009 07:22
To: rules-users@lists.jboss.org
Subject: [rules-users] Parsing XML using Drools


Hi All,
  How can we read and parse a XML file using
drools ?
 
Does Drools support the SAX or DOM parsing .
 
 
Regards
 
Ankit

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


RE: [rules-users] Working with dates in rules

2009-01-29 Thread Anstis, Michael (M.)
Hi David,
 
Sorry it was of little help.
 
A rule of thumb is to stay away from eval as it kills performance (the
patterns can't be indexed).
 
I'm not sure if Drools can handle Date variables (the docs state it
handles Data literals formatted as dd-mmm- so Cheese( date ==
27-Oct-2008) works).
 
I guess you could look at something like this (gees, this is going to
show how green I am with Drools now):-
 
rule yuck
when
DateFactory($today : today )
$c : CreditCard( $expires : expirationDate )
ArrayList( size = 0 ) from collect( Day( date = $today, date
= $expires ))
then
//Difference between today and expiry date is more than zero
days
end
 
This does require the insertion of (possibly) huge amounts of Day facts.
Yuck. There must be a better way (in fact your eval looks s much
cleaner). I'm just throwing out ideas. 
 
Good luck with your adventures with Drools.
 
Mike




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of David Siefert
Sent: 29 January 2009 11:31
To: Rules Users List
Subject: Re: [rules-users] Working with dates in rules


Not sure--Drools 5 temporal reasoning looks like it would be the
answer.  Only problem is that I need a solution now, so I am stuck with
Drools 4.
 
This did give me some ideas though.  I created myself a class
called TemporalReasoner.  This has a few methods, namely to roll a date
(so I can tell it x amount of time from now), and then compare it to
another date.
 
So in my rule, lets say I have a fact CreditCard with property
expiration:Date (speaking uml-ishly for a property named 'expiration'
of type Date):
 
rule Fires when expiration less than today
  when
$c: CreditCard($expires : expirationDate)
eval(new
TemporalReasoner(Calendar.getInstance()).lessThan($expires))
  then
// do something for when credit card is still valid
end
 
Now, I'm still generally a noob with BRs, so I'm not sure how
this will affect performance.  Any advice?
 
Thanks,
David


On Thu, Jan 29, 2009 at 3:50 AM, Anstis, Michael (M.)
manst...@ford.com wrote:


Hi,
 
I wonder whether Drools 5 Complex Event Processing
Support (Temporal Reasoning) might be what you're looking for?
 

http://blog.athico.com/2008/07/drools-50-m1-new-and-noteworthy.html
 
With kind regards,
 
Mike




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of David Siefert
Sent: 29 January 2009 09:40
To: Rules Users List
Subject: [rules-users] Working with dates in
rules


Hi-
 
I'm wondering how it would be possible to
compare a part of a date in the lhs condition of a rule in a Drool.  In
other words, I need to compare a date to see if it is x days from the
current date, n hours from current time, etc.  Would anyone be kind
enough to provide an example?  I'm thinking I may have to implement
something of my own to offer that functionality?
 
Big thanks,
David


___
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] Working with dates in rules

2009-01-29 Thread Anstis, Michael (M.)
You got it.
 
You won't find this proposal in any pattern books!! ;-)
 
At least you understood the syntax, so you can now officially consider
yourself not a noob.




From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of David Siefert
Sent: 29 January 2009 12:59
To: Rules Users List
Subject: Re: [rules-users] Working with dates in rules


Ah! Sorry, I believe you were saying Day is a fact that I would
have to create for each likely day  The collect operation is what
gathers all those (Day) facts into a list that is counted. so the rule
fires if there is more than 0 day facts.
 
My bad!
 
Thanks,
David


On Thu, Jan 29, 2009 at 6:53 AM, David Siefert
siefert.david.mailingl...@gmail.com wrote:


Hey, that was quite clever.  Where can I find more about
Day()?  I did some research about DateFactory which I can see how dates
get parsed according to the documentation, as well as compared with the
conditional operators (, , =, =, etc).
 
Thanks,
David


On Thu, Jan 29, 2009 at 5:57 AM, Anstis, Michael (M.)
manst...@ford.com wrote:


Hi David,
 
Sorry it was of little help.
 
A rule of thumb is to stay away from eval as
it kills performance (the patterns can't be indexed).
 
I'm not sure if Drools can handle Date variables
(the docs state it handles Data literals formatted as dd-mmm- so
Cheese( date == 27-Oct-2008) works).
 
I guess you could look at something like this
(gees, this is going to show how green I am with Drools now):-
 
rule yuck
when
DateFactory($today : today )
$c : CreditCard( $expires :
expirationDate )
ArrayList( size = 0 ) from collect(
Day( date = $today, date = $expires ))
then
//Difference between today and expiry
date is more than zero days
end
 
This does require the insertion of (possibly)
huge amounts of Day facts. Yuck. There must be a better way (in fact
your eval looks s much cleaner). I'm just throwing out ideas. 
 
Good luck with your adventures with Drools.
 
Mike





From:
rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of David Siefert

Sent: 29 January 2009 11:31
To: Rules Users List
Subject: Re: [rules-users] Working with
dates in rules


Not sure--Drools 5 temporal reasoning
looks like it would be the answer.  Only problem is that I need a
solution now, so I am stuck with Drools 4.
 
This did give me some ideas though.  I
created myself a class called TemporalReasoner.  This has a few methods,
namely to roll a date (so I can tell it x amount of time from now), and
then compare it to another date.
 
So in my rule, lets say I have a fact
CreditCard with property expiration:Date (speaking uml-ishly for a
property named 'expiration' of type Date):
 
rule Fires when expiration less than
today
  when
$c: CreditCard($expires :
expirationDate)
eval(new
TemporalReasoner(Calendar.getInstance()).lessThan($expires))
  then
// do something for when credit card
is still valid
end
 
Now, I'm still generally a noob with
BRs, so I'm not sure how this will affect performance.  Any advice?
 
Thanks,
David


On Thu, Jan 29, 2009 at 3:50 AM, Anstis

RE: [rules-users] Human Task

2009-01-29 Thread Anstis, Michael (M.)
Hi,
 
A Swim lane is a term associated with UML Activity diagrams where the 
activities undertaken by certain actors are grouped into lanes.
 
Here's the first Google result I found... 
http://www.jiscinfonet.ac.uk/InfoKits/process-review/process-review-9.5
 
With kind regards,
 
Mike




From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of 
raphael.bernh...@orange-ftgroup.com
Sent: 29 January 2009 13:04
To: rules-users@lists.jboss.org
Subject: RE: [rules-users] Human Task


I have an additional question...
 
I'm unable to understand the term swinlanes: it does not exist in my 
English- French Harrap's version ;-)
 
May you give me some synonyms or any translation if someone knows one.
 
-- 
Raphaël BERNHARD --- mailto:raphael.bernh...@orange-ftgroup.com 

Orange LABS
905, Rue Albert Einstein 
06921 SOPHIA ANTIPOLIS Cedex 
Tel: (+33) 4 92 94 52 94 Fax: (+33) 4 92 38 93 20 




De : rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] De la part de Mark Proctor
Envoyé : jeudi 29 janvier 2009 00:59
À : Rules Users List
Objet : Re: [rules-users] Human Task


Femke De Backere wrote: 

Hi! 


Can somebody give me some more information on the Human 
Task in the ruleflow and the use of Apache Mina with it. The 
drools-docs-flow.pdf 
(https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/docs/drools-flow/html/ch09.html)
 
https://hudson.jboss.org/hudson/job/drools/lastSuccessfulBuild/artifact/trunk/target/docs/drools-flow/html/ch09.html%29
  was interesting, but is still missing a few parts.

best place to look is with the unit tests:

http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/service/

This one is a good starting point.

http://anonsvn.labs.jboss.com/labs/jbossrules/trunk/drools-process/drools-process-task/src/test/java/org/drools/task/service/TaskLifeCycleTest.java




Thx!


Femke




___
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] Run a set of rules in a group B from a rule in a group A

2009-01-21 Thread Anstis, Michael (M.)
Please accept that my knowledge is based on 4.x and there might be other
alternatives in 5.

Rules are not ran but their patterns (LHS) evaluated as facts
(objects) are inserted into Working Memory. When all patterns in the LHS
of a rule are matched activations are placed on the agenda for execution
of the consequence (RHS) when fireAllRules() is called (or other
mechanisms to run what is on the agenda are invoked; such as RuleFlow).
So you could have rules in Group A cause Group B to receive the focus
but it is the RHS's execution order you control and not the pattern
matching - which will happen for Group A and Group B when facts are
inserted into WM.

Look at Agenda Groups and RuleFlow. This should help.

With kind regards,

Mike

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Thierry B
Sent: 21 January 2009 10:48
To: rules-users@lists.jboss.org
Subject: [rules-users] Run a set of rules in a group B from a rule in a
group A


Hello,

Is it possible to run a rule from a group A, and if conditions of that
rule
are satisfied that in consequence to tell Drools to run rules of a group
B ?
And if it's possible, how to do that?

Thanks :-)


-- 
View this message in context:
http://www.nabble.com/Run-a-set-of-rules-in-a-group-B-from-a-rule-in-a-g
roup-A-tp21580767p21580767.html
Sent from the drools - user mailing list archive at Nabble.com.

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

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


RE: [rules-users] Run a set of rules in a group B from a rule in agroup A

2009-01-21 Thread Anstis, Michael (M.)
Hi,

See below.
 
executing a rule is really two parts: LHS pattern matching (which
can't be stopped for a given RuleBase) and execution of the RHS (which
can be controlled by the agenda and truth maintenance).

I hope my time away hasn't led to me giving wrong advice.

Mike

-Original Message-
From: rules-users-boun...@lists.jboss.org
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of Thierry B
Sent: 21 January 2009 12:53
To: rules-users@lists.jboss.org
Subject: RE: [rules-users] Run a set of rules in a group B from a rule
in agroup A


Hello,

So if I've well understand :

- before calling fireAllRules(), Drools know for all rules (from any
group)
definied in DRL files, those which all patterns in the LHS of a rule are
matched, and those rules are placed on a agenda. 

At which moment exactly, Drools verified from a rule that all of its
pattern
in the LHS are matched, if it's before callling fireAllRules() ?

 Yes, LHS is evaluated on workingMemory.insert(o). A call to
fireAllRules() executes the activations on the agenda (i.e. RHS queued
as a consequence of LHS being matched on workingMemory.insert(o)).

- And fireAllRules() permit to execute all rules that are placed on
agenda

 Yes

- When using setFocus() from a java class or a rule, we can control the
order of rules to specify to execute rules from group B, and group C... 

 I believe so.

- So it's not possible to tell Drools that we don't want to execute a
group
of rules if a rule A is not matched : in that group of rules : those
which
all paterns match LHS will be inevitably executed.

 Wrong. The rules won't be executed (read as activations - RHS -
won't be run) but you can't stop the LHS being evaluated.

All these points that I said, are exact?

Thanks :-)


Anstis, Michael (M.) wrote:
 
 Please accept that my knowledge is based on 4.x and there might be
other
 alternatives in 5.
 
 Rules are not ran but their patterns (LHS) evaluated as facts
 (objects) are inserted into Working Memory. When all patterns in the
LHS
 of a rule are matched activations are placed on the agenda for
execution
 of the consequence (RHS) when fireAllRules() is called (or other
 mechanisms to run what is on the agenda are invoked; such as
RuleFlow).
 So you could have rules in Group A cause Group B to receive the focus
 but it is the RHS's execution order you control and not the pattern
 matching - which will happen for Group A and Group B when facts are
 inserted into WM.
 
 Look at Agenda Groups and RuleFlow. This should help.
 
 With kind regards,
 
 Mike
 
 

-- 
View this message in context:
http://www.nabble.com/Run-a-set-of-rules-in-a-group-B-from-a-rule-in-a-g
roup-A-tp21580767p21582595.html
Sent from the drools - user mailing list archive at Nabble.com.

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

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


RE: [rules-users] M2: What Revision?

2008-09-30 Thread Anstis, Michael (M.)
I unwrapped my Christmas present early to find that the image links in
the documentation are unfortunately broken in the downloads. I haven't
tried from SVN. :-(
 
For example
file:///C:/etirelli/workspace/jboss/jbrules-trunk/drools-docs/drools-doc
s-guvnor/en/Chapter-Guvnor/NewMainScreen.png
 
Obviously not critical to the function!




From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Edson Tirelli
Sent: 30 September 2008 03:37
To: Rules Users List
Subject: Re: [rules-users] M2: What Revision?



   It is up:

http://www.jboss.org/drools/downloads.html

   We will publish the release notes soon.

   []s
   Edson


2008/9/29 Mark Proctor [EMAIL PROTECTED]


Steve Nunez wrote:


Gentlemen,

What revision was finally 'blessed' as M2? We'd
like to build ourselves and begin testing sooner rather than later.



http://anonsvn.labs.jboss.com/labs/jbossrules/tags/5.0.0.23197.MR2/
Edson is uploading the binary artifacts as we speak, a
maven bug in the release proces has held him up that we couldn't fix, so
after a day or so of that he is uploading by hand. 



Regards,
- SteveN




This message was sent using IMP, the Internet
Messaging Program.


___
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





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


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


RE: [rules-users] Update vs insert

2008-09-11 Thread Anstis, Michael (M.)
What version of Drools are you using?
 
Pre-5 has Shadow Facts so you can't rely upon pass-by-reference. I
believe 5 has had Shadow Facts removed.
 
Insert places a new object into WM whereas update refreshes (the shadow)
of an existing one.
 
I would expect you to have to use update in your example:-
 
rule Add person to math class 
no-loop 
when 
person : Person(likesMath == true) 
then 
person.setClassName(Math); 
update(person); 
end 
 
rule And now, time for something completely different 
no-loop 
when 
person : Person(likesMath == true) 
then 
PreferredClass p = new PreferredClass(Math);
p.setPerson(person);
insert(p); 
end 
 
 
Cheers,
 
Mike




From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Shyam, Pallav
(MSCIBARRA)
Sent: 11 September 2008 11:40
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Update vs insert



Very strange. The facts are passed into the WM by-reference.
Therefore the query should work after calling the
person.setClassName(Math) on the fact. And this should work without
calling the insert or update.

This leaves me guessing that the query does not work on the
facts directly, instead they work on shadow facts. 







From: [EMAIL PROTECTED] 
To: Rules Users List 
Sent: Thu Sep 11 04:41:37 2008
Subject: [rules-users] Update vs insert 




Hello, 

   What is the difference between calling insert and update in a
rule file? When I use insert my queries don't work, but if I use update
they seem to. I don't mind using update, but I would like to understand
the difference between the two. Here is my rule file.

rule Add person to math class 
no-loop 
when 
person : Person(likesMath == true) 
then 
person.setClassName(Math); 
insert(person); 
end 

   I also have a query: 

   query getPeopleForClass(String _className) 
  Person(className == _className) 
   end 

   When I add two facts to working memory, where the likesMath
attribute is true, then run my query I get zero results back. When I
change the rule, Add person to math class, to use update(person)
instead of insert(person) two students are returned.

  Any help would be appreciated. 

Thanks, 
Dan 


Daniel Quinn 
Fedex - Custom Critical 
Software Specialist I 
234.310.4090(x2586) 

-Original Message- 
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED] ] On Behalf Of
[EMAIL PROTECTED]

Sent: Wednesday, September 10, 2008 2:27 PM 
To: rules-users@lists.jboss.org 
Subject: [rules-users] Re: looping problem 

Hello, 

thanks that works. I just forgot to set the focus in the init
rule.. 

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




NOTICE: If received in error, please destroy and notify sender.
Sender does not intend to waive confidentiality or privilege. Use of
this email is prohibited when received in error.

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


RE: [rules-users] getting latest date

2008-09-11 Thread Anstis, Michael (M.)
You might need to add the MemberDataRecords into WM and use not exists
 
when
$d : Data() 
$mdr : MemberDataRecord( $d1 : loggedInDate )
not exists MemberDataRecord ( loggedInDate  $d1 )
then
//Smurf
end
  




From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Kapila
Silwathge
Sent: 11 September 2008 13:09
To: Rules Users List
Subject: Re: [rules-users] getting latest date


yeah.i did the same with following code
 
//
$d : Data($memDataRecods :memberDataRecords ) 



$mdr : MemberDataRecord($loggedindate:logged_in_date )from
$memDataRecods not MemberDataRecord( logged_in_date  $loggedindate )

//

when what happened was it iterates over earch memDataRecods in
decending order

what i need is to get only the very first record...

- Original Message - 
From: Shyam, Pallav (MSCIBARRA)
mailto:[EMAIL PROTECTED]  
To: rules-users@lists.jboss.org 
Sent: Thursday, September 11, 2008 5:09 PM
Subject: Re: [rules-users] getting latest date


rule 
when
m : MemberDataRecords( d : loggedInDate) from Data( )
and not MemberDataRecords( loggedInDate  d) from Data(
)

then

end




From: [EMAIL PROTECTED] 
To: rules-users@lists.jboss.org 
Sent: Thu Sep 11 19:05:22 2008
Subject: [rules-users] getting latest date 




HI all.
 
I am inserting an Obect from a class called Data() to
the working memory
 
Data object has a Collection (ArrayList) of Objects from
a class called MemberDataRecords()
 
MemberDataRecords object has a field called loggedInDate
of type Date()(Accually SimpleDate a subclass of java util date())
 
how can i get MemberDataRecords object which contain the
last loggedInDate 
 
Kapila Silwathge



NOTICE: If received in error, please destroy and notify
sender. Sender does not intend to waive confidentiality or privilege.
Use of this email is prohibited when received in error.







___
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] Java code Vs Drools

2008-08-13 Thread Anstis, Michael (M.)
Why not add your ArrayList items individually into WM?

rule P1 110

salience 1
activation-group 1

  when
PriorityType( pricetype == 10,20,30,40,110 )
t:TlbObjectAttributeData( lngAttrTypeId == 110 )
  then
result.add(t);
end

Would this not give the same result and give you the indexing Mark has
commented upon?

Cheers,

Mike 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Harsh Jetly
Sent: 13 August 2008 10:03
To: rules-users@lists.jboss.org
Subject: [rules-users] Java code Vs Drools 


I have been evaluating the rule engine (ie Drools 4.0.4). I have created
an
application which has about 20 rules . I insert about 500 arraylists
into
the working memory and each arraylist contains about 4 objects. The rule
engine picks the object that is the best match from the arraylist and
stores it .
This processing takes about 0.953 secs .

Now this very same scenario I have implemented in using java code (if
..else)...it takes about 0.016secs .

I was expecting the rule engine to give a better performance.
Considering
the use of alpha node caching and other factors of the rete algorithm.

This is how one of the rules look in the rule file :

rule P1 110

salience 1
activation-group 1

  when
PriorityType( pricetype == 10,20,30,40,110 )
list :ArrayList(  )
t:TlbObjectAttributeData( lngAttrTypeId == 110 ) from list
  then
  result.add(t);

end


Am I doing something wrong or this application is not harnessing the
pluses
of the rule engine .

If so can you please tell me which kind of application should I build to
highlight the performance of a rule engine .

Appreciate it


Regards
Harsh Jetly
SOA
Center of Excellence



__
___
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] Fetching values of an object's attribute setbydifferent rules

2008-08-12 Thread Anstis, Michael (M.)
Globals don't pass down the RETE network and so Drools won't try to pass
them down the network (although if the Class you insert is not used in
any LHS patterns it will probably be filtered out at the top of the
network by a ObjectTypeNode) so they might offer (insignificantly)
faster performance. Also to insert a fact and retrieve later it'd be a
good idea to hang onto the FactHandle... Not much in it (I think), just
personal preference.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of psentosa
Sent: 12 August 2008 11:26
To: rules-users@lists.jboss.org
Subject: RE: [rules-users] Fetching values of an object's attribute
setbydifferent rules


yup, that's what I'm planing to use now.
Now that you mentioned it, is there any advantage of using the list as
global over using it by just inserting it normally (session.insert)?
Again, really appreciate your answers a lot!Thanks

Paul



Anstis, Michael (M.) wrote:
 
 OK, so here is my take on things:-
 
 +--+   ++   +---+
 |  |   ||   |   |
 | Sub-system 1 |--| Sub-system 2   |--| Sub-system 3 uses |
 | sets up data |   | Rules \ Drools |   | results from sub- |
 +--+   ||   | system 2  |
++   +---+
 
 
 I would be inclined to have ListWashRuleValueHolder  as a global in
WM
 and append instances of WashRuleValueHolder to the list in RHS of
rules
 (or a Map or something so you can retrieve what you want easily). Also
 have you looked at StatelessSession.executeWithResults() - which I
 haven't personally used but would give you what (I think) you need (if
 stateless is acceptable too!).
 
 Cheers,
 
 Mike
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of psentosa
 Sent: 12 August 2008 09:45
 To: rules-users@lists.jboss.org
 Subject: Re: [rules-users] Fetching values of an object's attribute
set
 bydifferent rules
 
 
 Thank you Mike and Kris for the answer.
 So I'll give it a try again to explain :)
 
 The rules I described have information that I need to go further with
my
 application,
 i.e. with the wash example, when rule A fires, it'll give information
 about
 the washing instruction regarding the temperature and detergent.
 Now, let's say, I have another block of codes apart from this RE-part,
 which
 needs those information (.e.g a WashMachine Object). These info should
 only
 be defined within the rules. So my question before was, how can I pass
 those
 to my washMachine?
 That's why idea was to insert a new/empty value holder, set the value
to
 the
 holder when the rule fire, and I can use the value holder (which
already
 contains value/has info from the fired rules).
 I'm not sure if using such a ValueHolder is the best way to fetch some
 values set within the rules.
 I hope this is clearer now, and any idea would be great!
 Thanks in advance
 
 Paul 
 
 
 
 
 
 psentosa wrote:
 
 Hi, 
 
 I have the following problems:
 I need to prove an object based on certain rules, where the parts of
 the
 rules should be kept to be used in further process within my
 application.
 In order to fetch those parts, my idea was to insert an additional
 object
 as value holder for the rule's parts,
 put values on them when the corresponding rule is fired, so that
later
 on
 I can process those value holder after my appl gets the control back
 from
 Ruleengine.
 
 
 The example below:
 
 Shirt shirt = new Shirt(...)
 WashRuleValueHolder holder = new WashRuleValueHolder();
 
 session.insert(shirt);
 session.insert(holder);
 ..
 
 session.dispose()
 
 System.out.println(holder.getTemperature());
 System.out.println(holder.getDetergent());
 ===
 
 rule A
 when
   Shirt (dirtinessLevel == high)
   $holder : WashRuleValueHolder()
 then
   System.out.println (this cloth should be washed in 60 degree
 water
 with 1 spoon of detergent)
  $holder.temperature = 60;
  $holder.detergent = 1;
 
 rule B
 when
  Shirt(material == satin)
  $holder : WashRuleValueHolder()
 then
System.out.println (this cloth should be washed in 30 degree
 water
 with 0,5 spoon of detergent)
  $holder.temperature = 30;
  $holder.detergent = 0,5;
 
 Now, in case both rules evaluate to true, I'd have problem with my
 valueholder, bcs depending on which one of the rules was fired
latest,
 that'd be the value I got from the holder, and I need both of them.
 So, my questions:
 
 - Is using such a value holder a good solution to fetch the rules'
 value?
 Or is there any better solution?
 - How to handle this problem of multiple value association to the
 holder,
 so I still can get all the values without one overwriting the other
 and
 they are still connected?
 
 Any idea highly appreciated, thanks in advance!
 
 
 
 
 
 -- 
 View this message in context:

http://www.nabble.com/Fetching

RE: [rules-users] Use of a DAO in LHS

2008-08-11 Thread Anstis, Michael (M.)
Hi Jean-Baptiste,
 
Here is a good (complete) example you can try following:
 
http://www.redhatmagazine.com/2008/07/11/jboss-drools-meets-hibernate/
 
With kind regards,
 
Mike




From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of BINET 
JEAN-BAPTISTE
Sent: 11 August 2008 08:06
To: Rules Users List
Subject: RE: [rules-users] Use of a DAO in LHS


On the contrary of what you said I read the documentation. And there is 
this sentence :
The next example shows how we can reason over the results of a 
hibernate query. The Restaurant pattern will reason over and bind with each 
result in turn:
but after there is no example 
I already tried to use the from keyword but I didn't succeed in 
writting a good syntax. So, that's why I ask the question.
The only thing I succeed in is to write a function which uses my dao to 
do SQL query.Then I call this function with eval in the LHS.
But how to use the from keyword ???
 
BR
 
Jean-Baptiste
 


De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] De la part de Anstis, 
Michael (M.)
Envoyé : vendredi 8 août 2008 17:36
À : Rules Users List
Objet : RE: [rules-users] Use of a DAO in LHS


I suspect you may not have read the documentation.
 
Take a look at the from keyword.




From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of 
BINET JEAN-BAPTISTE
Sent: 08 August 2008 16:01
To: rules-users@lists.jboss.org
Subject: [rules-users] Use of a DAO in LHS



Hello, 

I have a DRL file in which I have a global variable 
representing a DAO. 
So, I succeed in writting a rule which uses this DAO to run a 
SQL query 
on the database from the RHS part. 
But now, I would like to use my DAO in the LHS, I mean I want 
to fire my 
rule only if a condition is ok on the result of my SQL query. 
Is it possible to call a method of my DAO in the LHS part ? 
I have not found an example. 

Thanks. 

Regards, 

Jean-Baptiste 

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


RE: [rules-users] Fetching values of an object's attribute set bydifferent rules

2008-08-11 Thread Anstis, Michael (M.)
Hi psentosa,

I don't fully understand what you require, but won't using a List of
WashRuleMatches provide what you need?

rule A
when
  $s : Shirt (dirtinessLevel == high)
  $holder : WashRuleValueHolder()
Then
System.out.println (this cloth should be washed in 60 degree
water with 1 spoon of detergent)
WashRuleMatch m = new WashRuleMatch();
m.setTemperature(60);
m.setDetergent(1);
m.setShirt($s);
$holder.add(m);
//insertLogical(m);

rule B
when
 $s : Shirt(material == satin)
 $holder : WashRuleValueHolder()
then
System.out.println (this cloth should be washed in 30 degree
water with 0,5 spoon of detergent)
WashRuleMatch m = new WashRuleMatch();
m.setTemperature(30);
m.setDetergent(0.5);
m.setShirt($s);
$holder.add(m);
//insertLogical(m);

Do you need only one WashRuleValueHolder for each shirt?

[WashRuleValueHolder setup by rules]

rule A1.0
when
  $s : Shirt (dirtinessLevel == high)
  not WashRuleValueHolder(shirt == $s)
Then
WashRuleValueHolder wrvh = new WashRuleValueHolder($s);
insertLogical(wrvh);

rule A1.1
when
  $s : Shirt (dirtinessLevel == high)
  $holder : WashRuleValueHolder(shirt == $s)
Then
System.out.println (this cloth should be washed in 60 degree
water with 1 spoon of detergent)
WashRuleMatch m = new WashRuleMatch();
m.setTemperature(60);
m.setDetergent(1);
m.setShirt($s);
$holder.add(m);
//insertLogical(m);

Etc...

With kind regards,

Mike

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of psentosa
Sent: 11 August 2008 10:04
To: rules-users@lists.jboss.org
Subject: [rules-users] Fetching values of an object's attribute set
bydifferent rules


Hi, 

I have the following problems:
I need to prove an object based on certain rules, where the parts of the
rules should be kept to be used in further process within my
application.
In order to fetch those parts, my idea was to insert an additional
object as
value holder for the rule's parts,
put values on them when the corresponding rule is fired, so that later
on I
can process those value holder after my appl gets the control back from
Ruleengine.


The example below:

Shirt shirt = new Shirt(...)
WashRuleValueHolder holder = new WashRuleValueHolder();

session.insert(shirt);
session.insert(holder);
..

session.dispose()

System.out.println(holder.getTemperature());
System.out.println(holder.getDetergent());
===

rule A
when
  Shirt (dirtinessLevel == high)
  $holder : WashRuleValueHolder()
then
  System.out.println (this cloth should be washed in 60 degree
water
with 1 spoon of detergent)
 $holder.temperature = 60;
 $holder.detergent = 1;

rule B
when
 Shirt(material == satin)
 $holder : WashRuleValueHolder()
then
   System.out.println (this cloth should be washed in 30 degree
water
with 0,5 spoon of detergent)
 $holder.temperature = 30;
 $holder.detergent = 0,5;

Now, in case both rules evaluate to true, I'd have problem with my
valueholder, bcs depending on which one of the rules was fired latest,
that'd be the value I got from the holder, and I need both of them.
So, my questions:

- Is using such a value holder a good solution to fetch the rules'
value? Or
is there any better solution?
- How to handle this problem of multiple value association to the
holder, so
I still can get all the values without one overwriting the other and
they
are still connected?

Any idea highly appreciated, thanks in advance!



-- 
View this message in context:
http://www.nabble.com/Fetching-values-of-an-object%27s-attribute-set-by-
different-rules-tp18922201p18922201.html
Sent from the drools - user mailing list archive at Nabble.com.

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

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


RE: [rules-users] Fetching values of an object's attribute setbydifferent rules

2008-08-11 Thread Anstis, Michael (M.)
Hi Paul,

What about subclassing List and adding a type attribute?

class MyArrayList extends ArrayList {

private String type;

public String getType() {
return type;
}

}

Rule smurf
when
$l : MyArrayList( type == 'shirt' )
...
then
...
end

Still not understanding your requirement but happy to keep punting ideas
until you get the spark.

Cheers,

Mike
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of psentosa
Sent: 11 August 2008 14:48
To: rules-users@lists.jboss.org
Subject: RE: [rules-users] Fetching values of an object's attribute
setbydifferent rules


Hi Mike,

thanks for the reply.
Actually for each object I check, depending on how many rules are
activated,
I'd need so many value holder too.
So, each value holder actually contains information about each activated
rule (e.g. regarding the temperature and detergent.
But thank you for the keyword LIST. I think, instead of using 2 level
(i.e.
Value Holder and the Match-objects, I could use
session.insert(ListValueHolder), and for every activated rule, in THEN
part I'll create a new ValueHolder, set its values, and add it to the
list.

But another question to this:
How can I insert 2 different kind of lists, and refer to them?
I saw that ListMyClass() can't be used, and only List() is possible

when
 $wash : List()
 $shirt : List()
then
 $wash.add(new Wash..())
 $shirt.add(new Shirt())

Can RE find the correct list to add the objet? Or how should I do this?

Again, thanks in advance :)

Paul


Hi psentosa,

I don't fully understand what you require, but won't using a List of
WashRuleMatches provide what you need?

rule A
when
  $s : Shirt (dirtinessLevel == high)
  $holder : WashRuleValueHolder()
Then
System.out.println (this cloth should be washed in 60 degree
water with 1 spoon of detergent)
WashRuleMatch m = new WashRuleMatch();
m.setTemperature(60);
m.setDetergent(1);
m.setShirt($s);
$holder.add(m);
//insertLogical(m);

rule B
when
 $s : Shirt(material == satin)
 $holder : WashRuleValueHolder()
then
System.out.println (this cloth should be washed in 30 degree
water with 0,5 spoon of detergent)
WashRuleMatch m = new WashRuleMatch();
m.setTemperature(30);
m.setDetergent(0.5);
m.setShirt($s);
$holder.add(m);
//insertLogical(m);

Do you need only one WashRuleValueHolder for each shirt?

[WashRuleValueHolder setup by rules]

rule A1.0
when
  $s : Shirt (dirtinessLevel == high)
  not WashRuleValueHolder(shirt == $s)
Then
WashRuleValueHolder wrvh = new WashRuleValueHolder($s);
insertLogical(wrvh);

rule A1.1
when
  $s : Shirt (dirtinessLevel == high)
  $holder : WashRuleValueHolder(shirt == $s)
Then
System.out.println (this cloth should be washed in 60 degree
water with 1 spoon of detergent)
WashRuleMatch m = new WashRuleMatch();
m.setTemperature(60);
m.setDetergent(1);
m.setShirt($s);
$holder.add(m);
//insertLogical(m);

Etc...

With kind regards,

Mike


-- 
View this message in context:
http://www.nabble.com/Fetching-values-of-an-object%27s-attribute-set-by-
different-rules-tp18922201p18926194.html
Sent from the drools - user mailing list archive at Nabble.com.

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

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


RE: [rules-users] Decision table not triggering

2008-08-08 Thread Anstis, Michael (M.)
I think you might need to post more of your source if possible.

Where are you setting PoolInfo.daysBeforeSummons to 5, outside WM and
before fireAllRules or within the RHS of another rule?

Thanks,

Mike

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Hehl, Thomas
Sent: 07 August 2008 21:41
To: 'Rules Users List'
Subject: RE: [rules-users] Decision table not triggering

Nope. Only one of each.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Greg Barton
Sent: Thursday, August 07, 2008 4:33 PM
To: Rules Users List
Subject: Re: [rules-users] Decision table not triggering

Is there more than one PoolInfo object in working
memory?  If so does any one of them match the rule? 

Also, the rule conditions would create a cartesian
join because the PoolInfo and PostponementRequest are
not logically related.  In other words, if you had
PoolInfo1, PoolInfo2, PostponementRequest1,
PostponementRequest2 in working memory, and all
matched the rule, you'd get the following rule
firings:

PoolInfo1, PostponementRequest1
PoolInfo1, PostponementRequest2
PoolInfo2, PostponementRequest1
PoolInfo2, PostponementRequest2

Probably not what you want.

GreG

--- Hehl, Thomas [EMAIL PROTECTED] wrote:

 I have a unit test that calls a decision table that
 generated the following
 rule with drools 4.0.7:
 
  
 
 #From row number: 10
 
 rule postponePart_10
 
   
 
   when
 
 PoolInfo(courtLocation == 101,
 daysBeforeSummons = 7,
 daysBeforeSummons = 999)
 
 postponementRequest:
 PostponementRequest(requestDaysAfterSummons
 = 30, requestDaysAfterSummons = 90,
 requestedDayOfWeek = 2,
 requestedDayOfWeek = 2)
 
   then
 
 postponementRequest.setAllowed(true);
 
 end
 
  
 
 This rule passes when daysBeforeSummons  = 30. I
 then change the
 daysBeforeSummons to 5 and the rule still passes. I
 have debugged this and
 watched it run rule 10, so I don't know what else to
 do. Does this look like
 a bug?
 
  
 
  
 
 Thom Hehl
 Sr. eJuror Architect
 ACS: Government Solutions
 
 * Office (859) 277-8800 x 144
 * [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]  
 1733 Harrodsburg Road
 Lexington, KY 40504-3617
 
 
 
 This e-mail message, including any attachments, is
 for the sole use of the
 intended recipient(s) and may contain confidential
 and privileged
 information. Any unauthorized review, use,
 disclosure or distribution is
 prohibited. If you are not the intended recipient,
 please contact the sender
 by reply e-mail and destroy all copies of the
 original message and notify
 sender via e-mail at [EMAIL PROTECTED]
 mailto:[EMAIL PROTECTED]  or by telephone at
 859-277-8800 ext. 144.
 Thank you.
 
  
 
  ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users
 



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

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


RE: [rules-users] Drools vs Business Logic

2008-08-08 Thread Anstis, Michael (M.)
Well, IMO, common sense suggests highly specialised hand crafted code
optimised to a particular problem domain *should* be faster than a
generic algorithm (taking this further why not dump the high level
languages all together and opt for C++ or assembler, if you really
really want you squeeze performance?!?). However should your problem
domain change you have the burden of changing and re-optimising your
code. Lots of hassle. IMO, rule engines are great where your problem
domain is likely to change or you want to externalise your rule
definitions for whatever reason (maintainability, exposure to user
definitions etc). You'd be better off comparing the performance of a
prototype hand-crafted solution to generic rule engine solution - I
think you'd be surprised as to just how fast the generic solution is -
there have been quite a few postings to this group where people have
done performance tests of Drools. Only you can make these decisions as
you know your requirements best. 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Harsh Jetly
Sent: 08 August 2008 08:18
To: rules-users@lists.jboss.org
Subject: [rules-users] Drools vs Business Logic 


Hi ,


Firstly I would like to apologize for sending the same question to both
the
mailing lists and sending it multiple number of times. I assure you , it
shall not happen again .


I am using version 4.0.4 of drools . I have a basic question :
If we compare a rule engine to code written within the application ,
which
would prove to be faster .
I know about the rete algorithm and concepts of node sharing and caching
.
Another question that I have is , in which situation will Drools be best
suited ?

Thanks a ton
Harsh Jetly


Larsen  Toubro Infotech Ltd.
www.Lntinfotech.com

This Document is classified as:

|--|
| [X]  |
|--|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

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


RE: [rules-users] Drools vs Business Logic

2008-08-08 Thread Anstis, Michael (M.)
Section 2.2. Why use a Rule Engine in the documentation gives a wealth
of extra information that I forgot about first time round!

-Original Message-
From: Anstis, Michael (M.) 
Sent: 08 August 2008 09:07
To: 'Rules Users List'
Subject: RE: [rules-users] Drools vs Business Logic 

Well, IMO, common sense suggests highly specialised hand crafted code
optimised to a particular problem domain *should* be faster than a
generic algorithm (taking this further why not dump the high level
languages all together and opt for C++ or assembler, if you really
really want you squeeze performance?!?). However should your problem
domain change you have the burden of changing and re-optimising your
code. Lots of hassle. IMO, rule engines are great where your problem
domain is likely to change or you want to externalise your rule
definitions for whatever reason (maintainability, exposure to user
definitions etc). You'd be better off comparing the performance of a
prototype hand-crafted solution to generic rule engine solution - I
think you'd be surprised as to just how fast the generic solution is -
there have been quite a few postings to this group where people have
done performance tests of Drools. Only you can make these decisions as
you know your requirements best. 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Harsh Jetly
Sent: 08 August 2008 08:18
To: rules-users@lists.jboss.org
Subject: [rules-users] Drools vs Business Logic 


Hi ,


Firstly I would like to apologize for sending the same question to both
the
mailing lists and sending it multiple number of times. I assure you , it
shall not happen again .


I am using version 4.0.4 of drools . I have a basic question :
If we compare a rule engine to code written within the application ,
which
would prove to be faster .
I know about the rete algorithm and concepts of node sharing and caching
.
Another question that I have is , in which situation will Drools be best
suited ?

Thanks a ton
Harsh Jetly


Larsen  Toubro Infotech Ltd.
www.Lntinfotech.com

This Document is classified as:

|--|
| [X]  |
|--|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

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


RE: [rules-users] Use of a DAO in LHS

2008-08-08 Thread Anstis, Michael (M.)
I suspect you may not have read the documentation.
 
Take a look at the from keyword.




From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of BINET
JEAN-BAPTISTE
Sent: 08 August 2008 16:01
To: rules-users@lists.jboss.org
Subject: [rules-users] Use of a DAO in LHS



Hello, 

I have a DRL file in which I have a global variable representing
a DAO. 
So, I succeed in writting a rule which uses this DAO to run a
SQL query 
on the database from the RHS part. 
But now, I would like to use my DAO in the LHS, I mean I want to
fire my 
rule only if a condition is ok on the result of my SQL query. 
Is it possible to call a method of my DAO in the LHS part ? 
I have not found an example. 

Thanks. 

Regards, 

Jean-Baptiste 

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


RE: [rules-users] determinism with rulebase partitioning

2008-08-01 Thread Anstis, Michael (M.)
Hi Mark,

A few questions:-

(A) What does parallel evaluation of a rulebase mean? Is it designed
to optimise, for example, two threads processing a stateless and
stateful session?

(B) Are there only two partitions, both of which are invisible to the
user? Is there any value in allowing user-defined partitions?

(C) Does the partition used depend upon what type of session is used
(i.e. stateless always uses the partition without an agenda whereas
stateful always uses the partition with an agenda)?

(D) Can a rule sometimes be deterministic and sometimes not (i.e.
depends upon the type of session)?

Cheers,

Mike

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mark Proctor
Sent: 01 August 2008 07:05
To: Rules Users List
Subject: [rules-users] determinism with rulebase partitioning

We have rulebase partitioning almost working, this allows parallel 
evaluation of a rulebase. For stateless lessions with no agenda this 
will allow for much faster executions, where you don't care about 
deterministic execution. However for deterministic execution its more 
complicated. The current plan is to have an agenda per parition, which 
means that we no longer have rulebase wide deterministic execution 
order, only with the partition itself. The user is unlikely to be aware 
of the created partitions, so won't be aware of the unditermistic 
behavour of their rulebase. Anyone have any input on mechanisms users 
can do to help the rulebase know what needs to be executed 
deterministically and what doesn't?

Mark
___
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] 'from global' and the workingMemory

2008-07-30 Thread Anstis, Michael (M.)
I believe the from keyword will iterate only the items in list1.

I don't consider it naïve though; just doing what it is documented to do.

If you want to iterate facts in the RETE network you need to insert them into 
working memory.

You could use a rule to do this (copy from a global into WM) or do it from your 
application.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Yoni Mazar
Sent: 30 July 2008 09:46
To: rules-users@lists.jboss.org
Subject: [rules-users] 'from global' and the workingMemory


Hi all,

Let's look at the following example:
DRL file***
global java.util.List list1;
global java.util.List list2;
rule r1 when Fact(...) from list1 then 
Application
ListFact facts1 = ...
ListFact facts2 = ...
ListFact allFacts= facts1+facts2

StatelessSession session = ...
session.setGlobal(list1, facts1);
session.setGlobal(list2, facts2);

session.execute(allFacts)
The question: will rule r1 use the facts from the working memory and a
rete algorithm, or will it naively loop on list1 items?

BTW, can we use generic in the DRL section? for example:
global java.util.ListFact list1;

Thanks for the help, Yoni
-- 
View this message in context: 
http://www.nabble.com/%27from-global%27-and-the-workingMemory-tp18728639p18728639.html
Sent from the drools - user mailing list archive at Nabble.com.

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

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


RE: [rules-users] 'from global' and the workingMemory

2008-07-30 Thread Anstis, Michael (M.)
OK, sorry, I missed that (important) part ;-)

Reading the API Docs says execute Insert a List of facts, an fire the rules, 
returning when finished. This will assert the list of facts as SEPARATE facts 
to the engine (NOT as a List). 

So I guess r1 will activate for ALL facts in allFacts but whether the 
pattern in r1 (from) leads to duplicate activations of the same objects 
obtained from the global I don't know. Section 2.5.8. Truth Maintenance with 
Logical Objects of the manual talks about STATED facts and a check for 
equivalence but I think this only applies to insertions into WM. I'd guess that 
you'd get two activations for those facts in list1 and allFacts because of the 
use of from - but it would be a guess. Have you conducted a test (if so what 
did you get) or is it hyperthetical at the moment?

Sorry my eager response turned out not to be that helpful after all!

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Yoni Mazar
Sent: 30 July 2008 10:15
To: rules-users@lists.jboss.org
Subject: RE: [rules-users] 'from global' and the workingMemory


Thanks for the prompt response.
In the example bellow one can see that list1 items are actually passed to
the execute() method. Hence the dilema whether the engine will look at the
WM or at the global. to my understanding, it will loop on the global. I just
want to be sure that I understand it correctly.

Thanks, Yoni


Anstis, Michael (M.) wrote:
 
 I believe the from keyword will iterate only the items in list1.
 
 I don't consider it naïve though; just doing what it is documented to do.
 
 If you want to iterate facts in the RETE network you need to insert them
 into working memory.
 
 You could use a rule to do this (copy from a global into WM) or do it from
 your application.
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Yoni Mazar
 Sent: 30 July 2008 09:46
 To: rules-users@lists.jboss.org
 Subject: [rules-users] 'from global' and the workingMemory
 
 
 Hi all,
 
 Let's look at the following example:
 DRL file***
 global java.util.List list1;
 global java.util.List list2;
 rule r1 when Fact(...) from list1 then 
 Application
 ListFact facts1 = ...
 ListFact facts2 = ...
 ListFact allFacts= facts1+facts2
 
 StatelessSession session = ...
 session.setGlobal(list1, facts1);
 session.setGlobal(list2, facts2);
 
 session.execute(allFacts)
 The question: will rule r1 use the facts from the working memory and a
 rete algorithm, or will it naively loop on list1 items?
 
 BTW, can we use generic in the DRL section? for example:
 global java.util.ListFact list1;
 
 Thanks for the help, Yoni
 -- 
 View this message in context:
 http://www.nabble.com/%27from-global%27-and-the-workingMemory-tp18728639p18728639.html
 Sent from the drools - user mailing list archive at Nabble.com.
 
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users
 
 ___
 rules-users mailing list
 rules-users@lists.jboss.org
 https://lists.jboss.org/mailman/listinfo/rules-users
 
 

-- 
View this message in context: 
http://www.nabble.com/%27from-global%27-and-the-workingMemory-tp18728639p18729195.html
Sent from the drools - user mailing list archive at Nabble.com.


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

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


RE: [rules-users] Measuring Drools Memory Usage

2008-07-29 Thread Anstis, Michael (M.)
Do you use a stateful session?
 
Are your measurements before and after you've inserted facts into
working memory?
 
Would be helpful to the group to post your use-case source?
 
Thanks,
 
Mike




From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Roger
Tanuatmadja
Sent: 29 July 2008 02:12
To: Rules Users List
Subject: [rules-users] Measuring Drools Memory Usage


Hi, 
 
Has anyone attempted to measure the incremental memory usage of
using Drools? Anyone cares to share their methodology?
 
I am currently following the following methodology:
1. Prevent garbage collection from happening by using large Xms
Xmx (1024m in my case), a NewRatio of 2 (I am sure other sizes will work
as well) and verbogegc enabled to confirm that no garbage collection is
happening.
2. Use Runtime.freeMemory before and after fireAllRules and
measuring the difference. 
 
The problem with my methods so far has been that after a
positive memory usage (indicating you are using memory), subsequent use
case (the same one) incurs zero memory usage which is very strange. 
 
So I guess my question is 2 fold: anyone care to share their
methodology, and can anyone see what's wrong with mine?
 
Thanks,
 
Roger

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


RE: [rules-users] database access via JDBC

2008-07-28 Thread Anstis, Michael (M.)
You can use any technology you like to get data from outside the Working
Memory using the from keyword.
 
Look at the documentation for more details.




From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of thomas kukofka
Sent: 28 July 2008 14:01
To: Rules Users List
Subject: [rules-users] database access via JDBC


Hello,

is it possible to access a database from within the rule file
via JDBC?
I only read about access via Hibernate. Is there any JDBC
example?

regards
Tom


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


RE: [rules-users] How to invoke particular ruleflow multiple rule flowsfrom from stateless session

2008-07-23 Thread Anstis, Michael (M.)
drools.getworkingmemory.startprocess(id) Starts a new process instance
for the process with the given id.

Section 6.8.4. Using a rule flow in your application of the (4.0.5)
manual gives more information.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of raj_drools
Sent: 22 July 2008 18:59
To: rules-users@lists.jboss.org
Subject: [rules-users] How to invoke particular ruleflow multiple rule
flowsfrom from stateless session


i'm using stateles ssession . 

i have multiple rule flows , i want to invoke respective rule flow from
controller . 

i can invoke ruleflow  drools.getworkingmemory.startprocess(id). from a
dummy rule . 

i can do the above procedure if i have single ruleflow . 

i'm having multiple rule flows , how can i invoke particular ruleflow 
-- 
View this message in context:
http://www.nabble.com/How-to-invoke-particular-ruleflow-multiple-rule-fl
ows-from--from-stateless-session-tp18595249p18595249.html
Sent from the drools - user mailing list archive at Nabble.com.

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

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


[rules-users] RE: [rules-dev] Multi threading usage best practice

2008-07-14 Thread Anstis, Michael (M.)
Cross posted for information.
 
Ths subject is more for the user list than the dev' one.
 
Cheers,




From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of 9Lives 9Lives
Sent: 14 July 2008 14:33
To: Rules Dev List
Subject: RE: [rules-dev] Multi threading usage best practice


TnX Mike 4 the quick response.
 
I'm afraid that u r right regarding the through-put ;-(
Using the synchronized method will probably solve my problem
but will damage the solution.
 
If u have any other thoughts on the matter i would love 2 hear
them.
 
Regards
Dotan








Subject: RE: [rules-dev] Multi threading usage best practice
Date: Mon, 14 Jul 2008 14:24:02 +0100
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]



Hi,
 
Would synchronising on working memory effectively serialise the
effects of fireAllRules()?

...
synchronised(wm) {
wm.fireAllRules();
}
...

I don't know whether this would kill your through-put either.
 
Cheers,
 
Mike




From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of 9Lives 9Lives
Sent: 14 July 2008 13:41
To: [EMAIL PROTECTED]
Subject: [rules-dev] Multi threading usage best practice


Hello
 
I'm using Drools 4.0.7 inside a mail relay application 2
determine the operations that need 2 b executed on each passing message.
To do this i'm using the following scenario:


1.  
I have a ruleBase.newStatefulSession().
2.  
I have a fixed set of facts.
3.  
I have a fixed set of rules.
4.  
Each mailer (a thread that is handling a single
message) is inserting the message to the working memory, calls the
fireAllRules method and retracts the message.
5.  
Rules that r executed change custom attributes
in the message.

Problem:
I noticed that sometimes a rule can b executed on the
same message more then once.
 
Assumption:
My guess is that because i'm working is a multi
threading environment but using a stateful session, what happens is:


1.  Thread A is inserting Message A. 
2.  Thread B is inserting Message B 
3.  Thread A is calling fireAllRules 
4.  Rule X is executed on messages A + B. 
5.  Thread B is calling fireAllRules 
6.  Rule X is executed on messages A + B 
7.  Thread A is retracting Message A 
8.  Thread B is retracting message B

Question:
My goal is 2 make sure a rule is executed only once on a
single message.
Any ideas on how 2 avoid the situation described above?
 
TnX
Dotan
 
 




Invite your mail contacts to join your friends list with
Windows Live Spaces. It's easy! Try it!
http://spaces.live.com/spacesapi.aspx?wx_action=createwx_url=/friends.
aspxmkt=en-us  




Discover the new Windows Vista Learn more!
http://search.msn.com/results.aspx?q=windows+vistamkt=en-USform=QBRE


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


RE: [rules-users] Drools 4 poor performance scaling?

2008-07-09 Thread Anstis, Michael (M.)
I wonder whether is's a benefit of truth maintenance? If a new fact is
inserted into working memory that could cause an activation of a rule
that contains an accumulate (or collect) to change then the whole
accumulate (or collect) operator is executed again?!?

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Fenderbosch,
Eric
Sent: 09 July 2008 14:41
To: Rules Users List
Subject: RE: [rules-users] Drools 4 poor performance scaling?

FYI for the group.  We seem to have solved our performance problem.

I'll describe our problem space a bit some people have some context.  We
load up about 1200 Jobs with about 3000 Stops and about 1500 Vehicles
with about 2000 Workers.  We then calculate Scores for each Vehicle for
each Job.  Some combinations get excluded for various reasons, but we
end up with 700k - 900k total facts.  We do score totaling and sorting
using accumulators.

One of our teams members (nice find Dan) decided to try to isolate the
accumulation rules until all our other facts are loaded.  Those rules
now have a not ColdStarting() condition and our startup code inserts a
ColdStarting fact as the first fact and retracts it when all the Jobs
and Workers have been loaded.  This changed our startup time from over
50 minutes to under 5.  There's some sort of strange propagation and
looping going on with accumulation on the fly, at least with our facts
and rules.

I'll put an entry on the wiki as well.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Fenderbosch,
Eric
Sent: Monday, June 30, 2008 11:46 AM
To: Rules Users List
Subject: RE: [rules-users] Drools 4 poor performance scaling?

We are having a similar problem, although our fact count is much higher.
Performance seems pretty good and consistent until about 400k facts,
then performance degrades significantly.  Part of the degradation is
from bigger and more frequent GCs, but not all of it.

Time to load first 100k facts: ~1 min
Time to load next 100k facts: ~1 min
Time to load next 100k facts: ~2 min
Time to load next 100k facts: ~4 min

This trend continues, going from 600k to 700k facts takes over 7
minutes.  We're running 4.0.7 on a 4 CPU box with 12 GB, 64 bit RH Linux
and 64 bit JRockit 5.  We've allocated a 9 GB heap for the VM using
large pages, so no memory paging is happening.  JRockit is started w/
the -XXagressive parameter, which enables large pages and the more
efficient hash function in HashMap which was introduced in Java5 update
8.

http://e-docs.bea.com/jrockit/jrdocs/refman/optionXX.html

The end state is over 700k facts, with the possibility of nearly 1M
facts in production.  After end state is reached and we issue a few GC
requests, if looks like our memory per fact is almost 9k, which seems
quite high as most of the facts are very simple.  Could that be due to
our liberal use of insertLogical and TMS?

We've tried performing a commit every few hundred fact insertions by
issuing a fireAllRules periodically, and that seems to have helped
marginally.

I tried disabling shadow proxies and a few of our ~390 test cases fail
and one loops indefinitely.  I'm pretty sure we could fix those, but
don't want to bother if this isn't a realistic solution.

Any thoughts?

Thanks

Eric

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ron Kneusel
Sent: Thursday, June 26, 2008 12:47 PM
To: rules-users@lists.jboss.org
Subject: [rules-users] Drools 4 poor performance scaling?


I am testing Drools 4 for our application and while sequential mode is
very fast I get very poor scaling when I increase the number of facts
for stateful or stateless sessions.  I want to make sure I'm not doing
something foolish before deciding on whether or not to use Drools
because from what I am reading online it should be fast with the number
of facts I have.

The scenario:  I have 1000 rules in a DRL file.  They are all of the
form:

rule rule
when 
Data(type == 0, value 0.185264);
Data(type == 3, value  0.198202);
then 
insert(new AlarmRaised(0));
warnings.setAlarm(0, true);
end

where the ranges checked on the values and the types are randomly
generated.  Then, I create a Stateful session and run in a loop timing
how long it takes the engine to fire all rules as the number of inserted
facts increases:

//  Run 
for(j=0; j  100; j+=5) {

if (j==0) {
nfacts = 1;
} else {
nfacts = j;
}

System.out.println(nfacts + :);

//  Get a working memory
StatefulSession wm = ruleBase.newStatefulSession();

//  Global - output
warnings = new Alarm();
wm.setGlobal(warnings, warnings);

//  Add facts
st = (new Date()).getTime();
for(i=0; i  nfacts; i++) {
wm.insert(new Data(rand.nextInt(4),

RE: [rules-users] Rules 'firing' multiple times?

2008-07-08 Thread Anstis, Michael (M.)
Hi,
 
Given the rule you show it doesn't matter how many records you have on a
table UNLESS they are inserted into working memory. So, assuming you
have code outside of that below which inserts each individual record
into working memory, then you can expect one activation to appear on the
agenda for each Emp_Crime_Record object in working memory that have
disposition equal to GUILTY. Does this make sense?
 
Rule activations are put on the agenda as objects are inserted into
working memory and not when you call fireAllRules() - which executes the
activations on the agenda. So, every time you insert an object into
working memory the object is checked against the patterns defined in the
left-hand-side (when). If they match an activation is put on the
agenda (the right-hand-side - then) for later execution (when you call
fireAllRules).
 
Cheers,
 
Mike




From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of pramod george
Sent: 08 July 2008 10:58
To: rules-users@lists.jboss.org
Subject: [rules-users] Rules 'firing' multiple times?



Hi all.
I have this question on drools rules and I'm not sure if this
is the right thinking?
I have a rule defined in a drl file:
when 
c: Emp_Crime_Record(DISPOSITION == GUILTY);
then 
System.out.println(CriminalRecordRule fired...);
end

Here, if the table Emp_Crime_Record is got 5 rows that satisfy
this condition ie:- DISPOSITION == GUILTY, then does this rule get
fired
5 times? Ie:- the sop gets printed 5 times?

For this, if there are a million records that satisfy this
condition - then the firing happens a million times?

I would be greatful if this can be clarified?
Thanks a million!  :)

-Promod




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


RE: [rules-users] One question about Database interface

2008-07-08 Thread Anstis, Michael (M.)
Hi,

Jaroslaw Kijanowski's article looks like a really good starting point
for you!

Hibernate provide Entity Manager and Annotations extensions if you want
to go the JPA route.

From a Drool's perspective you need only concern yourself with from
which is documented as:-

6.5.2.8. From

The from Conditional Element allows users to specify a source for
patterns to reason over. This allows the engine to reason over data not
in the Working Memory. This could be a sub-field on a bound variable or
the results of a method call. It is a powerful construction that allows
out of the box integration with other application components and
frameworks. One common example is the integration with data retrieved
on-demand from databases using hibernate named queries.
 
For information on the rest of Jaroslaw's example, you will need to read
up on Hibernate.

With kind regards,

Mike

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Senlin Liang
Sent: 08 July 2008 13:12
To: Rules Users List
Subject: Re: [rules-users] One question about Database interface

Thanks.  Where could I find the related manual or instructions? I
searched through the doc for drools, and the email archive, there is
really no good example or explanation on how to achieve this.

(What I want is to insert, select or delete some objects in relational
database such as mysql.)

Any information is greatly appreciated.
Thanks.

On Tue, Jul 8, 2008 at 4:20 AM, Anstis, Michael (M.) [EMAIL PROTECTED]
wrote:
 Have a look at an example posted earlier this week whereby somebody
 (sorry I forget who) was using JPA from within a rule.

 Once you understand how JPA was used then the remaining questions
relate
 more specifically to JPA.

 As Mark says, (native) Hibernate can also be used very easily.

 With kind regards,

 Mike


 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Senlin Liang
 Sent: 08 July 2008 03:18
 To: Rules Users List
 Subject: [rules-users] One question about Database interface

 Hi all,

 Is there some convinent database interface implemented in Drools
 (store and retrieve data from DBMS, such as mysql) ?

 I checked the manual, and found no such information. So I am assuming
 that I will have to use JDBC. Is it right?

 Thanks,
 Senlin Liang
 ___
 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




-- 
Senlin Liang
___
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] Package parameters

2008-06-26 Thread Anstis, Michael (M.)
Hi,

I don't think Drools supports this directly, but would this not be as
accomplishable with DSL?

Your Drools rule could then be written something like this (bare in mind I'm
no DSL expert):-

DSL:

[when]There is a hemoglobin lab result with=LabResult(type==hemoglobin)
[when]- a value less than {v}=value{v}

Rule: 

There is a hemoglobin lab result with
- a value less than 42

With kind regards,

Mike 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Yoni Mazar
Sent: 26 June 2008 15:29
To: rules-users@lists.jboss.org
Subject: [rules-users] Package parameters


Hi all,
We are at the begining of a new clinical decision-support project. We are
considering using a BRMS to manage and execute our business logic. As part
of our research, we evaluated JRules and Drools. JRules has a nice feature
that we could not find in Drools. We'd like to know if we are
misunderstanding something, or maybe this feature is missing.

In JRules, one can define a ruleset (corresponds to a package) with
parameters. Each parameter has a datatype (a class), a direction
(in/out/inout), and an alias. Then, within the rules, the user can refer to
the parameter alias. For example, a user can define a ruleset with the
following parameters: 
*class=LabResult, direction=in, alias=hemoglobin
*class=LabResult, direction=in, alias=creatinin
Then, within a rule, one can write:
when hemoglobin.value10 and creatinin.value34
then...
Now, the application retrieves the patient data accordingle (hemoglobin and
creatinine data separetly) and sets the ruleset parameters:
ruleset.parameters.add(hemoglobin,hemoglobinFact)
ruleset.parameters.add(creatinin,creatininFact)

This approach simplifies the rule authoring process significantly!

Writing this logic in Drools will be:
package cdss
import LabResult;

rule
when 
LabResult(type=hemoglobin  value 10)
LabResult(type=creatinin value 34)
then...

workingMemory.Assert(hemoglobinFact);
workingMemory.Assert(creatininFact);

Does someone has an idea how to bridge this gap using Drools?
Im not sure if using parameters JRule complies with JSR94 specification.

Thanks,
Yoni
-- 
View this message in context:
http://www.nabble.com/Package-parameters-tp17979190p17979190.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


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Stateless session and rule flows

2008-06-26 Thread Anstis, Michael (M.)
Hi,

I believe Stateless session is only a wrapper around a stateful session, so
you're only gaining convenience by using a Stateless one.

Why not write your own wrapper that allows for the execution of a rule flow
too?

Cheers,

Mike

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Yoni Mazar
Sent: 26 June 2008 15:31
To: rules-users@lists.jboss.org
Subject: [rules-users] Stateless session and rule flows


Hi Guys, 

We are trying to work with drools with stateless session (Sequential) and to
apply rule flows. 

we use the following code:

//define diagnosis and patient here
...

 StatelessSession session = ruleBase.newStatelessSession();
//Here we would like to use: session.startProcess(ruleflow id) but this is
a method which belongs to 
//StatefullSession only.
 session.execute(new Object[] {diagnosis, patient});

How can we do that in steteless mode?

Thanks, 

Yoni
-- 
View this message in context:
http://www.nabble.com/Stateless-session-and-rule-flows-tp17863849p17863849.h
tml
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


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Drools 4.0.7 supports Clustering and DB interaction ?

2008-05-30 Thread Anstis, Michael (M.)
Partial answer.

2. Drools supports database interactions. Have a look at the from clause
which allows for retrieval of data from outside the working memory.

Cheers,

Mike

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Thalupula Ravi
Sent: 30 May 2008 09:13
To: rules-users@lists.jboss.org
Subject: [rules-users] Drools 4.0.7 supports Clustering and DB interaction ?


Hi,

Can some one answer my questions regarding drools support

1. is drools supports clustering?
2. is drools supports Database interactions?

appreciate your help. it would be great for me, if any body provide examples
for above things.



-- 
View this message in context:
http://www.nabble.com/Drools-4.0.7-supports-Clustering-and-DB-interaction---
tp17553747p17553747.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


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Re: Old drools-spring project

2008-05-30 Thread Anstis, Michael (M.)
Without knowledge of your use case or domain model the below seems
reasonable!
 
Cheers,
 
Mike


  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Lake Pancake
Sent: 30 May 2008 13:33
To: rules-users@lists.jboss.org
Subject: [rules-users] Re: Old drools-spring project


Thanks for the reply.  I was primarily attracted to spring-drools because of
the use of Java to define complex logic in the conditions, but I have since
found this old thread that summarizes pretty nicely how to do that without
spring-drools:

http://article.gmane.org/gmane.comp.java.drools.user/1204

Based on the above suggestion of using facts I've come up with the
following rule:

rule Decline Request
dialect mvel
when
request : Request( status == ( RequestStatus.validated ) )
Condition( request == request, failed == true )
then
request.setStatus( requestStatus.declined );
update( request );
end

Then I insert into the session Java classes that extend my Condition
abstract.  Each Condition contains the request, and should any Condition
return true from its getFailed method, then the request is declined.

Seem reasonable?  



On Thu, May 29, 2008 at 8:32 AM, Lake Pancake [EMAIL PROTECTED] wrote:



I found this:

http://docs.codehaus.org/display/DROOLS/Drools+Spring+Tutorial

The latest version available for drools-spring appears to be 2.5-beta-1.  Is
it stable and does it work with Drools 4 or should I stay away?

Thanks





smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Nested Rules

2008-05-22 Thread Anstis, Michael (M.)
Erm, Rule Flow springs immediately to mind.
 
Or you can use semaphore Facts yourself - but you're re-inventing the (Rule
Flow) wheel.
 
rule rule 1
when
condition is true
then
insert(new SemaphoreFact());
end
 
rule rule 2
when
SemaphoreFact()
Some other conditions are true;
then
action
end
 
rule rule 3
when
Even more conditions
then
action
end
 


  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Vishal Deshmukh
Sent: 22 May 2008 10:31
To: rules-users@lists.jboss.org
Subject: [rules-users] Nested Rules


Hi
 
I  am using Drools 4.0.4 with Eclipse 3.2. I m much happy with the results.
But now my application needs nested loops..
Can i write nested rules like 
 
rule rule 1  // if condition of rule 1 is true then only execute
rule 2 other wise skip it
when
condition is true
then
execute rule2
 
rule rule 2 
when
condition is true
then
action
 
rule rule 3
when 
  condition is true
then
 action
 
Thanks and Rgards
 
Vishal





smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] newbie question on when condition syntax

2008-05-02 Thread Anstis, Michael (M.)
Hi Richard,
 
The when section matches fact (object) patterns, so your requirement could
be written as:-
 
when there is a Test Fact 'A' and another Test Fact 'B' where the 'x'
property of 'A' equals the 'y' property of fact 'B' plus 1 then.
 
This would become:-
 
rule Rule 1
when
Test( $y : y )
Test( x == ($y + 1) )
then
System.out.println(Rule 1 matches);
end
  
By default both patterns can match the same object, so test data:-
 
A : x = 1, y = 1
B : x = 2, y = 1
 
Will cause the rule to activate twice:-
 
A and B
B and B
 
With kind regards,
 
Mike



  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Richard Bremner
Sent: 02 May 2008 08:53
To: rules-users@lists.jboss.org
Subject: [rules-users] newbie question on when condition syntax


Hi, 

say I have a class with two fields, x and y: 

public class Test { 
int x = 1; 
int y = 2; 

getters/setters... 
} 


I would like a rule which fires when y = x + 1 

my initial thought would be something like: 

rule Rule 1 

when 
test : Test (y == x + 1) 
then 
System.out.println(Rule 1 matches.); 

end 


but this is invalid syntax and I can not find any examples of such a rule.
I'm doing my best but reading the manual etc. I'm struggling with the syntax
here and can't figure it out.

any help really appreciated! 



smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] newbie question on when condition syntax

2008-05-02 Thread Anstis, Michael (M.)
Hi Richard,
 
Glad I can be of help (this forum as a whole is actually very helpful).
 
Reading your email you understand me correctly (you even picked up on the
implicit AND between pattern matches).
 
With a bit of imagination complex problems can be solved with Drools; just
like programming you need to adjust your mindset sometimes and try a
different tact.
 
Personally, if your rules are not user-facing, I wouldn't worry about DSL -
even if they do don't worry for the time being!
 
Make sure to read the excellent manual, many people have put a lot of work
into this and it is invaluable.
 
Read about dialect to answer your question about rule language, to save me
copy and pasting.
 
Good luck,
 
Mike

  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Richard Bremner
Sent: 02 May 2008 11:38
To: Rules Users List
Subject: Re: [rules-users] newbie question on when condition syntax


Hi Mike,

Thanks very much, after a few minutes of staring I think I have understood
your very well put answer!

If I understand you right, what is happening is:

Test( $y : y )

This means, WHEN there is an instance of Test, assign the value of its y
property to $y

AND

WHEN there is an instance of Test where it's x property is equal to $y + 1

THEN fire.


I think I understand that. I am going to need to do this with some pretty
complicated formulae, containing up to 8 different variables. I have a fixed
data set and need to find certain patterns in them based on the formulae. I
have most of the program figured out, my only trouble is expressing my
formulae in the correct syntax. I will try to extend this principle you have
explained to me and hope it can cope with the extra complication... unless
there would be a better way to achieve this?

I am really sorry but I am totally new to drools - but am committed to using
it on a project so I guess I'm going to get to know it pretty well :-)

I read briefly that one can define a DSL, I might look at this eventually to
build an easier mechanism for expressing my formulae - if that can be
achieved using a DSL.

Can the whole rule be defined in Groovy/Java - if so I might be easier doing
that. I have so much work to do!


many thanks

Richard




2008/5/2 Anstis, Michael (M.) [EMAIL PROTECTED]:


Hi Richard,
 
The when section matches fact (object) patterns, so your requirement could
be written as:-
 
when there is a Test Fact 'A' and another Test Fact 'B' where the 'x'
property of 'A' equals the 'y' property of fact 'B' plus 1 then.
 
This would become:-
 
rule Rule 1
when
Test( $y : y )
Test( x == ($y + 1) )
then
System.out.println(Rule 1 matches);
end
  
By default both patterns can match the same object, so test data:-
 
A : x = 1, y = 1
B : x = 2, y = 1
 
Will cause the rule to activate twice:-
 
A and B
B and B
 
With kind regards,
 
Mike



  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Richard Bremner
Sent: 02 May 2008 08:53
To: rules-users@lists.jboss.org
Subject: [rules-users] newbie question on when condition syntax


Hi, 

say I have a class with two fields, x and y: 

public class Test { 
int x = 1; 
int y = 2; 

getters/setters... 
} 


I would like a rule which fires when y = x + 1 

my initial thought would be something like: 

rule Rule 1 

when 
test : Test (y == x + 1) 
then 
System.out.println(Rule 1 matches.); 

end 


but this is invalid syntax and I can not find any examples of such a rule.
I'm doing my best but reading the manual etc. I'm struggling with the syntax
here and can't figure it out.

any help really appreciated! 


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






smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] RuleBase relation with working memory

2008-04-28 Thread Anstis, Michael (M.)
It will occur whenever you (the developer) make it occur.

I guess Rulebase is the RETE network (without memory nodes) and the WM's are
in essence the RETE network memory nodes.

This is my interpretation of their roles.

Here's an example:-

Rulebase

RuleBase ruleBase = RuleBaseFactory.newRuleBase();
ruleBase.addPackage(pkg);

Working Memory
--
WorkingMemory wm1 = ruleBase.newStatefulSession();
WorkingMemory wm2 = ruleBase.newStatefulSession();
WorkingMemory wm3 = ruleBase.newStatefulSession();
WorkingMemory wm4 = ruleBase.newStatefulSession();
...

Rulebase 1:n.



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of anandhakrishnan
Sent: 28 April 2008 15:30
To: rules-users@lists.jboss.org
Subject: [rules-users] RuleBase relation with working memory


Please Explain, RuleBase 1:n relationship with Working memory, when will it
occur.
Please give an example

thanks In Advance
-- 
View this message in context:
http://www.nabble.com/RuleBase-relation-with-working-memory-tp16940200p16940
200.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


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] StateFullSession / StatelessSession

2008-04-28 Thread Anstis, Michael (M.)
Have you read the manual? 

I would really, really suggest you do.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of anandhakrishnan
Sent: 28 April 2008 15:37
To: rules-users@lists.jboss.org
Subject: [rules-users] StateFullSession / StatelessSession



What are statefulsession rules and statelesssion rules, 
What is the difference, 
Can I get any example


When shud i use statefullsession, and when shud i use statelesssession 
Please help

thanks in advance
-- 
View this message in context:
http://www.nabble.com/StateFullSession---StatelessSession-tp16940355p1694035
5.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


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Fundamental Question

2008-04-24 Thread Anstis, Michael (M.)
IMO, the analogy between Rule Engine and ORDBMS *could* be made with only
very simple business rules covering one object (presumably mapped to one
table). However you would still need to design mechanisms to support truth
maintenance and an activation schedule. Once the complexity of your business
rules exceeds even the very simple you will need to implement a whole host
of cross-table-triggers to support different objects in a rule (and who
knows how complex the business rules will become?). This doesn't even touch
upon more advanced features like collect and accumulate. You would be in
essence implement a rule engine in a ORDBMS using the ORDBMS triggers and
tables as the RETE network nodes. I would compare using a rule engine vs
ORDBMS to using say, RichFaces instead of HTML and the XMLHttpRequest
object: both can achieve the same result but one is more painful. Drools is
free, fast, feature rich and easy to use. Why reinvent the wheel?

With kind regards,

Mike

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Raffi
Khatchadourian
Sent: 23 April 2008 16:48
To: rules-users
Subject: [rules-users] Fundamental Question

What is the difference in using a rules engine like drools as opposed to
using either an object database or ORDBMS mapping to a database with
triggers?
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Re: Is this scenario suitable for using Drools?

2008-04-23 Thread Anstis, Michael (M.)
So, in my usual helpful manner I thought Drools would be a perfect match and
put together what I thought would be a simple example:-
 
package com.sample
 
global com.sample.DBUtils dbutils;

rule a1
when
$max : Integer() from accumulate( Integer( $v : intValue ) from
dbutils.getNumbers(), max($v) )
then
System.out.println($max);
end 
 
 
public class DBUtils {
 
public Integer[] getNumbers() {
 
Integer[] numbers = new Integer[10];
for (int i = 0; i  numbers.length; i++) {
numbers[i] = (int) (Math.random() * 100);
}
return numbers;
}
}
 
However this led to some errors:-
 
org.drools.RuntimeDroolsException: java.lang.ClassCastException:
[Ljava.lang.Integer; incompatible with java.lang.Integer
 at org.drools.rule.Accumulate.accumulate(Accumulate.java:131)
 at org.drools.reteoo.AccumulateNode.assertTuple(AccumulateNode.java:127)
 at
org.drools.reteoo.CompositeTupleSinkAdapter.createAndPropagateAssertTuple(Co
mpositeTupleSinkAdapter.java:73)
 at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.jav
a:116)
 at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObject
SinkAdapter.java:22)
 at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:153)
 at org.drools.reteoo.Rete.assertObject(Rete.java:177)
 at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
 at
org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction.execute(
ReteooWorkingMemory.java:179)
 at
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorking
Memory.java:1292)
 at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:89
1)
 at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:85
8)
 at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:65
9)
 at com.sample.DroolsTest.main(DroolsTest.java:36)
Caused by: java.lang.ClassCastException: [Ljava.lang.Integer; incompatible
with java.lang.Integer
 at org.drools.base.java.lang.Integer968047027$intValue.getIntValue(Unknown
Source)
 at
org.drools.base.ClassFieldExtractor.getIntValue(ClassFieldExtractor.java:197
)
 at org.drools.rule.Declaration.getIntValue(Declaration.java:230)
 at
com.sample.Rule_a1_0AccumulateExpression0Invoker.evaluate(Rule_a1_0Accumulat
eExpression0Invoker.java:16)
 at
org.drools.base.accumulators.JavaAccumulatorFunctionExecutor.accumulate(Java
AccumulatorFunctionExecutor.java:74)
 at org.drools.rule.Accumulate.accumulate(Accumulate.java:123)
 ... 13 more

Have I done something really stupid and is Drools a fit?
 
Cheers,
 
Mike



  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Cheng Wei Lee
Sent: 22 April 2008 17:27
To: rules-users@lists.jboss.org
Subject: [rules-users] Re: Is this scenario suitable for using Drools?


I've 2 algorithms to calculate the cost of a product. At any one time, there
is only 1 algorithm in use. Initially algorithm 1 will be the default.
Subsequently, the decision to use which algorithm will depend on customers
feedback. The algorithms are:

Algorithm 1:
Cost = MAX(P1, T1, P2, T2, P3, T3, ...)

Algorithm 2:
Cost = MIN(P1, P2, P3, ...) + MIN(T1, T2, T3, ...)

The values of P1, P2, ... are stored within a database. The number of Ps 
Ts are unknown but can be determined by querying the database, Would drools
be a good option to use to store the algorithms? If so, how could I be able
to retrieve the values of P1, P2, etc from the database from within drools?

Thanks!





smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] What-if analysis

2008-04-23 Thread Anstis, Michael (M.)
I believe this is an example of backwards-chaining.
 
(From the manual) Drools only supports forward-chaining at present although
...Drools will be adding support for Backward Chaining in its next major
release
 
Have you looked at Geoffrey De Smet's drools-solver excellent work? Will
this provide what you need?
 
Cheers,
 
Mike


  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ravi Shankar
(Singtel)
Sent: 22 April 2008 23:25
To: rules-users@lists.jboss.org
Subject: [rules-users] What-if analysis


Dear all,
 
Does Drools support what-if analysis?
 
For example, I have the data for the sales done by a salesman for the past
one year. There is a commission available to the salesman for the same he is
doing. I use the data to plot a graph showing the efficiency of all salesmen
in my company.
 
Assume that the comany wants a profit of , say, 10% more than what currently
is, I mean what if the comany wants more revenue, what should be the
values for sales. It is a trivial example, but just enough for understanding
my query - can we use Drools for this? Is it being used in financial
inductry where derivatives etc are used widely?
 
Thanks and regards,
Ravion



smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Re: Is this scenario suitable for using Drools?

2008-04-23 Thread Anstis, Michael (M.)
Thanks Steve,
 
This fixed the problem!
 
For Cheng Wei Lee's benefit this is the complete solution (I had to fix
another part):-
 
public class DBUtils {
 
public Collection getNumbers() {
 
Integer[] numbers = new Integer[10];
for (int i = 0; i  numbers.length; i++) {
numbers[i] = (int)Math.random() * 100;
}
return Arrays.asList(numbers);
}
}
 
rule a1
when
$max : Number() from accumulate( Number( $v : intValue ) from
dbutils.getNumbers(), max($v) )
then
System.out.println($max.intValue());
end 
 
With kind regards,
 
Mike



  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Steven Williams
Sent: 23 April 2008 09:07
To: Rules Users List
Subject: Re: [rules-users] Re: Is this scenario suitable for using Drools?


change DBUtils to return a Collection and it should work I think.


On Wed, Apr 23, 2008 at 5:50 PM, Anstis, Michael (M.) [EMAIL PROTECTED]
wrote:


So, in my usual helpful manner I thought Drools would be a perfect match and
put together what I thought would be a simple example:-
 
package com.sample
 
global com.sample.DBUtils dbutils;

rule a1
when
$max : Integer() from accumulate( Integer( $v : intValue ) from
dbutils.getNumbers(), max($v) )
then
System.out.println($max);
end 
 
 
public class DBUtils {
 
public Integer[] getNumbers() {
 
Integer[] numbers = new Integer[10];
for (int i = 0; i  numbers.length; i++) {
numbers[i] = (int) (Math.random() * 100);
}
return numbers;
}
}
 
However this led to some errors:-
 
org.drools.RuntimeDroolsException: java.lang.ClassCastException:
[Ljava.lang.Integer; incompatible with java.lang.Integer
 at org.drools.rule.Accumulate.accumulate(Accumulate.java:131)
 at org.drools.reteoo.AccumulateNode.assertTuple(AccumulateNode.java:127)
 at
org.drools.reteoo.CompositeTupleSinkAdapter.createAndPropagateAssertTuple(Co
mpositeTupleSinkAdapter.java:73)
 at
org.drools.reteoo.LeftInputAdapterNode.assertObject(LeftInputAdapterNode.jav
a:116)
 at
org.drools.reteoo.SingleObjectSinkAdapter.propagateAssertObject(SingleObject
SinkAdapter.java:22)
 at org.drools.reteoo.ObjectTypeNode.assertObject(ObjectTypeNode.java:153)
 at org.drools.reteoo.Rete.assertObject(Rete.java:177)
 at org.drools.reteoo.ReteooRuleBase.assertObject(ReteooRuleBase.java:192)
 at
org.drools.reteoo.ReteooWorkingMemory$WorkingMemoryReteAssertAction.execute(
ReteooWorkingMemory.java:179)
 at
org.drools.common.AbstractWorkingMemory.executeQueuedActions(AbstractWorking
Memory.java:1292)
 at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:89
1)
 at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:85
8)
 at
org.drools.common.AbstractWorkingMemory.insert(AbstractWorkingMemory.java:65
9)
 at com.sample.DroolsTest.main(DroolsTest.java:36)
Caused by: java.lang.ClassCastException: [Ljava.lang.Integer; incompatible
with java.lang.Integer
 at org.drools.base.java.lang.Integer968047027$intValue.getIntValue(Unknown
Source)
 at
org.drools.base.ClassFieldExtractor.getIntValue(ClassFieldExtractor.java:197
)
 at org.drools.rule.Declaration.getIntValue(Declaration.java:230)
 at
com.sample.Rule_a1_0AccumulateExpression0Invoker.evaluate(Rule_a1_0Accumulat
eExpression0Invoker.java:16)
 at
org.drools.base.accumulators.JavaAccumulatorFunctionExecutor.accumulate(Java
AccumulatorFunctionExecutor.java:74)
 at org.drools.rule.Accumulate.accumulate(Accumulate.java:123)
 ... 13 more

Have I done something really stupid and is Drools a fit?
 
Cheers,
 
Mike



  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Cheng Wei Lee
Sent: 22 April 2008 17:27
To: rules-users@lists.jboss.org
Subject: [rules-users] Re: Is this scenario suitable for using Drools?


I've 2 algorithms to calculate the cost of a product. At any one time, there
is only 1 algorithm in use. Initially algorithm 1 will be the default.
Subsequently, the decision to use which algorithm will depend on customers
feedback. The algorithms are:

Algorithm 1:
Cost = MAX(P1, T1, P2, T2, P3, T3, ...)

Algorithm 2:
Cost = MIN(P1, P2, P3, ...) + MIN(T1, T2, T3, ...)

The values of P1, P2, ... are stored within a database. The number of Ps 
Ts are unknown but can be determined by querying the database, Would drools
be a good option to use to store the algorithms? If so, how could I be able
to retrieve the values of P1, P2, etc from the database from within drools?

Thanks!




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






-- 
Steven Williams

Supervising Consultant

Object Consulting
Office: 8615 4500 Mob: 0439 898 668 Fax: 8615 4501
[EMAIL PROTECTED]
www.objectconsulting.com.au

consulting | development | training | support
our experience makes the difference 



smime.p7s
Description: S/MIME cryptographic signature

RE: [rules-users] To insert facts or use the find clause?

2008-04-18 Thread Anstis, Michael (M.)
Don't ask me to explain why but the Drools team always recommend flattening
hierarchies before inserting into WM ;-) 

I *think* this allows for individual facts' properties to be indexed in the
RETE network thus affording a performance increase.

I guess there's also implications to do with truth maintenance whereby
objects accessed using from should be time-constant.

My 2c's worth; I'm sure Edson, Mark, Michael et al will elaborate.

Cheers,

Mike

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Raffi
Khatchadourian
Sent: 18 April 2008 02:34
To: rules-users@lists.jboss.org
Subject: [rules-users] To insert facts or use the find clause?

I would like to use Drools to reason about a graph structure using
queries. The graph consists of a collection of nodes, which in turn each
have a collection of edges to nodes. Currently, I have a single fact in
the Drools working memory, the graph. My queries then use the from
clause to obtain information about the nodes and edges within the graph.
I was wondering if it would be better to instead traverse the entire
structure adding each node and edge as facts into the working memory.
Any ideas? Thanks!
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Why double rule activation?

2008-04-17 Thread Anstis, Michael (M.)
I have tried to re-produce using System.out.println instead of IELogger
and I don't get any double activations :-(

Could the problem be elsewhere (e.g. IELogger?).


package com.sample

import com.sample.MyVariable;

rule Light is off
when
$brightness : MyVariable(uniqueName == [EMAIL PROTECTED],
currentValue == 0.0)
then
System.out.println(DimmerSwitch1 has no brightness value);
end

rule Light Below 50%
when
$brightness : MyVariable(uniqueName == [EMAIL PROTECTED],
currentValue  0.50, currentValue  0.0)
then
System.out.println(DimmerSwitch1 is below 50% brightness);
end

rule Light 50% or Above
when
$brightness : MyVariable(uniqueName == [EMAIL PROTECTED],
currentValue = 0.5)
then
System.out.println(DimmerSwitch1 is at or above 50%
brightness);
End

public static final void main(String[] args) {

WorkingMemoryFileLogger logger = null;

try {

RuleBase ruleBase = readRule();
WorkingMemory workingMemory = ruleBase.newStatefulSession();
logger = new WorkingMemoryFileLogger(workingMemory);
logger.setFileName(events.log);

MyVariable v1 = new MyVariable([EMAIL PROTECTED], 0.0d);
MyVariable v2 = new MyVariable([EMAIL PROTECTED], 0.4d);
MyVariable v3 = new MyVariable([EMAIL PROTECTED], 0.6d);
workingMemory.insert(v1);
workingMemory.insert(v2);
workingMemory.insert(v3);
workingMemory.fireAllRules();

} catch (Throwable t) {
t.printStackTrace();
} finally {
if (logger != null) {
logger.writeToDisk();
}
}
}

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Bagwell, Allen F
Sent: 16 April 2008 20:50
To: Rules Users List
Subject: [rules-users] Why double rule activation?

I've encountered rule engine behavior I'm knocking my head against the wall
trying to figure out.  I'm a Drools newbie, so please forgive if this I am
doing something bone-headed wrong.

Basically I'm inserting an object into my working memory.  The object itself
has a default setting of 0.0 for a brightness value, and this setting
matches the LHS condition for my first rule.  The problem is the rule
activates twice for a single object insertion as described in the audit log.
It consequently executes twice when I fire all rules. Then whenever I change
the value in question, any single update to the same object also causes
double rule activation and execution.

The rules I've written are not complex. Here's my drl file:

package dimmerie;

#list any import classes here.

import knowledgebase.*;
import NipcLogger;

#declare any global variables here

global NipcLogger IELogger;

rule Light is off
when
$brightness : MyVariable(uniqueName == [EMAIL PROTECTED],
currentValue == 0.0)
then
IELogger.info(DimmerSwitch1 has no brightness value);
end

rule Light Below 50%
when
$brightness : MyVariable(uniqueName == [EMAIL PROTECTED],
currentValue  0.50, currentValue  0.0)
then
IELogger.info(DimmerSwitch1 is below 50% brightness);
end

rule Light 50% or Above
when
$brightness : MyVariable(uniqueName == [EMAIL PROTECTED],
currentValue = 0.5)
then
IELogger.info(DimmerSwitch1 is at or above 50%
brightness);
end

I'm hoping I've described enough without having to post additional code.
Can anyone suggest why this is happening?

Thanks,
Allen


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


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Why double rule activation?

2008-04-17 Thread Anstis, Michael (M.)
My test was ran with 4.0.5, but Eclipse plug-in 4.0.3 - part of my lazy
upgrade process ;-) 

I will re-run with the latest Eclipse plug-in and see if the Audit View is
correct (in 4.0.3 it shows 3 inserts, 3 activations and 3 executions).

Can you run my test and confirm you get what's expected?

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Bagwell, Allen F
Sent: 17 April 2008 16:00
To: Rules Users List
Subject: RE: [rules-users] Why double rule activation?


I appreciate the effort.

The problem isn't in the logger. It's just standing in for System.out so
that I can reference a file for output (it's an extension of log4j).

The actual Drools audit view is reporting double activation and execution on
insert and update of the objects.

I'm using a loop to insert my objects into Drools, and I thought at first
perhaps I was inserting them more than once. But I don't see that happening.
In any event wouldn't the audit log tell me if I was doing that?

-A


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Anstis, Michael
(M.)
Sent: Thursday, April 17, 2008 2:11 AM
To: Rules Users List
Subject: RE: [rules-users] Why double rule activation?

I have tried to re-produce using System.out.println instead of IELogger
and I don't get any double activations :-(

Could the problem be elsewhere (e.g. IELogger?).


package com.sample

import com.sample.MyVariable;

rule Light is off
when
$brightness : MyVariable(uniqueName == [EMAIL PROTECTED],
currentValue == 0.0)
then
System.out.println(DimmerSwitch1 has no brightness value);
end

rule Light Below 50%
when
$brightness : MyVariable(uniqueName == [EMAIL PROTECTED],
currentValue  0.50, currentValue  0.0)
then
System.out.println(DimmerSwitch1 is below 50% brightness);
end

rule Light 50% or Above
when
$brightness : MyVariable(uniqueName == [EMAIL PROTECTED],
currentValue = 0.5)
then
System.out.println(DimmerSwitch1 is at or above 50%
brightness); End

public static final void main(String[] args) {

WorkingMemoryFileLogger logger = null;

try {

RuleBase ruleBase = readRule();
WorkingMemory workingMemory = ruleBase.newStatefulSession();
logger = new WorkingMemoryFileLogger(workingMemory);
logger.setFileName(events.log);

MyVariable v1 = new MyVariable([EMAIL PROTECTED], 0.0d);
MyVariable v2 = new MyVariable([EMAIL PROTECTED], 0.4d);
MyVariable v3 = new MyVariable([EMAIL PROTECTED], 0.6d);
workingMemory.insert(v1);
workingMemory.insert(v2);
workingMemory.insert(v3);
workingMemory.fireAllRules();

} catch (Throwable t) {
t.printStackTrace();
} finally {
if (logger != null) {
logger.writeToDisk();
}
}
}

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Bagwell, Allen F
Sent: 16 April 2008 20:50
To: Rules Users List
Subject: [rules-users] Why double rule activation?

I've encountered rule engine behavior I'm knocking my head against the wall
trying to figure out.  I'm a Drools newbie, so please forgive if this I am
doing something bone-headed wrong.

Basically I'm inserting an object into my working memory.  The object itself
has a default setting of 0.0 for a brightness value, and this setting
matches the LHS condition for my first rule.  The problem is the rule
activates twice for a single object insertion as described in the audit log.
It consequently executes twice when I fire all rules. Then whenever I change
the value in question, any single update to the same object also causes
double rule activation and execution.

The rules I've written are not complex. Here's my drl file:

package dimmerie;

#list any import classes here.

import knowledgebase.*;
import NipcLogger;

#declare any global variables here

global NipcLogger IELogger;

rule Light is off
when
$brightness : MyVariable(uniqueName == [EMAIL PROTECTED],
currentValue == 0.0)
then
IELogger.info(DimmerSwitch1 has no brightness value); end

rule Light Below 50%
when
$brightness : MyVariable(uniqueName == [EMAIL PROTECTED],
currentValue  0.50, currentValue  0.0)
then
IELogger.info(DimmerSwitch1 is below 50% brightness); end

rule Light 50% or Above
when
$brightness : MyVariable(uniqueName == [EMAIL PROTECTED],
currentValue = 0.5)
then
IELogger.info(DimmerSwitch1 is at or above 50%
brightness); end

I'm hoping I've described enough without having to post additional code.
Can anyone suggest why this is happening?

Thanks,
Allen


___
rules

RE: [rules-users] Synch Business Object / Working Memory

2008-04-11 Thread Anstis, Michael (M.)
I guess the example is a simplification as c (in RHS) has not been bound
to a fact.
 
Anyway, that aside, do you call update to ensure WM knows of changes to
facts otherwise properties need to be time-constant which in your example
they are not.


  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jonathan
Guéhenneux
Sent: 11 April 2008 09:34
To: Rules Users List
Subject: [rules-users] Synch Business Object / Working Memory


Hi,

I have two rules :

rule rule 1 - 1

salience 90
ruleflow-group rfg1
when
a : A(
eComputed == false,
c  15,
d = 75)
then
c.setE(0);
end



rule rule 1 - 2

salience 10
ruleflow-group rfg1
when
a : A(
eComputed == false,
c = 15,
d = 75)
then
c.setE(1);
end



and part of the corresponding business code :

public class A {

...

public String getEComputed(){
   if(eComputed)
  return true;
   else
  return false;
}

...

public void setE(int e){
this.e = e;
eComputed = true;
}

...

}



so, I expected that if the first rule is activated, the second won't be. But
according to my tests, the two rule can be fired on the same object A.
While debugging, I noticed the getEComputed method was only called once. I
suppose that I should write this :


rule rule 1 - 1

salience 90
ruleflow-group rfg1
when
a : A(
eComputed == false,
c  15,
d = 75)
then
c.setE(0);
c.setEComputed(true);
end



rule rule 1 - 2

salience 10
ruleflow-group rfg1
when
a : A(
eComputed == false,
c = 15,
d = 75)
then
c.setE(1);
c.setEComputed(true);
end

But I would prefer another solution. Thanks for help.


  _  

Plus de 15 millions de français utilisent Windows Live Messenger !
Téléchargez Messenger,  http://www.windowslive.fr/messenger/ c'est gratuit
! 



smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Synch Business Object / Working Memory

2008-04-11 Thread Anstis, Michael (M.)
In essence, yes. Have a look at update in the manual (and a read on Shadow
Facts will probably be useful too).


  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jonathan
Guéhenneux
Sent: 11 April 2008 10:24
To: Rules Users List
Subject: RE: [rules-users] Synch Business Object / Working Memory


yes, i made a mistake. its a.setE(...) and not c.setE(...).

I don't call update. If I dont call update, properties of an object are just
read one time for all rules?




  _  

Subject: RE: [rules-users] Synch Business Object / Working Memory
Date: Fri, 11 Apr 2008 09:47:43 +0100
From: [EMAIL PROTECTED]
To: rules-users@lists.jboss.org


I guess the example is a simplification as c (in RHS) has not been bound
to a fact.
 
Anyway, that aside, do you call update to ensure WM knows of changes to
facts otherwise properties need to be time-constant which in your example
they are not.


  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jonathan
Guéhenneux
Sent: 11 April 2008 09:34
To: Rules Users List
Subject: [rules-users] Synch Business Object / Working Memory


Hi,

I have two rules :

rule rule 1 - 1

salience 90
ruleflow-group rfg1
when
a : A(
eComputed == false,
c  15,
d = 75)
then
c.setE(0);
end



rule rule 1 - 2

salience 10
ruleflow-group rfg1
when
a : A(
eComputed == false,
c = 15,
d = 75)
then
c.setE(1);
end



and part of the corresponding business code :

public class A {

...

public String getEComputed(){
   if(eComputed)
  return true;
   else
  return false;
}

...

public void setE(int e){
this.e = e;
eComputed = true;
}

...

}



so, I expected that if the first rule is activated, the second won't be. But
according to my tests, the two rule can be fired on the same object A.
While debugging, I noticed the getEComputed method was only called once. I
suppose that I should write this :


rule rule 1 - 1

salience 90
ruleflow-group rfg1
when
a : A(
eComputed == false,
c  15,
d = 75)
then
c.setE(0);
c.setEComputed(true);
end



rule rule 1 - 2

salience 10
ruleflow-group rfg1
when
a : A(
eComputed == false,
c = 15,
d = 75)
then
c.setE(1);
c.setEComputed(true);
end

But I would prefer another solution. Thanks for help.


  _  

Plus de 15 millions de français utilisent Windows Live Messenger !
Téléchargez  http://www.windowslive.fr/messenger/ Messenger, c'est gratuit
! 


  _  

Plus de 15 millions de français utilisent Windows Live Messenger !
Téléchargez Messenger,  http://www.windowslive.fr/messenger/ c'est gratuit
! 



smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Synch Business Object / Working Memory

2008-04-11 Thread Anstis, Michael (M.)
I was thinking something more like this:-
 
package com.sample

import com.sample.Test
 
rule rule 1 - 1
salience 90
when
a : Test(
 computed == false,
c  15,
d = 75)
then
 System.out.println(setting e to 0);
a.setE(0);
update(a);
end

 

rule rule 1 - 2
salience 10
when
a : Test(
computed == false,
c  15,
d = 75)
then
 System.out.println(setting e to 1);
a.setE(1);
end


Note rule rule 1 - 2 deliberately uses the same patterns as rule rule 1 -
1.

 
package com.sample;
 
public class Test {

private boolean computed =false;
private int c=0;
private int d=80;
private int e;
 
public String getComputed(){
   if(computed)
  return true;
   else
  return false;
}
 
public int getC() {
return c;
}
 
public int getD() {
return d;
}
 
public void setE(int e){
this.e = e;
computed = true;
}
 
}

Rule rule 1 - 1 is the only rule to run (and runs once); the second
activatino being cancelled due to the update to computed. Here's the audit
view:-
 
object-stream
  list
org.drools.audit.event.ActivationLogEvent
  activationIdrule 1 - 1 [1]/activationId
  rulerule 1 - 1/rule
  declarations[EMAIL PROTECTED](1)/declarations
  type4/type
/org.drools.audit.event.ActivationLogEvent
org.drools.audit.event.ActivationLogEvent
  activationIdrule 1 - 2 [1]/activationId
  rulerule 1 - 2/rule
  declarations[EMAIL PROTECTED](1)/declarations
  type4/type
/org.drools.audit.event.ActivationLogEvent
org.drools.audit.event.ObjectLogEvent
  factId1/factId
  objectToString[EMAIL PROTECTED]/objectToString
  type1/type
/org.drools.audit.event.ObjectLogEvent
org.drools.audit.event.ActivationLogEvent
  activationIdrule 1 - 1 [1]/activationId
  rulerule 1 - 1/rule
  declarations[EMAIL PROTECTED](1)/declarations
  type6/type
/org.drools.audit.event.ActivationLogEvent
org.drools.audit.event.ActivationLogEvent
  activationIdrule 1 - 2 [1]/activationId
  rulerule 1 - 2/rule
  declarations[EMAIL PROTECTED](1)/declarations
  type5/type
/org.drools.audit.event.ActivationLogEvent
org.drools.audit.event.ObjectLogEvent
  factId1/factId
  objectToString[EMAIL PROTECTED]/objectToString
  type2/type
/org.drools.audit.event.ObjectLogEvent
org.drools.audit.event.ActivationLogEvent
  activationIdrule 1 - 1 [1]/activationId
  rulerule 1 - 1/rule
  declarations[EMAIL PROTECTED](1)/declarations
  type7/type
/org.drools.audit.event.ActivationLogEvent
  /list
/object-stream 
 


  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jonathan
Guéhenneux
Sent: 11 April 2008 11:33
To: Rules Users List
Subject: RE: [rules-users] Synch Business Object / Working Memory


Ok, I think I understood well. I modified my business code, now I call if

(wm != null)
wm.update(wm.getFactHandle(this), this);

each time a properties is modified.

But it is worse. Rules that sould be activated only once actually loop, even
if I add the no-loop clause.

I understand why they loop, assuming update = (rectact + insert), but I dont
get a solution to my problem. I just want to notify an object changement in
order to read again the properties, but I dont want to restart the ruleflow.

Sorry, but I find hard to say it in english because even in french, it's not
very clear ;)


  _  

Subject: RE: [rules-users] Synch Business Object / Working Memory
Date: Fri, 11 Apr 2008 10:39:41 +0100
From: [EMAIL PROTECTED]
To: rules-users@lists.jboss.org


In essence, yes. Have a look at update in the manual (and a read on Shadow
Facts will probably be useful too).


  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jonathan
Guéhenneux
Sent: 11 April 2008 10:24
To: Rules Users List
Subject: RE: [rules-users] Synch Business Object / Working Memory


yes, i made a mistake. its a.setE(...) and not c.setE(...).

I don't call update. If I dont call update, properties of an object are just
read one time for all rules?




  _  

Subject: RE: [rules-users] Synch Business Object / Working Memory
Date: Fri, 11 Apr 2008 09:47:43 +0100
From: [EMAIL PROTECTED]
To: rules-users@lists.jboss.org


I guess the example is a simplification as c (in RHS) has not been bound
to a fact.
 
Anyway, that aside, do you call update to ensure WM knows of changes to
facts otherwise properties need to be time-constant which in your example
they are not.


  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jonathan
Guéhenneux
Sent: 11 April 2008 09:34
To: Rules Users List
Subject: [rules-users] Synch Business Object / Working Memory


Hi,

I have two rules :

rule rule 1 - 1

salience 90
ruleflow-group rfg1
when
  

RE: [rules-users] modify()

2008-04-11 Thread Anstis, Michael (M.)
I've got 4.0.5 and it mentions insert, update and retract throughout the
manual.

There was an API change some versions ago, but I forget when exactly.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of X10
Sent: 11 April 2008 12:34
To: Rules Users List
Subject: [rules-users] modify()

Hi,
I take it the modify() that's in the manual got replaced by
update()?

Christine

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


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Synch Business Object / Working Memory

2008-04-11 Thread Anstis, Michael (M.)
Do you need ruleflow? Perhaps this is too simple and I misunderstood.
 
package com.sample;
 
public class Test {
 
private Integer a;
private Integer b;
private Integer c;
 
public Integer getA() {
return a;
}
 
public Integer getB() {
return b;
}
 
public Integer getC() {
return c;
}
 
public void setA(Integer a) {
this.a = a;
}
 
public void setB(Integer b) {
this.b = b;
}
 
public void setC(Integer c) {
this.c = c;
}
 
}
 
package com.sample
 
import com.sample.Test
 
rule rule 1
salience 90
when
a : Test( a != null, b == null )
then
 System.out.println(setting b to 10);
a.setB(10);
update(a);
end
 
rule rule 2
salience 80
when
a : Test( b : b != null, c == null )
then
 System.out.println(setting c to b x 5);
a.setC(b * 5);
update(a);
end
 
rule rule 3
salience 70
when
a : Test( c != null )
then
 System.out.println(c =  + a.getC());
end

 


  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jonathan
Guéhenneux
Sent: 11 April 2008 13:23
To: Rules Users List
Subject: RE: [rules-users] Synch Business Object / Working Memory


Indeed, it works but I will have to use such booleans for a lot of rules.

Cause my rule flow is schematically :

compute A
compute B(A)
compute C(B)
...

Perhaps I may create several ruleflows, one per independant computing?



  _  

Subject: RE: [rules-users] Synch Business Object / Working Memory
Date: Fri, 11 Apr 2008 12:11:32 +0100
From: [EMAIL PROTECTED]
To: rules-users@lists.jboss.org


I was thinking something more like this:-
 
package com.sample

import com.sample.Test
 
rule rule 1 - 1
salience 90
when
a : Test(
 computed == false,
c  15,
d = 75)
then
 System.out.println(setting e to 0);
a.setE(0);
update(a);
end

 

rule rule 1 - 2
salience 10
when
a : Test(
computed == false,
c  15,
d = 75)
then
 System.out.println(setting e to 1);
a.setE(1);
end


Note rule rule 1 - 2 deliberately uses the same patterns as rule rule 1 -
1.

 
package com.sample;
 
public class Test {

private boolean computed =false;
private int c=0;
private int d=80;
private int e;
 
public String getComputed(){
   if(computed)
  return true;
   else
  return false;
}
 
public int getC() {
return c;
}
 
public int getD() {
return d;
}
 
public void setE(int e){
this.e = e;
computed = true;
}
 
}

Rule rule 1 - 1 is the only rule to run (and runs once); the second
activatino being cancelled due to the update to computed. Here's the audit
view:-
 
object-stream
  list
org.drools.audit.event.ActivationLogEvent
  activationIdrule 1 - 1 [1]/activationId
  rulerule 1 - 1/rule
  declarations[EMAIL PROTECTED](1)/declarations
  type4/type
/org.drools.audit.event.ActivationLogEvent
org.drools.audit.event.ActivationLogEvent
  activationIdrule 1 - 2 [1]/activationId
  rulerule 1 - 2/rule
  declarations[EMAIL PROTECTED](1)/declarations
  type4/type
/org.drools.audit.event.ActivationLogEvent
org.drools.audit.event.ObjectLogEvent
  factId1/factId
  objectToString[EMAIL PROTECTED]/objectToString
  type1/type
/org.drools.audit.event.ObjectLogEvent
org.drools.audit.event.ActivationLogEvent
  activationIdrule 1 - 1 [1]/activationId
  rulerule 1 - 1/rule
  declarations[EMAIL PROTECTED](1)/declarations
  type6/type
/org.drools.audit.event.ActivationLogEvent
org.drools.audit.event.ActivationLogEvent
  activationIdrule 1 - 2 [1]/activationId
  rulerule 1 - 2/rule
  declarations[EMAIL PROTECTED](1)/declarations
  type5/type
/org.drools.audit.event.ActivationLogEvent
org.drools.audit.event.ObjectLogEvent
  factId1/factId
  objectToString[EMAIL PROTECTED]/objectToString
  type2/type
/org.drools.audit.event.ObjectLogEvent
org.drools.audit.event.ActivationLogEvent
  activationIdrule 1 - 1 [1]/activationId
  rulerule 1 - 1/rule
  declarations[EMAIL PROTECTED](1)/declarations
  type7/type
/org.drools.audit.event.ActivationLogEvent
  /list
/object-stream 
 


  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jonathan
Guéhenneux
Sent: 11 April 2008 11:33
To: Rules Users List
Subject: RE: [rules-users] Synch Business Object / Working Memory


Ok, I think I understood well. I modified my business code, now I call if

(wm != null)
wm.update(wm.getFactHandle(this), this);

each time a properties is modified.

But it is worse. Rules that sould be activated only once actually loop, even
if I add the no-loop clause.

I understand why they loop, 

RE: [rules-users] Synch Business Object / Working Memory

2008-04-11 Thread Anstis, Michael (M.)
I am confident Drools supports what you are looking for; did you try
update() - or modify() - in the then part of the rule (and not in Java as
you code snippet)?
 
Can you explain more the need for the computed flag on the fact? Is the
value of a property set sometimes whilst calculated at other times?
 
Stick with both Drools and the group - we'll get you to where you want to
be.


  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jonathan
Guéhenneux
Sent: 11 April 2008 15:41
To: Rules Users List
Subject: RE: [rules-users] Synch Business Object / Working Memory


First, thank you for yours answers which are very clear. Your solution will
probably work. I'm just desapointed that there is no way to synchronized the
shadow with the object. That would be great for my work.



  _  

Subject: RE: [rules-users] Synch Business Object / Working Memory
Date: Fri, 11 Apr 2008 14:57:52 +0100
From: [EMAIL PROTECTED]
To: rules-users@lists.jboss.org


Do you need ruleflow? Perhaps this is too simple and I misunderstood.
 
package com.sample;
 
public class Test {
 
private Integer a;
private Integer b;
private Integer c;
 
public Integer getA() {
return a;
}
 
public Integer getB() {
return b;
}
 
public Integer getC() {
return c;
}
 
public void setA(Integer a) {
this.a = a;
}
 
public void setB(Integer b) {
this.b = b;
}
 
public void setC(Integer c) {
this.c = c;
}
 
}
 
package com.sample
 
import com.sample.Test
 
rule rule 1
salience 90
when
a : Test( a != null, b == null )
then
 System.out.println(setting b to 10);
a.setB(10);
update(a);
end
 
rule rule 2
salience 80
when
a : Test( b : b != null, c == null )
then
 System.out.println(setting c to b x 5);
a.setC(b * 5);
update(a);
end
 
rule rule 3
salience 70
when
a : Test( c != null )
then
 System.out.println(c =  + a.getC());
end

 


  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jonathan
Guéhenneux
Sent: 11 April 2008 13:23
To: Rules Users List
Subject: RE: [rules-users] Synch Business Object / Working Memory


Indeed, it works but I will have to use such booleans for a lot of rules.

Cause my rule flow is schematically :

compute A
compute B(A)
compute C(B)
...

Perhaps I may create several ruleflows, one per independant computing?



  _  

Subject: RE: [rules-users] Synch Business Object / Working Memory
Date: Fri, 11 Apr 2008 12:11:32 +0100
From: [EMAIL PROTECTED]
To: rules-users@lists.jboss.org


I was thinking something more like this:-
 
package com.sample

import com.sample.Test
 
rule rule 1 - 1
salience 90
when
a : Test(
 computed == false,
c  15,
d = 75)
then
 System.out.println(setting e to 0);
a.setE(0);
update(a);
end

 

rule rule 1 - 2
salience 10
when
a : Test(
computed == false,
c  15,
d = 75)
then
 System.out.println(setting e to 1);
a.setE(1);
end


Note rule rule 1 - 2 deliberately uses the same patterns as rule rule 1 -
1.

 
package com.sample;
 
public class Test {

private boolean computed =false;
private int c=0;
private int d=80;
private int e;
 
public String getComputed(){
   if(computed)
  return true;
   else
  return false;
}
 
public int getC() {
return c;
}
 
public int getD() {
return d;
}
 
public void setE(int e){
this.e = e;
computed = true;
}
 
}

Rule rule 1 - 1 is the only rule to run (and runs once); the second
activatino being cancelled due to the update to computed. Here's the audit
view:-
 
object-stream
  list
org.drools.audit.event.ActivationLogEvent
  activationIdrule 1 - 1 [1]/activationId
  rulerule 1 - 1/rule
  declarations[EMAIL PROTECTED](1)/declarations
  type4/type
/org.drools.audit.event.ActivationLogEvent
org.drools.audit.event.ActivationLogEvent
  activationIdrule 1 - 2 [1]/activationId
  rulerule 1 - 2/rule
  declarations[EMAIL PROTECTED](1)/declarations
  type4/type
/org.drools.audit.event.ActivationLogEvent
org.drools.audit.event.ObjectLogEvent
  factId1/factId
  objectToString[EMAIL PROTECTED]/objectToString
  type1/type
/org.drools.audit.event.ObjectLogEvent
org.drools.audit.event.ActivationLogEvent
  activationIdrule 1 - 1 [1]/activationId
  rulerule 1 - 1/rule
  declarations[EMAIL PROTECTED](1)/declarations
  type6/type
/org.drools.audit.event.ActivationLogEvent
org.drools.audit.event.ActivationLogEvent
  activationIdrule 1 - 2 [1]/activationId
  rulerule 1 - 2/rule
  declarations[EMAIL PROTECTED](1)/declarations
  type5/type

RE: [rules-users] Access to currently executing rule in consequence?

2008-04-11 Thread Anstis, Michael (M.)
There is an implicit KnowledgeHelper object called drools available in the
RHS.
 
drools.getRule().getName() will provide what you need.



  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
[EMAIL PROTECTED]
Sent: 11 April 2008 16:04
To: rules-users@lists.jboss.org
Subject: [rules-users] Access to currently executing rule in consequence?



Is there an easy way to access information about the currently executing
rule (e.g. Name, salience, group) within a rule consequence?  E.g.
 
rule Sample Rule
salience = 100
when
$v : Fact(name == Test)
then
System.out.println(The currently executing rule is  +
???.getName());
end
 
I could copy the name into the print but of course then I have it in two
places I need to keep in sync. I know I can get the full log but that's not
what I'm interested in. 
 
-Russ



smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] modify()

2008-04-11 Thread Anstis, Michael (M.)
I *seem* to be able to still use update in the RHS with 4.0.5.

Perhaps I've got my binaries mixed up. If I get the chance I'll do a clean
install.

Thanks for the clarification - I don't want to end up confusing matters with
my help ;-)

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mark Proctor
Sent: 11 April 2008 12:51
To: [EMAIL PROTECTED]; Rules Users List
Subject: Re: [rules-users] modify()

X10 wrote:
 Hi,
 I take it the modify() that's in the manual got replaced by
 update()?
   
The meanings have changed, but both exist to some degree. modify() is a 
specail keyword used in the java/mvel consequence. Inside a consequence 
it is the preferred way modify facts, so that the engine is notified. 
Outside of consequence, in normal Java, one an object has been changed 
you need to notify the engine, this is done via the update() method, 
which tells the engine the fact has been updated.

The main difference is that update( handle ) only takes a single 
parameter where as modify( object ) { field1 = value1, field2 = value2 } 
takes key/value pair comma separated list of setters. the language used 
to apply those setters is dependant on whether you are using the mvel or 
java dialect.

Mark
 Christine

 ___
 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


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Ruleflows

2008-04-10 Thread Anstis, Michael (M.)
IMO, the first.
 
Another answer; I believe RuleFlow controls the activation sequence so IMO
yes. Kris, care to correct me?


  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jonathan
Guéhenneux
Sent: 10 April 2008 11:36
To: Rules Users List
Subject: [rules-users] Ruleflows


Hi,

I have to compute the gravity of a debt according to a set of rules
organized in a ruleflow. I will have to process about ten thousands debts
every minute.
There is no dependency between the debts. All the rules are applied to one
debt.

What is the best strategy?

- Insert all the debts, and start the ruleflow process
 or
- (Insert one debt, start the ruleflow process) for each debt

Another question:

If a rule r1 in the ruleflow group rfg1 is fired on a debt d1, can a
second rule r2 in the same ruleflow group be fired on the same debt d1?


  _  

Discutez gratuitement avec vos amis en vidéo ! Téléchargez Messenger,
http://www.windowslive.fr/messenger/ c'est gratuit ! 



smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Short circuiting evaluations on LHS

2008-04-07 Thread Anstis, Michael (M.)
All facts are matched against all patterns upon insertion into working
memory. The (Drools) techniques you describe affect the execution of
activations (i.e. RHS) not pattern matching.
 
I think (but it's a vague recollection) however that the sequence of
patterns has an affect (so you want most restrictive first and least
restrictive last). So my thought would be to try to add a pattern to the
start of each rule that checks whether there are more than one survivor
before the other (more expensive) patterns. Just a thought from what I
recall - I haven't tried it:-
 
rule expensive
when
ArrayList( size  1 ) from collect( SuperClassOfAllFacts( ) )
someExpensivePattern( )
then
something();
end
 
 


  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Newman, Jason
Sent: 03 April 2008 20:07
To: rules-users@lists.jboss.org
Subject: [rules-users] Short circuiting evaluations on LHS



I am currently using Drools 4.0 to determine the best choice out of a data
set based on business rules. The rules eliminate (retract) facts until a
single fact survives, and is used for additional processing. I have found
Drools to be a great solution for this problem, and plan to role it out for
additional survivor rules. My problem is in optimization - this is
essentially a batch processing application, and speed is very important (of
course it is  - show me the case where it isn't, right?).

Some of the later evaluations in the rules are fairly expensive (invoking
complex queries from the database), and generally apply to only a small set
of the use cases. For most use cases, the survivor will have been determined
after the first or second rule, so I only want to perform the expensive
evaluations if necessary. I have not found a way to avoid or schedule the
LHS evaluations from firing when inserting the fact into the working memory.
I have played around with agenda groups and rule flows, but haven't had any
luck. The only way I can think of at this point is to break my rules into
separate rule bases, and manually copy survivors from one working memory
to the next, performing my own short circuiting outside of the rules being
fired. 

Is there any other technique that I have missed? From a maintenance
standpoint, I would prefer to be able to use one rule base/rule flow to
manage the rules (there are only about 10 total rules, so the base is not
very large - and I would have to break it into 4 or 5 different rule bases,
which seems like it will be a pain across the 5 different areas I need to
implement the rules.)

Thanks, 

-Jason 


The information transmitted (including attachments) is

covered by the Electronic Communications Privacy Act,

18 U.S.C. 2510-2521, is intended only for the person(s) or

entity/entities to which it is addressed and may contain

confidential and/or privileged material. Any review,

retransmission, dissemination or other use of, or taking

of any action in reliance upon, this information by persons

or entities other than the intended recipient(s) is prohibited.

If you received this in error, please contact the sender and

delete the material from any computer.





smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Rules File Design Consideration

2008-04-07 Thread Anstis, Michael (M.)
If you cannot combine the rules into new rules I would suggest looking at
rule flow.


  _  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Chong Minsk Goh
Sent: 04 April 2008 10:57
To: rules-users@lists.jboss.org
Subject: [rules-users] Rules File Design Consideration


Hi,
 
Any help to the problem below is much appreciated : )
 
Here is the problem:
 
I have a set of rules. Intially these rules are evaluated individually.
However, now there is a need to fire these rules in groups which is similar
to a logic gate AND or OR. And, the results of this groups of rules are
collected and returned to the user/
 
For example:
 
There are 4 rules:
Rule 1
Rule 2
Rule 3
Rule 4
 
Now, need to evaluate (Rule 1 AND Rule 2 AND Rule 3) OR Rule 4 
And I need to know what are the results of Rule 1 to Rule 4 individually.
 
 
What is the best way to implement a AND or OR using Drools?
 
 
Best regards
Chong Minsk



smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Can only reason over sub-objects if you use the FromConditional Element

2008-03-17 Thread Anstis, Michael (M.)
IMO, you have not informed the engine\RETE network that details have changed
in your first example.

This would probably be a better example:-

rule 30 is the new 20
when
person : Person( $d : details.age == 30 )
then
person.getDetails().setAge(20);
System.out.println( Now 20 :  + person );
update( person );
update( $d );
end
 
The From works because it gets external data rather than using that already
in the engine\RETE network.

IMO, I think the rules are working correctly; it's just a misunderstanding
of how the engine\RETE network function.

I hope this helps.

Thanks,

Mike

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Aaron Dixon
Sent: 14 March 2008 20:51
To: Rules Users List
Subject: [rules-users] Can only reason over sub-objects if you use the
FromConditional Element

It appears that you MUST use the From Condition Element to reason over
sub-objects.

I have a Person class. Person::getDetails() returns a Details
instance, which has the name and age of the person. (This is a
contrived example to demonstrate the issue.)

My rules are:

rule 30 is the new 20
when
person : Person( details.age == 30 )
then
person.getDetails().setAge(20);
System.out.println( Now 20 :  + person );
update( person );
end

rule Older than 20 - Good
salience -100
when
person : Person( )
Details( age  20 ) from person.details
then
System.out.println( Older than 20 (good) :  + person );
end

rule Older than 20 - Bad
salience -100
when
person : Person( details.age  20 )
then
System.out.println( Older than 20 (bad) :  + person );
end

I assert Abe, Bob, Cat, Don, and Eve with ages of 10, 20, 30, 40, and
50, respectively. The output is as follows.

Now 20 : Person(Details(Cat,20))
Older than 20 (good) : Person(Details(Eve,50))
Older than 20 (bad) : Person(Details(Eve,50))
Older than 20 (good) : Person(Details(Don,40))
Older than 20 (bad) : Person(Details(Don,40))
Older than 20 (bad) : Person(Details(Cat,20))


You can see that the Bad rule is more concise but it does not use
the From Conditional Element and therefore it doesn't work properly
(Cat is determined to be older than 20 when she is not.)

Why does Drools allow the Bad rule to be written and compiled when
it does not behave properly?

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


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] RE: Can I use drools to solve my problem?

2008-03-13 Thread Anstis, Michael (M.)
I think you misunderstand how rules work.
 
All Facts inserted into working memory will be compared to all patterns in
all rules; and where a match is found an activation recorded (i.e. LHS
runs).
 
So the following would group all products of type (if you insert
DelieveryList's into WM and set the type for each list you only need the one
rule):-
 
rulegroup by type
when
$d : DelieveryList ( $t : productType )
$p : Product( type == $t )   
then
$d.add($p)
end

You don't need to iterate with rules; simply add all the objects to WM.
 
Cheers,
 
Mike



  _  

From: KinG CD [mailto:[EMAIL PROTECTED] 
Sent: 12 March 2008 19:07
To: Anstis, Michael (M.)
Subject: RE: Can I use drools to solve my problem?


Actually I was able to get near to that, but thank you very much, it cleared
my mind. My problem still is to group things. So I have a list of products
and I want to group them by type. So I want to create N lists for N types,
each list with every product  of a certain type.
 
e.g
 
Product
-type
-name
-id
 
===
 
productList{product1, product2, product3,...,productN}
 
I want a rule that 
 
rulegroup by type
   when
  iterate the List and generate a productListbyType grouping all
products of typeN
   then
  deliveryList.add(productListbyType)
  remove each product from the main List(i dont think i really nedd
that)
end
 
and loop in that rule until list is 'cleared'(all products have been sent to
their right lists.
 
sorry for bothering you, but i really searched for that and did not found. I
could iterate the list with the from collect bu i dont know how to use an
abstract type, how to iterate for all kind of types. we can have N types.
 
thank you very much.


  _  

Subject: RE: Can I use drools to solve my problem?
Date: Mon, 10 Mar 2008 10:21:45 +
From: [EMAIL PROTECTED]
To: rules-users@lists.jboss.org
CC: [EMAIL PROTECTED]


In my opinion it will be much easier if you insert individual Orders and
Products
 
Here's a hurriedly put together example to help you think in terms of rules
(I have no experience of your problem domain so this might be laughably
wrong):-
 
Global ArrayList branch1;
 
rule Delievery split - Branch 1
when

$p : Product( $b : branch = Branch 1 )
$o : Order( products contains $p )
then
OrderDelievery od = new OrderDelievery($o, $p, $b);
insert(od);
end
 
rule Consolidate delieveries
when
$od : OrderDelievery( branch = Branch 1 )
then
branch1.add($od);
end
 
Or you could just retrieve the OrderDelievery objects from WM at the end.
 
Drools can definately achieve what you want. If you can solve the problem
with hard-coded rules you can solve it with Drools.
 
Good luck,
 
Mike


  _  

From: KinG CD [mailto:[EMAIL PROTECTED] 
Sent: 07 March 2008 17:08
To: Anstis, Michael (M.)
Subject: RE: Can I use drools to solve my problem?


alright. I was trying not to boder you.
 
My companie is developing a billing software for a e-commerce site. So we
have an Order and we have to transform it into deliveries. So each Order has
many products and I have to filter it and define X deliveries(i call it
'delivery split'). There are filters like disponibility(in how many days it
will be ok), brach(in what city is the product), type(if it is a kit,
ticket...),...
 
I tried many ways and i really think that drools isn't the best tool for my
problem. The point is that mi boos dont want to use the hard code for define
the deliveries. He wats drolls to do everything. So i tried inserting the
the order in the WM, and using 'rom' chained with 'collect' i could iterate
and set a list based in some rules, but how can i create lists based on the
branch. how can i group in Y different lists the Z different products i
have.
 
I also inserted each product manually and tried to manipulate each one. But
the point is that the rules should be interdependent but i was not able to
do it.
 
the resume is that i want to take the order and set N deliveries based on
interdependent rules. i would like to do almost everything with drools not
using the hard code.
 
Sorry for the English, thanj you very much for the help, i'm a little lost.

ect: FW: Can I use drools to solve my problem?
 Date: Fri, 7 Mar 2008 15:45:22 +
 From: [EMAIL PROTECTED]
 To: rules-users@lists.jboss.org
 CC: [EMAIL PROTECTED]
 
 Posted to forum for a wider audience.
 
 I think you will need to be more specific with your use case.
 
 With kind regards,
 
 Mike
 
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
 Sent: 07 March 2008 15:35
 To: Anstis, Michael (M.)
 Subject: Can I use drools to solve my problem?
 
 I have a list of products and want to divide this list in other lists
 applying the rules, than i want to apply the same rules to this new lists.
 So I keep dividing them until no rules are applicable anymore.
 
 Thank you



  _  

Encontre o que você procura com mais eficiência

[rules-users] RE: Can I use drools to solve my problem?

2008-03-10 Thread Anstis, Michael (M.)
In my opinion it will be much easier if you insert individual Orders and
Products
 
Here's a hurriedly put together example to help you think in terms of rules
(I have no experience of your problem domain so this might be laughably
wrong):-
 
Global ArrayList branch1;
 
rule Delievery split - Branch 1
when
$p : Product( $b : branch = Branch 1 )
$o : Order( products contains $p )
then
OrderDelievery od = new OrderDelievery($o, $p, $b);
insert(od);
end
 
rule Consolidate delieveries
when
$od : OrderDelievery( branch = Branch 1 )
then
branch1.add($od);
end
 
Or you could just retrieve the OrderDelievery objects from WM at the end.
 
Drools can definately achieve what you want. If you can solve the problem
with hard-coded rules you can solve it with Drools.
 
Good luck,
 
Mike


  _  

From: KinG CD [mailto:[EMAIL PROTECTED] 
Sent: 07 March 2008 17:08
To: Anstis, Michael (M.)
Subject: RE: Can I use drools to solve my problem?


alright. I was trying not to boder you.
 
My companie is developing a billing software for a e-commerce site. So we
have an Order and we have to transform it into deliveries. So each Order has
many products and I have to filter it and define X deliveries(i call it
'delivery split'). There are filters like disponibility(in how many days it
will be ok), brach(in what city is the product), type(if it is a kit,
ticket...),...
 
I tried many ways and i really think that drools isn't the best tool for my
problem. The point is that mi boos dont want to use the hard code for define
the deliveries. He wats drolls to do everything. So i tried inserting the
the order in the WM, and using 'rom' chained with 'collect' i could iterate
and set a list based in some rules, but how can i create lists based on the
branch. how can i group in Y different lists the Z different products i
have.
 
I also inserted each product manually and tried to manipulate each one. But
the point is that the rules should be interdependent but i was not able to
do it.
 
the resume is that i want to take the order and set N deliveries based on
interdependent rules. i would like to do almost everything with drools not
using the hard code.
 
Sorry for the English, thanj you very much for the help, i'm a little lost.

ect: FW: Can I use drools to solve my problem?
 Date: Fri, 7 Mar 2008 15:45:22 +
 From: [EMAIL PROTECTED]
 To: rules-users@lists.jboss.org
 CC: [EMAIL PROTECTED]
 
 Posted to forum for a wider audience.
 
 I think you will need to be more specific with your use case.
 
 With kind regards,
 
 Mike
 
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
 Sent: 07 March 2008 15:35
 To: Anstis, Michael (M.)
 Subject: Can I use drools to solve my problem?
 
 I have a list of products and want to divide this list in other lists
 applying the rules, than i want to apply the same rules to this new lists.
 So I keep dividing them until no rules are applicable anymore.
 
 Thank you



  _  

Encontre o que você procura com mais eficiência! Instale já a Barra de
Ferramentas com Windows Desktop Search! É GRÁTIS!
http://www.windowslive.com.br  



smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Making my own agenda Filter

2008-03-10 Thread Anstis, Michael (M.)
Your anonymous sub-class isn't entered or it doesn't run as expected?

In your accept override you compare object references - type == AGENDA.
Is this what you really want?


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mehak
Sent: 10 March 2008 13:49
To: rules-users@lists.jboss.org
Subject: [rules-users] Making my own agenda Filter


Hi I am using this code to make my own agenda filter. In this case if the
type of rule is agenda then agenda filter to focus on that agenda is set
else agenda filter for rule is set.

private static AgendaFilter buildAgendaFilter(RuleConfig rule)
{   final String searchName = rule.getRuleName();
final String type = rule.getRuleType();
AgendaFilter filter = new AgendaFilter() // The control doesnt go
inside
this code
{
public boolean accept(Activation activation)
{   if(type == AGENDA)
{

if((activation.getRule().getAgendaGroup()).equalsIgnoreCase(searchName)) 
{  System.out.println(searchName);
return true;
}
return false;
}

else
   {
 
if((activation.getRule().getName()).equalsIgnoreCase(searchName)) 
  {  
  return true;
  }
return false;
   }
}
};
return filter;

The problem is that the control doesnt go inside the new agenda creation.
Please let me know if something is wrong with the way I have used it.
Thanks
-- 
View this message in context:
http://www.nabble.com/Making-my-own-agenda-Filter-tp15950765p15950765.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


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] FW: Can I use drools to solve my problem?

2008-03-07 Thread Anstis, Michael (M.)
Posted to forum for a wider audience.

I think you will need to be more specific with your use case.

With kind regards,

Mike

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: 07 March 2008 15:35
To: Anstis, Michael (M.)
Subject: Can I use drools to solve my problem?

I have a list of products and want to divide this list in other lists
applying the rules, than i want to apply the same rules to this new lists.
So I keep dividing them until no rules are applicable anymore.

Thank you


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Plz reply : Descending order rule

2008-02-21 Thread Anstis, Michael (M.)
Are you sure you only have three facts?

Your original resultset showed Order value=5 which is not in the dataset
shown in your most recent email.
 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Barath
Sent: 21 February 2008 10:34
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] Plz reply : Descending order rule


Hi,

Let me say my understanding about this rule...

rule Descending order
when
$a : Order( $value : value )
not Order( value  $value)
then
System.out.println(value :+$value);   
retract($a);
end

1. Order value=1let this be A
2. Order value=2let this be B
3. Order value=3let this be C

Case 1 :   $a : Order($value : 1)
  not Order(2  1)
   So this rule is True.

Case 2 :   $a : Order($value : 1)
  not Order(3  1)
   So this rule is True.

Case 3 :   $a : Order($value : 2)
  not Order(2  3)
   So this rule is True.

Case 4 :   $a : Order($value : 2)
  not Order(2  1)
   So this rule is False.

Case 5 :   $a : Order($value : 3)
  not Order(3  1)
   So this rule is False.

Case 6 :   $a : Order($value : 3)
  not Order(3  2)
   So this rule is False.

This indicates the rule should fire for three times but its not the case.
I know i going wrong some where but i couldn't figure out.
Plz do help me.

Barath.


Barath wrote:
 
 Hi,
 
 Can u explain me the rule flow for the below rule ?.
 This will help me to get some clear idea about rules.
 
 rule Descending order
 when
 $a : Order( $value : value )
 not Order( value  $value)
 then
 System.out.println(value :+$value); 
 retract($a);
 end
 
 I am having the following ,
 
 1. Order value=1
 2. Order value=2
 3. Order value=3
 4. Order value=4
 5. Order value=5
 
 Can u explain the flow(when part) for this 5 object ?
 
 Note my understanding(in when) : 1st line  take one order object
  2nd line check for
 any other object with grater 'value'
  But i dont know
 sequence in which the objects are taken.
 
 Plz do reply..
 
 Thanks in advance,
 Barath.
 ___
 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/Plz-reply-%3A-Descending-order-rule-tp15606103p1560726
1.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


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Plz reply : Descending order rule

2008-02-21 Thread Anstis, Michael (M.)
Code:-

public static final void main(String[] args) {
...
WorkingMemory wm = ruleBase.newStatefulSession();

wm.insert(new Order(1));
wm.insert(new Order(2));
wm.insert(new Order(3));
wm.fireAllRules();

...
} 

Rule:-

rule Descending order
when
$a : Order( $value : value )
not Order( value  $value)
then
System.out.println(value :+$value);
retract($a);
end

Gives:-

value :3
value :2
value :1

I agree with Scott, is there something else afoot?

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Christian Spurk
Sent: 21 February 2008 13:20
To: Rules Users List
Subject: Re: [rules-users] Plz reply : Descending order rule

Hi Barath!

Barath wrote:
 This indicates the rule should fire for three times but its not the case.

Looking at your last e-mail only: as far as I can see, the rule indeed 
fires exactly three times ... It prints the following:

value :3
value :2
value :1

Probably I don't quite understand the problem? Or maybe your actual 
problem does not occur in this simple testcase?

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


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] Plz reply : Descending order rule

2008-02-21 Thread Anstis, Michael (M.)
Sorry I agree with Christian not Scott!

I will try to refer to the correct email in my inbox next time ;-)

-Original Message-
From: Anstis, Michael (M.) 
Sent: 21 February 2008 14:00
To: 'Rules Users List'
Subject: RE: [rules-users] Plz reply : Descending order rule

Code:-

public static final void main(String[] args) {
...
WorkingMemory wm = ruleBase.newStatefulSession();

wm.insert(new Order(1));
wm.insert(new Order(2));
wm.insert(new Order(3));
wm.fireAllRules();

...
} 

Rule:-

rule Descending order
when
$a : Order( $value : value )
not Order( value  $value)
then
System.out.println(value :+$value);
retract($a);
end

Gives:-

value :3
value :2
value :1

I agree with Scott, is there something else afoot?

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Christian Spurk
Sent: 21 February 2008 13:20
To: Rules Users List
Subject: Re: [rules-users] Plz reply : Descending order rule

Hi Barath!

Barath wrote:
 This indicates the rule should fire for three times but its not the case.

Looking at your last e-mail only: as far as I can see, the rule indeed 
fires exactly three times ... It prints the following:

value :3
value :2
value :1

Probably I don't quite understand the problem? Or maybe your actual 
problem does not occur in this simple testcase?

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


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: Re[rules-users] te Tree view ... tutorial?

2008-02-11 Thread Anstis, Michael (M.)
2.4. Rete Algorithm in the manual provides some insight.

Let the group know whether this satisfies your curiosity - otherwise Google
for Dr. Charles Forgy or RETE for detailed stuff.

Don't forget Drools is based upon RETE but has many enhancements.

Happy reading

Mike

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Noc2
Sent: 11 February 2008 15:30
To: rules-users@lists.jboss.org
Subject: Re[rules-users] te Tree view ... tutorial?


hello all, 

as newbie to drools, i was working with rule files when i accidentally found
the  Rete Tree View. Curious as i am, i went searching on the net on how
to read this thing. I have found some information on what it is, but
unfortenatly, when i try to link the information to the real life situation,
i realized that some things didnt match. 

So i am still looking for a nice tutorial or explanation of the Rete Tree
view. Anybody that could help me? All suggestions are welcome. 

Thanks in advance, 
Noc2 
-- 
View this message in context:
http://www.nabble.com/Rete-Tree-view-...-tutorial--tp15413110p15413110.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


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


RE: [rules-users] compare string and int in LHS

2008-02-08 Thread Anstis, Michael (M.)
You could use an inline eval too.

The problem possibly lies more with your model; why not have one subclass
expose the String property and another the Integer property and code the
rules using the subclasses? Much safer throughout the entire application
than having to worry whether some field is meant to be a string or number
(It's very easy to question problems though - there could be very good
reason why you need the model as is).

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of brenner
Sent: 08 February 2008 12:33
To: rules-users@lists.jboss.org
Subject: Re: [rules-users] compare string and int in LHS


Hi,

I have found a solution, but I don't know that it is the best:
My solution:

I have extend my Class with a method which returns the string as a integer.
And my rule is like this:

i : Integer( intValue = 1) from $test.getValue(Test.VALUE_TYP_INTEGER);

Is that the only/best solution. 
Can't I convert Strings to Integer on the LHS of a rule?

greeting
Daniel




brenner wrote:
 
 Hi,
 
 I have a class, wich contains a string value. This value is in some use
 cases an integer. 
 For this use case I want to convert (parse) the string typ to an integer
 because I want that the following rule matches: 
 
 rule
   when
 t : Test(value = 1)
   then
 System.out.println(t)
 end
 
 
 class Test {

String value;
 
getValue();
setValue();
 
 }
 
 Have anyone a solution or some help for me?
 Is that possible what I want to do?
 
 Thanks
 Daniel
 

-- 
View this message in context:
http://www.nabble.com/compare-string-and-int-in-LHS-tp15337728p15354435.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


smime.p7s
Description: S/MIME cryptographic signature
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


  1   2   >