Chapter-1-Introduction-to-Expert-Systems1章介绍了专家系统课件

上传人:风*** 文档编号:240607006 上传时间:2024-04-24 格式:PPT 页数:47 大小:745KB
收藏 版权申诉 举报 下载
Chapter-1-Introduction-to-Expert-Systems1章介绍了专家系统课件_第1页
第1页 / 共47页
Chapter-1-Introduction-to-Expert-Systems1章介绍了专家系统课件_第2页
第2页 / 共47页
Chapter-1-Introduction-to-Expert-Systems1章介绍了专家系统课件_第3页
第3页 / 共47页
资源描述:

《Chapter-1-Introduction-to-Expert-Systems1章介绍了专家系统课件》由会员分享,可在线阅读,更多相关《Chapter-1-Introduction-to-Expert-Systems1章介绍了专家系统课件(47页珍藏版)》请在装配图网上搜索。

1、Chapter 8:Advanced Pattern MatchingExpert Systems:Principles and Programming,Fourth EditionExpert Systems:Principles and Programming,Fourth Edition2Field ConstraintsIn addition to pattern matching capabilities and variable bindings,CLIPS has more powerful pattern matching operators.Consider writing

2、a rule for all people who do not have brown hair:We could write a rule for every type of hair color that is not brown.This involves testing the condition in a roundabout manner tedious,but effective.Expert Systems:Principles and Programming,Fourth Edition3Field ConstraintsThe technique for writing a

3、 rule for all non-brown hair colors implies that we have the ability to supply all hair colors virtually impossible.An alternative is to use a field constraint to restrict the values a field may have on the LHS the THEN part of the rule.Expert Systems:Principles and Programming,Fourth Edition4Connec

4、tive ConstraintsConnective constraints are used to connect variables and other constraints.Not connective the acts on the one constraint or variable that immediately follows it.Or constraint the symbol|is used to allow one or more possible values to match a field or a pattern.And constraint the symb

5、ol&is useful with binding instances of variables and on conjunction with the not constraint.Expert Systems:Principles and Programming,Fourth Edition5Combining Field ConstraintsField constraints can be used together with variables and other literals to provide powerful pattern matching capabilities.E

6、xample#1:?eyes1&blue|greenThis constraint binds the persons eye color to the variable,?eyes1 if the eye color of the fact being matched is either blue or green.Example#2:?hair1&blackThis constraint binds the variable?hair1 if the hair color of the fact being matched is not black.Expert Systems:Princ

7、iples and Programming,Fourth Edition6Functions and ExpressionsCLIPS has the capability to perform calculations.The math functions in CLIPS are primarily used for modifying numbers that are used to make inferences by the application program.Expert Systems:Principles and Programming,Fourth Edition7Num

8、eric Expressions in CLIPSNumeric expressions are written in CLIPS in LISP-style using prefix form the operator symbol goes before the operands to which it pertains.Example#1:5+8(infix form)+5 8(prefix form)Example#2:(infix)(y2 y1)/(x2 x1)0(prefix)(/(-y2 y1)(-x2 x1)0)Expert Systems:Principles and Pro

9、gramming,Fourth Edition8Return ValuesMost functions(addition)have a return value that can be an integer,float,symbol,string,or multivalued value.Some functions(facts,agenda commands)have no return values just side effects.Division results are usually rounded off.Return values for+,-,and*will be inte

10、ger if all arguments are integer,but if at least one value is floating point,the value returned will be float.Expert Systems:Principles and Programming,Fourth Edition9Variable Numbers of ArgumentsMany CLIPS functions accept variable numbers of arguments.Example:CLIPS(-3 5 7)returns 3-5=-2-7=-9There

11、is no built-in arithmetic precedence in CLIPS everything is evaluated from left to right.To compensate for this,precedence must be explicitly written.Expert Systems:Principles and Programming,Fourth Edition10Embedding ExpressionsExpressions may be freely embedded within other expressions:Expert Syst

12、ems:Principles and Programming,Fourth Edition11Summing Values Using RulesSuppose you wanted to sum the areas of a group of rectangles.The heights and widths of the rectangles can be specified using the deftemplate:(deftemplate rectangle(slot height)(slot width)The sum of the rectangle areas could be

13、 specified using an ordered fact such as:(sum 20)Expert Systems:Principles and Programming,Fourth Edition12Summing ValuesA deffacts containing sample information is:(deffacts initial-information(rectangle(height 10)(width 6)(rectangle(height 7)(width 5)(rectangle(height 6)(width 8)(rectangle(height

14、2)(width 5)(sum 0)Expert Systems:Principles and Programming,Fourth Edition13Summing ValuesExpert Systems:Principles and Programming,Fourth Edition14The Bind FunctionSometimes it is advantageous to store a value in a temporary variable to avoid recalculation.The bind function can be used to bind the

15、value of a variable to the value of an expression using the following syntax:(bind )Expert Systems:Principles and Programming,Fourth Edition15I/O FunctionsWhen a CLIPS program requires input from the user of a program,a read function can be used to provide input from the keyboard:Expert Systems:Prin

16、ciples and Programming,Fourth Edition16Read Function from KeyboardThe read function can only input a single field at a time.Characters entered after the first field up to the are discarded.To input,say a first and last name,they must be delimited with quotes,“xxx xxx”.Data must be followed by a carr

17、iage return to be read.Expert Systems:Principles and Programming,Fourth Edition17I/O from/to FilesInput can also come from external files.Output can be directed to external files.Before a file can be accessed,it must be opened using the open function:Example:(open“mydata.dat”data“r”)mydata.dat is th

18、e name of the file(path can also be provided)Expert Systems:Principles and Programming,Fourth Edition18I/O from/to Filesdata is the logical name that CLIPS associates with the file“r”represents the mode how the file will be used here read accessThe open function acts as a predicate functionReturns t

19、rue if the file was successfully openedReturns false otherwiseExpert Systems:Principles and Programming,Fourth Edition19Table 8.2 File Access ModesExpert Systems:Principles and Programming,Fourth Edition20Close FunctionOnce access to the file is no longer needed,it should be closed.Failure to close

20、a file may result in loss of information.General format of the close function:(close)(close data)exampleExpert Systems:Principles and Programming,Fourth Edition21Reading/Writing to a FileWhich logical name used,depends on where information will be written logical name t refers to the terminal(standa

21、rd output device).Expert Systems:Principles and Programming,Fourth Edition22FormattingOutput sent to a terminal or file may need to be formatted enhanced in appearance.To do this,we use the format function which provides a variety of formatting styles.General format:(format *)Expert Systems:Principl

22、es and Programming,Fourth Edition23FormattingLogical name t standard output device;or logical name associated with a file.Control string:Must be delimited with quotesConsists of format flags to indicate how parameters should be printed1 1 correspondence between flags and number of parameters constan

23、t values or expressionsReturn value of the format function is the formatted string nil can be used to suppress printing.Expert Systems:Principles and Programming,Fourth Edition24FormattingExample:(format nil“Name:%-15s Age:%3d”“Bob Green”35)Produces the results:“Name:Bob green Age:35”Expert Systems:

24、Principles and Programming,Fourth Edition25Specifications of Format Flag%-m.NxThe“-”means to left justify(right is the default)M total field width no truncation occursN number of digits of precision default=6x display format specificationExpert Systems:Principles and Programming,Fourth Edition26Tabl

25、e 8.3 Display Format SpecificationsExpert Systems:Principles and Programming,Fourth Edition27Readline FunctionTo read an entire line of input,the readline function can be used:(readline)Example:(defrule get-name=(printout t“What is your name?“(bind?response(readline)(assert(users-name?response)Exper

26、t Systems:Principles and Programming,Fourth Edition28Predicate FunctionsA predicate function is defined to be any function that returns:TRUEFALSEAny value other than FALSE is considered TRUE.We say the predicate function returns a Boolean value.Expert Systems:Principles and Programming,Fourth Editio

27、n29The Test Conditional ElementProcessing of information often requires a loop.Sometimes a loop needs to terminate automatically as the result of an arbitrary expression.The test condition provides a powerful way to evaluate expressions on the LHS of a rule.Rather than pattern matching against a fac

28、t in a fact list,the test CE evaluates an expression outermost function must be a predicate function.Expert Systems:Principles and Programming,Fourth Edition30Test ConditionA rule will be triggered only if all its test CEs are satisfied along with other patterns.(test)Example:(test(?value 1)Expert S

29、ystems:Principles and Programming,Fourth Edition31Predicate Field ConstraintThe predicate field constraint:allows for performing predicate tests directly within patterns.The predicate field constraint is more efficient than using the test CE.It can be used just like a literal field constraint by its

30、elf or part of a complex field.The predicate field constraint is always followed by a function for evaluation(predicate function).Expert Systems:Principles and Programming,Fourth Edition32Return Value ConstraintThe return value constraint=allows the return value of a function to be used for comparis

31、on inside a pattern.The return value constraint must be followed by a function(not necessarily a predicate function).The function must have a single-field return value.Expert Systems:Principles and Programming,Fourth Edition33The OR Conditional ElementConsider the two rules:Expert Systems:Principles

32、 and Programming,Fourth Edition34OR Conditional ElementThese two rules can be combined into one rule or CE requires only one CE be satisfied:Expert Systems:Principles and Programming,Fourth Edition35The And Conditional ElementThe and CE is opposite in concept to the or CE requiring all the CEs be sa

33、tisfied:Expert Systems:Principles and Programming,Fourth Edition36Not Conditional ElementWhen it is advantageous to activate a rule based on the absence of a particular fact in the list,CLIPS allows the specification of the absence of the fact in the LHS of a rule using the not conditional element:E

34、xpert Systems:Principles and Programming,Fourth Edition37Not ConditionalWe can implement this as follows:Expert Systems:Principles and Programming,Fourth Edition38The Exists Conditional ElementThe exists CE allows one to pattern match based on the existence of at least one fact that matches a patter

35、n without regard to the total number of facts that actually match the pattern.This allows a single partial match or activation for a rule to be generated based on the existence of one fact out of a class of facts.Expert Systems:Principles and Programming,Fourth Edition39Exists ConditionalExpert Syst

36、ems:Principles and Programming,Fourth Edition40ExistsWhen more than one emergency fact is asserted,the message to the operators is printed more than once.The following modification prevents this:Expert Systems:Principles and Programming,Fourth Edition41ExistsThis assumes there was already an alert t

37、riggered by an operator-emergency rule.What if the operators were merely placed on alert to a drill:Expert Systems:Principles and Programming,Fourth Edition42ExistsNow consider how the rule has been modified using the exists CE:(defrule operator-alert-for-emergency(exists(emergency)(not (operator-al

38、ert)=(printout t“Emergency:Operator Alert”crlf)(assert(operator-alert)Expert Systems:Principles and Programming,Fourth Edition43Forall/LogicalConditional ElementsThe forall CE allows one to pattern match based on a set of CEs that are satisfied for every occurrence of another CE.The logical CE allow

39、s one to specify that the existence of a fact depends on the existence of another fact or group of facts.Expert Systems:Principles and Programming,Fourth Edition44SummaryWe have introduced the concept of field constraints not,and,and or.Functions are entered into CLIPS top-level command loop or are

40、used on the LHS or RHS of a rule.Many functions have variable number of argumentsFunction calls can be nested w/in other function callsExpert Systems:Principles and Programming,Fourth Edition45SummaryCLIPS provides several I/O functions.Open/closePrintout/read/readlineFormatVarious concepts for controlling the flow of execution are availableAlso included in the discussion were the following CEs:Test,And,Or,Exists,Forall,and logical谢谢你的阅读v知识就是财富v丰富你的人生

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!