0
我想用在LHS约束变量来声明一个规则的显着性,以便与事实数据库中定义的更严格的时间限制,优先规则。我想下面应该工作:在显着性声明中使用变量在规则定义
(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))
但这种失败与错误:
[EVALUATN1] Variable a is unbound
[PRCCODE6] This error occurred while evaluating arguments for the deffunction testsal.
[PRNTUTIL8] This error occurred while evaluating the salience for defrule testr.
ERROR:
(defrule MAIN::testr
(declare (salience (testsal ?a 4)
是否有使用绑定在LHS在规则的显着性声明一个变量的方法吗?
如果不是,根据事实库中的一些事实确定优先级的常用方法是什么?请注意,我不想禁止规则触发,我只想优先考虑其他规则,所以只需向LHS添加约束条件可能无效。
但我不能做的显着性取决于规则的接地,可以吗?我的目标是制定一个可以通过两个不同的基础来激活的规则,并且我想优先考虑一个。 – morxa
您可以在模式中绑定全局值:(sal?a&:(bind?* sal-a *?a))。但是,为了使其正常工作,每个规则都必须有自己的全局变量。 –