CLIPS LHS binding variables

bep*_*e95 5 planning iterative-deepening clips

I'm trying to write a CLIPS program which use the Iterative Deepening algorithm to solve a planning problem. For this same reason I would like to keep a low branching factor.

In the following code ?s is the variable which represent the level of the tree; I would like to use a single rule to make different checks. This is what I tried to do:

(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)
))
Run Code Online (Sandbox Code Playgroud)

Obviously it doesn't work. I'd like to use the boolean values of the single and's in the LHS to assert some facts into the RHS of the rule.

How can I do that? Any ideas?

Gar*_*ley 1

or条件元素的工作原理是为规则条件中的每个排列创建单独的规则。每个排列都使用原始规则的操作,因此在规则操作中找到的每个变量都必须出现在每个排列中。