FuzzyLogic (ExpertSystem)
FuzzyLogic (ExpertSystem)
azakaria
IF_THEN rule
IF A THEN B
azakaria
Example 1
R1 :IF the photo is THEN he is xPM
IT CANNOT FIRE
RULE R1 azakaria
Certainty Factor (CF)
R1: IF CF = 1.0
THEN HE is definitely xPM of
M’sia
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
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
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
0 OR 1 01
azakaria
The concept of Membership
function
DON’T TRUST ME
azakaria
PARADOX 2
azakaria
THIS IS AN UNFAIR WORLD
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
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
azakaria
CLEAR AND
UNCLEAR ABRUPT
BORDER CHANGE
LINE
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
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
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
azakaria
Shapes of membership function
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
0.6
0.4
SMALL
0.8
5 10 12 15 20
0 5 10 15 20 25
Wind Speed m/s
BLADE ANGLE
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
azakaria
Fuzzification
• To convert a real number to fuzzy value
0.8
0.5
0.4
0.0
azakaria
Rule Evaluation
• To select appropriate rule to fire
0.8
0.5
0.4
0.0
Very
slow
cold
=
cool
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]
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.
inadequate Marginal
Adequate Low High
Normal
1 5 10 1 5
OR 10
Risk Index
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
10 50 100
To demonstrate how fuzzy ES
reaches its conclusion when
1. Only rule is fired
2. Two rules are fired
inadequate Marginal
Adequate Low High
Normal
1 3 5 7 10 1 5
OR 10
Risk Index
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
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
It is estimated to be 1 5
Risk index around 3.5 10 Risk Index
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.
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
azakaria