Re: [rules-users] Problem with DRL language/ XLS decision tables.

2010-07-22 Thread Greg Barton
Considering that googling on "rule latch" will return this thread on gmane as 
the 2nd link, you might find research difficult. :)  I think Tom coined that 
term in this context, but it fits.  The basic idea is that you use an object as 
an indicator of what processing has happened, and whether or not rules should 
fire.

class RuleLatch {
  public final String name;
  public final DataObject dataObject;
  public RuleLatch(String name, DataObject dataObject) { 
    this.name = name; this.dataObject = dataObject;
  }
}

when 
  data: DataObject(...selection conditions for data...)
  level1Latch: RuleLatch(name == "level1Foo", dataObejct == data)
  level2Latch: RuleLatch(name == "level2Bar", dataObject == data)
then
  ...if this rule wants to cancel all subsequent "level1Foo" it retracts 
level1Latch...

  ...if this rule wants to cancel all subsequent "level2Bar" it 
retractslevel2Latch...
end

An alternative, more efficient, but not as OO happy way, is to put the control 
information into the DataObject itself.  Drools does a lot of optimization on 
the == tests with hashing, but if speed is a priority it might not be enough.  
So...

class DataObject {
  public boolean level1Foo = true;

  public boolean level2Bar = true;
}

when 

  data: DataObject(level1Foo == true, level2Bar == true, ...selection 
conditions for data... )
then

  ...if this rule wants to cancel all subsequent "level1Foo" it updates 
level1Foo = false...


  ...if this rule wants to cancel all subsequent "level2Bar" it updates 
level2Bar = false...

end



--- On Thu, 7/22/10, tom ska  wrote:

From: tom ska 
Subject: Re: [rules-users] Problem with DRL language/ XLS decision tables.
To: "Rules Users List" 
Date: Thursday, July 22, 2010, 11:50 AM


Thanks for reacting ;)
I did some simulations, and after them, I want of course to parallelize this 
process of processing 2 billions facts. But as far as I wrote, Drools engine, 
can't do this. And I have to create threads manually in application (with pool 
of sessions). Am I right? Tuning number of data sounds fine to me, so I will 
try method with "rule latch" too (but I have to read about this, because, I 
don't know what is it, and I don't want to waste your time ;) But still I don't 
know how to use StatefulSessions to do this...

Summarising, there are 3 methods to do, what I want to do (apart of a 
scalability problem - yet ;)
1.)with StatelessSession for one fact at time and "activation group"

2.)"rule latch" - I have to read more about it
3.)with a pool of StatefulSessions that I reuse - but I still don't know how to 
do it using StatefulSessions

Really thanks for help ;)


P.S. I use Drools 5 :)


  
___

rules-users mailing list

rules-users@lists.jboss.org

https://lists.jboss.org/mailman/listinfo/rules-users






-Inline Attachment Follows-

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



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


Re: [rules-users] Problem with DRL language/ XLS decision tables.

2010-07-22 Thread tom ska
Thanks for reacting ;)
I did some simulations, and after them, I want of course to parallelize this
process of processing 2 billions facts. But as far as I wrote, Drools
engine, can't do this. And I have to create threads manually in application
(with pool of sessions). Am I right? Tuning number of data sounds fine to
me, so I will try method with "rule latch" too (but I have to read about
this, because, I don't know what is it, and I don't want to waste your time
;) But still I don't know how to use StatefulSessions to do this...
Summarising, there are 3 methods to do, what I want to do (apart of a
scalability problem - yet ;)
1.)with StatelessSession for one fact at time and "activation group"
2.)"rule latch" - I have to read more about it
3.)with a pool of StatefulSessions that I reuse - but I still don't know how
to do it using StatefulSessions
Really thanks for help ;)


P.S. I use Drools 5 :)

>
> ___
> 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] Problem with DRL language/ XLS decision tables.

2010-07-22 Thread Greg Barton
You could always have a pool of StatefulSessions that you reuse. (This would 
allow you to run concurrently in multiple threads as well.)  As long as these 
billions of facts don't need to interact that'll work fine.  However I'd 
suggest that you try the "rule latch" method that Thomas suggested.  That way 
you could tune the number of data objects you insert into a single pooled 
session, instead of inserting one at a time.  And I'm guessing that, no matter 
how efficient you get, throwing 2 billion in memory at once won't scale. :)

--- On Thu, 7/22/10, tom ska  wrote:

From: tom ska 
Subject: Re: [rules-users] Problem with DRL language/ XLS decision tables.
To: "Rules Users List" 
Date: Thursday, July 22, 2010, 9:17 AM

Hi,
thanks for so quick answer. I think, that using StatelessSession could be a 
solution, but as I understood, I have to insert only one fact to the facts 
base. But, I have about 2 billions of facts that I want to process with Drools, 
and execution time, is for me really important. A think, that inserting one 
fact at time means for me additional time to initialise engine (when adding a 
new fact, and removing old one). Am I right?


Thanks :)

2010/7/22 Pavel Tavoda 

Don't know details of your problem but it's typical situation where

you can use StatelessSession, insert one fact at time and use

activation-group.



Pavel



2010/7/22 tom ska :

> Hello,

> I have a problem with defining rules. I insert many, many objects (facts) to

> ksession object (StatefulKnowledgeSession). I want to fire rules for all of

> them(facts), but I want to fire only one rule from all rules for each one

> fact(not always this same rule is fired, because I use salience).

> activation-group is not appropriate, because it works only with one object

> (fact) - rest is not processed by engine.

> Second question is: how can I stop processing rules, bot only for one fact,

> not for all of them.

>

> Thanks,

> tom.

>

> P.S. forgive me my English... :)

> P.S.2 Firstly I want to do this in DRL, then, I'll try with XLS, and write

> post if I would find problems...

>

>

>

> ___

> 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


Re: [rules-users] Problem with DRL language/ XLS decision tables.

2010-07-22 Thread Pavel Tavoda
You can't insert 2 bilion facts to memory. Handling of processed facts
will be more expensive than creating StalessSession and process each
item. On our system with maybe 200 rules evaluation cost for one fact
is 2-5 ms. And you can parallelize it in your case, depends on
hardware which you have.

Pavel

2010/7/22 tom ska :
> Hi,
> thanks for so quick answer. I think, that using StatelessSession could be a
> solution, but as I understood, I have to insert only one fact to the facts
> base. But, I have about 2 billions of facts that I want to process with
> Drools, and execution time, is for me really important. A think, that
> inserting one fact at time means for me additional time to initialise engine
> (when adding a new fact, and removing old one). Am I right?
>
> Thanks :)
>
> 2010/7/22 Pavel Tavoda 
>>
>> Don't know details of your problem but it's typical situation where
>> you can use StatelessSession, insert one fact at time and use
>> activation-group.
>>
>> Pavel
>>
>> 2010/7/22 tom ska :
>> > Hello,
>> > I have a problem with defining rules. I insert many, many objects
>> > (facts) to
>> > ksession object (StatefulKnowledgeSession). I want to fire rules for all
>> > of
>> > them(facts), but I want to fire only one rule from all rules for each
>> > one
>> > fact(not always this same rule is fired, because I use salience).
>> > activation-group is not appropriate, because it works only with one
>> > object
>> > (fact) - rest is not processed by engine.
>> > Second question is: how can I stop processing rules, bot only for one
>> > fact,
>> > not for all of them.
>> >
>> > Thanks,
>> > tom.
>> >
>> > P.S. forgive me my English... :)
>> > P.S.2 Firstly I want to do this in DRL, then, I'll try with XLS, and
>> > write
>> > post if I would find problems...
>> >
>> >
>> >
>> > ___
>> > 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] Problem with DRL language/ XLS decision tables.

2010-07-22 Thread tom ska
Hi,
thanks for so quick answer. I think, that using StatelessSession could be a
solution, but as I understood, I have to insert only one fact to the facts
base. But, I have about 2 billions of facts that I want to process with
Drools, and execution time, is for me really important. A think, that
inserting one fact at time means for me additional time to initialise engine
(when adding a new fact, and removing old one). Am I right?

Thanks :)

2010/7/22 Pavel Tavoda 

> Don't know details of your problem but it's typical situation where
> you can use StatelessSession, insert one fact at time and use
> activation-group.
>
> Pavel
>
> 2010/7/22 tom ska :
> > Hello,
> > I have a problem with defining rules. I insert many, many objects (facts)
> to
> > ksession object (StatefulKnowledgeSession). I want to fire rules for all
> of
> > them(facts), but I want to fire only one rule from all rules for each one
> > fact(not always this same rule is fired, because I use salience).
> > activation-group is not appropriate, because it works only with one
> object
> > (fact) - rest is not processed by engine.
> > Second question is: how can I stop processing rules, bot only for one
> fact,
> > not for all of them.
> >
> > Thanks,
> > tom.
> >
> > P.S. forgive me my English... :)
> > P.S.2 Firstly I want to do this in DRL, then, I'll try with XLS, and
> write
> > post if I would find problems...
> >
> >
> >
> > ___
> > 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] Problem with DRL language/ XLS decision tables.

2010-07-22 Thread Pavel Tavoda
Don't know details of your problem but it's typical situation where
you can use StatelessSession, insert one fact at time and use
activation-group.

Pavel

2010/7/22 tom ska :
> Hello,
> I have a problem with defining rules. I insert many, many objects (facts) to
> ksession object (StatefulKnowledgeSession). I want to fire rules for all of
> them(facts), but I want to fire only one rule from all rules for each one
> fact(not always this same rule is fired, because I use salience).
> activation-group is not appropriate, because it works only with one object
> (fact) - rest is not processed by engine.
> Second question is: how can I stop processing rules, bot only for one fact,
> not for all of them.
>
> Thanks,
> tom.
>
> P.S. forgive me my English... :)
> P.S.2 Firstly I want to do this in DRL, then, I'll try with XLS, and write
> post if I would find problems...
>
>
>
> ___
> 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] Problem with DRL language/ XLS decision tables.

2010-07-22 Thread Swindells, Thomas
The easiest way to do this is to use a custom helper object eg RuleLatch(fact, 
"name").
You would write your rules so that for each group of mutually exclusive rules 
then for the fact they match against they check the absence of an appropriate 
RuleLatch, as part of their result part they then insert the appropriate rule 
latch - thereby preventing any other rule from running.

The easiest way to stop processing a particular fact is to retract it.  If you 
do need to keep it in your working memory then use the RuleLatch concept as 
above - each rule may check for two latches, one latch for a particular group 
of rules as described above, the other latch is a more global control which 
only a couple of rules insert.

Hope that makes sense,

Thomas

From: rules-users-boun...@lists.jboss.org 
[mailto:rules-users-boun...@lists.jboss.org] On Behalf Of tom ska
Sent: 22 July 2010 14:27
To: rules-users@lists.jboss.org
Subject: [rules-users] Problem with DRL language/ XLS decision tables.

Hello,
I have a problem with defining rules. I insert many, many objects (facts) to 
ksession object (StatefulKnowledgeSession). I want to fire rules for all of 
them(facts), but I want to fire only one rule from all rules for each one 
fact(not always this same rule is fired, because I use salience). 
activation-group is not appropriate, because it works only with one object 
(fact) - rest is not processed by engine.
Second question is: how can I stop processing rules, bot only for one fact, not 
for all of them.

Thanks,
tom.

P.S. forgive me my English... :)
P.S.2 Firstly I want to do this in DRL, then, I'll try with XLS, and write post 
if I would find problems...




**
This message is confidential and intended only for the addressee. If you have 
received this message in error, please immediately notify the 
postmas...@nds.com and delete it from your system as well as any copies. The 
content of e-mails as well as traffic data may be monitored by NDS for 
employment and security purposes. To protect the environment please do not 
print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, 
United Kingdom. A company registered in England and Wales. Registered no. 
3080780. VAT no. GB 603 8808 40-00
**
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


[rules-users] Problem with DRL language/ XLS decision tables.

2010-07-22 Thread tom ska
Hello,
I have a problem with defining rules. I insert many, many objects (facts) to
ksession object (StatefulKnowledgeSession). I want to fire rules for
*all*of them(facts), but I want to fire only one rule from all rules
for each one
fact(not always this same rule is fired, because I use salience).
activation-group is not appropriate, because it works only with one object
(fact) - rest is not processed by engine.
Second question is: how can I stop processing rules, bot only for one fact,
not for all of them.

Thanks,
tom.

P.S. forgive me my English... :)
P.S.2 Firstly I want to do this in DRL, then, I'll try with XLS, and write
post if I would find problems...
___
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users