Hi Oana,

On 2/16/07, nicolae oana <[EMAIL PROTECTED]> 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
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to