[rules-users] Subclass match superclass problem.
nicolae oana
oananicolae1981 at yahoo.com
Fri Feb 16 12:15:15 EST 2007
Thanks Marcus for your response.
But it isn't the case for my problem.
To add a new condition like that don't solve anything in my case. Imagine we have 10 classes like ConvertibleCar. What we do then?
Regards,
Oana
Marcus Ilgner <marcus.ilgner at gmail.com> wrote: Hi Oana,
On 2/16/07, nicolae oana wrote:
> Hi everybody,
>
> I have a class Car which is superclass for class ConvertibleCar, two rules
> (described below) and a ConvertibleCar fact in working memory that causes
> both rules to fire, resulting this way an unwanted change to the car`s
> attribute and an infinite loop.
>
> How do I evitate this problem: the specialization class fact to not match
> its superclass column in a rule?
>
> ConvertibleCar car =new ConvertibleCar(10000);
>
> rule "rule-1"
> when
> $car:Convertible()
> then
> $car.setPotentialTheftRating("high");
> end
>
> rule "rule-2"
> when
> $car:Car(price<20000)
> then
> $car.setPotentialTheftRating("low");
> end
>
> Best regards, Oana
>
I'd say that this behaviour is correct in principle. If you want to
avoid this, you could add further constraints in the rules concerning
the superclass:
rule "rule-2"
when
$car:Car(price<20000, class != Convertible.class)
then
$car.setPotentialTheftRating("low");
end
I'm not sure if this works exactly like that (don't have a Drools
installation at hand), but I guess you get the idea.
Best regards
Marcus
_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
---------------------------------
The fish are biting.
Get more visitors on your site using Yahoo! Search Marketing.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070216/a0a94dae/attachment.html
More information about the rules-users
mailing list