CLIPS 条件规则
CLIPS conditional rule
如何在 CLIPS 中创建条件规则来查找输出
例如
(deftemplate holiday
(slot hotel (allowed-symbols nice good poor))
(slot weather (allowed-symbols sunny raining))
)
(deftemplate output
(slot option (allowed-symbols go plan stay))
)
有了这个,我们如何创建像
这样的规则
if hotel = poor then stay
if hotel = poor and weather = raining then stay
if (hotel = poor and weather = sunny) or (hotel = good and weather = raining) then plan
谢谢
(defrule hotel-rule1
(holiday (hotel ?hotel&:(eq ?hotel poor)))
=>
(assert (output (option stay)))
)
(defrule hotel-rule2
(holiday (hotel ?hotel&:(eq ?hotel poor)) (weather ?weather&:(eq ?weather raining)))
=>
(assert (output (option stay)))
)
我会把你最后一条规则的 "or" 条件分成两条不同的规则,类似于我写的例子。
再见
尼克
如何在 CLIPS 中创建条件规则来查找输出
例如
(deftemplate holiday
(slot hotel (allowed-symbols nice good poor))
(slot weather (allowed-symbols sunny raining))
)
(deftemplate output
(slot option (allowed-symbols go plan stay))
)
有了这个,我们如何创建像
这样的规则if hotel = poor then stay
if hotel = poor and weather = raining then stay
if (hotel = poor and weather = sunny) or (hotel = good and weather = raining) then plan
谢谢
(defrule hotel-rule1
(holiday (hotel ?hotel&:(eq ?hotel poor)))
=>
(assert (output (option stay)))
)
(defrule hotel-rule2
(holiday (hotel ?hotel&:(eq ?hotel poor)) (weather ?weather&:(eq ?weather raining)))
=>
(assert (output (option stay)))
)
我会把你最后一条规则的 "or" 条件分成两条不同的规则,类似于我写的例子。
再见 尼克