0% found this document useful (0 votes)
62 views

FuzzyLogic (ExpertSystem)

Basic introduction on Fuzzy Logic. Easy to understand Fuzzy Logic in an expert system and the comparison between it.

Uploaded by

Isa Ikhram
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

FuzzyLogic (ExpertSystem)

Basic introduction on Fuzzy Logic. Easy to understand Fuzzy Logic in an expert system and the comparison between it.

Uploaded by

Isa Ikhram
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 69

PNB40103 AIB

FUZZY LOGIC EXPERT SYTEM


13 April 2020
azakaria
CLOs
Differentiate between Boolean logic and
Fuzzy logic
Describe what is Fuzzy thinking
Write fuzzy rules
Understand linguistic variable and its
values
Solve problem by fuzzy logic expert
system
azakaria
Recap
Conventional Expert System
Whats wrong with this system?

azakaria
IF_THEN rule
IF A THEN B

This condition requires 100% match of A in


order to trigger (fire) this rule

 Condition A or a or A cannot fire this rule


 Certainty factor CF is introduced to overcome
this problem

azakaria
Example 1
R1 :IF the photo is THEN he is xPM

If the input given to the Expert is this OR

IT CANNOT FIRE
RULE R1 azakaria
Certainty Factor (CF)
R1: IF CF = 1.0
THEN HE is definitely xPM of
M’sia

CF= 0.80 Then He is almost certainly xPM


of Msia

CF = 0.4
Then he may be PM of M’sia

azakaria
Question 1
What is the CF for the following
a)He may be wrong
b)She weighs 100Kg
c)High degree of certainty that MH370 Aircraft had been
landed in Gobi Desert
d)PM says the mega projects initiated by the previous are
to be cancelled.
e)During this two-week period, all of you and your children
should stay at home. Just stay at home. Spend some time
with your children, wife and family.

azakaria
FUZZY EXPERT SYSTEM

azakaria
Albert Einstein

"So far as the laws of


mathematics refer to
reality, they are not
certain. And so far as
they are certain, they
do not refer to reality."

Reality is NOT perfect or precise


azakaria
Human use imprecise
word azakaria
It is easier to ask machine to
perform task with clear
instruction

azakaria
What is FUZZY THINKING ?
EXPERTS RELY ON COMMON SENSE, USE VAGUE AND AMBIGIOUS
TERMS.
E.G.
1. IF THE PRODUCT IS COMPLEX THEN USE THREE PLATE MOULD
2. IF RINGGIT IS FALLING THEN BUY ASN
3. IF THE DISTANCE IS NEAR THEN BRAKE HARD
The question is HOW complex is Complex
HOW falling is falling
HOW near is near or How hard is hard

FUZZY LOGIC ALLOWS the VAGUE and AMBIGIOUS TERMS


USED BY HUMAN TO BE PROCESSED BY COMPUTER.

azakaria
Question 2
Change the following to fuzzy rules
a)IF A is 20 then B = 100
b)IF it is rain then bring an umbrella
c)IF the price of house is above RM200K
then don’t buy the house
d)IF salary is below RM 2000 then the
category is B40

azakaria
Fuzzy means UNCLEAR or BLURR ,
but Fuzzy logic does not mean
unclear LOGIC azakaria
Everything is a matter of degree

There is a GRADUAL change


Lotfi A.Zadeh from one apple to no apple
The inventor of
FL azakaria
BOOLEAN LOGIC VS FUZZY LOGIC

0 0 1 1 1 0 0.25 0.5 0.75 1.0

BOOLEAN LOGIC FUZZY LOGIC

TWO VALUED LOGIC MULTI-VALUED LOGIC

0 OR 1 01

BLACK OR WHITE 1.0 BLACK


0.8 BLACK AND 0.2 WHITE
TRUE OR FALSE 0.2 TRUE AND 0.8 FALSE
YES OR NO 0.5 YES AND 0.5 NO

azakaria
The concept of Membership
function

Boolean set Fuzzy set


You are either in Group S or Sc Near the border, there is
overlapped membership.
You can have both S and
Sc member
azakaria
PARADOX 1

A BUMBER STICKER READS

DON’T TRUST ME

DO WE TRUST THE DRIVER ?


IF WE TRUST THE DRIVER THEN BY INSTRUCTION WE DON’T
IF WE DON’T , THEN AGAIN BY INSTRUCTION WE HAVE TRUSTED THE
DRIVER.
WE END UP BOTH TRUSTING AND NOT TRUSTING THE DRIVER

azakaria
PARADOX 2

RUSSELL’S BARBER posts a sign which reads

I SHAVE ALL, AND ONLY, THOSE MEN WHO DO


NOT SHAVE THEMSELVES.

QUESTION: WHO SHAVE THE BARBER ?


IF HE SHAVES HIMSELF, THEN BY ONLY THE SIGN HE DOES NOT.
BUT IF HE DOES NOT SHAVE HIMSELF THEN BY THE SIGN HE DOES
HE SEEMS BOTH SHAVE AND DOES NOT SHAVE HIMSELF AT THE
SAME TIME

azakaria
THIS IS AN UNFAIR WORLD

WHY A SMAL FISH LIVES IN A BIG BOWL , A BIGGER FISH IN A


SMLL BOWL???? YOU MAY SAY ONE IS RICHER THAN THE
OTHER azakaria
GRADE SYSTEM –Border line
cases
Mark Grade /point Status 1. Why 79 is A-
value but 80 is A
80-100 A (4.000) pass
75-79 A- (3.67) 2. Why 74 is B+
but 75 is A-
70-74 B+ (3.33) pass
65-69 B (3.000
60-64 B- (2.67)

55-59
50-54
C+ (2.33)
C (2.00)
pass IS IT
45-49
40-44
C- ( 1.67)
D (1.00)
FAIR???
0-39 F (0) Fail
azakaria
MANDATORY DEATH
PENALTY
in possession
of 200gm or
more cannabis

If YOU are caught in possession of 200gm,


then you will be sentenced to mandatory
death penaly, another person with 199.9gm
will escape. !! IS IT azakaria
FAIR??
Question 3
a) What is fuzzy logic ?
b) How does it differs from
Certainty factor ?

azakaria
FUZZY SET
BOOLEAN LOGIC CANNOT REPRESENT VAGUE CONCEPT.
FUZZY SET THEORY : AN ELEMENT BELONGS TO A FUZZY SET WITH A CERTAIN
DEGREE OF MEMBERSHIP
CLASSICAL EXAMPLE OF THE FUZZY SET THEORY IS TALL MEN

Name Height cm Crisp Fuzzy


Degree of membership
A 208 1 1.00
B 205 1 1.00
C 198 1 0.98
D 181 1 0.82
E 179 0 0.78
F 172 0 0.24
G 167 0 0.15
H 158 0 0.06
I 155 0 0.01
J 152 0 0.00

azakaria
CLEAR AND
UNCLEAR ABRUPT
BORDER CHANGE
LINE

FUZZY LOGIC ALLOWS YOU TO DEFINE THE BORDER LINE


CASES
azakaria
Boolean Logic Vs Fuzzy Logic

azakaria
Typical
example in
our
everyday
life

azakaria
How tall are these guys

azakaria
GRADUAL CHANGE
FROM NOT TALL TO
TALL

azakaria
How present this in Fuzzy set

azakaria
FUZZY SET

Set 1 : Young 0-40 years


Set 2 : Middle-ages 20-70 years
Set 3 : Old 50 -100 years

azakaria
HOW TO REPRESENT A FUZZY SET IN A
COMPUTER

1.0

short average
tall
0
150 160 170 180 190 200 210

1.0

0.8
tall
short
0.6

0.4
average

0.0

150 160 170 180 190 200 210

azakaria 183 cm 183cm = 0.6Tall


and 0.2Short
LINGUISTIC VARIABLES AND HEDGES

EXAMPLE:

ALI IS TALL
LINGUISTIC VARIABLE VALUE

EXAMPLE :
IF VIBRATION IS HIGH
THEN FORCE IS HIGH
THE UNIVERSE OF DISCOURSE FOR
IF TEMPERATURE IS HOT SPEED CAN RANGE SAY BETWEEN 0
TO 200 KM/H
THEN BLOW MORE AIR
IF SPEED IS LOW
THEN STOPPING_DISTANCE IS SHORT
azakaria
HEDGES ARE TERMS USED TO MODIFY FUZZY SET
E.G. SOMEWHAT, VERY, TOO , SLIGHTLY ETC

APPLICATIONS
ALL PURPOSE : VERY, QUITE, EXTREMELY
TRUTH VALUE: QUITE TRUE, MOSTLY FALSE
PROBABILITIES: LIKELY , NOT VERY LIKELY
POSSIBLITIES: ALMOST IMPOSSIBLE, QUITE POSSIBLE
azakaria
Question 4
• Describe how tall are these creatures

azakaria
FUZZY RULES
IF X is A THEN Y is B

X and Y are linguistic variables , A and B are


linguistic values

CLASSICAL RULE FUZZY RULE


IF SPEED IS > 100 IF SPEED IS HIGH
THEN COMPOUND IS RM100 THEN COMPOUND IS MEDIUM

azakaria
Shapes of membership function

In general Triangular and Trapezoidal MFs are sufficient

azakaria
FUZZY REASONING
THE ANTECEDENT(condition) IS A FUZZY STATEMENT
ALL RULES FIRE TO SOME EXTENT, OR FIRE PARTIALLY
IF THE ANTECEDENT(condition) IS TRUE TO SOME DEGREE OF
MEMBERSHIP THAN THE CONSEQUENT IS ALSO TRUE TO THAT SAME
DEGREE.
EXAMPLE:
IF WIND SPEED IS STRONG
THEN BLADE ANGLE IS SMALL

STRONG SMALL

Wind speed Blade angle


STRONG
1.0

0.6

0.4

SMALL
0.8
5 10 12 15 20
0 5 10 15 20 25
Wind Speed m/s
BLADE ANGLE

IF Wind Speed is STRONG THEN BLADE ANGLE IS SMALL

azakaria
MULTIPLE ANTECEDENTS
IF project_duration is long
AND project_staffing is large
AND project_funding is inadequate
THEN risk is high

MULTIPLE CONSEQUENTS
IF haze is dangerously high
THEN face_mask sale is increased
outdoor_activities is reduced

azakaria
FUZZY INFERENCE
TECHNIQUES
1. MAMDANI METHOD
2. SUGENO METHOD
MAMDANI : 4 STEPS

1.FUZZIFICATION OF INPUT VARIABLES


2.RULE EVALUATION
3. AGGREGATION
4. DEFUZZIFICATION

azakaria
Fuzzification
• To convert a real number to fuzzy value

0.8

0.5

0.4

0.0

Temperature 9 = 1.0 COLD


Temperature 12.5 =0.5COLD 0.5 COOL
Temperature 18 = 0.8COOL ,0.4 GOOD

azakaria
Rule Evaluation
• To select appropriate rule to fire

0.8

0.5

0.4

0.0

R1: IF Temp is COLD then Fan speed is V.SLOW


R2 : IF Temp is COOL then Fan speed is SLOW
R3: IF Temp is HOT then Fan speed is Very Fast
For Temp = 9 , only R1 is fired
For Temp = 12.5 , R1 and R2 are fired azakaria
Aggregation
• To aggregate all fired rules

Very
slow
cold

IF TEMP IS COLD THEN FAN SPEED VERY SLOW


+
Slow

=
cool

Temp C Fan speed RPM


IF TEMP IS COOL THEN FAN SPEED IS SLOW
azakaria
Defuzzification
• Transform fuzzy value to real number

To find the centre of


1.0
gravity of the area
shown (green)
0.8
1.Estimation
2.Calculation
0.5

0.0
0 50 100 150 200
FAN SPEED IN RPM

azakaria
EXAMPLE
Fuzzy logic in Risk assessment

Rule 1:
IF project_funding is adequate
OR project_staffing is small
THEN risk is low
Rule 2
IF project_funding is marginal
AND project_staffing is large
THEN risk is normal
Rule 3
IF project_funding is inadequate
THEN risk is high

azakaria
Fuzzy System
2 input an 1 output system
3 rules
Project Funding =[inadequate, marginal, adequate]
Project Staffing = [small, large]
Risk = [low , normal, high]

Universe of discourse (Range) Membership function shape


Project Funding 1 - 10 mil Triangular or Trapezoidal
Project staffing 10 - 100
Risk index 1 -10

azakaria
Membership Function

inadequate Marginal
Adequate Low High
Normal

1 5 10 1 5
Funding (Mil) 10 Risk Index
You should be able to estimate the
range of different fuzzy values,
Small Large they must be overlapped.

Next draw membership function of


each rule. In this case we are going
to have 3 sets of diagram
10 50 100
Rule 1: IF project Funding is adequate OR project staffing is
small Then the risk is Low

inadequate Marginal
Adequate Low High
Normal

1 5 10 1 5
OR 10
Risk Index

Note ONLy membership function


related to the rule are highlighted
Small large (yellow)

10 50 100
Rule 2 : IF project funding is Marginal and Project staffing is
Large Then the Risk is Normal

inadequate Marginal
Adequate Low High
Normal

1 5 10 1 5
AND 10
Risk Index

Small Large

10 50 100
Rule 3 : IF project funding is inadequate Then the Risk is
High

inadequate Marginal
Adequate Low High
Normal

1 5 10 1 5
10
Risk Index

Please note : project


Small High staffing is not
highlighted

10 50 100
To demonstrate how fuzzy ES
reaches its conclusion when
1. Only rule is fired
2. Two rules are fired

 Question : what will be the risk index if


a. project funding is 7 millions
b. project funding is 7 millions and staffing
is 60 people
azakaria
Rule 1: IF project Funding is adequate OR project staffing is
small Then the risk is Low

inadequate Marginal
Adequate Low High
Normal

1 3 5 7 10 1 5
OR 10
Risk Index

Given : Funding is 7mil.


Step 1 Fuzzification
Small large What is the fuzzy value for 3mil?
3Mil = 0.8aAdequate

10 50 100
Rule 1: IF project Funding is adequate OR project staffing is
small Then the risk is Low

0.8A
inadequate Marginal
Adequate Low High
Normal

1 3 5 7 10 1 5
OR 10 Risk Index
Given : Funding is 7mil.
Step 2. Rule evaluation
Small large R1 IF proFunding is adequate then
Risk is Low
IF proFunding is 0.8 adequate then
what is the Risk?
R1 is fired. The answer lies within
the area in blue
10 50 100
Rule 1: IF project Funding is adequate OR project staffing is
small Then the risk is Low

inadequate Marginal
Adequate Low High
Normal

1 3 5 1 5
10 OR 10 Risk Index
Given : Funding is 7mil.
Step 3. Rule aggregation
Since ONLY R1 is fired , there is
Small large NO rule aggregation

10 50 100
Rule 1: IF project Funding is adequate OR project staffing is
small Then the risk is Low

inadequate Marginal
Adequate Low High
Normal

1 3 5 1 5
10 OR 10 Risk Index
Given : Funding is 7mil.
Step 4. Defuzzification
Small large We have to find the areas center of
gravity.
In this case ,the centre of gravity is
around 2.
Answer is Risk index is 2 (Low)

10 50 100
b)Funding is 6Mil staff is 60people

0.7inadequate Marginal
Adequate Low High
Normal
0.4

1 5 7 10 1 5
Funding (Mil) 10 Risk Index
Given : Fund = 7 mil Staff = 60
Step 1 Fuzzification
Fund 7mil is 0.7 adequate and 0.4
Small Large
Marginal
Staff = 60 = 0.6Large and 0.5Small

10 50 100
b)Funding is 6Mil staff is 60people

Given : Fund = 7 mil Staff = 60


Step 2 Rule evaluation
0.7inadequate Marginal Fund 7mil is 0.7ad and 0.4 Mar.
Adequate Staff = 60 = 0.6L and 0.4S
Possible Rules
0.4 1.Fund is adequate , staff is large
2.Fund is adequate, staff is small
3.Fund is marg , staff is large
1 5 7 10 4.Fund is marg , staff is small
Funding (Mil)
Given rules
R1. IF fund adeq or staff is small
R2. IF Fund is Marg and Satff is
Small Large Large
R3 . IF Fund is inadeq

In this case we find only R1 and


R2 are applicable
10 50 100
Rule 1: IF project Funding is adequate OR project staffing is
small Then the risk is Low

Marginal 0.7
inadequate
Adequate Low High
Normal

0.4

1 5 7 10 1 5
OR 10
Risk Index
Step2 Rule evaluation
R1 becomes
Small large IF fund is 0.7 adeq OR staff is 0.4
Small
0.4S
Bcos it involves OR we must take max
value i.e 0.7
Hence the answer is 0.7 as shown in
blue outline
10 50 60 100
Rule 2 : IF project funding is Marginal and Project staffing is
Large Then the Risk is Normal

inadequate Marginal
Adequate Low High
Normal
0.4M

1 5 10 1 5
AND
10 Risk Index

R2 becomes
IF fund 0.4 Marginal AND Staff is 0.5L
Small Large Bcoz it is AND operation, you must
take min value i.e. 0.4
0.5 L
The answer is area below 0.4 line

10 50 100
Step 3 aggregation

inadequate Marginal
Adequate Low High
Normal

1 5 10 1 5
10 Risk Index
Step 3 Aggregation

Result of R1 + R2 =
Step 4 Defuzzifaction

Last step is to defuzzify the


Low High
fuzzy value into real number
Normal
Find the blue area center of
gravity

It is estimated to be 1 5
Risk index around 3.5 10 Risk Index

Please in Matlab it will


automatically calculated.
Question 5

Give fuzzified value for temperature below


a)15 F
b) 40 F
c) 80 F
azakaria
Question 6
State how
many rules are
fired in

azakaria
Question 7
Estimate defuzzifed value for

b. azakaria
Question 8
1. Consider the following real variables in everyday life
i. A vehicle speed measured in how fast it travels
ii. A breakfast measured in how much you like it.
iii. A journey by train measured in how much you enjoyed travelling
by it.
iv. A driving test measured in how successful are you getting the
driving license.
v. A man’s salary measured in RM.

a. In each case suggest a fuzzy variable(and its values) corresponding


to these real variables.

b. Which of these FIVE variables in which a fuzzy variable is not really


necessary ?why
Question 9
IF years-of-employment is LONG
THEN credit-risk is LOW

Suggest rules for


a. years-of-employments is SHORT
b. unemployed

azakaria
Lab exercise
MOLDcost system has the following Q1. RUN A FUZZY
rules INFERENCE TO
R1 : IF component is SMALL DETERMINE THE
COST OF MAKING
AND complexity is LOW MOULD FOR A
THEN the cost is LOW COMPONENT OF SIZE
200 mm2 with medium
R2: IF component is MEDIUM complexity of 4
AND complexity is MEDIUM
Hints:
THEN cost is MEDIUM
U for Component size : 0  500
R3 : IF component is SMALL
U for COST : 0  50K
AND complexity is HIGH
U for complexity : 0  10
THEN cost is HIGH
Use triangular fuzzy sets

azakaria
Solution

Input 1 :comp size [small, medium]


Input 2 : complexity [Low, Med, Hi]
Output : Cost [low, Med, hi]

Again this is 2 input and 1 output system


Please watch the video for its solution using
Matlab

azakaria

You might also like