CLIPS重点.doc

上传人:土8路 文档编号:10014099 上传时间:2021-04-10 格式:DOC 页数:5 大小:25.50KB
返回 下载 相关 举报
CLIPS重点.doc_第1页
第1页 / 共5页
CLIPS重点.doc_第2页
第2页 / 共5页
CLIPS重点.doc_第3页
第3页 / 共5页
CLIPS重点.doc_第4页
第4页 / 共5页
CLIPS重点.doc_第5页
第5页 / 共5页
亲,该文档总共5页,全部预览完了,如果喜欢就下载吧!
资源描述

《CLIPS重点.doc》由会员分享,可在线阅读,更多相关《CLIPS重点.doc(5页珍藏版)》请在三一文库上搜索。

1、Clips 图形化界面开发的重点CLIPS的程序一般包含有规则,事实和对象。推理机决定了哪条规则应该被执行和在什么时候被执行。一个用CLIPS写成的基于规则库的专家系统程序是一个数据-驱动型程序,程序里的事实,对象数据通过推理机的激活执行。1:对简单事实非模板事实的支持,随意化非模板化事实的支持。(所有的简单的事实经过归纳都可以模板化,后者形式上更工整,更严格)一个简单事实的例子(duck)(hunter-game duck Brian)2:对简单规则的推理支持 (重点)(defrule duck(animal-is duck)=(assert (sound-is quack)3:对规则出现的

2、变量的支持。?sound代表变量。(重点) (defrule make-quack(duck-sound ?sound)=(assert (sound-is ?sound)4:clips中的模板的支持和处理。模板可以看着c中的结构体。其中的重点是对数据类型,取值范围的限定。Clips中模板的一个例子 (重点)(deftemplate prospect;自定义模板关系名“vital information”;可选注释(slot name;字段名(type STRING);字段类型(default ?DERIVE);字段“名字”的默认值(slot assets(type SYMBOL)(defau

3、lt rich)(slot age(type NUMBER); NUMBER类型可以是整型INTEGER或浮点型FLOAT(default 80)5:对测试条件的支持。对输入的判断测试。(重点)测试条件元素用(test ( ?mark 80)这种方式下例判断所有比80高的成绩是好成绩(defrule is-good(mark ?mark)(test ( ?mark 80)=(printout t good! crlf)6:CLIPS关系运算的支持AND OR NOT条件元素的支持(重点)(defrule num-test?number ?num 99)(retract ?number)(pri

4、ntout t yes crlf)7:CLIPS-forall条件元素和exists条件元素。(重点)forall,表示每次出另一个CE时,一组CE被满足的情况。格式如下(forall+),为使forallCE得到满足,每个匹配的事实必须匹配所有事实。exists,表示至少存在一个事实与某模式匹配,而不管实际匹配该模式的事实总数。(defrule test-number(forall (number ?num)(test (= ?num 0)=(printout t OK crlf)8:对logical支持,表示一条事实依赖其他的事实,一旦所依赖的事实不存在,则某事实也相应从事实库中删除。(重

5、点)CLIPS (Quicksilver Beta 09/24/07)CLIPS (deftemplate student-skill(slot no)(slot skill)CLIPS (deftemplate student-mark(slot no)(slot mark)CLIPS (defrule goodstudentskill(logical (student-skill (no ?no)(skill?skill)(test (eq ?skill good)=(assert (good-student-no ?no)CLIPS (defrule goodstudentmark(lo

6、gical (student-mark (no ?no)(mark ?mark)(test( ?mark 90)=(assert (good-student-no ?no)9:对字段的约束。和test约束作用,但是写法更简洁。&表示对变量的与约束|表示或表示非。下操作查出与两个人,第一个人有绿眼睛或蓝眼睛,头发不是黑色,第二人与第一人名字不一样,眼睛不一样,但头发一样或为红色(defrule persons-match(person (name ?name1) (eye?eye1&blue|green) (hair?hair1&black)(person (name?name2&?name1)

7、 (eye ?eye2&eye1)(hair ?hair2&red|?hair1)=(printout t ?name1 has ?eye1 eyes and ?hair1 hair crlf)(printout t ?name2 has ?eye2 eyes and ?hair2 hair crlf)10. 对变量绑定的支持。绑定的目的是绑定后进行变量赋值。(重点)(defrule MAIN:sum-areas?sum - (sum?total)?new-area (retract ?sum ?new-area)(bind ?total-area (+ ?total?area)(printo

8、ut t total= ?total+ ?area = ?total-area crlf)(assert (sum?total-area)11. 对事实撤销的支持。可以随时撤销一个事实。和事实绑定一起使用(重点)(defrule MAIN:sum-areas?sum - (sum?total) ;绑定事实area (retract ?sum ?new-area);撤销事实12.对规则优先级支持l (declare (salience20)声明了规则的优先级,数字越大优先级越高l 在规则同等优先级的情况下,事实按照堆栈的要求处理,后进先出/相同优选级的处理CLIPS (defrule first

9、(first first)=(printout t second crlf)CLIPS (defrule second(second second)=(printout t third crlf)CLIPS (assert (firstfirst)(second second)CLIPS (run)thirdsecond/下面的规则的优先级优先级不同CLIPS (defrule first(declare (salience 20)(first first)=(printout t secondcrlf)CLIPS (defrule second(declare (salience 10)(secondsecond)=(printout t thirdcrlf)CLIPS (run)CLIPS (assert (first first)(second second)CLIPS (run)secondthird

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 社会民生


经营许可证编号:宁ICP备18001539号-1