From: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Grimshaw, Jeffrey
Sent: 26 January 2007 16:34
To: Rules Users List
Subject: RE: [rules-users] RE: Why not retracting?Hi Michael. I've only been using JBoss Rules for about 2 weeks, so keep that in mind when reading my reply.The way I understand it works is that facts are evaluated against the LHS of all the rules in the ruleset as they are asserted. That is, when a fact is added to the WorkingMemory, the engine determines which rules apply to that fact. You may expect that evaluation to take place when the rules are "run". This may have something to do with the behavior you are seeing.For more info on what I'm talking about, see section 1.6.4.2 of the user docs.Cheers,--Jeff
From: rules-users-bounces@lists.jboss.org [mailto:rules-users-bounces@lists.jboss.org] On Behalf Of Anstis, Michael (M.)
Sent: Friday, January 26, 2007 8:08 AM
To: Rules Users List
Subject: [rules-users] RE: Why not retracting?By way of an update; if the retraction is made within a different Agenda Group the rules work as expected.
However the problem of the retraction having no obvious affect when operated within the same Agenda Group remains.
Is this a bug?
_____________________________________________
From: Anstis, Michael (M.)
Sent: 26 January 2007 11:32
To: 'Rules Users List'
Subject: Why not retracting?Hello,
I have the following rules; one removes "Prices" that do not have the required "Economic Level" from working memory, the other calculates a "Costs":-
rule "Cost - remove prices that do not have the required 'Economic Level'"
agenda-group "stamping-costs"
//salience 1
when
p : Price ( economicLevel != ( Utilities.makeDate(1, 1, 2007) ) )
then
System.out.println("Retracting "+p.toString());
retract(p);
endrule "Cost - calculate cost for 'Stamping process' on a process"
agenda-group "stamping-costs"
//salience 2
when
r : ResourceEntry ( m : machine )
//p : Price ( economicLevel == ( Utilities.makeDate(1, 1, 2007) ), machine == ( m ) )
p : Price ( machine == ( m ) )
then
Cost cost = new Cost(r, p);
cost.setCost((float) (r.getUsage() * p.getRate()));
assert(cost);
endThe problem is that the "Cost" rule still works upon ALL "Prices" (even those with an incorrect "Economic Level").
If I change the line in the "Cost" rule to also check the "Economic Level" the rules work as expected (i.e. "Costs" are only calculated using "Prices" with an "Economic Level" of 01/01/2007).
I've tried using "salience" levels too (as commented in the above Rules) but this doesn't have any effect either.
What am I doing wrong?
Cheers,
Mike