Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

44
Fuzzy Expert System Fuzzy Logic ي ن كاها ن س ح م ر كت دhttp:// www.um.ac.ir/ ~kahani/

Transcript of Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

Page 1: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

Fuzzy Expert System

Fuzzy Logic

كاهاني دكترمحسنhttp://www.um.ac.ir/~kahani/

Page 2: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Introduction Experts rely on common sense when they solve

problems. How can we represent expert knowledge that uses

vague and ambiguous terms in a computer? Fuzzy logic is not logic that is fuzzy, but logic that is

used to describe fuzziness. Fuzzy logic is the theory of fuzzy sets, sets that

calibrate vagueness. Fuzzy logic is based on the idea that all things admit

of degrees.

Page 3: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Fuzzy Logic Boolean logic uses sharp distinctions. Fuzzy logic reflects how people think. It

attempts to model our sense of words, our decision making and our common sense. As a result, it is leading to new, more human, intelligent systems.

Page 4: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Fuzzy Logic Histroty Fuzzy, or multi-valued logic was introduced in the

1930s by Jan Lukasiewicz, a Polish philosopher. This work led to an inexact reasoning technique often called possibility theory.

Later, in 1937, Max Black published a paper called “Vagueness: an exercise in logical analysis”. In this paper, he argued that a continuum implies degrees.

In 1965 Lotfi Zadeh, published his famous paper “Fuzzy sets”.

Zadeh extended possibility theory into a formal system of mathematical logic.

Page 5: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Why fuzzy? As Zadeh said, the term is concrete,

immediate and descriptive.

Why logic? Fuzziness rests on fuzzy set theory, and

fuzzy logic is just a small part of that theory.

Page 6: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Definition Fuzzy logic is a set of mathematical principles for

knowledge representation based on degrees of membership.

Unlike two-valued Boolean logic, fuzzy logic is multi-valued.

It deals with degrees of membership and degrees of truth.

Fuzzy logic uses the continuum of logical values between 0 (completely false) and 1 (completely true).

Page 7: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Range of logical values in Boolean and fuzzy logic

Page 8: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Fuzzy sets The concept of a set is fundamental to

mathematics. However, our own language is also the

supreme expression of sets. For example, car indicates the set of cars. When we say a car, we mean one out of the set of cars.

Page 9: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Tall men example

Page 10: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Crisp and fuzzy sets of “tall men”

Page 11: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

A fuzzy set is a set with fuzzy boundaries

The x-axis represents the universe of discourse The y-axis represents the membership value of the

fuzzy set. In classical set theory, crisp set A of X is defined as

fA(x): X → {0, 1}, where In fuzzy theory, fuzzy set A of universe X is defined

μA(x): X → [0, 1], where μA(x) = 1 if x is totally in A;

μA(x) = 0 if x is not in A;

0 < μA(x) < 1 if x is partly in A.

Page 12: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

fuzzy set representation First, we determine the membership

functions. In our “tall men” example, we can obtain fuzzy sets of tall, short and average men.

The universe of discourse − the men’s heights − consists of three sets: short, average and tall men.

Page 13: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Crisp and fuzzy sets

Page 14: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Representation of crisp and fuzzy subsets

Typical functions : sigmoid, gaussian and pi. However, these functions increase the time of

computation. Therefore, in practice, most applications use linear fit functions.

Page 15: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Membership Functions (MFs)Characteristics of MFs:

Subjective measures Not probability functions

MFs

Heights5’10’’

.5

.8

.1

“tall” in Asia

“tall” in the US

“tall” in NBA

Page 16: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Fuzzy SetsFuzzy SetsFormal definition:

A fuzzy set A in X is expressed as a set of ordered pairs:

A x x x XA {( , ( ))| }

Universe oruniverse of discourse

Fuzzy setMembership

function(MF)

A fuzzy set is totally characterized by aA fuzzy set is totally characterized by amembership function (MF).membership function (MF).

Page 17: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Fuzzy Sets with Discrete Universes

Fuzzy set C = “desirable city to live in”X = {SF, Boston, LA} (discrete and nonordered)

C = {(SF, 0.9), (Boston, 0.8), (LA, 0.6)}Fuzzy set A = “sensible number of children”

X = {0, 1, 2, 3, 4, 5, 6} (discrete universe)

A = {(0, .1), (1, .3), (2, .7), (3, 1), (4, .6), (5, .2), (6, .1)}

Page 18: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Fuzzy Sets with Cont. Universes

Fuzzy set B = “about 50 years old”X = Set of positive real numbers (continuous)

B = {(x, B(x)) | x in X}

B xx

( )

1

150

10

2

Page 19: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Alternative NotationA fuzzy set A can be alternatively denoted as follows:

A x xAx X

i i

i

( ) /

A x xA

X

( ) /

X is discrete

X is continuous

Note that and integral signs stand for the union of membership grades; “/” stands for a marker and does not imply division.

Page 20: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Fuzzy PartitionFuzzy PartitionFuzzy partitions formed by the linguistic values “young”, “middle aged”, and “old”:

Page 21: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

MF Terminology

MF

X

.5

1

0Core

Crossover points

Support

- cut

Page 22: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

MF Formulation

Triangular MF: trimf x a b cx ab a

c xc b

( ; , , ) max min , ,

0

Trapezoidal MF: trapmf x a b c dx ab a

d xd c

( ; , , , ) max min , , ,

1 0

Generalized bell MF: gbellmf x a b cx cb

b( ; , , )

1

12

Gaussian MF: gaussmf x a b c ex c

( ; , , )

12

2

Page 23: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

MF Formulation

Page 24: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Linguistic variables and hedges

At the root of fuzzy set theory lies the idea of linguistic variables.

A linguistic variable is a fuzzy variable. For example, the statement “John is tall” implies that the linguistic variable John takes the linguistic value tall.

Page 25: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Example In fuzzy expert systems, linguistic variables are used

in fuzzy rules. For example:IF wind is strongTHEN sailing is good

IF project_duration is longTHEN completion_risk is high

IF speed is slowTHEN stopping_distance is short

Page 26: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Hedge A linguistic variable carries with it the

concept of fuzzy set qualifiers, called hedges.

Hedges are terms that modify the shape of fuzzy sets. They include adverbs such as very, somewhat, quite, more or less and slightly.

Page 27: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Fuzzy sets with the hedge very

Page 28: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Representation of hedges

Page 29: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Representation of hedges (cont.)

Page 30: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Operations of fuzzy sets The classical set theory developed in

the late 19th century by Georg Cantor describes how crisp sets can interact. These interactions are called operations.

Page 31: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Cantor’s sets

Page 32: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

ComplementCrisp Sets: Who does not belong to the set?

Fuzzy Sets: How much do elements not belong to the set?

The complement of a set is an opposite of this set.

μA(x) = 1 − μA(x)

Page 33: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

ContainmentCrisp Sets: Which sets belong to which other sets?

Fuzzy Sets: Which sets belong to other sets? A set can contain other sets. The smaller set is called

subset. In crisp sets, all elements of a subset entirely belong

to a larger set. In fuzzy sets, each element can belong less to the

subset than to the larger set. Elements of the fuzzy subset have smaller memberships in it than in the larger set.

Page 34: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

IntersectionCrisp Sets: Which element belongs to both sets?

Fuzzy Sets: How much of the element is in both sets? In classical set theory, an intersection between two

sets contains the elements shared by these sets In fuzzy sets, an element may partly belong to both

sets with different memberships. A fuzzy intersection is the lower membership in both sets of each element.

μA∩B(x) = min [μA(x), μB(x)] = μA(x) ∩ μB(x)

where xX

Page 35: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

UnionCrisp Sets: Which element belongs to either set?

Fuzzy Sets: How much of the element is in either set? The union of two crisp sets consists of every element

that falls into either set. In fuzzy sets, the union is the reverse of the

intersection. That is, the union is the largest membership value of the element in either set.

μAB(x) = max [μA(x), μB(x)] = μA(x) μB(x)

where xX

Page 36: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Operations of fuzzy sets

Page 37: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Fuzzy rules In 1973, Lotfi Zadeh published his

second most influential paper. This paper outlined a new approach to analysis of complex systems, in which Zadeh suggested capturing human knowledge in fuzzy rules.

Page 38: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

What is a fuzzy 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; and A

and B are linguistic values determined by fuzzy sets on the universe of discourses X and Y, respectively.

Page 39: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

classical vs. fuzzy rules? A classical IF-THEN rule uses binary logic

Rule: 1IF speed is > 100THEN stopping_distance is long

Rule: 2IF speed is < 40THEN stopping_distance is short

Rule: 1IF speed is fastTHEN stopping_distance is long

Rule: 2IF speed is slowTHEN stopping_distance is short

Representing the stopping distance rules in a fuzzy form:

Page 40: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Fuzzy Rules Fuzzy rules relate fuzzy sets. In a fuzzy system, all rules fire to some

extent, or in other words they fire partially.

If the antecedent is true to some degree of membership, then the consequent is also true to that same degree

Page 41: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Fuzzy sets of tall and heavy men

These fuzzy sets provide the basis for a weight estimation model. The model is based on a relationship between a man’s height and his weight:

IF height is tall

THEN weight is heavy

Page 42: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

monotonic selection The value of the output or a truth membership grade

of the rule consequent can be estimated directly from a corresponding truth membership grade in the antecedent. This form of fuzzy inference uses a method called monotonic selection.

Page 43: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Fuzzy Rule A fuzzy rule can have multiple antecedents, for

example:IF project_duration is longAND project_staffing is largeAND project_funding is inadequateTHEN risk is high

IF service is excellentOR food is deliciousTHEN tip is generous

Page 44: Fuzzy Expert System Fuzzy Logic دكترمحسن كاهاني kahani

دانش مهندسي و خبره -سيستمهايكاهاني دكتر

Fuzzy Rule The consequent of a fuzzy rule can also include

multiple parts, for instance:

IF temperature is hot

THEN hot_water is reduced;

cold_water is increased