Hi Andreas.

The Combination monster strikes again !

Add this as your first condition:
         <java:condition>System.identityHashCode(Y) >
System.identityHashCode (X)</java:condition>

This will ensure that only "useful" combinations are added. When I add that,
9 tuples took about 14milliseconds, and 20 took about 1 second (!) - your
mileage may vary. Before that I was getting worse times then you (my machine
in more humble, it would seem?). Perhaps you can confirm that this is what
you need?

We/I have been planning for some time to build in a feature to remove
"unhelpful" combinations, by making use of the System identity of the fact
objects, and this certainly re-inforces that. Note that the above is just a
bit of "sugar" such that the rule will only be activated for unique
combinations of tuple instances (by using identity hashcode, it is
arbitrary, but unique).

In general, for *most* people having (fact1, fact2) and (fact2, fact1)
combinations is not terribly helpful, so I would like it on by default in
Drools 3 (no change to drools 2) (any one care to disagree?). So instead of
Combinations, we end up with Permutations (or is it the other way around? I
should have payed more attention in school rather then perving at the girl
in front).

Of course, I could be horribly wrong, and get blasted by people asking why
they are not getting all possible Combinations any more ! (perhaps I didn't
waste my time looking at the girl in front after all).

So in summary, try the above condition, and let me know if you get better
(and still correct) results. In Drools 3 we will aim to include this
condition implicitly via a few different means, but I think the same result
can be achieved (in fact there will be lots of other performance advantes,
of which this is just one).


For a bit more of an explanation by someone much much smarter and more
eloquent then me, read Simon Harris blog:
http://www.redhillconsulting.com.au/blogs/simon/archives/000213.html



----------------------------

Regards,

Michael
JBoss Business Rules

On 1/22/06, Andreas Andreakis <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I agree that generic-general purpose RuleEngines can not hold this
> computation.
>
> The problem is that you have dublication of Facts, which kill
> memory-space.
> For instance, if you execute the Example with 4 Triples under Drools you
> get:
>
> <0> <subClassOf> <1>
> <1> <subClassOf> <2>
> <2> <subClassOf> <3>
> <3> <subClassOf> <4>
> <0> <subClassOf> <2>
> <2> <subClassOf> <4>
> <1> <subClassOf> <3>
> <0> <subClassOf> <3>
> <1> <subClassOf> <4>
> <0> <subClassOf> <4>
> *<0> <subClassOf> <3>*
> *<1> <subClassOf> <4>*
> *<0> <subClassOf> <4>
> <0> <subClassOf> <4>
> <0> <subClassOf> <4>
> <0> <subClassOf> <4>*
>
> The marked Triples are dublicates. With a growing number of Triples the
> dublicates grow exponentialy.
> Each of the Triple is represented by a TripleObject (see Triple Class in
> first email). Theoreticly, Drools does a correct Job. In Practice, this
> behaviour is not always desired.
>
>

Reply via email to