Thanks for this advice, thats exactly what Im looking for, and if I want
to use it in the guvnor, is it planned to realize this also there or can it
be done unde Other meta data -> type? I use guvnor version 5.0.
Regards,
Dominik
Von: Vincent Legendre [mailto:vincent.legendre@eurodecision.com]
Gesendet: Dienstag, 19. Oktober 2010 17:27
An: Rules Users List
Cc: Dominik Hüttner; leonardo.f.gomes(a)gmail.com
Betreff: Re: [rules-users] Get rid of redundant conditions in combined
rules.
There is something in 5.x which allow a rule to inherit from another.
Inheritance is on parent rule conditions.
May be you could write something like this:
rule "london_guys"
when
customer:Customer(town=="London")
then
System.out.println(customer.getLname() + " is inhabitant of
London");
end
rule "london teachers" extends "london_guys"
when
Customer(job=="TEACHER") from customer
then
System.out.println(customer.getLname() + " is a teacher");
end
BUT ...
1 - As you can see you cannot inject a new contraint in a 'parent'
pattern. So you have to use first variable as a source for the second
pattern ...
2 - Bindings in parent rule only works in 5.1 version (may be only in
trunk), so be careful
To conclude, try to check (here <
https://jira.jboss.org/browse/JBRULES-1812>
, for a sample, that may not work, this functionnality is not documented
yet), but I think leonardo's solution is best. May be you can adapt it to
avoid create new classes, but you could use an additional field in your
actual class to "tag" facts according to what your first rules concludes.
Le 19/10/2010 16:29, Dominik Hüttner a écrit :
Hi Leonardo,
the performance problem I thought of meant removing and inserting the facts
again and again, if I would remove the facts, that dont fit the first rule
and execute the second rule only on the remaining facts.
The solution you offered, does, what I intend, but the problem is, that I
have to create a new class for every rule-pair and I want to use it
flexible, without having to create a new class / model for every rule. Is
there maybe another way to solve this problem?
Kind regards,
Dominik
Von: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] Im Auftrag von Leonardo Gomes
Gesendet: Dienstag, 12. Oktober 2010 16:37
An: Rules Users List
Betreff: Re: [rules-users] Get rid of redundant conditions in combined
rules.
If your problem is performance, don't worry. Conditions evaluation is
shared, so in the second rule you won't re-evaluate the entire working
memory (to know
more:http://www.drdobbs.com/184405218).
If you're worried about not having to repeat the conditions on the second
rule, I would create inferred facts when the first rule matches and use then
in the second rule + the additional conditions.
Something like:
Rule1:
when
customer:Customer(town=="London")
then
insert new LondonCustomer( customer );
Rule2:
when
london : LondonCustomer(customer.job=="TEACHER")
then
System.out.println(london.customer.getLname() + " is a
teacher");
2010/10/12 Dominik Hüttner <d.huettner(a)tiq-solutions.de>
Hello everyone,
Ive got a question. Im using drools-guvnor to execute some rule-scenarios.
I have to solve the following problem: I have an amount of objects in my
working memory and cant remove objects from the working memory in the
then-part of the rule. I want to combine two rules, the first rule selects
some objects and the second rule checks only these selected objects for
additional criteria. I have to use two rules, because I want to report the
objects selected in the first rule, too. Now I have implemented this with
two rules and in the second rule, the criterias of the first rule are copied
to the second rule, my question is, is there a way to get rid of this
redundandance?
I have tried this with a rule flow, but the problem is, this always works on
the whole working memory, but I cant remove the not used objects from
working memory for performance reasons. Is there another way to solve this
problem?
Here is an example for what I intend to do:
Rule1:
when
customer:Customer(town=="London")
then
System.out.println(customer.getLname() + " is inhabitant of
London");
Rule2:
when
customer:Customer(town=="London",job=="TEACHER")
then
System.out.println(customer.getLname() + " is a teacher");
This example illustrates, with the first rule I want to get to know, how
many customers are from London and in the second rule I want to know, how
many of the London customers are teachers. I want to create a kind of
statistics. I have quite a lot of conditions for the first rule, so I dont
want to have them redundantly.
Greetings, Dominik
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
--
Vincent LEGENDRE
Consultant Sénior
EURODECISION
9A rue de la Porte de Buc 78000 VERSAILLES
Tél. : +33 (0)1 39 07 12 40
Direct : +33 (0)1 39 07 26 16
www.eurodecision.com
<
http://www.eurodecision.com/> EURODECISION