[rules-users] RE: Why not retracting?
Anstis, Michael (M.)
manstis1 at ford.com
Fri Jan 26 11:08:10 EST 2007
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);
> end
>
> rule "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);
> end
>
> The 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20070126/4c461681/attachment.html
More information about the rules-users
mailing list