Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić [email protected].

36
Fuzzy logic Fuzzy logic Introduction 2 Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Raki Aleksandar Raki ć ć rakic rakic @etf.rs @etf.rs

Transcript of Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić [email protected].

Page 1: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

Fuzzy logicFuzzy logic

Introduction 2Introduction 2Fuzzy Sets & Fuzzy Rules

Aleksandar RakiAleksandar Rakićć

[email protected]@etf.rs

Page 2: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

2

ContentsContents

Characteristics of Fuzzy SetsCharacteristics of Fuzzy Sets OperationsOperations PropertiesProperties Fuzzy RulesFuzzy Rules ExamplesExamples

Page 3: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

3

Characteristics of Fuzzy Characteristics of Fuzzy SetsSets

The classical set theory developed in the late 19th century The classical set theory developed in the late 19th century by Georg Cantor describes how crisp sets can interact. by Georg Cantor describes how crisp sets can interact. These interactions are called These interactions are called operationsoperations..

Also fuzzy sets have well defined Also fuzzy sets have well defined propertiesproperties..

These properties and operations are the basis on which the These properties and operations are the basis on which the fuzzy sets are used to deal with uncertainty on the one fuzzy sets are used to deal with uncertainty on the one hand and to represent knowledge on the other.hand and to represent knowledge on the other.

Page 4: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

4

Note: Membership Note: Membership FunctionsFunctions

When a fuzzy set When a fuzzy set AA is constructed over continuous universe of discourse is constructed over continuous universe of discourse XX, it is , it is described by its (continuous) membership function:described by its (continuous) membership function:

AA((xx),),

where where xx X.X. When elements of a fuzzy set When elements of a fuzzy set AA belong to a finite universe of discourse: belong to a finite universe of discourse:

AA = { = {xx11, , xx22, .., , .., xxnn},},

usually a fuzzy set is denoted as:usually a fuzzy set is denoted as:

AA = = AA((xxii)/)/xxii + …………. + + …………. + AA((xxnn)/)/xxnn

where where AA((xxii)/)/xxii (a singleton) is a pair: (a singleton) is a pair:

““grade of membership” grade of membership” //element.element.

Page 5: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

5

Operations of Fuzzy SetsOperations of Fuzzy Sets

Intersection Union

Complement

Not A

A

Containment

AA

B

BA BAA B

Page 6: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

6

ComplementComplement

Crisp SetsCrisp Sets: Who does not belong to the set?: Who does not belong to the set? Fuzzy SetsFuzzy Sets: How much do elements not belong to the set?: How much do elements not belong to the set?

The complement of a set is an opposite of this set. For The complement of a set is an opposite of this set. For example, if we have the set of tall men, its complement is example, if we have the set of tall men, its complement is the set of NOT tall men. When we remove the tall men set the set of NOT tall men. When we remove the tall men set from the universe of discourse, we obtain the complement. from the universe of discourse, we obtain the complement.

If A is the fuzzy set, its complement If A is the fuzzy set, its complement AA can be found as can be found as follows:follows:

AA((xx) = 1 ) = 1 AA((xx).).

Page 7: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

7

ContainmentContainment

Crisp SetsCrisp Sets: Which sets belong to which other sets?: Which sets belong to which other sets? Fuzzy SetsFuzzy Sets: How much sets belong to other sets?: How much sets belong to other sets?

Similar to a Chinese box, a set can contain other sets. The Similar to a Chinese box, a set can contain other sets. The smaller set is called the smaller set is called the subsetsubset. For example, the set of tall . For example, the set of tall men contains all tall men; very tall men is a subset of tall men. men contains all tall men; very tall men is a subset of tall men. However, the tall men set is just a subset of the set of men.However, the tall men set is just a subset of the set of men.

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

In fuzzy sets, however, each element can belong less to the In fuzzy sets, however, each element can belong less to the subset than to the larger set. Elements of the fuzzy subset subset than to the larger set. Elements of the fuzzy subset have smaller memberships in the subset than in the larger set.have smaller memberships in the subset than in the larger set.

To be further discussed in Properties of fuzzy sets...To be further discussed in Properties of fuzzy sets...

Page 8: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

8

IntersectionIntersection Crisp SetsCrisp Sets: Which element belongs to both sets?: Which element belongs to both sets? Fuzzy SetsFuzzy Sets: How much of the element is in both sets?: How much of the element is in both sets?

In classical set theory, an intersection between two sets In classical set theory, an intersection between two sets contains the elements shared by these sets. For example, contains the elements shared by these sets. For example, the intersection of the set of tall men and the set of fat men the intersection of the set of tall men and the set of fat men is the area where these sets overlap. is the area where these sets overlap.

In fuzzy sets, an element may partly belong to both sets In fuzzy sets, an element may partly belong to both sets with different memberships.with different memberships.

A fuzzy intersection is the A fuzzy intersection is the lower membershiplower membership in both sets in both sets of each element. The fuzzy intersection of two fuzzy sets of each element. The fuzzy intersection of two fuzzy sets AA and and BB on universe of discourse X: on universe of discourse X:

AABB((xx) = min [) = min [AA((xx), ), BB((xx)] = )] = AA((xx) ) BB((xx), ),

where where xxX.X.

Page 9: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

9

UnionUnion Crisp SetsCrisp Sets: Which element belongs to either set?: Which element belongs to either set? Fuzzy SetsFuzzy Sets: How much of the element is in either set?: How much of the element is in either set?

The union of two crisp sets consists of every element that falls The union of two crisp sets consists of every element that falls into either set. For example, the union of tall men and fat into either set. For example, the union of tall men and fat men contains all men who are tall OR fat.men contains all men who are tall OR fat.

In fuzzy sets, the union is the reverse of the intersection. That In fuzzy sets, the union is the reverse of the intersection. That is, the union is the is, the union is the largest membership largest membership value of the value of the element in either set. The fuzzy operation for forming the element in either set. The fuzzy operation for forming the union of two fuzzy sets A and B on universe X can be given union of two fuzzy sets A and B on universe X can be given as:as:

AABB((xx) = max [) = max [AA((xx), ), BB((xx)] = )] = AA((xx) ) BB((xx), ),

where where xxXX..

Page 10: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

10

Operations of Fuzzy SetsOperations of Fuzzy Sets

Page 11: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

11

Properties of Fuzzy SetsProperties of Fuzzy Sets

Equality of two fuzzy setsEquality of two fuzzy sets Inclusion of one set into another Inclusion of one set into another

fuzzy setfuzzy set Cardinality of a fuzzy setCardinality of a fuzzy set An empty fuzzy setAn empty fuzzy set -cuts (alpha-cuts)-cuts (alpha-cuts)

Page 12: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

12

EqualityEquality

Fuzzy set Fuzzy set AA is considered equal to a fuzzy set is considered equal to a fuzzy set BB, IF AND , IF AND ONLY IF:ONLY IF:

AA((xx)) = = BB((xx), ), xxXX

Example: Example: AA = 0.3/1 + 0.5/2 + 1/3, = 0.3/1 + 0.5/2 + 1/3, BB = 0.3/1 + 0.5/2 + 1/3, = 0.3/1 + 0.5/2 + 1/3,

therefore therefore AA = = B.B.

Page 13: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

13

InclusionInclusion

Inclusion of one fuzzy set into another fuzzy set. Fuzzy set Inclusion of one fuzzy set into another fuzzy set. Fuzzy set A A XX is included is included in (is a subset of) another fuzzy set, in (is a subset of) another fuzzy set, B B XX::

AA((xx) ) BB((xx), ), xxXX

Example: Consider Example: Consider XX = {1, 2, 3} and sets = {1, 2, 3} and sets AA and and BB

AA = 0.3/1 + 0.5/2 + 1/3; = 0.3/1 + 0.5/2 + 1/3;

BB = 0.5/1 + 0.55/2 + 1/3 = 0.5/1 + 0.55/2 + 1/3

then then AA is a subset of is a subset of B, or B, or A A BB

Page 14: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

14

CardinalityCardinality Cardinality of a crisp (non-fuzzy) set Cardinality of a crisp (non-fuzzy) set ZZ is the number of is the number of

elements in elements in ZZ. BUT the cardinality of a fuzzy set . BUT the cardinality of a fuzzy set AA, the so-, the so-called SIGMA COUNT, is expressed as a SUM of the values of called SIGMA COUNT, is expressed as a SUM of the values of the membership function of the membership function of AA, , AA((xx):):

cardcardAA = = AA((xx11) + ) + AA((xx22) + ) + …… AA((xxnn) = ) = ΣΣAA((xxii),), for for ii=1..=1..nn

Example: Consider Example: Consider XX = {1, 2, 3} and sets = {1, 2, 3} and sets AA and and BB

AA = 0.3/1 + 0.5/2 + 1/3; = 0.3/1 + 0.5/2 + 1/3;

BB = 0.5/1 + 0.55/2 + 1/3 = 0.5/1 + 0.55/2 + 1/3

cardcardAA = 1.8= 1.8

cardcardBB = 2.05= 2.05

Page 15: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

15

Empty Fuzzy SetEmpty Fuzzy Set

A fuzzy set A fuzzy set AA is empty, IF AND ONLY IF: is empty, IF AND ONLY IF:

AA((xx) = 0, ) = 0, xxXX

Example: Consider Example: Consider XX = {1, 2, 3} and fuzzy set = {1, 2, 3} and fuzzy set

AA = 0/1 + 0/2 + 0/3, = 0/1 + 0/2 + 0/3,

then then AA is is empty.empty.

Page 16: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

16

Alpha-CutAlpha-Cut An An -cut or -cut or -level set of a fuzzy set -level set of a fuzzy set AA XX is an ORDINARY SET is an ORDINARY SET

AA XX, such that:, such that:

AA={={AA((xx)), , xxXX}.}.

Example: Consider Example: Consider XX = {1, 2, 3} and set = {1, 2, 3} and set AA = 0.3/1 + 0.5/2 + = 0.3/1 + 0.5/2 + 1/31/3

then: then: AA0.50.5 = {2, 3}, = {2, 3}, AA0.10.1 = {1, 2, 3}, = {1, 2, 3}, AA11 = {3}. = {3}. Example: Consider continuous universe of discourse Example: Consider continuous universe of discourse XX = [ = [aa, , bb] ]

and fuzzy set and fuzzy set A A with the membership function with the membership function AA((xx). ). -cuts for -cuts for some some 11 and and 22 are:are:

Page 17: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

17

Fuzzy Set NormalityFuzzy Set Normality

A fuzzy subset of X is called A fuzzy subset of X is called normalnormal if there exists at least if there exists at least one element one element xxXX such that such that AA((xx) = 1.) = 1.

A fuzzy subset that is not normal is called A fuzzy subset that is not normal is called subnormalsubnormal..

All crisp subsets except for the null set are normal. In fuzzy All crisp subsets except for the null set are normal. In fuzzy set theory, the concept of nullness essentially generalises to set theory, the concept of nullness essentially generalises to subnormality.subnormality.

The The heightheight of a fuzzy set of a fuzzy set AA is the largest membership grade is the largest membership grade of an element in of an element in AA

heightheight((AA) = max) = maxxx((AA((xx)).)). Fuzzy set is called Fuzzy set is called normal normal if and only if:if and only if:

heightheight((AA) = 1.) = 1.

Page 18: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

18

Fuzzy Sets Core and Fuzzy Sets Core and SupportSupport

Assume Assume AA is a fuzzy set over universe of discourse is a fuzzy set over universe of discourse XX.. The The supportsupport of of AA is the is the crisp subset of crisp subset of XX consisting of all consisting of all

elements with membership grade:elements with membership grade:

suppsupp((AA) = {) = {xx AA((xx) ) 0 and 0 and xxXX}} The The core core of of AA is the is the crisp subset of crisp subset of XX consisting of all consisting of all

elements with membership grade:elements with membership grade:

corecore((AA) = {) = {xx AA((xx) = 1 and ) = 1 and xxXX}} Example:Example:

1 0 a b X = [a,b]

core(A) supp(A)

height(A) = 1 (normal fuzzy set)

Membership function has a

trapezoidal form

Page 19: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

19

Fuzzy Set Math Fuzzy Set Math OperationsOperations

kAkA = { = {kkAA((xx), ), xxXX}}

Let Let kk =0.5, and =0.5, and

AA = {0.5/a, 0.3/b, 0.2/c, 1/d} = {0.5/a, 0.3/b, 0.2/c, 1/d}

thenthen

kkAA = {0.25/a, 0.15/b, 0.1/c, 0.5/d} = {0.25/a, 0.15/b, 0.1/c, 0.5/d}

AAmm = { = {AA((xx))mm, , xxXX}}

Let Let mm =2, and =2, and

AA = {0.5/a, 0.3/b, 0.2/c, 1/d} = {0.5/a, 0.3/b, 0.2/c, 1/d}

thenthen

AAmm = {0.25/a, 0.09/b, 0.04/c, 1/d} = {0.25/a, 0.09/b, 0.04/c, 1/d} ……

Page 20: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

20

Fuzzy Sets ExamplesFuzzy Sets Examples Consider two fuzzy subsets of the set Consider two fuzzy subsets of the set XX,,

XX = {a, b, c, d, e } = {a, b, c, d, e }

referred to as referred to as AA and and BB

AA = {1/a, 0.3/b, 0.2/c 0.8/d, 0/e} = {1/a, 0.3/b, 0.2/c 0.8/d, 0/e}

andand

BB = {0.6/a, 0.9/b, 0.1/c, 0.3/d, = {0.6/a, 0.9/b, 0.1/c, 0.3/d, 0.2/e}0.2/e}

SupportSupport::

suppsupp((AA) = {a, b, c, d }) = {a, b, c, d }

suppsupp((BB) = {a, b, c, d, e }) = {a, b, c, d, e } CoreCore::

corecore((AA) = {a}) = {a}

corecore((BB) = {}) = {} CardinalityCardinality::

cardcard((AA) = 1+0.3+0.2+0.8+0 = 2.3) = 1+0.3+0.2+0.8+0 = 2.3

cardcard((BB) = 0.6+0.9+0.1+0.3+0.2 = 2.1) = 0.6+0.9+0.1+0.3+0.2 = 2.1

ComplementComplement::

AA = {1/a, 0.3/b, 0.2/c 0.8/d, 0/e} = {1/a, 0.3/b, 0.2/c 0.8/d, 0/e}

AA = {0/a, 0.7/b, 0.8/c 0.2/d, 1/e} = {0/a, 0.7/b, 0.8/c 0.2/d, 1/e} UnionUnion::

AA BB = {1/a, 0.9/b, 0.2/c, 0.8/d, = {1/a, 0.9/b, 0.2/c, 0.8/d, 0.2/e}0.2/e}

IntersectionIntersection::AA BB = {0.6/a, 0.3/b, 0.1/c, 0.3/d, = {0.6/a, 0.3/b, 0.1/c, 0.3/d,

0/e}0/e}

Page 21: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

21

Fuzzy Sets ExamplesFuzzy Sets Examples Again. two fuzzy subsets of the set Again. two fuzzy subsets of the set XX = {a, b, c, d, e }: = {a, b, c, d, e }:

AA = {1/a, 0.3/b, 0.2/c 0.8/d, 0/e} and = {1/a, 0.3/b, 0.2/c 0.8/d, 0/e} and BB = {0.6/a, 0.9/b, 0.1/c, 0.3/d, = {0.6/a, 0.9/b, 0.1/c, 0.3/d, 0.2/e}0.2/e}

kAkA::for for kk=0.5=0.5kAkA = {0.5/a, 0.15/b, 0.1/c, 0.4/d, 0/e} = {0.5/a, 0.15/b, 0.1/c, 0.4/d, 0/e}

AAmm::for for mm=2=2AAaa = {1/a, 0.09/b, 0.04/c, 0.64/d, 0/e} = {1/a, 0.09/b, 0.04/c, 0.64/d, 0/e}

αα-cut-cut::

AA0.20.2 = {a, b, c, d} = {a, b, c, d}

AA0.30.3 = {a, b, d} = {a, b, d}

AA0.80.8 = {a, d} = {a, d}

AA11 = {a} = {a}

Page 22: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

22

Fuzzy RulesFuzzy Rules In 1973, Lotfi Zadeh published his second most influential In 1973, Lotfi Zadeh published his second most influential

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

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

IFIF xx is is AA THENTHEN y y is is BB

where where xx and and yy are linguistic variables; and are linguistic variables; and AA and and BB are linguistic are linguistic values determined by fuzzy sets on the universe of discourses values determined by fuzzy sets on the universe of discourses XX and and YY, respectively., respectively.

Page 23: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

23

Classical vs. Fuzzy RulesClassical vs. Fuzzy Rules A classical IF-THEN rule uses binary logic, for example,A classical IF-THEN rule uses binary logic, for example,

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

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

The variable speed can have any numerical value between The variable speed can have any numerical value between 0 and 220 km/h, but the linguistic variable 0 and 220 km/h, but the linguistic variable stopping_distance can take either value long or short. stopping_distance can take either value long or short.

In other words, classical rules are expressed in the black-In other words, classical rules are expressed in the black-and-white language of Boolean logic.and-white language of Boolean logic.

Page 24: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

24

Classical vs. Fuzzy RulesClassical vs. Fuzzy Rules We can also represent the stopping distance rules in a fuzzy We can also represent the stopping distance rules in a fuzzy

form:form:

Rule 1:Rule 1: IF speed is fast THEN stopping_distance is longIF speed is fast THEN stopping_distance is long Rule 2:Rule 2: IF speed is slow THEN stopping_distance is shortIF speed is slow THEN stopping_distance is short

In fuzzy rules, the linguistic variable speed also has the range In fuzzy rules, the linguistic variable speed also has the range (the universe of discourse) between 0 and 220 km/h, but this (the universe of discourse) between 0 and 220 km/h, but this range includes fuzzy sets, such as slow, medium and fast. range includes fuzzy sets, such as slow, medium and fast.

The universe of discourse of the linguistic variable The universe of discourse of the linguistic variable stopping_distance can be between 0 and 300 m and may stopping_distance can be between 0 and 300 m and may include such fuzzy sets as short, medium and long.include such fuzzy sets as short, medium and long.

Fuzzy rules relate fuzzy sets.Fuzzy rules relate fuzzy sets. In a fuzzy system, all rules fire to some extentIn a fuzzy system, all rules fire to some extent, or in , or in

other words they fire partially. If the antecedent is true to other words they fire partially. If the antecedent is true to some degree of membership, then the consequent is also some degree of membership, then the consequent is also true to that same degree.true to that same degree.

Page 25: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

25

Firing Fuzzy RulesFiring Fuzzy Rules These fuzzy sets provide the basis for a weight estimation These fuzzy sets provide the basis for a weight estimation

model. The model is based on a relationship between a model. The model is based on a relationship between a man’s height and his weight:man’s height and his weight:

IFIF height is tall THENheight is tall THEN weight is heavyweight is heavy

Tall men Heavy men

180

Degree ofMembership1.0

0.0

0.2

0.4

0.6

0.8

Height, cm

190 200 70 80 100160

Weight, kg

120

Degree ofMembership1.0

0.0

0.2

0.4

0.6

0.8

Page 26: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

26

Firing Fuzzy RulesFiring Fuzzy Rules The value of the output or a truth membership grade of the The value of the output or a truth membership grade of the

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

Tall menHeavy men

180

Degree ofMembership1.0

0.0

0.2

0.4

0.6

0.8

Height, cm

190 200 70 80 100160

Weight, kg

120

Degree ofMembership1.0

0.0

0.2

0.4

0.6

0.8

Page 27: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

27

Firing Fuzzy RulesFiring Fuzzy Rules A fuzzy rule can have multiple antecedents, for example:A fuzzy rule can have multiple antecedents, for example:

IFIF project_duration is long ANDproject_duration is long AND project_staffing is project_staffing is large ANDlarge AND

project_funding is inadequateproject_funding is inadequateTHENTHEN risk is highrisk is high

IFIF service is excellent ORservice is excellent OR food is deliciousfood is deliciousTHENTHEN tip is generoustip is generous

The consequent of a fuzzy rule can also include multiple The consequent of a fuzzy rule can also include multiple parts, for instance:parts, for instance:

IFIF temperature is hottemperature is hotTHENTHEN hot_water is reduced;hot_water is reduced;

cold_water is increasedcold_water is increased

Page 28: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

28

Fuzzy Sets ExampleFuzzy Sets Example Air-conditioning involves the delivery of air which can be Air-conditioning involves the delivery of air which can be

warmed or cooled and have its humidity raised or lowered.warmed or cooled and have its humidity raised or lowered.

An air-conditioner is an apparatus for controlling, especially An air-conditioner is an apparatus for controlling, especially lowering, the temperature and humidity of an enclosed space. lowering, the temperature and humidity of an enclosed space. An air-conditioner typically has a fan which An air-conditioner typically has a fan which blows/cools/circulates fresh air and has cooler and the cooler is blows/cools/circulates fresh air and has cooler and the cooler is under thermostatic control. Generally, the amount of air being under thermostatic control. Generally, the amount of air being compressed is proportional to the ambient temperature.compressed is proportional to the ambient temperature.

Consider Johnny’s air-conditioner which has five control Consider Johnny’s air-conditioner which has five control switches: COLD, COOL, PLEASANT, WARM and HOT. The switches: COLD, COOL, PLEASANT, WARM and HOT. The corresponding speeds of the motor controlling the fan on the corresponding speeds of the motor controlling the fan on the air-conditioner has the graduations: MINIMAL, SLOW, MEDIUM, air-conditioner has the graduations: MINIMAL, SLOW, MEDIUM, FAST and BLAST.FAST and BLAST.

Page 29: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

29

Fuzzy Sets ExampleFuzzy Sets Example The rules governing the air-conditioner are as follows:The rules governing the air-conditioner are as follows:

RULE 1:RULE 1:IFIF TEMP is COLDTEMP is COLD THENTHEN SPEED is MINIMALSPEED is MINIMAL

RULE 2:RULE 2:IFIF TEMP is COOLTEMP is COOL THENTHEN SPEED is SLOWSPEED is SLOW

RULE 3:RULE 3:IFIF TEMP is PLEASANTTEMP is PLEASANT THENTHEN SPEED is MEDIUMSPEED is MEDIUM

RULE 4:RULE 4:IFIF TEMP is WARMTEMP is WARM THENTHEN SPEED is FASTSPEED is FAST

RULE 5:RULE 5:IFIF TEMP is HOTTEMP is HOT THENTHEN SPEED is BLASTSPEED is BLAST

Page 30: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

30

Fuzzy Sets ExampleFuzzy Sets ExampleThe The temperaturetemperature graduations are related to graduations are related to Johnny’s perception of Johnny’s perception of ambient temperatures.ambient temperatures.

where:where:

Y : Y : temptemp value belongs to value belongs to the set (0<the set (0<AA((xx)<1)<1))

Y* : Y* : temptemp value is the ideal value is the ideal member to the set (member to the set (AA((xx)=1)=1))

N : temp value is not a N : temp value is not a member of the set (member of the set (AA((xx)=0)=0))

TemTemp p

((00C)C)

COLDCOLD COOLCOOL PLEASANPLEASANTT

WARMWARM HOTHOT

00 Y*Y* NN NN NN NN

55 YY YY NN NN NN

1010 NN YY NN NN NN

12.512.5 NN Y*Y* NN NN NN

1515 NN YY NN NN NN

17.517.5 NN NN Y*Y* NN NN

2020 NN NN NN YY NN

22.522.5 NN NN NN Y*Y* NN

2525 NN NN NN YY NN

27.527.5 NN NN NN NN YY

3030 NN NN NN NN Y*Y*

Page 31: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

31

Fuzzy Sets ExampleFuzzy Sets ExampleJohnny’s perception of the Johnny’s perception of the speedspeed of the motor is as of the motor is as follows:follows:

where:where:

Y : Y : temptemp value belongs to value belongs to the set (0<the set (0<AA((xx)<1)<1))

Y* : Y* : temptemp value is the ideal value is the ideal member to the set member to the set ((AA((xx)=1)=1))

N : temp value is not a N : temp value is not a member of the set (member of the set (AA((xx)=0)=0))

Rev/secRev/sec

(RPM)(RPM)MINIMALMINIMAL SLOWSLOW MEDIUMMEDIUM FASFAS

TTBLASBLAS

TT

00 Y*Y* NN NN NN NN

1010 YY NN NN NN NN

2020 YY YY NN NN NN

3030 NN Y*Y* NN NN NN

4040 NN YY NN NN NN

5050 NN NN Y*Y* NN NN

6060 NN NN NN YY NN

7070 NN NN NN Y*Y* NN

8080 NN NN NN YY YY

9090 NN NN NN NN YY

100100 NN NN NN NN Y*Y*

Page 32: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

32

Fuzzy Sets ExampleFuzzy Sets Example The analytically expressed membership for the reference fuzzy The analytically expressed membership for the reference fuzzy

subsets for the subsets for the temperaturetemperature are: are: COLD:COLD: for 0 ≤ for 0 ≤ t t ≤ 10≤ 10 COLDCOLD((tt) = ) = –– t t / 10 + 1/ 10 + 1

COOL:COOL: for 0 ≤ for 0 ≤ t t ≤ 12.5≤ 12.5 COOLCOOL((tt) = ) = t t / 12.5/ 12.5

for 12.5 ≤ for 12.5 ≤ tt ≤ 17.5 ≤ 17.5 COOLCOOL((tt) = ) = –– t t / 5 + 3.5/ 5 + 3.5

etcetc…… all based on the linear equation: all based on the linear equation: yy = = axax + + bbTemperature Fuzzy Sets

0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0.8

0.9

1

0 5 10 15 20 25 30

Temperature Degrees C

Tru

th V

alu

e

Cold

Cool

Pleasent

Warm

Hot

Page 33: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

33

Fuzzy Sets ExampleFuzzy Sets Example The analytically expressed membership for the reference fuzzy The analytically expressed membership for the reference fuzzy

subsets for the subsets for the speedspeed are: are: MINIMAL:MINIMAL: for 0 ≤ for 0 ≤ v v ≤ 30≤ 30 MINIMALMINIMAL((vv) = ) = –– v v / 30 + 1/ 30 + 1 SLOW:SLOW: for 10 ≤ for 10 ≤ v v ≤ 30≤ 30 SLOWSLOW((vv) = ) = v v / 20 / 20 –– 0.5 0.5

for 30 ≤ for 30 ≤ vv ≤ 50 ≤ 50 SLOWSLOW((vv) = ) = –– v v / 20 + 2.5/ 20 + 2.5 etcetc…… all based on the linear equation: all based on the linear equation: yy = = axax + + bb

Speed Fuzzy Sets

0

0.2

0.4

0.6

0.8

1

0 10 20 30 40 50 60 70 80 90 100

Speed

Tru

th V

alu

e

MINIMAL

SLOW

MEDIUM

FAST

BLAST

Page 34: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

34

ExercisesExercises

ForForA = {0.2/a, 0.4/b, 1/c, 0.8/d, 0/e}A = {0.2/a, 0.4/b, 1/c, 0.8/d, 0/e}B = {0/a, 0.9/b, 0.3/c, 0.2/d, 0.1/e}B = {0/a, 0.9/b, 0.3/c, 0.2/d, 0.1/e}

calculate the following:calculate the following: Support, Core, Cardinality, and Complement for Support, Core, Cardinality, and Complement for AA and and BB

independently,independently, Union and Intersection of A and B,Union and Intersection of A and B, the new set the new set CC = = AA22

the new set the new set DD = 0.5 = 0.5BB the new set the new set EE, which is the alpha cut at , which is the alpha cut at AA0.50.5

Page 35: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

35

SolutionsSolutionsA = {0.2/a, 0.4/b, 1/c, 0.8/d, 0/e}A = {0.2/a, 0.4/b, 1/c, 0.8/d, 0/e}B = {0/a, 0.9/b, 0.3/c, 0.2/d, 0.1/e}B = {0/a, 0.9/b, 0.3/c, 0.2/d, 0.1/e}

SupportSupportSupp(A) = {a, b, c, d}Supp(A) = {a, b, c, d}Supp(B) = {b, c, d, e}Supp(B) = {b, c, d, e}

CoreCoreCore(A) = {c}Core(A) = {c}Core(B) = {}Core(B) = {}

CardinalityCardinalityCard(A) = 0.2 + 0.4 + 1 + 0.8 + 0 = 2.4Card(A) = 0.2 + 0.4 + 1 + 0.8 + 0 = 2.4Card(B) = 0 + 0.9 + 0.3 + 0.2 + 0.1 = 1.5Card(B) = 0 + 0.9 + 0.3 + 0.2 + 0.1 = 1.5

ComplementComplementComp(A) = {0.8/a, 0.6/b, 0/c, 0.2/d, 1/e}Comp(A) = {0.8/a, 0.6/b, 0/c, 0.2/d, 1/e}Comp(B) = {1/a, 0.1/b, 0.7/c, 0.8/d, 0.9/e}Comp(B) = {1/a, 0.1/b, 0.7/c, 0.8/d, 0.9/e}

Page 36: Fuzzy logic Introduction 2 Fuzzy Sets & Fuzzy Rules Aleksandar Rakić rakic@etf.rs.

36

SolutionsSolutionsA = {0.2/a, 0.4/b, 1/c, 0.8/d, 0/e}A = {0.2/a, 0.4/b, 1/c, 0.8/d, 0/e}B = {0/a, 0.9/b, 0.3/c, 0.2/d, 0.1/e}B = {0/a, 0.9/b, 0.3/c, 0.2/d, 0.1/e}

UnionUnionAAB = {0.2/a, 0.9/b, 1/c, 0.8/d, 0.1/e}B = {0.2/a, 0.9/b, 1/c, 0.8/d, 0.1/e}

IntersectionIntersectionAAB = {0/a, 0.4/b, 0.3/c, 0.2/d, 0/e}B = {0/a, 0.4/b, 0.3/c, 0.2/d, 0/e}

C=AC=A22

C = {0.04/a, 0.16/b, 1/c, 0.64/d, 0/e}C = {0.04/a, 0.16/b, 1/c, 0.64/d, 0/e}

D = 0.5D = 0.5BBD = {0/a, 0.45/b, 0.15/c, 0.1/d, 0.05/e}D = {0/a, 0.45/b, 0.15/c, 0.1/d, 0.05/e}

E = AE = A0.50.5

E = {c, d}E = {c, d}