Oana,
Although your example used a superclass/subclass relationship, the
problem is not due to that relationship, You could just as well have
written two CAR rules :
"if a car's price is <20000, then risk of theft is low"
"if a car has the stealth radar avoidance option, then risk of theft
is high"
You might be upset by the infinite loop, but there is no way to know how
you would like to assess the theft risk of a car that satisfies BOTH
conditions.
Here are two ways you might deal with this.
a) maybe neither of these conditions is really sufficient to determine
the theft risk, but simply to influence that risk. The "then" part of
the rule should just increment/decrement a value the accumulates the net
risk. But don't have the increment/decrement also tell drools that the
CAR was modified.
b) maybe the rules are TOTALLY ORDERED in your analytical model, and the
first rule that applies is the only one that matters. You can use
SALIENCE in drools to capture ordering. If all the rules are in a single
activation group, then only the highest salience match will actually run
(at least, that is my understanding). Again, you must not tell drools
that the CAR has been modified just because you set its theft
assessment.
_____
From: rules-users-bounces(a)lists.jboss.org
[mailto:rules-users-bounces@lists.jboss.org] On Behalf Of nicolae oana
Sent: Friday, February 16, 2007 2:11 AM
To: rules-users(a)lists.jboss.org
Subject: [rules-users] Subclasses matche superclasses problem.
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
_____
The fish are biting.
Get more visitors
<
http://us.rd.yahoo.com/evt=49679/*http://searchmarketing.yahoo.com/arp/
sponsoredsearch_v2.php?o=US2140&cmp=Yahoo&ctv=Q107Tagline&s=Y&s2=EM&b=50
on your site using Yahoo! Search Marketing.
<
http://us.rd.yahoo.com/evt=49679/*http://searchmarketing.yahoo.com/arp/
sponsoredsearch_v2.php?o=US2140&cmp=Yahoo&ctv=Q107Tagline&s=Y&s2=EM&b=50