Fuzzy Systems
Chapter 4 in the book – page 87.
Statements and Definitions:
-
Father of fuzzy logic is Lotfi Zadeh
-
The word fuzzy is the opposite of crisp. In our conventional programming logic we use Boolean logic. Boolean logic uses sharp distinctions. (Yes/no, true/false, etc.)
-
Question with crisp answer: Q: Do you want a donut? A: Yes
-
Fuzzy answer to same question: Q: Do you want a donut? A: Sort of.
-
Fuzzy logic is not logic that is fuzzy, but logic that is used to describe fuzziness. It is the theory of fuzzy sets, sets that describe fuzziness.
-
Fuzzy logic is useful to us because it helps us quantify and describe the words that people use when describing and thinking about problems and situations. Examples:
-
The car is really quick.
-
Tom’s back is quite hairy.
-
The motor is running really hot.
Considering the examples above, using Boolean logic we would need to define a point at which a car is really quick, but where is that.
A Camaro is considered really quick to many people. If it runs a 14.1 second quarter mile are all cars that are slower than Camaros really slow?
How many hairs does someone need to have on their back for it to be quite hairy? If Tom’s back has 2500 hairs, and Mary’s has 2200, is Mary lucky because she does not have a hairy back?
If we define really hot as 245 degree’s or higher, is it normal for my car to run at 243 degrees?
As can be seen from the example above, a car is either quick, or slow.
5.1 Fundamentals of Fuzzy Logic
The basic idea of fuzzy set theory is that an element of a fuzzy set belongs with a certain degree of membership. Thus a proposition may be partly true or partly false. This degree is a real number between 0 to 1.
The universe of discourse is the range of all possible values applicable to a chosen variable.
The classic example is the set of tall men. The elements of the set are all men, but they have varying degrees of membership based on their heights. The universe of discourse is their heights.
|
|
Degree of membership
|
Name
|
Height (cm)
|
Crisp
|
Fuzzy
|
Chris
|
208
|
1
|
1.0
|
Mark
|
205
|
1
|
1.0
|
John
|
198
|
1
|
.98
|
Tom
|
181
|
1
|
.82
|
David
|
179
|
0
|
.78
|
Mike
|
172
|
0
|
.24
|
Bob
|
167
|
0
|
.15
|
Steven
|
158
|
0
|
.06
|
Bill
|
155
|
0
|
.01
|
Peter
|
152
|
0
|
.00
|
Below we graph the degree of membership versus height for both Crisp and Fuzzy sets.
5.2 Set definitions
Crisp
-
Let X be the universe of discourse. x is a member of X
-
Let A be a crisp set.
-
The membership function fA(x) determines if x is a member of A.
fA(x) : X → 0, 1
where
fA(x) = 1, if x is a member of A, 0 if x is not a member of A.
Fuzzy
-
Let X be the universe of discourse. x is a member of X
-
Let A be a fuzzy set.
-
The membership function µA(x) determines the degree of membership element x has in fuzzy set A.
µA(x) : X → [ 0, 1]
µA(x) = 1 if x is totally in A;
µA(x) = 1 if x is not in A;
0 < µA(x) < 1 if x is partly in A.
5.3 Defining membership functions
So the key here is how to define the membership function µA(x)
Lets take another example:
Universe of discourse X – men’s heights
X = {x1, x2, x3, x4, x5}
A is a crisp subset of X such that A = { x2, x3 }
Membership to A can be described by :
A = {(x1, 0), (x2, 1), (x3, 1), (x4, 0), (x5, 0)}
That is A is a set of pairs {(xi, µA(xi))} where µA(xi) is the membership function of element xi in the subset of A.
Representation of Fuzzy sets:
A = { (x1, µA(x1), (x2, µA(x2), ………(xn, µA(xn)}
Or
A = { µA(x1)/ x1, µA(x2)/ x2,………… µA(xn)/ xn}
The function µA is the function that determines an elements degree of membership in the set. Typical functions are Gaussian, Sigmoid, etc. Linear functions are used commonly, they take less computation time, thus the linear fit function. A fit vector can be used. Below are the fit vectors for the ‘short, average, tall men’ graph.
For the above example the fit vectors are:
Tall men = { 0/180, .5/185, 1/190} = {0/180, 1/190}
Short men = {1/160, .5/165, 0/170} = {1/160, 0/170}
Average men = {0/165, 1/175, 0/185}
5.4 Linguistic Variables and Hedges
Example –
John is tall.
The linguistic variable John takes the linguistic value tall.
We can use these variables in fuzzy expert systems.
IF wind is strong
THEN sailing is good
IF John is tall
THEN John runs fast
We use hedges (very, somewhat, quite, more or less, etc) to modify our linguistic variables.
tall
|
|
|
|
|
height
|
linear
|
a little (µA(x)^1.3)
|
Very (µA(x)^2)
|
more or less sqrt(µA(x))
|
|
|
|
|
|
170
|
0
|
0
|
0
|
0
|
180
|
0
|
0
|
0
|
0
|
181
|
0.1
|
0.050119
|
0.01
|
0.316228
|
182
|
0.2
|
0.123407
|
0.04
|
0.447214
|
183
|
0.3
|
0.209054
|
0.09
|
0.547723
|
184
|
0.4
|
0.303863
|
0.16
|
0.632456
|
185
|
0.5
|
0.406126
|
0.25
|
0.707107
|
186
|
0.6
|
0.51475
|
0.36
|
0.774597
|
187
|
0.7
|
0.628966
|
0.49
|
0.83666
|
188
|
0.8
|
0.748199
|
0.64
|
0.894427
|
189
|
0.9
|
0.871998
|
0.81
|
0.948683
|
190
|
1
|
1
|
1
|
1
|
200
|
1
|
1
|
1
|
1
|
To calculate these variable values use the line equation to find the linear function:
y = m*x + b
m = (y1 – y0)/(x1 – x0)
b = y0 – m*x0
Then do the operation that the hedge calls for.
5.45
Operations on Fuzzy sets – see page 97
Putting it all together
Fuzzy Rules:
IF x is A
THEN y is B
x, y : linguistic variables (crisp)
A, B : linguistic values determined by fuzzy sets on the universe of discourses X, and Y.
Example:
IF speed over speed limit is somewhat fast
THEN ticket is very expensive
Let speed over speed limit = 30mph
That gives a degree of membership of .77 in the somewhat fast set.
Then using the .77 degree of membership in the somewhat fast set maps to a ticket costing between 80 and 100 dollars in the ticket very expensive set.
speed over
|
fast 0
|
fast 1
|
|
ticket cost
|
expensive
|
expensive 2
|
0
|
0
|
0
|
|
20
|
0.2
|
0.04
|
5
|
0.1
|
0.316228
|
|
40
|
0.4
|
0.16
|
10
|
0.2
|
0.447214
|
|
60
|
0.6
|
0.36
|
15
|
0.3
|
0.547723
|
|
80
|
0.8
|
0.64
|
20
|
0.4
|
0.632456
|
|
100
|
1
|
1
|
25
|
0.5
|
0.707107
|
|
120
|
1
|
1
|
30
|
0.6
|
0.774597
|
|
140
|
1
|
1
|
35
|
0.7
|
0.83666
|
|
|
|
|
40
|
0.8
|
0.894427
|
|
|
|
|
45
|
0.9
|
0.948683
|
|
|
|
|
50
|
1
|
1
|
|
|
|
|
55
|
1
|
1
|
|
|
|
|
60
|
1
|
1
|
|
|
|
|
65
|
1
|
1
|
|
|
|
|
70
|
1
|
1
|
|
|
|
|
|
|
|
|
|
|
|
-
To find the exact value of the ticket, you would need to interpolate between 80 and 100 dollars.
-
You need to make sure that you can do this.
-
What are the fit vectors for these two sets?
How does it all work?
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
Rule 1:
IF x is A3
OR y is B1
THEN z is C1
Rule 2:
IF x is A2
AND y is B2
THEN z is C2
Rule 3
IF x is A1
THEN z is C3
funding
|
|
|
|
staffing
|
|
|
risk
|
|
|
|
percent
|
adequate
|
low
|
high
|
percent
|
small
|
large
|
percent
|
low
|
high
|
normal
|
0
|
0
|
1
|
0
|
0
|
1
|
0
|
0
|
1
|
0
|
0
|
10
|
0
|
1
|
0
|
10
|
1
|
0
|
10
|
1
|
0
|
0
|
20
|
0
|
1
|
0
|
20
|
1
|
0
|
20
|
0.66
|
0
|
0
|
30
|
0
|
0.8
|
0
|
30
|
0.8
|
0
|
30
|
0.33
|
0
|
0.33
|
40
|
0.33
|
0.6
|
0
|
40
|
0.6
|
0.2
|
40
|
0
|
0
|
0.67
|
50
|
0.67
|
0.4
|
0
|
50
|
0.4
|
0.4
|
50
|
0
|
0
|
1
|
60
|
1
|
0.2
|
0
|
60
|
0.2
|
0.6
|
60
|
0
|
0
|
0.67
|
70
|
0.67
|
0
|
0.25
|
70
|
0
|
0.8
|
70
|
0
|
0.33
|
0.33
|
80
|
0.33
|
0
|
0.5
|
80
|
0
|
1
|
80
|
0
|
0.66
|
0
|
90
|
0
|
0
|
0.75
|
90
|
0
|
1
|
90
|
0
|
1
|
0
|
100
|
0
|
0
|
1
|
100
|
0
|
1
|
100
|
0
|
1
|
0
|
-
Fuzzification
-
Rule Evaluation
-
Aggregation of rule outputs
-
Defuzzificaiton
Example:
Step : Fuzzify inputs
Let project funding = 35%
µ(inadequate_funding) = µ(A1) = .5;
µ(marginal_funding) = µ(A2) = .2;
µ(adequate_funding) = µ(A3) = 0.0;
Let project staffing = 60%
µ(staffing_small) = µ(B1) = .1;
µ(staffing_large) = µ(B2) = .7;
Step 2: Evaluate the rules
When we evaluate the rules, we must evaluate each all if parts (antecedents) and find values for the then parts (consequents). For conjunctions like AND and OR we do operations like min and max.
Rule 1:
(A3 OR B1) ≈ max(0, .1) = .1
Mapping .1 to the risk_low set we get:
C1 = .1
Rule 2:
(A2 AND B2) ≈ min(.2, .7) = .2
Mapping .2 to the risk_normal set we get:
C2 = .2
Rule 3:
A1 = .5
C3 = .5
Step 3: Aggregation of consequents
In this step we unify the outputs of all the rules.
In our example we clipped the top off each of our 3 risk sets, so now we sum these areas into one resultant area. See the bottom of figure 4.10 on page 108.
Step 4: Defuzzification
In order to turn our resultant fuzzy sum (we summed the clipped fuzzy sets from each of our rules in 1 big fuzzy resultant set) we find the center of gravity (COG) of the set.
What we mean by center of gravity is that we want to locate the point at where we can slice the set into two equal pieces.
We can use the following formula to get an estimate of the COG.
COG ≈ ∑ab µA(x)x / ∑ab µA(x)
µA(x) the consequent of each of our rules
x the x axis value of the set
b the upper range of the x domain of the set
a the lower range of the x domain of the set
x
|
y1
|
x
|
y2
|
9.99
|
0
|
30.001
|
0
|
10
|
0.1
|
30.001
|
0.3
|
20
|
0.1
|
40
|
0.3
|
30
|
0.1
|
50
|
0.3
|
30.001
|
0
|
60
|
0.3
|
|
|
60.001
|
0
|
For our example problem:
COG = (0 + 10 + 20)*.1 + (30 + 40 + 50 + 60)*.2 + (70 + 80 + 90 + 100)*.5
.1 + .1 + .1 + .2 + .2 + .2 + .2 + .5 + .5 + .5 +.5
= 3 + 36 + 170
3.1
= 209/3.1 = 67.4%
So the aggregate risk is 67.4%
Assignment questions – page 126
1, 2, 3, 4, 5, 6, 7, 8, 11
Share with your friends: |