?????? (Knowledge Based Design) by 4Tt8737D

VIEWS: 6 PAGES: 27

									     Clips
Intro. & Demo.
       2007. 10. 1

    Hyo-kwang Lee
 adpc9@icad.kaist.ac.kr

                          1
Introduction to CLIPS




                        2
What is CLIPS
  CLIPS
     Expert System Shell
     C Language Integrated Production System
     JESS : Java clone of CLIPS


  Created
     In 1985
     At Artificial Intelligence Section of NASA’s
      Johnson Space Cetner

  http://www.ghg.net/clips/CLIPS.html
                                                     3
Key Features of CLIPS
  Knowledge representation
     Rule-based, object-oriented, procedural
      programming paradigms

  Portability
     Written in C
     Able to be ported to any system with an ANSI
      compliant C or C++ compiler

  Integration/Extensibility
     Can be embedded within procedural code, called
      as a subroutine, and integrated with languages
      such as C, Java, FORTRAN and ADA
                                                     4
To install CLIPS
  Download
     http://www.ghg.net/clips/download/
     Document, Executables, Source,…


  Install
     http://www.ghg.net/clips/download/executa
      bles/pc/CLIPSWin.zip
     Unzip CLIPSWin.zip  CLIPSWin.exe

                                              5
To Start CLIPS




                 6
Example – Hello, world!
  “Hello, world!” on the screen
  (printout t "Hello, world!" crlf)




                                      7
Example – Animal.clp




                       8
CLIPS – Basic Syntax




                       9
Introduction
  Basic elements of an expert system
     Fact-list
     Rule-base
     Inference engine

  Program written in CLIPS consists of
     Facts
     Rules
     Objects
                                         10
Fact
  Making a list
     assert
     Example
        (assert (duck quack))

  Same assertions to run every time?
     deffacts
     Example
        (deffacts walk “some facts about walking”
             (status walking)
             (walk-sine walk)
         )
     (reset) for assertion
                                                     11
Rule
  Making a Rule
     IF THEN rule
      IF an animal is a duck
      THEN the sound made is quack


     Defrule




                                     12
Rule




       13
Template
 Making a Template
     deftemplate
     Group of related fields in a pattern
     List of slot




                                             14
Function
  Making a Function
     deffunction




                      15
Class




        16
Ex1 – What’s that fruit?

                                    Red       “Grapes”
               Y
Diameter > 4       Vine   Color ?
                                    Green   “Watermelon”
       N

                                    Red       “Cherry”
                   Tree   Color ?
                                    Green     “Apple”




                                                   17
Ex 1 – Source
; ******************************************
; rules                                        (defrule watermelon
; ******************************************       (fruitclass vine)
(defrule vine                                      (color red)
     (diameter ?dia)                           =>
     (test (> ?dia 4))                             (printout t “Grapes." crlf))
=> (assert (fruitclass vine)))
                                               (defrule cherry
(defrule tree                                      (fruitclass tree)
    (diameter ?dia)                                (color red)
    (test (< ?dia 4))                          =>
=> (assert (fruitclass tree)))                     (printout t “Cherry." crlf))

;============================                  (defrule apple
(defrule watermelon                                (fruitclass tree)
    (fruitclass vine)                              (color green)
    (color green)                              =>
=>                                                 (printout t “Apple." crlf))
    (printout t “Watermelon." crlf))
                                                                                  18
Ex 1 – Run
; **************************************   CLIPS
; facts
; **************************************   CLIPS> (load “ex1.clp”)
(deffacts fruit_conditions                 CLIPS> (defffacts fruit_conditions
                                              (diameter 1) (color red))
    (diameter 1)
                                           CLIPS> (reset)
    (color red))                           CLIPS> (run)
                                           Cherry.




                                                                                19
   Ex 2 – Who drinks water?
There are five houses,
   each of a different color, inhabited by men of different nationalities,
   with different pets, drinks, and cigarettes.




                                                                             20
Ex 2 – Who drinks water?
The Englishman lives in the red house.
The Spaniard owns the dog.
The ivory house is immediately to the left of the green house, where the coffee
   drinker lives.
The milk drinker lives in the middle house.
The man who smokes Old Golds also keeps snails.
The Ukrainian drinks tea.
The Norwegian resides in the first house on the left.
The Chesterfields smoker lives next door to the fox owner.
The Lucky Strike smoker drinks orange juice.
The Japanese smokes Parliaments.
The horse owner lives next to the Kools smoker, whose house is yellow.
The Norwegian lives next to the blue house.

Now, who drinks water? And who owns the zebra?




                                                                          21
Ex 3 - CMP
Cannibals and Missionaries Problem

  Another classic AI problem. The point is
  to get three cannibals and three missionaries
  across a stream with a boat that can only
  hold two people. If the cannibals outnumber
  the missionaries on either side of the stream,
  then the cannibals will eat the missionaries.
  Now, how can get them all across the stream?


                                                   22
Ex 3 - CMP




             23
  Ex – Switch Catalogue Automation System

          Part Search System

Web Search Module
                                Admin module
    GUI (Web)       internet
                  Weak Points of the existing System
  Search Engine
                  -W/o Fact-Based Knoweldge Rule
                   ex) “X kind of switch and V voltage are given,
    Database         the switch should be smaller than size Y.”
                         Data Dictionary


                  -Not exactly same CAD model size as
                   what customers really want
                    internet
                   -> must be edited later.


Web                            Web
browser                        browser          PartDB, Inc.(www.partdb.com)
                                                                      24
   Ex – Switch Catalogue Automation System
                                                                       1st stage
Customer
         시스템 구성          Expert System Shell
                      (Intelligent Rule Element)
                                                     Fact Base
                                                                    -Web-based
Demand     User
         Interface
                                                                    -Switch spec
 Input                      Application             Knowledge
                           Programming                 Base         -Size
                             Interface              (Rule Base)




               Table Parametric              Design
                    Model          +      Parameter Set
                                                                       2nd stage


Switch
                                                                    -Stand Alone
                                                     Part Family
 CAD       User              CAD System
                                                    Functionality   -CAD Model
         Interface          (Pro/Engineer)
Model



                                                                             25
EX - Customers can design their own
 products w/o engineers interface. Modeler
                                   SMS                         SMS Sender


                                                            DB
                  Architecture                           Connector
                                              Server                 3D Modeler
                                                           FTP
                                                         Connector
                                                 DB
                                                Server



                Client

                     Expert                     FTP
  Web Browser




                               DB Connector
                     System                     Server

                         FTP Connector



                                                                      26
EX - Customers can design their own
 products w/o engineers interface.




                                      27

								
To top