clips - Using variables in salience declaration in a rule definition -
i want use variable bound in lhs declare salience of rule in order prioritize rules stricter time limit defined in fact database. figured following should work:
(set-salience-evaluation when-activated) (deffunction testsal (?a ?b) (integer (+ ?a ?b))) (defrule testr (declare (salience (testsal ?a 4))) (sal ?a) ?tf <- (fire testr) => (printout t "running testr") (retract ?tf) ) (assert (sal 3)) (assert (fire testr))
but fails error:
[evaluatn1] variable unbound [prccode6] error occurred while evaluating arguments deffunction testsal. [prntutil8] error occurred while evaluating salience defrule testr. error: (defrule main::testr (declare (salience (testsal ?a 4)
is there way use variable bound in lhs in salience declaration of rule?
if not, common way prioritize depending on facts in fact base? note not want disallow rule fire, want prioritize other rules, adding constraint lhs not work.
use global variable rather fact:
clips> (set-salience-evaluation when-activated) when-activated clips> (defglobal ?*sal-a* = 0) clips> (defrule testr (declare (salience (+ ?*sal-a* 4))) ?tf <- (fire testr) => (printout t "running testr") (retract ?tf)) clips> (bind ?*sal-a* 3) 3 clips> (assert (fire testr)) <fact-1> clips> (agenda) 7 testr: f-1 total of 1 activation. clips>
Comments
Post a Comment