0
更新代码: 在哪里添加支票?f<-(practice-is-on-off OFF)
如何做一个逻辑或在CLIPS?
(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)
)
)
谢谢@bogatron。我喜欢版本1.但是,当我这样做时,它导致规则进入无限循环。我试着把一个检查'?f < - (练习(练习是开关ON))'......但我迷失在它的语法中......你能结合使用AND和OR逻辑在CLIPS中的相同规则?非常感谢您的帮助! – engr007 2013-04-26 02:14:39
除非你还检查CE上的练习开关是否为“开”.....什么是CE?我怎么能做到这一点...这就是我在上述问题中所提到的问题。我想我错过了你的笔记。再次感谢@ bogatron。 – engr007 2013-04-26 02:16:24
CE =“条件元素” - 它只是规则中“if”部分的前提之一。为了检查ON/OFF,你可能想修改你的'练习匹配语句就像'(练习(paddlers?p&:(<?p 6))(练习开关ON) 。我会修改我的答案,加上这个。 – bogatron 2013-04-26 02:44:15