Hi, I am trying to modify an unordered fact to store an average weight. I have the following rule to try and do this:
(defrule avgweight ;Give this rule with a high salience, so it always fires first (declare (salience 100)) ?aw <- (average-weight (averageweight ?X)) (LoadCellSensor1 (mass ?mass1)) (LoadCellSensor2 (mass ?mass2)) (LoadCellSensor3 (mass ?mass3)) (LoadCellSensor4 (mass ?mass4)) => (bind ?*totalweight* (+ ?mass1 ?mass2 ?mass3 ?mass4)) (bind ?*averageweight* (/ ?*totalweight* 4)) (bind ?*averageweight* (- ?*averageweight* 0.5)) (modify ?aw (averageweight ?*averageweight*)) (printout t "Total weight is: " ?*totalweight* ", and average weight is: " ?*averageweight* crlf) ) Which I interpreted as 'if any of the shadow facts are updated, and for any current value of the average-weight fact, recalculate the ?*averageweight* global and modify the average-weight fact with the new value'. Without the pattern match on the average-weight fact and subsequent modification, this rule seems to work fine, simply updating the global each time any of the shadow facts is updated. However, with the average-weight fact included as above, everything goes mad and this rule just seems to fire constantly! Am I performing the modification wrong? Thanks for all your help Greg -------------------------------------------------------------------- To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]' in the BODY of a message to [EMAIL PROTECTED], NOT to the list (use your own address!) List problems? Notify [EMAIL PROTECTED] --------------------------------------------------------------------