衝 !
Archive for the ‘Clips’ Category
CLIPS Review
Posted in Clips on May 28, 2006 | No Comments »
Expert System 筆記
(1)定義樣板
(deftemplate 名稱 (slot 名) (multislot 名))
ex: (deftemplate stu (slot id) (multislot name))
(2)定義規則範例
(defrule 名稱
?f<-(student tarono)
;這是註解,把某個fact的位址bind到?f
=>
(retract ?f)
;撤除此條fact
(assert (student abc))
)
(defrule r1
?f <-(student ?id)
?f2<-(stu_info (id ?id) (father ?f) (mother ?m))
;?id bind 上面那條規則的?id
=>
…..
)
(defrule r2
?f <-(student ?id)
(test (eq ?id 91610043))
; field constraint 測試 ?id 是否為 91610043
=>
….
)
註: eq 適用於各種型態的測試(symbol string number)
其他還有 neq , > , < , = , [...]