我试图编写一个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)
))很明显这不管用。我想使用LHS中单个and的布尔值来向规则的RHS中断言一些事实。
我怎么能这么做?有什么想法吗?
发布于 2018-07-13 21:01:27
或条件元素通过在规则的条件下为每个置换创建单独的规则来工作。每个置换都使用原始规则的操作,因此在规则的操作中找到的每个变量都必须存在于每个置换中。
https://stackoverflow.com/questions/51323444
复制相似问题