Без темы
<<  Internship in Siberia Introducing ISO-IEC 17067:2013  >>
Intro to CLIPS Paula Matuszek CSC 9010, Spring, 2011
Intro to CLIPS Paula Matuszek CSC 9010, Spring, 2011
CLIPS History
CLIPS History
What is it
What is it
Versions of CLIPS
Versions of CLIPS
CLIPS Components
CLIPS Components
CLIPS Facts
CLIPS Facts
Valid Facts
Valid Facts
Adding Facts
Adding Facts
Retracting Facts
Retracting Facts
Rules
Rules
Rules Format
Rules Format
Rules Example
Rules Example
Initial-fact
Initial-fact
The Agenda
The Agenda
Agenda Example
Agenda Example
Starting CLIPS
Starting CLIPS
Some Basic CLIPS Commands
Some Basic CLIPS Commands
More Basic CLIPS Commands
More Basic CLIPS Commands
“Hello World” in CLIPS
“Hello World” in CLIPS
To Make It Run
To Make It Run
To Make It Run
To Make It Run
IDE
IDE
SNOW Example
SNOW Example

Презентация на тему: «Intro to CLIPS Paula Matuszek CSC 9010, Spring, 2011». Автор: Paula A Matuszek. Файл: «Intro to CLIPS Paula Matuszek CSC 9010, Spring, 2011.ppt». Размер zip-архива: 46 КБ.

Intro to CLIPS Paula Matuszek CSC 9010, Spring, 2011

содержание презентации «Intro to CLIPS Paula Matuszek CSC 9010, Spring, 2011.ppt»
СлайдТекст
1 Intro to CLIPS Paula Matuszek CSC 9010, Spring, 2011

Intro to CLIPS Paula Matuszek CSC 9010, Spring, 2011

01/12/2011

Knowledge-Based Systems, Paula Matuszek

1

2 CLIPS History

CLIPS History

CLIPS = C Language Integrated Production System Developed at NASA in the 1980s C was used as implementation language (because of restricted availability of LISP compilers and problems of integration LISP-code with non-LISP applications) Initial version: a production rule interpreter. This is what we will use. Extensions include COOL: CLIPS Object-Oriented Language JESS: Java Expert Systems Shell Fuzzy Clips: Fuzzy logic, for capturing uncertainty

01/12/2011

Knowledge-Based Systems, Paula Matuszek

2

3 What is it

What is it

Classic Rule-Based Expert System shell Core is facts and rules Inference is forward chaining using the RETE algorithm Multiple conflict resolution strategies Advantages: Written in C; portable, embeddable, fast Public domain, readily available Easy to set up, low initial effort

01/12/2011

Knowledge-Based Systems, Paula Matuszek

3

4 Versions of CLIPS

Versions of CLIPS

CLIPS is written in C => CLIPS is portable => there are different versions that run on different platforms: mac, unix, windows. Latest released version 6.24 can be downloaded from the CLIPS web site for Windows and OS X. There is a beta version 6.30, but we are not going to use it. Feel free to explore it if you wish. Download from http://clipsrules.sourceforge.net/

01/12/2011

Knowledge-Based Systems, Paula Matuszek

4

5 CLIPS Components

CLIPS Components

A basic CLIPS program has three primary components: Facts Rules Agenda Facts represent information about the state of the world. Rules represent things to do with/about facts.

01/12/2011

Knowledge-Based Systems, Paula Matuszek

5

6 CLIPS Facts

CLIPS Facts

Facts are what CLIPS believes to be true. The simplest form of a fact is a single string. (snowing) (“January 11”) An ordered fact is a list of one or more strings: (snowing “January 11”)

01/12/2011

Knowledge-Based Systems, Paula Matuszek

6

7 Valid Facts

Valid Facts

Examples of valid ordered facts (single-field) (two fields) (speed 38 mph) (cost 78 dollars 23 cents) (name “John Doe”)

01/12/2011

Knowledge-Based Systems, Paula Matuszek

7

8 Adding Facts

Adding Facts

Putting facts into the CLIPS fact base is done by asserting. CLIPS> (assert(snowing)) <Fact-1> This is the fact index. CLIPS> (assert(snowing Jan11)) <Fact-2> You can also ask CLIPS what facts it knows. CLIPS> (facts) f-0 (initial-fact) f-1 (snowing) f-2 (snowing Jan11) For a total of 3 facts. CLIPS>

01/12/2011

Knowledge-Based Systems, Paula Matuszek

8

9 Retracting Facts

Retracting Facts

Facts can be removed or retracted using (retract <fact-index>) CLIPS> (retract 1) CLIPS> (facts) f-0 (initial-fact) f-2 (snowing Jan11) For a total of 2 facts. CLIPS> Retract can be used for more than one fact CLIPS> (retract 0 2) CLIPS> (facts) CLIPS>

01/12/2011

Knowledge-Based Systems, Paula Matuszek

9

10 Rules

Rules

Rules in CLIPS are forward chaining production rules. LHS = Left Hand Side = IF = triggers RHS = Right Hand side = THEN = actions So a rule has a set of triggers; when they are true that rule is activated. When a rule is fired the actions take place. Conflict resolution determines which of the activated rules actually fires.

01/12/2011

Knowledge-Based Systems, Paula Matuszek

10

11 Rules Format

Rules Format

LHS => RHS Syntax: (defrule <rule-name> [<comment>] [<declaration>] ; salience <patterns>* ;LHS, premises, patterns, ;conditions, antecedent => <actions>*) ;RHS, actions, consequent

01/12/2011

Knowledge-Based Systems, Paula Matuszek

11

12 Rules Example

Rules Example

Example: (defrule snowing (snowing hard) => (assert(cancel class))) Rules can have more than one pattern/premise: (defrule travel-bad (SEPTA no) (traffic horrible) => (assert(cancel class)))

01/12/2011

Knowledge-Based Systems, Paula Matuszek

12

13 Initial-fact

Initial-fact

CLIPS has a special fact, initial-fact. It is asserted by the system and can be used to initiate inference when no other facts are known. A rule with no specified LHS will activate when initial-fact is true.

01/12/2011

Knowledge-Based Systems, Paula Matuszek

13

14 The Agenda

The Agenda

More than one rule may be activated at one time; CLIPS keeps all activated rules on an agenda. Conflict resolution chooses which to fire. In each cycle one rule will be chosen to fire The agenda can be listed: CLIPS> (agenda)

01/12/2011

Knowledge-Based Systems, Paula Matuszek

14

15 Agenda Example

Agenda Example

CLIPS> (defrule snowing (snowing hard) => (assert(cancel class))) CLIPS> (agenda) CLIPS> (defrule snowing2 (snowing hard) => (assert(alert maintenance))) CLIPS> (agenda) CLIPS> (assert(snowing hard)) <Fact-0> CLIPS> (agenda) 0 snowing: f-0 0 snowing2: f-0 For a total of 2 activations.

01/12/2011

Knowledge-Based Systems, Paula Matuszek

15

16 Starting CLIPS

Starting CLIPS

CLIPS can be run directly from the command line of a terminal window, but for Windows and Mac OS X there is a simple IDE which is preferable Windows: CLIPSWin.exe Mac: CLIPS IDE.app When you start it, the CLIPS prompt will appear: CLIPS> At that point you are at the CLIPS interpreter and can enter commands. Everything in CLIPS is surrounded by ( )

01/12/2011

Knowledge-Based Systems, Paula Matuszek

16

17 Some Basic CLIPS Commands

Some Basic CLIPS Commands

(exit) to exit from CLIPS (clear) to clear the environment from facts, rules, and other active definitions (reset) to set the fact base to its initial state (clears existing facts; sets (initial-fact), and all (deffacts) constructs in the program). Perform (reset) before each program run! (run) executes a program currently loaded into the CLIPS interpreter against currently defined rule- and fact-bases.

01/12/2011

Knowledge-Based Systems, Paula Matuszek

17

18 More Basic CLIPS Commands

More Basic CLIPS Commands

(load “filename.clp”) to load CLIPS program into the interpreter from the file named filename.clp . This also does syntax check and defines constructs in the file. In some cases you may omit quotes in the name. (facts) to display a list of currently active facts in the fact base. (rules) to display a set of rules currently in the rule base.

01/12/2011

Knowledge-Based Systems, Paula Matuszek

18

19 “Hello World” in CLIPS

“Hello World” in CLIPS

(defrule start (initial-fact) => (printout t “Hello, world!” crlf))

01/12/2011

Knowledge-Based Systems, Paula Matuszek

19

20 To Make It Run

To Make It Run

The usual method of working in CLIPS is: Type the code in a file, save it (e.g. hello-world.clp) Start CLIPS Do: File -> Load (in XCLIPS) or type (load hello-world.clp) When the file is loaded CLIPS will display: (load hello-world.clp) defining defrule start +j TRUE

01/12/2011

Knowledge-Based Systems, Paula Matuszek

20

21 To Make It Run

To Make It Run

Type (reset) Type (run) Tip: You can also use the menu To exit CLIPS use the menu or (exit)

01/12/2011

Knowledge-Based Systems, Paula Matuszek

21

22 IDE

IDE

The IDE includes a fairly simple editor. The open command in the file menu loads a file into the edit buffer. The new command creates an empty buffer. From the IDE you can load the buffer directly into CLIPS This is easier if you are making and testing a lot of small changes.

01/12/2011

Knowledge-Based Systems, Paula Matuszek

22

23 SNOW Example

SNOW Example

The file snow1.clp contains a program for deciding whether I will cancel class. Its input is provided by directly asserting the current conditions. If it concludes that class should be cancelled it will output a message.

01/12/2011

Knowledge-Based Systems, Paula Matuszek

23

«Intro to CLIPS Paula Matuszek CSC 9010, Spring, 2011»
http://900igr.net/prezentacija/anglijskij-jazyk/intro-to-clips-paula-matuszek-csc-9010-spring-2011-120171.html
cсылка на страницу

Без темы

661 презентация
Урок

Английский язык

29 тем
Слайды
900igr.net > Презентации по английскому языку > Без темы > Intro to CLIPS Paula Matuszek CSC 9010, Spring, 2011