[rules-users] Why not retracting?

Anstis, Michael (M.) manstis1 at ford.com
Fri Jan 26 06:32:22 EST 2007


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/e63643f6/attachment.html 


More information about the rules-users mailing list