我正在尝试编写一个使用迭代深化算法来解决规划问题的 CLIPS 程序。出于同样的原因,我想保持较低的分支因子。
在下面的代码?s
中是代表树级别的变量;我想使用一个规则来进行不同的检查。这就是我试图做的:
(defrule EXPAND::action
(declare (salience ?*load*))
(or
(and ?f1_a <- (status ?s transport ?c1&:(> ?c1 0) ?id1)
?f1_b <- (status ?s city ?q1&:(> ?q1 0) ))
(and ?f2_a <- (status ?s transport ?c2 ?id2)
?f2_b <- (status ?s city ?q2_a ?obj2)
?f2_c <- (status ?s carries ?id2 ?q2_b ?obj2))
(and ?f3_a <- (status ?s transport ?c3 ?id3)
?f3_b <- (status ?s city ?l3_a $?x3)
?f3_c <- (status ?s city ?l3_b $?y3)
?f3_d <- (distance ?l3_a ?d3 ?l3_b ?t3))
(test (neq (str-compare ?l3_a ?l3_b) 0))
)
=>
(if (and (fact-existp ?f1_a) (fact-existp ?f1_b))
then (assert bla1))
(if (and ?f2_a ?f2_b ?f2_c)
then (assert bla2))
(if (and ?f3_a ?f3_b ?f3_c ?f3_d)
then (assert bla3)
))
显然它不起作用。我想使用and
LHS 中单个 's 的布尔值将一些事实断言到规则的 RHS 中。
我怎样才能做到这一点?有任何想法吗?