IE 469 Manufacturing Systems
صنع نظم التصنيع469
Expert Systems
Part 1
1
Outline
• Introduction to Expert Systems (ES)
• Components of an ES
• Building an ES
• Implementations/References
2
Introduction
• Definitions
• A computer program designed to model the problem-
solving ability of a human expert.
Expert Systems Design and Development by Durkin
• A model and associated procedure that exhibits, within
a specific domain, a degree of expertise in problem
solving that is comparable to that of a human expert.
Introduction to Expert Systems by Ignizio
• A computer system which emulates the decision-
making ability of a human expert.
Expert Systems: Principles and Programming by
3
Giarratano and Riley
Criteria for Building an Expert System
• Does a human know how to solve the problem?
– If no human expert exists, it is not possible to develop rules describing the
problem.
– The techniques of solving the problem must be known and defined in order
to create an expert system
• Does the problem have a definable solution?
– ES shells are designed to select one or more possible solutions from a group.
– If all of the possible solutions cannot be specified, writing rules to solve the
problem is difficult.
• Is the level of understanding and scope appropriate?
– A problem that has too wide a scope or requires too deep a level of
understanding is not appropriate for an ES.
– An ES solves specific problems.
• Has the technique for solving the problem been documented?
– Solution may be a decision tree, manual procedure, written instructions, etc.
– Well-defined problems can be easily converted to an ES. 4
Level of Understanding
Problems
Wide
S
C
O
P Expert
E
Systems
Specific Limited Deep
Level of Understanding
Defining the problem to fall within the shaded area of the graph is very important -
Problem should NOT have too large a scope or too deep a level of understanding.
5
Why Use an Expert System?
• Preserves knowledge
– Builds up the corporate memory of the firm
• Frees expert from repetitive, routine jobs.
• Provide novice with expert advice on a specific subject.
• Wide distribution of rare human knowledge
• Aids in training new employees.
• Improves worker productivity.
• Provides second opinion in critical situations.
– Especially valuable when tired or under stress
6
Technical Advantages of an
Expert System
• Rapid prototype development
• Easier verification of software
• Easier maintenance of software
• Explains its reasoning in English to user when requested
• Truly self documenting software
• Easier to learn to build rule-based expert systems
• Inexpensive technology
• Automated consistency checking of knowledge in the
knowledge base
7
Comparison of a Human Expert and an
Expert System
Factor Human Expert Expert System
Time availability Workday Always
Geographic Local Any where availability
Safety Irreplaceable Replaceable
Perishable Yes No
Performance Variable Consistent
Speed Variable Consistent (usually faster)
Cost High Affordable
8
Disadvantages of an ES
• Brittleness
– only have access to highly specific domain knowledge
– cannot fall back on more general knowledge when
needed
• Lack of Meta-Knowledge
– do not have sophisticated knowledge about their own
operation
– cannot reason about their own scope and limitations
• Knowledge Acquisition is a bottleneck in applying ES
technology to new domains
• Validation of an ES is difficult
• Expert Systems can make mistakes 9
When to use an Expert System?
Ultimate users agree that payoff will be high
Application is knowledge intensive
A human expert exists
Not a natural-language intensive application
A wide range of test cases are available
Neither creativity nor physical skills are required
10
Personnel Involved
• Domain Expert
– a person who posses some skills that allow him/her to
draw upon past experiences and quickly focus on the
core of a given problem.
• User
– a person who will use the expert system and ultimately
benefit from the domain expert’s knowledge.
• Knowledge Engineer
– a person who designs, develops, and implements expert
systems (or other artificial intelligent applications).
11
Phases in Expert System Development
Phase 1 Reformulations
Assessment
Requirements Explorations
Phase 2
Knowledge Acquisition
Knowledge
Phase 3 Refinements
Design
Structure
Phase 4
Test
Evaluation
Phase 5
Documentation
Product
Phase 6
12
Maintenance
A Hierarchical Model of
Intelligence
Wisdom
Knowledge
+ Vision
Information
+ Experience
Data + Context
13
A Knowledge Engineer’s
View of Intelligence
Decisions
Knowledge
+ Analysis/Reduction
Facts + Rules of Thumb
”Raw” Data
+ Context
14
Components of an Expert System
• Inference Engine
– Reasons about knowledge
– Explains its reasoning
– Helps programmer build correct/consistent expert systems
• Knowledge Base
– Base is represented in easy to read English sentences
– Order of rules is not critical
• The expert system shell ( EXSYS) contains an existing
inference engine
• The knowledge base is the only part of the system the
programmer needs to develop 15
Knowledge Base
• Contains the domain-specific, problem solving
knowledge. There are two basic approaches.
– Rule: If-then statements that attempt to replicate the
thought process used by the expert.
(Known as Rule-Based Reasoning)
– Cases: Collection of previous solutions for situations and
generalizes a solution for current situation
(Known as Case-Based Reasoning)
Note: there are other ways to represent knowledge 16
Composition of a Rule
IF
Conditions
THEN
Conditions
and Choices
ELSE
Conditions
and Choices
NOTE:____________
REFERENCE______
17
IF
IF part is simply a series of test conditions, expressed as English
sentences or algebraic expressions:
Ex: Today is Wednesday or [X] > 1
The first rule will only be true if today is Wednesday.
The second rule will only be true if the variable X > 1.
Test is made by information:
provided by the user
derived by other rules
obtained from other sources
Tests can be derived with other boolean operators, i.e. AND or OR
18
THEN
Contains conditions similar to if statements, but they are not tests.
They are statements of fact.
IF “today is Wednesday” may or may not be true.
Then “today is Wednesday” is a valid fact if the IF conditions are true.
The valid fact is then added to the knowledge base within the system.
THEN condition may also contain statements that assign a value or
assigned value to a numeric or string value.
19
ELSE
ELSE part is the same as the THEN part and is applied if any
of the IF conditions are FALSE.
ELSE part is optional and not needed in most rules.
20
Example of Rule-Based
Reasoning
• Rule-based Reasoning
– Uses if-then rules:
1. IF you are 150 yds. away, THEN select the 7-iron.
2. IF you are in the rough, THEN use the next lower-
numbered club.
– Facts on current situation:
• 150yds, on rough, sunny day
– Applying the above two rules you will get 6-iron
as output.
21
Another Way to Represent
the Knowledge Base:
• Case-based Reasoning
– Looks at all related facts as a “case”
– Reasons about the differences.
– Example.
Step 1, Case base from previous games of experts:
• Case 1: (170 yds., in fairway) Answer: 5-iron.
• Case 2: (160 yds., in fairway) Answer: 6-iron.
• Case 3: (150 yds., in fairway) Answer: 7-iron.
• Case 4: (170 yds., in rough) Answer: 4-iron
22
Another Way to Represent
the Knowledge Base (Cont.)
• Case-Based Reasoning (second step):
– Apply rules about what doesn’t match the case:
a. If the situation is “fairway” and the case is for “rough”,
then use the next higher-numbered club.
b. If the situation is “rough” and the case is for “fairway”,
then use the next lower-numbered club.
– Since the situation is “rough” and Case 3 (the best
matching case) is for “fairway”,
• apply the b. rule above to derive our answer of 6-iron.
23
Reasoning Within an ES
• When to use Rule-Based Reasoning?
– When there is a lot of specific expert knowledge on a
particular subject and the expert can solve the problem
sequentially.
– When an explanation or an audit trail of the solution
is required.
• When to use Case-Based Reasoning?
—When the user wants to browse similar cases.
—When you have lots of typical situations or cases for the
knowledge base.
24
Confidence Modes
• One of the most powerful parts of an expert system is
being able to create rules which state that an answer is
probably, but not definitely, true.
• Process accomplished by assigning confidence modes
• Rule of Thumb -- Use the simplest one that will do the job!
• Ways to assign confidence modes:
– 0-10
– -100 to 100
– Increment/decrement system
– Custom formula 25
Tree Structured Rules
Model: items of a desk to include a telephone, a
computer, a pencil, legal paper, and floppy disks.
Black? Telephone
Color?
Yes
Computer
White?
Start Makes
Black?
Noise? Floppy Disk
Color? Rectangle?
No Legal Paper
Shape?
Yellow? Pencil
Cylindrical?
26
Converting Tree Structure to
an Expert System
• Rule 1: IF the item makes noise AND the color is black
– THEN telephone - Confidence 9/10
• Rule 2: IF the item makes noise AND the color is white
– THEN computer - confidence 10/10
• Rule 3: IF the item does not make noise AND the color is black
– THEN floppy disk - confidence 10/10
• Rule 4: IF the item does not make noise AND the color is yellow
AND the shape is rectangular
– THEN legal paper - confidence 7/10
• Rule 5: IF the item does not make noise AND the color is white AND
the shape is cylindrical
– THEN pencil - confidence 8/10
27
Architecture of Expert Systems
Knowledge Engineer
User interface
may employ: Knowledge-base
Editor
question-and-
answer,
General
User Knowledge Base
menu-driven,
Inference Engine
natural Case-specific
language, Data
graphics
Explanation
user
Subsystem
interface
28
Inference Engine Control
Strategies
• Control Strategies for Execution of Rules
– Backward Chaining
• Begins with a goal and works backwards towards
the initial conditions
– Forward Chaining
• Starts with available information and then draws
conclusions
29
Which Strategy to Use?
• When to use backward chaining?
– When a specific conclusion or set of conclusions is
being sought or tested.
– Common use: Classification
– Ex. Which one of “these” cars should I buy?
• When to use forward chaining?
—When you want all the possible conclusions.
—Common use: Diagnosis
—Ex. What job positions can I apply for?
30
Backward Chaining
• Runs rules in a “goal-driven” way.
• If a piece of information is needed, the program will
automatically check all of the rules to see if there is a rule that
could provide the needed information.
• The program will then “chain” to the new rule before completing
the first rule.
• The new rule may require information that can be found in yet
another rule.
• Logic of why the information is needed goes backward through the
chain of rules. 31
Backward Chaining Example
Rule 1:
IF
The day is hot
THEN
Go to the beach
The program needs to know if the day is hot. Program will automatically check all
rules to see if there is a rule that tells if the day is hot.
Rule 35:
IF
It is summer
and It is sunny
THEN
The day is hot.
If there are rules in the system that tests if it is summer or that it is sunny, it will test those
rules before rule 35 and test rule 35 before rule 1. The chain will continue until all
32
applicable rules are tested.
Forward Chaining
• Data-Driven way to run the rules.
• In pure forward chaining rules are simply tested in the order
they occur based on available data.
• If information is needed, other rules are NOT invoked.
• Instead, the user is asked for the information.
• Backward chaining systems are not dependent on order,
forward chaining rules are.
• Many systems are a hybrid of the two.
33
Meta Rules
• Meta rules ( also called control strategies) are rules about how
to apply a strategy
• A rule-based system consists of layers of rules
• Meta rules can determine which criteria a set of
rules should be instantiated against
• Ex: Two rules meet the firing criteria but result in different
outcomes, which rule do you fire:
Meta rule could fire the rule that is most recent
Meta rule could fire the rule that is more specific 34
Example of Control Strategy
Rules: If credit history is less than one year,
then applicant is a high credit risk.
If applicant is a doctor
then applicant is a low credit risk.
Facts: Cash is 25 years old
Cash has 6 months of credit history
Cash has been unemployed for three-fifths of a year
Cash is a doctor
Meta Rule: If more than one rule meets the criteria
then fire the rule that meets the most recent fact.
Cash is a doctor is most recent fact, therefore, applicant is a
low credit risk.
35
Example of a Meta-Rule
IF The car will not start
AND The electrical system is operating normally
THEN Use rules concerning the fuel system
36
Meta- Rule Hierarchy
Etc.
Meta Meta
Rules
Meta Rules
(rules about how to apply rules)
Rules
(Domain Knowledge)
37
Building an Expert System
• Analysis
• Specification
• Development
• Deployment
38
Analysis
• User/expert: Identify a potential
application.
• Knowledge Engineer: Is expert system the
answer?
– Task is well understood
– Expertise exists, is reliable, and the solution is
generally agreed upon
– Task is not too hard (but not too easy, either)
39
Specification
• User/Expert and Knowledge Engineer work
together to define the objectives of the
expert system application:
– Inputs
– Outputs
– Methodology
40
Development
• Knowledge Engineer: Learns how the
expert performs task:
– Called “knowledge acquisition”.
– Must cover current, historical, and hypothetical
cases.
• Develop a conceptual model of the ES.
– Framework consists of high-level descriptions
of the tasks and situations.
41
Development (contd)
• Decide how the inference, representation,
and control structure can be used to
replicate the decision process.
• Build the knowledge base.
• Verify and validate.
– Am I building the product right?
– Am I a building the right product?
42
Deployment
• Install the system for routine use.
• Fix bugs, update, and enhance.
Go back to development phase.
This loop remains active throughout the
life cycle of the project.
43
How Do Expert Systems REALLY
Differ from Conventional Programming
Languages?
• Primary difference is:
– Expert systems are developed by examining ways a human
expert would perform the task.
– Conventional programs are developed by examining ways a
computer would perform the task.
• When built, both procedural and deterministic.
• So the question that often comes out is....
Are expert systems truly intelligent?
44
Expert Systems vs Conventional Programs
Characteristic Conventional Program Expert System
Control by... Information & control integrated Knowledge separate from
control
Solution by... Algorithm Rules & inference
Execution Generally sequential Opportunistic rules
Input Must be complete Can be Incomplete
Design Structured Little or none
Expansion Done in major jumps Incremental
Representation Numeric Symbolic
Modify Difficult to modify Easy to modify
Results Final result given Recommendation w/expansion
Interface Command interface Natural dialogue
Answers Optimal Solution Acceptable solution
45
Application Categories Re-Visited
• Interpretation Inferring situation from observations/data
• Prediction Inferring likely consequences of situation
• Diagnosis Inferring malfunctions
• Design Configuring objects under constraints
• Planning Developing plans to achieve goals
• Monitoring Comparing observations to plans
• Debugging Prescribing remedies for malfunctions
• Repair Executing a plan to administer a remedy
• Instruction Diagnosing, debugging, and correcting
student performance
• Control Managing system behavior
• Selection Identifying best choice from a list of
possibilities
• Simulation Modeling the interaction between system
components 46