Title | L2 Fuzzy Theories |
---|---|
Author | bilal sarwar |
Course | Artificial Intelligence |
Institution | University of Hertfordshire |
Pages | 38 |
File Size | 912.4 KB |
File Type | |
Total Downloads | 76 |
Total Views | 122 |
L1 Intro 2Fuzzy Logic...
Lecture 2. Fundamentals of Fuzzy Logic Fuzzy sets and Membership functions Fuzzy operations Fuzzy rules
FUZZY SETS & MEMBERSHIP FUNCTIONS
LM
7ENT1013 Artificial Intelligence
2
What is ‘fuzzy’ logic? (recap) Is it 150.5kg in weight or 149.5kg??? ……
LM
LOOK OUT!!!
•“IF falling object is heavier than 150kg, THEN give warning.” • “IF falling object is lighter than 150kg, THEN no warning.”
• “IF falling object is HEAVY, THEN give warning.” • “IF falling object is LIGHT, THEN no warning.”
-- Conventional Logic
-- Human Logic 7ENT1013 Artificial Intelligence
3
Boolean logic vs. Fuzzy logic (recap) Degree of ‘tall’ Height (cm)
0
1
short
tall 180
Figure 2.1 (a) Two-valued Boolean logic
0
0.8
1
180
200
Degree of ‘tall’ Height (cm) 150
Figure 2.1 (b) Multi-valued fuzzy logic LM
7ENT1013 Artificial Intelligence
4
Crisp and fuzzy sets of “tall men” (recap) Degree of Membership 1.0
•
The x-axis represents the universe of discourse.
•
Elements of a fuzzy set are taken from a universe, the universe depending on the context.
•
The y-axis represents the membership value of the crisp/fuzzy set.
•
Every element is a member of the fuzzy set to some degree – this degree is given by the membership function µ(x).
•
In our case, the fuzzy set of ‘tall men’ maps height values into the corresponding membership values.
Crisp Set
0.8
Tall Men
0.6 0.4 0.2 0.0 150
160
170
180
190
200
210 Height, cm
Degree of Membership 1.0
Fuzzy Set
0.8 0.6 0.4 0.2 0.0 150
160
170
180
190
200
210 Height, cm
Plot of membership function LM
7ENT1013 Artificial Intelligence
5
Membership functions in Matlab (recap) 1.2 trapmf
gbellmf
trimf
gaussmf
gauss2mf
smf
1 0.8 0.6 0.4 0.2 0
1.2 zmf
psigmf
dsigmf
pimf
sigmf
1 0.8 0.6 0.4 0.2 0
Use Matlab help function to learn more. LM
7ENT1013 Artificial Intelligence
6
Steps to define a fuzzy set 1. First, we define the universe of discourse. In our “tall men” example, the universe of discourse is men’s heights: 150-210 cm.
2. Then we decide the possible fuzzy sets in the defined universe of discourse. For example, we obtain fuzzy sets of tall, short and average.
3. Finally, we determine the membership function for each fuzzy set in the defined universe of discourse. LM
7ENT1013 Artificial Intelligence
7
Crisp and fuzzy sets of short, average and tall men Degree of Membership 1.0
Crisp Sets
Short
0.8
Average
Tall
0.6 0.4 0.2 0.0 150
160
170
180
Degree of Membership 1.0
190
200
210 Height, cm
200
210
Fuzzy Sets
0.8 Short
0.6
Average
Tall
0.4 0.2
As you can see, a man who is 182 cm tall is a member of the ‘average men’ set with a degree of membership of 0.2, and at the same time, he is also a member of the ‘tall men’ set with a degree of 0.32.
0.0 150
LM
160
170
180
190
7ENT1013 Artificial Intelligence
8
Exercise: Define fuzzy sets that describe the forward speed and the turning speed of a car.
LM
7ENT1013 Artificial Intelligence
9
Hedge • Hedges are terms that modify the shape of fuzzy sets. Hedges can be used as – All-purpose modifiers, such as very, quite or extremely. – Truth-values, such as quite true or mostly false. – Probabilities, such as likely or not very likely. – Quantifiers, such as most, several or few. – Possibilities, such as almost impossible or quite possible.
• As operations, hedges can create new fuzzy sets. For example, ‘very’ derives a subset of very tall men from the set of tall men. LM
7ENT1013 Artificial Intelligence
10
Representation of hedges in fuzzy logic Hedge
LM
Mathematical Expression
A little
[A ( x )]1.3
Slightly
[A ( x )]1.7
Very
[A ( x)
2
Extremely
[A ( x)
3
Graphical Representation
7ENT1013 Artificial Intelligence
11
Representation of hedges in fuzzy logic Hedge
Very very
Mathematical Expression
Graphical Representation
[A ( x)]4
More or less
A ( x )
Somewhat
A ( x ) 2 A ( x ) 2
Indeed
if 0 A 0.5
1 2 1 A ( x ) 2 if 0.5 < A 1
LM
7ENT1013 Artificial Intelligence
12
Fuzzy sets with the hedge ‘very’ Degree of Membership 1.0 Short
0.8
Tall Average
0.6 0.4 0.2
Very Short
Very Tall
0.0 150
160
170
180
190
200
210 Height, cm
LM
7ENT1013 Artificial Intelligence
13
FUZZY OPERATIONS
LM
7ENT1013 Artificial Intelligence
14
Typical Operations on Crisp Sets X
Not A
B A
A
Complement
Containment
X A
B
Intersection LM
X
X A B
Union
7ENT1013 Artificial Intelligence
15
Operations of Fuzzy Sets • The name operations are inherited from classical set theory. • Operations describe how sets (either crisp or fuzzy) can interact with each other. • But an operation might function differently on fuzzy sets than on crisp sets.
LM
7ENT1013 Artificial Intelligence
16
Not A
Complement – “NOT” Crisp Sets: Who does not belong to the set? Fuzzy Sets: How much do elements not belong to the set?
X
A
• The complement of a fuzzy set is an opposite of this set.
Complement of crisp set A
(x) fuzzy set A
1 0
X
x
(x) 1
fuzzy set Not A
0
X LM
x
• If A is a crisp set, we remove the entire set A from the universe of discourse and we obtain the complement. • If A is a fuzzy set, its complement A can be found as follows: A(x) = 1 A(x) 7ENT1013 Artificial Intelligence
17
Containment – Sub/Superset
Crisp Sets: Which sets belong to which other sets? Fuzzy Sets: Which sets belong to which other sets?
X A
B
• A set can contain other sets. The smaller set is called the subset.
crisp set A is a subset of B
(x) B 1
A
0 (x)
X
1
B
x
A
0
X
A(x) ≤ B(x) x
fuzzy set A is a subset of B LM
• In crisp sets, all elements of a subset entirely belong to a larger set and membership values of both sets are 1 constantly. • In fuzzy sets, each element belongs less to the subset than to the larger set. • Note: fuzzy sets A and B here must have the same UoD. 7ENT1013 Artificial Intelligence
18
Intersection – “AND” Crisp Sets: Which element belongs to both sets? Fuzzy Sets: How much of an element is in both sets?
X A B
• An intersection between two crisp sets contains the elements shared by both sets.
Intersection of crisp sets A and B
• 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.
(x) 1
A
0 (x)
B X
x
• The fuzzy intersection of two fuzzy sets A and B on universe of discourse X: AB(x) = min [A(x), B(x)] = A(x) B(x), 0 x X where xX. Intersection of fuzzy sets A and B A B
1
LM
7ENT1013 Artificial Intelligence
19
Alternative Function for Intersection • Minimum is not the only function that can be used to express the intersection of two fuzzy sets (although it is the most commonly-used). We could also use the product of the two membership functions: AB(x) = A(x) * B(x) where x X. • Different functions may generate different results for the intersection. • But compare how these functions behave when A and B take values of 0 or 1.
LM
7ENT1013 Artificial Intelligence
20
The Fuzzy Empty Set, X B A
Membership function of -- (x) = 0 Membership function of X -- X(x) = 1 LM
7ENT1013 Artificial Intelligence
21
Crisp Sets: Which element belongs to either set? Fuzzy Sets: How much of an element is in either set?
X A B
Union of crisp set A and B
(x) 1
A
B
0 (x)
X
x
AB
1
Union – “OR”
• 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. • The union of two fuzzy sets A and B on universe X can be given as: AB(x) = max [A(x), B(x)] = A(x) B(x),
0 X
x
where xX.
Union of fuzzy set A and B LM
7ENT1013 Artificial Intelligence
22
Alternative Function for Union
Maximum is not the only function that can be used to express the union of two fuzzy sets (although it is the most commonly-used). We could also use the “probabilistic OR”: AB(x) = A(x) + B(x) - A(x) * B(x) where xX. Again, check how these function behave when A and B take values of 0 or 1.
LM
7ENT1013 Artificial Intelligence
23
Properties of Fuzzy Sets (1) • Commutativity:
AB=BA AB=BA
Order of conditions in a rule antecedent is not important. • Associativity:
A (B C) = (A B) C A (B C) = (A B) C
• Idempotency:
AA=A AA=A
LM
7ENT1013 Artificial Intelligence
24
Properties of Fuzzy Sets (2) • Identity:
A=A AX=X A= AX=A
• Transitivity:
If (A B) and (B C) then A C
• Involution:
(A) = A
Exercise: Can you prove Transitivity & Involution? LM
7ENT1013 Artificial Intelligence
25
Properties of Fuzzy Sets (3) • De Morgan’s Laws - true for “dual” operations: (A B) = A B (A B) = A B • Contradiction – NOT true for fuzzy sets: A A ≠ • Excluded middle – NOT true for fuzzy sets: A A ≠ X
Exercise: Can you prove and give examples of Contradiction & Excluded middle ? LM
7ENT1013 Artificial Intelligence
26
• Using fuzzy operations and their properties with hedges, we can create a variety of fuzzy sets based on the existing ones. Exercise: Given the MF of fuzzy set ‘tall’, what is the MF of fuzzy set ‘tall but not very tall’ (i.e. ‘average tall’)?
LM
7ENT1013 Artificial Intelligence
27
FUZZY RULES
LM
7ENT1013 Artificial Intelligence
28
Fuzzy Rules In 1973, Professor 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. Professor at University of California, Berkeley
Syntax of a fuzzy rule • A fuzzy rule can be defined as a conditional statement in the form: IF x is A IF speed is fast THEN y is B THEN stopping_distance is long where x and y are linguistic variables of the rule; A and B are linguistic values of the rule and they are determined by fuzzy sets on the universe of discourses X and Y, respectively. • Universe of discourses X and Y are defined for x and y. And fuzzy sets A and B are defined on X and Y in order to interpret x and y. LM
7ENT1013 Artificial Intelligence
30
Difference between classical and fuzzy rules? A classical IF-THEN rule uses binary/Boolean logic, for example, Rule 1: IF speed is > 100 THEN stopping_distance is 100
Rule 2: IF speed is < 40 THEN stopping_distance is 25
The variable speed can have any numerical value between 0 and 220 km/h (the universe of discourse), but each rule applies fully or not at all.
LM
7ENT1013 Artificial Intelligence
31
We can also represent the stopping distance rules in a fuzzy form: Rule 1: IF speed is fast THEN stopping_distance is long
Rule 2: IF speed is slow THEN stopping_distance is short
In fuzzy rules, the linguistic variable speed also has the same universe of discourse (between 0 and 220 km/h), but this range is interpreted by fuzzy sets, such as slow, medium and fast. The universe of discourse of the linguistic variable stopping_distance can be between 0 and 300 m and is interpreted by fuzzy sets such as short, medium and long.
LM
7ENT1013 Artificial Intelligence
32
In a fuzzy system, all rules are true to some degree, or in other words they fire partially. If the antecedent is true to some degree, then the consequent is also true to that same degree - Monotonic Selection.
LM
7ENT1013 Artificial Intelligence
33
Monotonic Selection Degree of Membership 1.0
Degree of Membership 1.0
Tall
0.8
0.8
0.6
0.6
0.4
0.4
0.2
0.2
0.0 160
0.0 180
190 200 Height, cm
IF height is tall THEN weight is heavy LM
70
Heavy
80
100 120 Weight, kg
According to this rule, for a given input value of height=183cm, an output weight=77kg should be generated (the red lines). 7ENT1013 Artificial Intelligence
34
A fuzzy rule can have multiple parts of antecedents, for example: IF AND AND THEN
project_duration is long project_staffing is large project_funding is inadequate risk is high
IF service is excellent OR food is delicious THEN tip is generous LM
7ENT1013 Artificial Intelligence
35
The consequent of a fuzzy rule can also include multiple parts, for instance: IF THEN
LM
temperature is hot hot_water is reduced; cold_water is increased.
Multiple parts in a rule consequent are independent to each other. So a FIS with two outputs is equivalent to two independent FISs with one output each. The only difference is that the rule antecedent is evaluated once here; while with two rules there will be two evaluations of the rule antecedents. 7ENT1013 Artificial Intelligence
36
Summary • Fuzzy logic is a set of mathematical principles for knowledge representation based on degrees of membership rather than on the crisp membership of classical binary logic. • Unlike two-valued Boolean logic, fuzzy logic is multi-valued and allows partial truth. • To represent a fuzzy set in a computer, we express it as a function and then map the elements of the set to their degrees of membership. LM
7ENT1013 Artificial Intelligence
37
• Hedges are fuzzy set qualifiers used to modify the shape of fuzzy sets and create new subsets. • Fuzzy rules are the expert knowledge, which contain linguistic uncertainty. • Fuzzy logic is a logic that describes fuzziness. As fuzzy logic attempts to model human’s sense of words, decision making and common sense, it is leading to more human, intelligent machines.
LM
7ENT1013 Artificial Intelligence
38...