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)
))
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?
The or conditional element works by creating separate rules for each permutation in the conditions of the rule. The actions of the original rule are used by each permutation, so every variable found in the actions of the rule must be present in each permutation.