首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CLIPS LHS绑定变量

CLIPS LHS绑定变量
EN

Stack Overflow用户
提问于 2018-07-13 10:50:44
回答 1查看 428关注 0票数 5

我试图编写一个CLIPS程序,它使用迭代深化算法来解决规划问题。出于同样的原因,我想保持一个较低的分支系数。

在下面的代码中,?s是表示树级别的变量;我想使用单个规则进行不同的检查。这就是我想做的:

代码语言:javascript
复制
(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中断言一些事实。

我怎么能这么做?有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-07-13 21:01:27

条件元素通过在规则的条件下为每个置换创建单独的规则来工作。每个置换都使用原始规则的操作,因此在规则的操作中找到的每个变量都必须存在于每个置换中。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51323444

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档