Kris Nuttycombe | 1 Aug 2008 01:10
Picon
Gravatar

Re: Reusing predicates

Thanks; my primary concern was the code replication, so I'll go with
the intermediate fact approach.

Kris

On Thu, Jul 31, 2008 at 4:54 PM, Edson Tirelli <tirelli <at> post.com> wrote:
>
>    Not sure if you are worried about syntax or performance. If you are
> worried about performance, just write your common Patterns in the same order
> among your multiple rules and the engine will reuse them.
>
>    If you are worried about the syntax, i.e. not replicating the same code
> among multiple rules, the intermediate fact is probably the best solution
> right now. We want to implement rule inheritance or rule templates, but we
> don't have it yet.
>
>    []s
>    Edson
>
> 2008/7/31 Kris Nuttycombe <kris.nuttycombe <at> gmail.com>
>>
>> Hi, all,
>>
>> I have a set of rules where the LHS is essentially the same except for
>> a couple of additional conditions in each case. What is the best way
>> to factor out these common predicates? Should I simply create an
>> intermediate fact based upon the common set of conditions and then
>> reason with that fact, or is there a way of reusing them without
>> adding another fact to the mix?
>>
(Continue reading)

Mark Proctor | 1 Aug 2008 08:05

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 <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Anstis, Michael (M. | 1 Aug 2008 08:40
Picon
Favicon

RE: determinism with rulebase partitioning

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: rules-users-bounces <at> lists.jboss.org
[mailto:rules-users-bounces <at> lists.jboss.org] 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 
(Continue reading)

Edson Tirelli | 1 Aug 2008 14:39
Favicon

Re: determinism with rulebase partitioning


    I think that even with rulebase partitions, we should continue to support current execution mode. So, we should keep a rulebase configuration that basically allow the user to defines: either single-thread (as it is today) or multi-thread (as we are trying to achieve) execution.

    Having that in mind, in the multi-thread mode:

(A) What does "parallel evaluation of a rulebase" mean? Is it designed
to optimise, for example, two threads processing a stateless and
stateful session?
   Means that rules that do not share nodes, being independent of each other (from an evaluation perspective), will be evaluated in parallel. This is very common scenario and a desidered feature in CEP engines.

(B) Are there only two partitions, both of which are invisible to the
user? Is there any value in allowing user-defined partitions?
    There will be as many partitions as the compiler can create for the given set of rules. Rules that share more nodes, are more difficult to partition, while rules that are independent from an LHS point of view, are easier to parallelize. In my opinion, the only thing that may be helpful to expose and allow the user to control is the maximum size of the thread pool that is used to propagate facts. Even that I'm not sure is so helpful, because it is complex to fine tune such things, since the partitioning is completely dependent on the rules added to the rulebase.

(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)?
    The partitioning of the rulebase is dependent upon the rules in the rulebase and nothing more. But that is different from the agenda. The agenda issue is much more complex, because even with partitions we can keep a single deterministic agenda (as long as it is not in active mode - runUntilHalt). Now, if the agenda is in active mode, or if we have multiple agendas (1 per partition, for instance), then the engine behavior becomes indeterministic. This is a common scenario in CEP systems that have multiple different "queries" running over the same set of streams, trying to detect and act upon them as soon as they are detected, and event streams are indeterministic by their own nature. In common rules engines scenarios, I'm not sure we can run in this indeterministic mode.

(D) Can a rule sometimes be deterministic and sometimes not (i.e.
depends upon the type of session)?
    It will always depend on the set of rules (the rulebase), not the type of session. One rule is always deterministic when considered in isolation, but two or more rules may or may not be deterministic in relation to each other. Just remember Eisten's Relativity Theory... ;)

   []s
   Edson

2008/8/1 Anstis, Michael (M.) <manstis1 <at> ford.com>
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: rules-users-bounces <at> lists.jboss.org
[mailto:rules-users-bounces <at> lists.jboss.org] 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 <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

_______________________________________________
rules-users mailing list
rules-users <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



--
Edson Tirelli
JBoss Drools Core Development
JBoss, a division of Red Hat <at> www.jboss.com
_______________________________________________
rules-users mailing list
rules-users <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
thomas kukofka | 1 Aug 2008 16:24
Picon

Problems with looping

Hello,

I have and less loop (the rule should only executed one for one InputObject) in the follwing rule although I use "no-loop":

rule "rulename"
  dialect "java"
  no-loop   
    when
        io: InputObject (type == InputObject.Type.Typename)
    then
        io.setStringPropertyValue(InputObject.PROPERTYVALUE, "somestring");
        update(oo);
       
end

I've read that I have to overwrite hashcode and equals, can this be the reason? If yes, do you have an example how to overwrite these methods?

Thomas
_______________________________________________
rules-users mailing list
rules-users <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
Vanina Beraudo | 1 Aug 2008 16:37
Picon

Re: Problems with looping

Hi,

you must use "no-loop true" and the rule will be executed one for one
InputObject.

2008/8/1 thomas kukofka <thomaskukofka <at> web.de>:
> Hello,
>
> I have and less loop (the rule should only executed one for one InputObject)
> in the follwing rule although I use "no-loop":
>
> rule "rulename"
>   dialect "java"
>   no-loop
>     when
>         io: InputObject (type == InputObject.Type.Typename)
>     then
>         io.setStringPropertyValue(InputObject.PROPERTYVALUE, "somestring");
>         update(oo);
>
> end
>
> I've read that I have to overwrite hashcode and equals, can this be the
> reason? If yes, do you have an example how to overwrite these methods?
>
> Thomas
>
> _______________________________________________
> rules-users mailing list
> rules-users <at> lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>

--

-- 
Lic. Vanina Beraudo
_______________________________________________
rules-users mailing list
rules-users <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

thomas kukofka | 1 Aug 2008 17:08
Picon

(no subject)


Hi, I used no-loop true but it still loops!!

Thomas

Hi

you must use "no-loop true" and the rule will be executed one for one InputObject.


2008/8/1 thomas kukofka <thomaskukofka at web.de>:

> Hello,

> I have and less loop (the rule should only executed one for one InputObject)

> in the follwing rule although I use "no-loop":

> rule "rulename"

>   dialect "java"

>   no-loop

>     when

>         io: InputObject (type == InputObject.Type.Typename)

>     then

>         io.setStringPropertyValue(InputObject.PROPERTYVALUE, "somestring");

>         update(oo);

> end

> I've read that I have to overwrite hashcode and equals, can this be the

> reason? If yes, do you have an example how to overwrite these methods?

> Thomas

_______________________________________________
rules-users mailing list
rules-users <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
thomas kukofka | 1 Aug 2008 17:10
Picon

Problems with looping

Hi, I used no-loop true but it still loops!!

Thomas

Hi

you must use "no-loop true" and the rule will be executed one for one InputObject.


2008/8/1 thomas kukofka <thomaskukofka at web.de>:

> Hello,

> I have and less loop (the rule should only executed one for one InputObject)

> in the follwing rule although I use "no-loop":

> rule "rulename"

>   dialect "java"

>   no-loop

>     when

>         io: InputObject (type == InputObject.Type.Typename)

>     then

>         io.setStringPropertyValue(InputObject.PROPERTYVALUE, "somestring");

>         update(oo);

> end

> I've read that I have to overwrite hashcode and equals, can this be the

> reason? If yes, do you have an example how to overwrite these methods?

> Thomas

_______________________________________________
rules-users mailing list
rules-users <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
Greg Barton | 1 Aug 2008 18:03
Picon
Favicon

Re: Problems with looping

Did you implement equals() and hashCode()?

Implementing them isn't hard.  Implementing them well
can be tricky, but for these purposes a simple
implementation will do.  Basically, with equals() you
want to compare the stuff contained in the objects. 
With hashCode() you want to produce an integer that
can be used in HashMaps.  The only restriction is
that, if o1.equals(o2) == true, then o1.hashCode() ==
o2.hashCode().  (The reverse is not necessarily true.)

The easiest way to implement these is to just compare
the fields that define the state of your object:

public class Foo {

  int bar;
  String bas;

  public boolean equals(Object o) {
    if(o instanceof Foo) {
      Foo other = (Foo)o;
      return bar == other.bar && bas != null &&
bas.equals(other.bas);
    } else {
      return false;
    }
  }

  public int hashCode() {
    int hash = 37;
    hash ^= bar;
    if(bas != null) {
      hash ^= bas.hashCode();
    }
    return hash;
  }
}

One good way to make this easier is to use the jakarta
commons EqualsBuilder and HashCodeBuilder classes. 
They also help you implement them "well," especially
hashCode.

GreG

--- thomas kukofka <thomaskukofka <at> web.de> wrote:

> Hi, I used no-loop true but it still loops!!
> 
> Thomas
> 
> Hi
> 
> you must use "no-loop true" and the rule will be
> executed one for one
> InputObject.
> 
> 
> 2008/8/1 thomas kukofka <thomaskukofka at
>
web.de<https://lists.jboss.org/mailman/listinfo/rules-users>
> >:
> 
> > Hello,
> 
> >
> 
> > I have and less loop (the rule should only
> executed one for one
> InputObject)
> 
> > in the follwing rule although I use "no-loop":
> 
> >
> 
> > rule "rulename"
> 
> >   dialect "java"
> 
> >   no-loop
> 
> >     when
> 
> >         io: InputObject (type ==
> InputObject.Type.Typename)
> 
> >     then
> 
> >        
> io.setStringPropertyValue(InputObject.PROPERTYVALUE,
> "somestring");
> 
> >         update(oo);
> 
> >
> 
> > end
> 
> >
> 
> > I've read that I have to overwrite hashcode and
> equals, can this be the
> 
> > reason? If yes, do you have an example how to
> overwrite these methods?
> 
> >
> 
> > Thomas
> > _______________________________________________
> rules-users mailing list
> rules-users <at> lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
> 

      
_______________________________________________
rules-users mailing list
rules-users <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Ron Kneusel | 1 Aug 2008 18:57
Picon
Favicon

Re: Compiling .drl files inside of a JUnit test


Edson wrote:
>
>Right now, Drools uses JUnit for all its unit and integration tests. Take a look at the integration tests
and I think you will figure out:
>http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-compiler/src/test/java/org/drools/integrationtests/

Thanks for the link but I do not see how this helps with my problem.  Perhaps it would if I could see the actual
.drl files.  For example, when I use getClass().getResourceAsStream(...) a null is returned but even it
that part worked, it wouldn't be any different than what I currently have.

Seeing the .drl file is not the problem.  Getting the import statements in the .drl file to actually find the
proper classes is.  Do you know how the actual .drl files used in the unit testing are referring to the
objects they need?

Ron

_________________________________________________________________
Use video conversation to talk face-to-face with Windows Live Messenger.
http://www.windowslive.com/messenger/connect_your_way.html?ocid=TXT_TAGLM_WL_Refresh_messenger_video_072008
_______________________________________________
rules-users mailing list
rules-users <at> lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users


Gmane