KnowledgeBased Problem Solving - PowerPoint PPT Presentation

1 / 32
About This Presentation
Title:

KnowledgeBased Problem Solving

Description:

Program. Sequence of FOPC sentences. All sentences are Horn clauses. p1 p2 ... then the problem is starter motor. Rule 4: if there is gas in fuel tank, and ... – PowerPoint PPT presentation

Number of Views:110
Avg rating:3.0/5.0
Slides: 33
Provided by: kimju
Category:

less

Transcript and Presenter's Notes

Title: KnowledgeBased Problem Solving


1
Knowledge-Based Problem Solving
  • Chap. 6, Chap. 8

2
Introduction
  • Problem solving
  • Knowledge Control
  • Knowledge
  • Logical sentence
  • ltIfthengt rules
  • Past experience
  • Control (search)
  • Recursive search with backward chaining Prolog
  • Production systems with forward chaining Jess
  • Find similar cases - CBR

3
Prolog
  • Logic programming
  • Program
  • Sequence of FOPC sentences
  • All sentences are Horn clauses
  • p1 ? p2 ? ? pn ? q
  • Inferencing mechanism
  • Backward-chaining, DFS (recursive search)

4
Production Systems
  • Production System
  • A computational model of problem solving process
  • Used for implementation of expert systems

5
Production Systems
  • Production rules
  • Problem solving knowledge
  • ltconditiongt ? ltactiongt
  • Exgt if earning(X, unsteady)
  • then income(inadequate)
  • if clear(X)
  • then pickup(X)
  • Working memory
  • Current states of the world
  • Exgt earning(1500, unsteady)
  • clear(a)

6
Production Systems
  • Recognize-act cycle
  • Match
  • Patterns in working memory are matched against
    rules
  • ? Conflict set
  • Conflict resolution
  • One of the rules in the conflict set is selected
  • Fire
  • Action is performed. Working memory is updated

7
Production Systems
  • Example

Match
Production Rules
Working Memory
R1 A ? B R2 A ? C R3 B ? D
A B
Fire R1
Conflict set R1, R2
8
Forward Chaining
9
Advantages
  • Separation of knowledge and control
  • Knowledge Production rules
  • Control Recognize-act cycle
  • ? Modification / update of KB is easy
  • Modularity
  • Production rules are independent each other
  • ? Incremental development is possible

10
JESS
  • CLIPS
  • C Language Integrated Production System
  • An expert system shell developed 1985 in NASA
  • Solve the problem of portability and
    extensibility of the LISP based systems
  • JESS
  • Java Expert System Shell
  • Developed 1997 in Sandia National Lab.
  • Simplified version of CLIPS written in Java
  • Easily integrated into Java codes
  • Inference engine
  • Forward-chaining, production system

11
JESS
  • How to use?
  • Download the User Manual and Jess package
  • http//herzberg.ca.sandia.gov or,
    http//www.jessrules.com/jess/index.shtml
  • Run in the command-line interface
  • Run Jess.bat (java jess.Main)
  • JESSgt (batch myfile.clp) (run)
  • Integrating with Java
  • Embed Jess program into Java program
  • Extend Jess with commands written in Java

12
Jess Language
  • Constants
  • Atoms kim, car1, 100, Good Bye
  • Lists (a b c), ( 1 2), (like kim lee)
  • Variables
  • Variables ?x, ?name
  • Binding (bind ?x kim)
  • Built-in functions
  • , -, , /, , lt, lt, eq, clear,
  • Usage ( ( 2 3) ( 1 2)), (clear)
  • Function definitions
  • (deffunction max (?a ?b)
  • (if (gt ?a ?b) then ?a
  • else ?b))

13
Jess Language
  • Facts
  • (like kim lee), (temperature 20), (start)
  • Add facts at runtime
  • (assert (like kim lee))
  • (assert (car (id 6433) (make benz)))
  • Add facts when Jess start (or reset)
  • (deffacts myfacts
  • (parent kim lee)
  • (parent lee park) .. )

14
Jess Language
  • Rules
  • (defrule alert
  • (temperature 100)
  • gt
  • (printout t Finished !!!))
  • " x,y Female(x) Ù Parent(x,y) Þ Mother(x,y)
  • (defrule rule-1
  • (female ?x)
  • (parent ?x ?y)
  • gt
  • (assert (mother ?x ?y)))

15
Jess Language
  • Connectives
  • ? multiple patterns in LHS
  • ? not supported (make separate rules)
  • (not ltpatterngt)
  • Test
  • Specify match condition
  • (defrule r1
  • (man (age ?a))
  • (test (gt ?a 20))
  • gt
  • ...

16
Jess Language
  • Pattern bindings
  • A variable that is binded to a pattern
  • (defrule r1
  • ?fact lt- (step ?n)
  • gt
  • (bind ?m ( ?n 1))
  • (retract ?fact)
  • (assert (step ?m)))
  • Other functions
  • Program control clear, reset, run, exit, ...
  • I/O read, printout, open, ...
  • Debug facts, rules, watch, unwatch, ...

17
Example
  • (deffacts initial-facts
  • (start))
  • (defrule ask
  • (start)
  • gt
  • (printout t "How many legs? (2 or 4)")
  • (assert (legs (read))))
  • (defrule human
  • (legs 2)
  • gt
  • (assert (answer human)))
  • (defrule animal
  • (legs 4)
  • gt
  • (assert (answer animal)))

18
Example
  • (defrule outout
  • (answer ?x)
  • gt
  • (printout t "It is " ?x "!" crlf))
  • (reset)
  • (run)
  • Example run
  • JESSgt ( 1 2)
  • 3
  • JESSgt (batch test.clp)
  • How many legs? (2 or 4)
  • 2
  • It is human!

19
Expert Systems
  • Expert system
  • Knowledge-based program
  • Provides answers to problems in specific domain
  • Problem Categories
  • Interpretation, prediction, diagnosis, design,
  • Separation of knowledge and control
  • Easy to represent knowledge
  • Easy to build and change KB
  • Same control and interface can be used for
    various systems
  • Expert System Shell

20
Expert Systems
  • Expert system architecture

KB
Shell
21
Knowledge Engineering
  • Knowledge acquisition
  • Building KB by acquiring knowledge from experts
  • ? Major bottleneck in building expert system
  • Knowledge engineer
  • Select tools
  • Extract knowledge (interview)
  • Build efficient KB

22
Rule-Based Reasoning
  • Represent knowledge as explicit rules
  • ltIf ... Then gt
  • Expert system as a production system
  • Inference engine - Production system
  • Knowledge base - Set of rules
  • Example Diagnosing automotive problems
  • Production system with backward chaining
  • Knowledge
  • Engine gets gas ? Light on (Battery is OK)
  • ? Turn over (Start motor is OK) ? Start (Spark
    plug OK)

23
Rule-Based Reasoning
  • Rules
  • Rule 1 if the engine is getting gas, and
  • the engine will turn over
  • then the problem is spark plugs
  • Rule 2 if the engine does not turn over, and
  • the lights do not come on
  • then the problem is battery
  • Rule 3 if the engine does not turn over, and
  • the lights do come on
  • then the problem is starter motor
  • Rule 4 if there is gas in fuel tank, and
  • there is gas in the carburetor
  • then the engine is getting gas

24
Rule-Based Reasoning
25
Rule-Based Reasoning
  • Backward chaining
  • Rule 1 fire, Rule 4 fire
  • Dialog with user
  • gas in fuel tank? yes
  • gas in carburetor? yes
  • engine turn over? why ?
  • It has been established that
  • 1. engine is getting gas
  • therefore if
  • 2. engine turn over
  • then the problem is spark plugs how 1 ?

26
Rule-Based Reasoning
  • This follows from rule 4
  • if
  • gas in fuel tank, and
  • gas in carburetor
  • then
  • engine is getting gas
  • gas in fuel tank was given by the user
  • gas in carburetor was given by the user
  • engine turn over? yes
  • The problem is spark plugs

27
Rule-Based Reasoning
  • Advantages
  • Use of expert knowledge
  • ? Good performance in limited domains
  • Separation of knowledge and control
  • Explanation is possible
  • Disadvantages
  • Need knowledge acquisition
  • Rules are brittle so can not handle noisy data

28
Case-Based Reasoning
  • Reasoning from cases
  • Case examples from past
  • Exgt Law cases
  • Procedure
  • 1. For a new problem, retrieve similar case
  • (based on common feature)
  • 2. Modify the retrieved case
  • (make it suitable for the current situation)
  • 3. Apply the modified case to get the solution
  • 4. Save the new case

29
Case-Based Reasoning
  • Example
  • customer sex age action?(f)
  • c1 M 40 N
  • c2 M 20 Y
  • c3 F 30 N
  • c4 M 30 Y
  • c5 F, 20 ? Y or N?
  • Rule-based
  • Rule if (sexF) then N. Therefore N
  • Case-based
  • C3 is most similar to c5. Therefore N

30
Case-Based Reasoning
  • k-Nearest Neighbor method
  • Define distance functions
  • dsex(A, B) A B (female0, male1)
  • dage(A, B) A B / max difference
  • d dsex dage
  • Example
  • dsum(c5, c1) 0 1 20 40 / 20 2.0
  • dsum(c5, c2) 0 1 20 20 / 20 1.0
  • dsum(c5, c3) 0 0 20 30 / 20 0.5
  • dsum(c5, c4) 0 1 20 30 / 20 1.5

31
Case-Based Reasoning
  • Prediction of value
  • Weighted average of neighbors
  • Example
  • 3-NN ? c3, c2, c4
  • f3 -1(N), f2 1(Y), f4 1(Y)
  • d35 0.5, d25 1.0, d45 1.5
  • f5 -11/0.5 11/1.0 11/1.5
  • -0.33
  • ? N

32
Case-Based Reasoning
  • Issues
  • Selection of features
  • Computing similarity
  • Advantages
  • Knowledge acquisition can be simplified
  • Provide learning capability to expert systems
  • Disadvantages
  • Lack of explanation capability
  • Store/compute trade-offs
Write a Comment
User Comments (0)
About PowerShow.com