更新的代码:
在哪里添加?f<-(practice-is-on-off OFF)
(defrule no-practice "Rules for when practice cannot be held"
(or ?f <- (practice (number-of-paddlers ?p&:(< ?p 6)))
?f <- (practice (number-of-coaches ?c&:(< ?c 1))))
=>
(modify ?f (practice-is-on-off OFF)))
;end
我在CLIPS中定义了一个模板,我正在使用逻辑运算符OR。 但是,当我加载模板时,它会抛出错误
[TMPLTDEF1] Invalid slot or not defined in corresponding deftemplate practice.
ERROR:
(defrule MAIN::no-practice "Rules for when practice cannot be held"
?f <- (practice (or
这就是我所拥有的: 提前感谢任何见解。感谢
(deftemplate practice "structure of a practice"
(slot number-of-paddlers (type NUMBER))
(slot number-of-coaches (type NUMBER))
(slot practice-is-on-off (type SYMBOL) (default ON))
(slot practice-id (type NUMBER))
)
(defrule no-practice "Rules for when practice cannot be held"
?f <- (practice
(or
(number-of-paddlers
?v_number-of-paddlers&:(
< ?v_number-of-paddlers 6))
(number-of-coaches
?v_number-of-coaches&:(
< ?v_number-of-coaches 1))
)
)
=>
(modify ?f (practice-is-on-off OFF)
)
)
答案 0 :(得分:0)
错误告诉您正在尝试匹配practice
deftemplate中名为“或”的插槽,并且该插槽不存在。以下是“无实践”规则的两个备用版本,它们将完成您要执行的操作。:
版本1:
(defrule no-practice "Rules for when practice cannot be held"
(or ?f <- (practice (practice-is-on-off ON)
(number-of-paddlers ?p&:(< ?p 6)))
?f <- (practice (practice-is-on-off ON)
(number-of-coaches ?c&:(< ?c 6))))
=>
(modify ?f (practice-is-on-off OFF)))
请注意,上述规则可能会针对practice
触发两次,除非您还检查CE中practice-is-on-off
是否为“ON”。
第2版:
(defrule no-practice "Rules for when practice cannot be held"
?f <- (practice (practice-is-on-off ON)
(number-of-paddlers ?p) (number-of-coaches ?c))
(test (or (< ?p 6) (< ?c 6)))
=>
(modify ?f (practice-is-on-off OFF)))