UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic...

35
UNIVERSITI TENAGA NASIONAL CSNB234 CSNB234 ARTIFICIAL INTELLIGENCE ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Instructor: Alicia Tang Y. C.

Transcript of UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic...

Page 1: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

UNIVERSITI TENAGA NASIONAL

CSNB234CSNB234ARTIFICIAL INTELLIGENCEARTIFICIAL INTELLIGENCE

Chapter 8.1Introduction to Fuzzy Logic and Fuzzy Rules

Chapter 8.1Introduction to Fuzzy Logic and Fuzzy Rules

Instructor: Alicia Tang Y. C.

Page 2: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

2

Fuzzy ThinkingFuzzy Thinking Fuzzy logic is used to describe fuzziness.

– Where fuzzy logic is the theory of fuzzy sets, sets that calibrate vagueness

– A fuzzy set can be defined as a set with fuzzy boundaries.

Fuzzy logic is based on the idea that all things admit of “degrees” or “scales”. – Such as: temperature, height, speed, distance, beauty

etc.– This is acceptable since experts rely on common sense

when they solve problems

How can we represent expert knowledge that uses vague and ambiguous terms in a computer?– By using fuzzy logic in representation!

Page 3: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

3

Fuzzy Logic Fuzzy Logic Introduced by Lofti Zadeh (1965)It is a powerful problem-solving methodology– Builds on a set of user-supplied human language rules

It deals with uncertainty and ambiguous criteria or values– Example: “the weather outside is cold”

but, how cold is actually the coldness you described?

What do you mean by ‘cold’ here?

– As you can see a particular temperature is cold to one person but it is not to another

– It depends on one’s relative definition of the said term

Page 4: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

4

Most natural language is bounded with vague and imprecise concepts

Example:– “He is quite tall”– “The student is intelligent”– “Today is a very hot day”

These statements are difficult to translate into more precise language

Fuzzy logic was introduced to design systems that can demonstrate human-like reasoning capability to understand such vague terms

Page 5: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

5

Degree of membership of a “tall” man

Height, cm Crisp value Fuzzy 208 1 1.00205 1 1.00198 1 0.98181 1 0.82179 0 0.78172 0 0.24167 0 0.15158 0 0.06155 0 0.01152 0 0.00

It will just return a ‘yes’ or a ‘no’

When a numericdata is given

In fuzzy,Probability is used

tall

Verytall

Extremelytall

Page 6: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

6

Relationships between uncertainty terms and certainty factor (CF)

Uncertainty term CF Definitely not -1.0Almost certainly not -0.8Probably not -0.6Maybe not -0.4Unknown -0.2 to +0.2Maybe +0.4Probably +0.6Almost certainly +0.8Definitely +1.0

CF takes value from -1 to 1

So, be careful when you use the term “may be”.. It represents only 40%

Page 7: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

7

What is not considered as fuzzy logic ?

Classical logic or Boolean logic that has two values are not fuzzy!– Example:

true or falseyes or noon or offblack or whitestart or stop

Page 8: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

8

Differences between Fuzzy Logic and Crisp Logic

CRISP LOGIC– precise properties

Full membership– YES or NO– TRUE or FALSE– 1 or 0

Crisp Sets– she is 18 years old– man 1.6m tall

FUZZY LOGIC– Imprecise properties

Partial membership– YES ---> NO– TRUE ---> FALSE– 1 ---> 0

Fuzzy Sets– she is about 18

years old– man about 1.6m tall

Page 9: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

9

How does Fuzzy Logic resembles Human intelligence?

It can handle at certain level of imprecision and uncertainty

By clustering & classification– dividing the scenario/problems into parts – focusing on each part with rank of importance and

alternatives to solve– combining the parts to as an integrated whole

It reflects some forms of the human reasoning process by– Setting hypothetical rules– Performing inferencing– Performing logic reasoning on the rules

Page 10: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

10

Tem

pera

ture

(C

º)

Boolean Logic (for ‘Temperature’) toDescribe terms such as ‘cold’, ‘hot’

0.0

100.0 Hot

Cold

It is discrete, i.e. based on two values

Page 11: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

11

Tem

per

atu

re (

C º

)

Fuzzy Logic (for ‘Temperature’)

0.0

100.0 Extremely Hot

Extremely Cold

Hot

Quite Hot

Quite Cold

Cold

It’s continuous…

Page 12: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

12

Fuzzy Logic canFuzzy Logic can

represent vague language naturallyenrich not replace crisps setsallow flexible engineering designimprove model performance

– E.g. save power consumption– E.g. increase lifespan

are simple to implement, and often work

Page 13: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

13

History of Fuzzy LogicHistory of Fuzzy Logic

1965 - Fuzzy Sets ( Lofti Zadeh, seminar) 1966 - Fuzzy Logic ( P. Marinos, Bell Labs) 1972 - Fuzzy Measure ( M. Sugeno, TIT) 1974 - Fuzzy Logic Control (E.H. Mamdani) 1980 - Control of Cement Kiln (F.L. Smidt, Denmatk) 1987 - Sendai Subway Train Experiment ( Hitachi) 1988 - Stock Trading Expert System (Yamaichi) 1989 - LIFE ( Lab for International Fuzzy Eng)

Page 14: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

14

Embedding Fuzzy Logic in Control Systems

Fuzzy Control used in the subway in Sendai, Japan– fuzzy control system is used to control the train's acceleration,

deceleration and braking– & passengers hardly notice when the train is actually changing its

velocity– has proven to be superior to both human and conventional

automated controllers– reduced the energy consumption been by 10%

The idea of fuzzy controlling technology has been enthusiastically received in Japan

Page 15: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

15

Fuzzy Logic ApplicationsFuzzy Logic ApplicationsFuzzy Logic success is mainly due to its introduction into consumer products such as:– temperature controlled electrical shower unit

– air conditioner– washing machines– refrigerators– television– rice cooker– brake control of vehicles– Etc.

Page 16: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

16

Fuzzy RuleFuzzy Rule

A fuzzy rule can be defined as a conditional statement in the form:

If x is A Then y is B

where x and y are linguistic variables; A and B are linguistic values determined by fuzzy sets

on the universe of discourses x and y, respectively

Page 17: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

17

What is the difference between classical and fuzzy rules?

Consider the rules in fuzzy form, as follows:

Rule 1 Rule 2IF driving_speed is fast IF driving_speed is slow

THEN stop_distance is long THEN stop_distance is short

In fuzzy rules, the linguistic variable speed can have the range between 0 and 220 km/h, but the range includes fuzzy sets,

such as slow, medium, fast. Linguistic variable stop_distance can take either value: long or short. The universe of discourse of the linguistic variable stop_distance can

be between 0 and 300m and may include such fuzzy sets as short, medium, and long.

Page 18: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

18

Example of Fuzzy RulesIF project_duration is shortAND project_staffing is mediumAND project_funding is inadequateTHEN risk is high

IF project_duration is longAND project_staffing is largeAND project_funding is adequateTHEN risk is low

IF project_duration is shortAND project_staffing is largeAND project_funding is adequateTHEN risk is medium

IF service is excellentOR food is deliciousTHEN tip is generous::

One setof 3 fuzzy rules

More can begenerated

Also, look at the linguistic values used here

Page 19: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

19

ExampleExampleProblems:

– How to handle the temperature of a room so that it is not too hot/cold

– How if too many students or very few students are in the room ?

How to designed an automatic air-conditioner which will be able to set temperature:– warmer when it is too cold, and– colder it is too hot?

Page 20: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

20

Fuzzy Logic MethodologyFuzzy Logic Methodology

Set the boundaries between two values(cold and hot) which will show the degrees of temperature– A sample set of rules

IF temperature is cold THEN set fan_speed to zero

IF temperature is cool THEN set fan_speed to low

IF temperature is warm THEN set fan_speed to medium

IF temperature is hot THEN set fan_speed to high

Page 21: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

21

1. Design a set of Fuzzy rules for bathroom shower use.

IF Water_Volume is full THEN set Temperature to hot IF Water_Volume is half THEN set Temperature to warm IF Water_Volume is quarter THEN set Temperature to cold

Exercises

Page 22: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

22

IF Load_Weight is heavy THEN set Water_Amount to maximum

IF Load_Weight is medium THEN set Water_Amount to regular

IF Load_Weight is light THEN set Water_Amount to minimum

IF Load_Weight is heavy THEN set Water_Amount to full IF Load_Weight is not_so_heavy THEN set Water_Amount to three_quarter IF Load_Weight is not_so_light THEN set Water_Amount to half IF Load_Weight is light THEN set Water_Amount to quarter

2. Design a set of fuzzy rules for an electrical washing machine

Or

Page 23: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

23

Membership Function

Cold Cool Warm Hot

0

1

-10 0 10 20 30ºC

Fuzzy Sets to Characterize the Temperature of a room

Expresses the shift of temperature more natural and smooth

Page 24: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

Exercise: Exercise: A question combiningA question combining

fuzzy rules & truth values and fuzzy rules & truth values and resolution proofresolution proof

Page 25: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

25

FUZZY RULES AND RESOLUTION PROOFFUZZY RULES AND RESOLUTION PROOF

((WORKED EXAMPLE)WORKED EXAMPLE)

Given the following fuzzy rules and facts with their Truth Values (TV) indicated in brackets:

Q ( TV = 0.3) TVs for factsW ( TV = 0.65)Q P S (TV = 1.0)S U ( TV = 1.0) TVs for fuzzy rulesW R ( TV = 0.9)W P ( TV = 0.6)

You are required to find (or compute) the Truth Value of U by using the fuzzy refutation and resolution rules.

Page 26: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

26

Convert facts and rules to clausal forms. [in our case, there are 4 rules that need conversion].

By resolution & refutation proof , we negate the goal. [in our case, this is U. assign a TV = 1.0 for it]

For those fuzzy rules, check to see if there is any Truth Value less than 0.5 (i.e. 50%); invert the clause and compute new TV for inverted clause using formula (1 – TV(old-clause)). [we have the clause Q which is < 0.5, in our example]

Apply resolution proof to reach at NIL (i.e. a direct contradiction).– Each time when two clauses are resolved (combined to yield a resolvent), the

minimum of the TVs is taken & assigned it to the new clause.

Combining resolution proof and Combining resolution proof and fuzzy refutation fuzzy refutation

Steps

Page 27: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

27

SolutionCONFLICT SET:

Q P S (TV=1.0) …………(1) S U (TV=1.0) …………(2) W R (TV=0.9) …………(3) W P (TV=0.6) …………(4) Q (TV=0.3) Q (1 – TV( Q ) = 0.7) …. (5) W (TV=0.65) …………(6) U (TV=1.0) …………(7)

2 & 7: S TV=1.0 ……(8) 8 & 1: Q P TV=1.0 ……(9) 9 & 5: P TV=0.7 ……(10) 10 & 4: W TV=0.6 ……(11)

11 & 6: NIL TV= 0.6 (ANSWER)

U is true, i.e. proven and it has a truth value of 0.6

Page 28: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

28

Supplementary slidesSupplementary slides

Page 29: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

29

Applications in Fuzzy logic Applications in Fuzzy logic decision makingdecision making

The most popular area of applications– fuzzy control– industrial applications in domestic appliances

– process control– automotive systems

Page 30: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

30

FFuzzy uzzy DDecision ecision MMaking aking in in Medicine - IMedicine - I

Medicine– the increased volume of information

available to physicians from new medical technologies

– the process of classifying different sets of symptoms under a single name and determining appropriate therapeutic actions becomes increasingly difficult

Page 31: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

31

FFuzzy uzzy DDecision ecision MMaking aking in in Medicine - IIMedicine - II

– The past history offered by the patient may be subjective, exaggerated, underestimated or incomplete

– In order to understand better and teach this difficult and important process of medical diagnosis, it can be modeled with the use of fuzzy sets

Page 32: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

32

FFuzzy uzzy DDecision ecision MMaking aking in in Medicine - IIIMedicine - III

The models attempt to deal with different complicating aspects of medical diagnosis– the relative importance of symptoms– the varied symptom patterns of different disease

stages– relations between diseases themselves– the stages of hypothesis formation– preliminary diagnosis– final diagnosis within the diagnostic process itself.

Page 33: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

33

FFuzzy uzzy DDecision ecision MMaking aking in in Medicine - IVMedicine - IV

Its importance emanates from the nature of medical information – highly individualized – often imprecise– context-sensitive

– often based on subjective judgmentTo deal with this kind of information without

fuzzy decision making and approximate reasoning is virtually impossible

Page 34: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

34

FFuzzy uzzy DDecision ecision MMaking aking in Information Systemsin Information Systems

Information systems– information retrieval and database

management has also benefited from fuzzy set methodology

– expression of soft requests that provide an ordering among the items that more or less satisfy the request

– allow for the presence of imprecise, uncertain, or vague information in the database

Page 35: UNIVERSITI TENAGA NASIONAL CSNB234 ARTIFICIAL INTELLIGENCE Chapter 8.1 Introduction to Fuzzy Logic and Fuzzy Rules Chapter 8.1 Introduction to Fuzzy Logic.

35

Conclusion

Fuzzy Logic Decision Making is used in many applications– Implemented using fuzzy sets

operation(if_then_else statements & logical operators)

– Resembles human decision making with its ability to work from approximate data and find a precise solutions