Important Disclaimer

The purpose of this blog is purely to serve as a compilation of good technical material for my students. No financial or other motives are involved. Most of the content in this blog has been reproduced from other sources. I have made every attempt to mention the source link at the beginning of each blog. All readers are requested to kindly acknowledge that source and not this blog, in case you find the post helpful. However, I have not been able to trace the source links for some of my older posts. I wish to emphasize that this is not intentional and any help in this regard would be appreciated.

Mar 2, 2007

Fuzzification and Defuzzification

Fuzzification

Step 1

The first step is to take the crisp inputs, x1 and y1 and determine the degree to which these inputs belong to each of the appropriate fuzzy sets.

Step 2: Rule Evaluation

The second step is to take the The fuzzified inputs,μ(x=A1) = 0.5, μ(x=A2) = 0.2, μ(y=B1) = 0.1 and μ(y=B2) =0.7, and apply them to the antecedents of the fuzzy rules. If a given fuzzy rule has multiple antecedents,the fuzzy operator (AND or OR) is used to obtain a single number that represents the result of the antecedent evaluation. This number (the truth value) is then applied to the consequent membership function.

To evaluate the disjunction of the rule antecedents, operation OR fuzzy operation. Typically, fuzzy expert systems make use of the classical fuzzy operation, union:
μA∪B(x) = max [μA(x),μB(x)]

Similarly, in order to evaluate the conjunction of the rule antecedents, we apply the AND fuzzy operation intersection:

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




Now the result of the antecedent evaluation can be applied to the membership function of the
consequent.

The most common method of correlating the rule consequent with the truth value of the rule
antecedent is to cut the consequent membership function at the level of the antecedent truth. This method is called clipping. Since the top of the membership function is sliced, the clipped fuzzy set loses some information. However, clipping is still often preferred because it involves less complex and faster mathematics, and generates an aggregated output surface that is easier to defuzzify.


While clipping is a frequently used method, scaling offers a better approach for preserving the original shape of the fuzzy set. The original membership function of the rule consequent is adjusted by multiplying all its membership degrees by the truth value of the rule antecedent . This method, generally loses less information, can be useful in fuzzy expert systems.


Step 3: Aggregation of the rule outputs

Aggregation is the process of unification of the outputs of all rules. We take the membership
functions of all rule consequents previously clipped or scaled and combine them into a single fuzzy set.

The input of the aggregation process is the list of clipped or scaled consequent membership functions and the output is one fuzzy set for each output variable.



Step 4: Defuzzification

The last step in the fuzzy inference process is defuzzification . Fuzziness helps us to evaluate the rules, but the final output of a fuzzy system has to be a crisp number. The input for the defuzzification process is the aggregate output fuzzy set and the output is a single number.

There are several defuzzification methods, but probably the most popular one is the centroid
technique. It finds the point where a vertical line would slice the aggregate set into two equal masses.

Mathematically this center center of gravity (COG) can be expressed as:


Centroid defuzzification method finds a point representing the centre of gravity of the fuzzy set A, on the interval, on the interval, ab.A reasonable estimate can be obtained by calculating it over a sample of points.

Fig. below shows the centroid method.


COG method



Overall operation of a Fuzzy System



Application


This post has been taken from http://www.seattlerobotics.org/encoder/mar98/fuz/flcases.html . The content has been reproduced here for solely for the benefit of students. Kindly acknowledge the original site and not this blog.


The following five cases show what the system computes as error decreases toward zero and then changes to a positive value. Pictures of the input and output membership functions are included. The rate-of-change of the error stays constant throughout the five cases. It is not likely that this would happen in a real system, but for purposes of this illustration, that case has been assumed. The values of error and error-dot indicated from the membership functions are plugged into the rulebase from the "KEY" below and the responses computed for each case. These responses are then mathematically combined to yield a crisp output.

Note that because the "zero" membership function is centered on zero in the output function, its influence in the output computation is only in the denominator. The center of the "zero" doesn't need to be at zero, it just happens to be in this example..

KEY:

(e<0) "negative" error value (er<0) "negative" error-dot value
(e=0) "zero" error value (er=0) "zero" error-dot value
(e>0) "positive" error value (er>0) "positive" error-dot value
EXAMPLE CASE 1 - ERROR= -1.0F

Figure 9 - EXAMPLE CASE 1: (initial conditions)

INPUT DEGREE OF MEMBERSHIP

"error" = -1.0: "negative" = 0.5, "zero" = 0.5, "positive" = 0.0
"error-dot" = +2.5: "negative" = 0.0, "zero" = 0.5, "positive" = 0.5

1. If (e < 0) AND (er < 0) then Cool 0.50 & 0.00 = 0.00
2. If (e = 0) AND (er < 0) then Heat 0.50 & 0.00 = 0.00
3. If (e > 0) AND (er < 0) then Heat 0.00 & 0.00 = 0.00 >>>>
4. If (e < 0) AND (er = 0) then Cool 0.50 & 0.50 = 0.50 >>>>
5. If (e = 0) AND (er = 0) then No_Chng 0.50 & 0.50 = 0.50
6. If (e > 0) AND (er = 0) then Heat 0.00 & 0.50 = 0.00 >>>>
7. If (e < 0) AND (er > 0) then Cool 0.50 & 0.50 = 0.50 >>>>
8. If (e = 0) AND (er > 0) then Cool 0.50 & 0.50 = 0.50
9. If (e > 0) AND (er > 0) then Heat 0.00 & 0.50 = 0.00

"negative" = (R1^2 + R4^2 + R7^2 + R8^2) (Cooling) = (0.00^2 + 0.50^2 + 0.50^2 + 0.50^2)^.5 = 0.866
"zero" = (R5^2)^.5 = (0.50^2)^.5 (No Change) = 0.500
"positive" = (R2^2 + R3^2 + R6^2 + R9^2) (Heating) = (0.00^2 + 0.00^2 + 0.00^2 + 0.00^2)^.5 = 0.000

Figure 10 - Output function

(neg_center * neg_strength + zero_center * zero_strength + pos_center * pos_strength) = OUTPUT
(neg_strength + zero_strength + pos_strength)

(-100 * 0.866 + 0 * 0.500 + 100 * 0.000) = -63.4% (cooling)
(0.866 + 0.500 + 0.000)
EXAMPLE CASE 2 - ERROR = +1.25F

Figure 11 - EXAMPLE CASE 2

INPUT DEGREE OF MEMBERSHIP

"error" = -0.5: "negative" = 0.25, "zero" = 0.75, "positive" = 0.0
"error-dot" = +2.5: "negative" = 0.0, "zero" = 0.50, "positive" = 0.50

1. If (e < 0) AND (er < 0) then Cool 0.25 & 0.0 = 0.00
2. If (e = 0) AND (er < 0) then Heat 0.75 & 0.0 = 0.00
3. If (e > 0) AND (er < 0) then Heat 0.00 & 0.0 = 0.00 >>>>
4. If (e < 0) AND (er = 0) then Cool 0.25 & 0.50 = 0.25 >>>>
5. If (e = 0) AND (er = 0) then No_Chng 0.75 & 0.50 = 0.50
6. If (e > 0) AND (er = 0) then Heat 0.00 & 0.50 = 0.00 >>>>
7. If (e < 0) AND (er > 0) then Cool 0.25 & 0.50 = 0.25 >>>>
8. If (e = 0) AND (er > 0) then Cool 0.75 & 0.50 = 0.50
9. If (e > 0) AND (er > 0) then Heat 0.00 & 0.50 = 0.00

"negative" = (R1^2 + R4^2 + R7^2 + R8^2) (Cooling) = (0.00^2 + 0.25^2 + 0.25^2 + 0.50^2)^.5 = 0.612
"zero" = (R5^2)^.5 = (0.50^2)^.5 (No Change) = 0.50
"positive" = (R2^2 + R3^2 + R6^2 + R9^2) (Heating) = (0.00^2 + 0.00^2 + 0.00^2 + 0.00^2)^.5 = 0.000

Figure 12 - Output function

(neg_center * neg_strength + zero_center * zero_strength + pos_center * pos_strength) = OUTPUT
(neg_strength + zero_strength + pos_strength)

(-100 * 0.612 + 0 * 0.50 + 100 * 0.000) = -55.1% (cooling)
(0.612 + 0.500 + 0.000)
EXAMPLE CASE 3 - ERROR = 0.0F

Figure 13 - EXAMPLE CASE 3

INPUT DEGREE OF MEMBERSHIP

"error" = 0.0: "negative" = 0.0, "zero" = 1.0, "positive" = 0.0
"error-dot" = +2.5: "negative" = 0.0, "zero" = 0.50, "positive" = 0.50

1. If (e < 0) AND (er < 0) then Cool 0.00 & 0.00 = 0.0
2. If (e = 0) AND (er < 0) then Heat 1.00 & 0.00 = 0.0
3. If (e > 0) AND (er < 0) then Heat 0.00 & 0.00 = 0.0
4. If (e < 0) AND (er = 0) then Cool 0.00 & 0.50 = 0.0 >>>>
5. If (e = 0) AND (er = 0) then No_Chng 1.00 & 0.50 = 0.50
6. If (e > 0) AND (er = 0) then Heat 0.00 & 0.50 = 0.0
7. If (e < 0) AND (er > 0) then Cool 0.00 & 0.50 = 0.0 >>>>
8. If (e = 0) AND (er > 0) then Cool 1.00 & 0.50 = 0.50
9. If (e > 0) AND (er > 0) then Heat 0.00 & 0.50 = 0.0

"negative" = (R1^2 + R4^2 + R7^2 + R8^2) (Cooling) = (0.0^2 + 0.0^2 + 0.0^2 + 0.50^2)^.5 = 0.50
"zero" = (R5^2)^.5 = (0.5^2)^.5 (No Change) = 0.5
"positive" = (R2^2 + R3^2 + R6^2 + R9^2) (Heating) = (0.00^2 + 0.00^2 + 0.00^2 + 0.00^2)^.5 = 0.000

Figure 14 - Output function

(neg_center * neg_strength + zero_center * zero_strength + pos_center * pos_strength) = OUTPUT
(neg_strength + zero_strength + pos_strength)

(-100 * 0.50 + 0 * 0.50 + 100 * 0.000) = -50% (cooling)
(0.50 + 0.50 + 0.000)
EXAMPLE CASE 4 - ERROR = +0.5F

Figure 15 - EXAMPLE CASE 4

INPUT DEGREE OF MEMBERSHIP

"error" = +0.50: "negative" = 0.0, "zero" = 0.75, "positive" = 0.25
"error-dot" = +2.5: "negative" = 0.0, "zero" = 0.50, "positive" = 0.50

1. If (e < 0) AND (er < 0) then Cool 0.00 & 0.00 = 0.0
2. If (e = 0) AND (er < 0) then Heat 0.75 & 0.00 = 0.0
3. If (e > 0) AND (er < 0) then Heat 0.25 & 0.00 = 0.0
4. If (e < 0) AND (er = 0) then Cool 0.00 & 0.50 = 0.0 >>>>
5. If (e = 0) AND (er = 0) then No_Chng 0.75 & 0.50 = 0.50 >>>>
6. If (e > 0) AND (er = 0) then Heat 0.25 & 0.50 = 0.25
7. If (e < 0) AND (er > 0) then Cool 0.00 & 0.50 = 0.0 >>>>
8. If (e = 0) AND (er > 0) then Cool 0.75 & 0.50 = 0.50 >>>>
9. If (e > 0) AND (er > 0) then Heat 0.25 & 0.50 = 0.25

"negative" = (R1^2 + R4^2 + R7^2 + R8^2) (Cooling) = (0.0^2 + 0.0^2 + 0.0^2 + 0.50^2)^.5 = 0.50
"zero" = (R5^2)^.5 = (0.5^2)^.5 (No Change) = 0.50
"positive" = (R2^2 + R3^2 + R6^2 + R9^2) (Heating) = (0.00^2 + 0.00^2 + 0.25^2 + 0.50^2)^.5 = 0.354

Figure 16 - Output function

(neg_center * neg_strength + zero_center * zero_strength + pos_center * pos_strength) = OUTPUT
(neg_strength + zero_strength + pos_strength)

(-100 * 0.50 + 0 * 0.5 + 100 * 0.354) = -10.8% (cooling)
(0.50 + 0.50 + 0.354)
EXAMPLE CASE 5 - ERROR = +1.0F

Figure 17 - EXAMPLE CASE 5

INPUT DEGREE OF MEMBERSHIP

"error" = +1.0: "negative" = 0.0, "zero" = 0.5, "positive" = 0.5
"error-dot" = +2.5: "negative" = 0.0, "zero" = 0.5, "positive" = 0.5

1. If (e < 0) AND (er < 0) then Cool 0.00 & 0.00 = 0.0
2. If (e = 0) AND (er < 0) then Heat 0.50 & 0.00 = 0.0
3. If (e > 0) AND (er < 0) then Heat 0.50 & 0.00 = 0.0
4. If (e < 0) AND (er = 0) then Cool 0.00 & 0.50 = 0.0 >>>>
5. If (e = 0) AND (er = 0) then No_Chng 0.50 & 0.50 = 0.5 >>>>
6. If (e > 0) AND (er = 0) then Heat 0.50 & 0.50 = 0.5
7. If (e < 0) AND (er > 0) then Cool 0.00 & 0.50 = 0.0 >>>>
8. If (e = 0) AND (er > 0) then Cool 0.50 & 0.50 = 0.5 >>>>
9. If (e > 0) AND (er > 0) then Heat 0.50 & 0.50 = 0.5

"negative" = (R1^2 + R4^2 + R7^2 + R8^2) (Cooling) = (0.00^2 + 0.00^2 + 0.00^2 + 0.50^2)^.5 = 0.500
"zero" = (R5^2)^.5 = (0.50^2)^.5 (No Change) = 0.500
"positive" = (R2^2 + R3^2 + R6^2 + R9^2) (Heating) = (0.00^2 + 0.00^2 + 0.50^2 + 0.50^2)^.5 = 0.707

Figure 18 - Output function

(neg_center * neg_strength + zero_center * zero_strength + pos_center * pos_strength) = OUTPUT
(neg_strength + zero_strength + pos_strength)

(-100 * 0.500 + 0 * 0.500 + 100 * 0.707) = +12.1% (heating)
(0.500 + 0.500 + 0.707)

No comments: