Unit IV Soft Computing
Unit IV Soft Computing
= {(x, µÃ(x)): x Є Ã}
Where, µÃ(x) is called membership function. The membership function, µÃ(x) maps
X on the interval [ ]
µÃ(x): X [ ]
The range of the membership function is subset of the non – negative real numbers whose
supremum is finite.
A normal fuzzy set is one whose membership function has at least one element x in X the
universe whose membership value is unity. Otherwise it will be subnormal fuzzy set as shown in
figure 1(b) and figure 1(c).
Figure 1(b) Normal Fuzzy set Figure 1(c) Subnormal Fuzzy set
Figure 1 (d) convex fuzzy set Figure 1 (e) Norn – convex fuzzy set
Crossover Point
The crossover points of a membership function are defined as the elements in the universe X for
which a particular fuzzy set ̃ has values equal to 0.5, i.e., for which
(x) = 0.5.
The height of a fuzzy set ̃ is the maximum value of the membership function, i.e.,
height ( ̃ ) = max ( (x))
For subnormal fuzzy set height ( ̃ ) <1
Lecture # 2 Inferences in Fuzzy Logic, Fuzzy IF-THEN
Rules
In crisp logic, the truth values acquired by proposition or predicate are 2-valued, namely True,
False which may be treated numerically equivalent to (0, 1). However, in fuzzy logic, the truth
values are multivalued such as absolutely true, very true, partly true, absolutely false and so on
numerically equivalent to (0-1).
Fuzzy Propositions
A fuzzy proposition is a statement which acquires a fuzzy truth value. Thus, given to be fuzzy
proposition, T ( ) represents the truth value (0-1) attached to . In its simplest form, fuzzy
propositions are associated with fuzzy sets. The fuzzy membership value associated with the
fuzzy set à for P is treated as the fuzzy truth value T ( ).
: Ram is honest.
T ( ) = 0.8 if P is partly true
T ( ) = 1 if P is absolutely true
Fuzzy Connectives
- Negation 1-T( )
V Disjunction max(T( ), T( ))
^ Conjunction min(T( ), T( ))
= =( × )∪( × )
The membership function of R is given by
Example
: Mary is efficient, T ( )) =0.8
: Ram is efficient, T ( ) =0.65
Solution
1 2 3 4
a 0 0 0 0
× = b 0.2 0.8 0.8 0
c 0.2 06 0.6 0
d 0.2 1 0.8 0
1 2 3 4
and × Y=a 1 1 1 1
b 0.2 0.2 0.2 0.2
c 0.4 0.4 0.4 0.4 1 2 3 4
d 0 0 0 0
a 0 0.4 1 0.8
Here Y is Universe of discourse could be
b 0 0.2 0.2 0.2
viewed as {(1, 1)(2,1)(3,1)(4,1)} a fuzzy set c 0 0.4 0.4 0.4
of all whose elements x have µ(x)=1. × = d 0 0 0 0
=( × )∪( × )
The membership function of R is given by
1 2 3 4
a 0 0 0 0
b 0.2 0.8 0.8 0
× = c 0.2 06 0.6 0
d 0.2 1 0.8 0
Fuzzy Quantifiers (Not Important from Examination point
of View –for Knowledge You may skip this topic)
Just as in crisp logic where predicates are
quantified by quantifiers, fuzzy logic It can be converted to simplest form
Here , ’, ‘are fuzzy terms. Every fuzzy linguistic statement above the line is
analytically known and what is below is analytically unknown.
’= ’o (x, y)
Where µ ′ (x) is the membership function of ̃ ’ µ (x, y) is the membership function of the
implication relation and µ ′ (y) is the membership function of ’
On the other hand, GMT has the form
IF x is ̃ THEN y is
′
̃′
To compute the membership function of ’ the max-min composition of fuzzy set ’
with (x, y) which is the known implication relation (IF-THEN) is used. That is,
’= ’o (x, y)
Apply the fuzzy Modes Ponens rule to deduce Rotation is quite slow
30 0 0 0 0 0 0
40 0 0 0 0 0 0
×̃ = 50 0 0 0 0 0 0
60 0 0 0 0 0 0
70 0 0 0.8 1 0.6 0
80 0 0 0.8 1 0.6 0
90 0 0 0.3 0.3 0.3
100 0 0 0 0 0 0
10 20 30 40 50 60
30 1 1 1 1 1 1
×Y= 40 1 1 1 1 1 1
50 1 1 1 1 1 1
60 1 1 1 1 1 1
70 0 0 0 0 0 0
80 0 0 0 0 0 0
90 0.7 0.7 0.7 0.7 0.7 0.7
100 1 1 1 1 1 1
10 20 30 40 50 60
30 1 1 1 1 1 1
40 1 1 1 1 1 1
50 1 1 1 1 1 1
60 1 1 1 1 1 1
(x, y) =max ( × ̃, ×Y) = 70 0 0 0.8 1 0.6 0
80 0 0 0.8 1 0.6 0
90 0.7 0.7 0.7 0.7 0.7 0.7
100 1 1 1 1 1 1
S = o (x, y) (set has membership vales for elements 90, and 100 only that 0.9 and 1
respectively. Membership values for remaining elements are 0)
= [0 0 0 0 0 0 0.9 1] × (x, y) = [1 1 1 1 1 1]
NOTE: (Apply max-min composition on matrices and (x, y))
Lecture # 4 Fuzzification & Defuzzification
Fuzzy linguistic descriptions are formal representations of systems made through fuzzy IF-
THEN rules. They encode knowledge about a system in statement of the form-
IF (a set of conditions) are satisfied THEN (a set of consequent) can be inferred,
where linguistic variables xi, yj take the values of fuzzy sets ̃ i and j respectively.
On the other hand, if the conclusion C to be drawn from a rule base R is the disjunction of the individual
consequents of each rule then
C1∪C2∪C3………………….∪Cn
Where µc(y) =max(c(µc(y1), µc(y2)….. µc (yn))) ∀y∈Y
Fuzzification
Fuzzification is the process of transforming crisp set to a fuzzy set or a fuzzy set to fuzzier set i.
e. crisp quantities converted to fuzzy quantities. This operation translates crisp input values into
linguistic variables. In the real-life world, the quantities may be thought of as crisp, accurate and
deterministic, but actually they are not so. They possess uncertainty within themselves. The
uncertainty may arise due to vagueness, imprecision and ambiguity. In this case the variable is
probably fuzzy and can be represented by a membership function.
For example, when one is told that temperature is 9 C, then person translates the crisp input
value into linguistic variable such as “cold” or “warm” according ones knowledge and then make
a decision about the need to wear jacket. If one fails to fuzzify then it is not possible to take
decision or error decision may be reached.
̃ = µ ( ). ( )+ µ ( 2 ). ( 2 ) + ……….+µ ( ). ( ) for I = 1 to n
Defuzzification-
In many situations, for a system whose output is fuzzy, it is easier to take crisp decision if the
output is represented as a single scalar quantity. This conversion of a fuzzy set to single crisp
value is called defuzification and it the reverse process of fuzzification..
Methods for defuzzification are
∑ . ( )
and x* = ∑ ( )
for a discrete membership function.
Here n represents the number of elements in the sample, xi“ are the elements, and µ (xi) is its
membership function.
∑ .∑ ( )
X*=
∑ .∑ ( )
Here n is the number of fuzzy sets and N is number of fuzzy variables. COS is actually the most
commonly used defuzzification method. It can be implemented easily and leads to rather fast
inference cycles.
∑
X* = Where M= {xi /µ (xi) equal to the height of fuzzy set}
| |
1.0
µ 0.75
0.5
0.25 0.3
0 1 2 3 4 5 6 7 8
x
Figure 4.1 1
1.0
µ 0.75
0.5 0.5
0.25
0 1 2 3 4 5 6 7 8 x
Figure 4.2 2
1.0 1.0
µ 0.75
0.5
0 1 2 3 4 5 6 7 8 x
Figure 4.3 3
1.0
1.0
µ 0.75
0.5
0.3
0 1 2 3 4 5 6 7 8 x
3.6 5.5
The defuzzification using (1) centroid method (2) COS method and (3) mean of maxima method
is presented below
Centroid Method
To Compute X* the centroid , we view the aggregate fuzzy set as shon in figure. In figure the
aggregate output has been divided into areas for better understanding
1.0
1.0
µ 0.75
7
0.5 4
0.3
5 c 8
2 3 9
1
0 1 2 3 4 5 6 7 8 x
3.6 5.5
Note-Compute area and centroid of each segment separately using mathematical formulae. In
figure 4.5 regions 1, 4, 7 are triangular and remaining are rectangular.
+ + 3
(Centroid for triangular region =
In the table area (A) shows the area of segments of the aggregate fuzzy set and X shows the
corresponding centroid.
Now
∑ . 18.353
X*= ∑
= = 4.9
3.715
Centre of Sums (COS) Method
Here, unlike centroid method the overlapping area is counted not once but twice. Making use of
aggregated fuzzy set shown the centre of sums, x* is given by
1.0
1.0
µ 0.75
0.5
0.3
2 3
1
0 1 2 3 4 5 6 7 8 x
Figure 4.6 –Aggregated fuzzy sets of 1, 2, viewed as area segments overlapping area
counted twice
For computation of x* we use table below
ΣA. 23.5
X* = = =5.0
ΣA 4.7
Since the aggregated fuzzy set shown in fig (d) is a continuous set x* the mean of maxima is
computed as x*=6.5.
Here M = {X ∈[6, 7] /µ(x) =1] and the height of the aggregate fuzzy set is 1.
Figure 4.7 below shows the defuzzyfied outputs using above three methods
1.0
µ 0.75
0.5
0.3
0 1 2 3 4 5 6 7 8 x
END DEFUZZIFICATION
CRISP OUTPUT FUZZY OUTPUT
Speed difference
Fuzzy Cruise Control
Throttle Control
Acceleration
Figure 5.2 Fuzzy Cruise Control System
A sample fuzzy rule base R governing the fuzzy cruise Control is as given in table below
Rule 1 If(speed difference is NL) and (acceleration is ZE) then (throttle control is PL)
Rule 2 If(speed difference is ZE) and (acceleration is NL) then (throttle control is PL)
Rule 3 If(speed difference is NM) and (acceleration is ZE) then (throttle control is PL)
Rule 4 If(speed difference is NS) and (acceleration is ZE) then (throttle control is PL)
Rule 5 If(speed difference is PS) and (acceleration is ZE) then (throttle control is PL)
Rule 6 If(speed difference is PL) and (acceleration is ZE) then (throttle control is PL)
Rule 7 If(speed difference is ZE) and (acceleration is ZE) then (throttle control is PL)
Rule 8 If(speed difference is ZE) and (acceleration is ZE) then (throttle control is PL)
Keys
NL – Negative Large NM – Negative Medium, NS - Negative Small, ZE- - Zero
PS – Positive Small, PM - Positive Medium, PL- Positive Large
Fuzzy Sets
The fuzzy sets which characterize the inputs and outputs are as given in figures
NL NM NS ZE PS PM PL
1
Degree of membership
NL NM NS ZE PS PM PL
1
Degree of membership
NL NM NS ZE PS PM PL
1
Degree of membership
For the fuzzification of inputs, that is, to compute the membership for the antecedents, the
formula illustrated in Figure 5.6) is used.
Y
Degree of
membership
MAX
Degree of membership
Slope 1 Slope 2
Compute
Delta 1=x-point1
and Point 1
X
Delta 2 =point2-x Delta 1 Delta 2 Point 2
Here, x which is the system input has its membership function value computed for all fuzzy sets.
For example, the system input speed difference deal with 7 fuzzy sets, namely NL, NM, NS, ZE,
PS, PM, PL. For a measured value of speed difference x’, the membership function of x, in each
of the seven sets in computed using formula shown in previous figure (l). Let µ̀ 1 , µ̀ 2 , µ̀ 3 , µ̀ 4 ,
µ̀ 5 , µ̀ 6 , µ̀ 7 , , be the seven membership values. Then all values are recorded for the input x’ in
an appropriate data structure.
Similarly, for each of the other system inputs (acceleration in this case), the fuzzy membership
value are recorded.
Example
Let the measured normalized speed difference be 100 and the normalized acceleration is 70, then
the fuzzified inputs after computation of the fuzzy membership values are shown in figure 5.7
below.
Inputs Speed Differnce Acceleration
100 95
0 NL 0 NL
0 NM 0.7813 NM
0.8436 0.2188 NS
0.1563 NSZE 0 ZE
0 PS 0 PS
0 PM 0 PM
0 PL 0 PL
Figure (m)5.7 Recorded values for seven different sets for speed difference =100 and Acceleration=70
The computations of the fuzzy membership values for the given inputs have been shown n figure 5.8
below
NS ZE
Degree of membership
63 95 127 159
X=100
Figure 5.8 Fuzzification of speed difference = 100
For the speed difference (x-=100) the qualifying sets are shown figure. Fuzzy membership function of x
for NS where
Delta 1 100-63=37
Delta 2 127-100=27
Slope 1=1/32=0.03125
Slope 2 =1/32=0.03125
37 × 0.03125
Degree of membership function µNS(x) =min 27 × 0.03125 =0.8438
NM NS
Degree of membership
31 63 95 127
X=70
The fuzzy membership function of x=70 for NM is µNM =0.7813 and for NS is µNS =0.2188 and
for remaining sets membership value will be zero.
Rule Strength Computation
The rule strength is obtained by computing the minimum of the membership function of the
antecedents.
Example
For the same rule base R given in table, the rule strength using the fuzzy membership value
illustrated in figure
Rule 1: min (0, 0) =0
Rule 2: min (0.1563, 0) =0
Rule 3: min (0, 0) =0
Rule 4: min (0.8438, 0) =0
Rule 5: min (0, 0.2188) =0
Rule 6: min (0, 0) =0
Rule 7: min (0.1563, 0.2188) =0.1563
Rule 8: min (0.1563, 0.7813) =0.1563
(For strength computation use rule from rule base R in Table 1 and for each rule put
corresponding membership values for speed difference and acceleration and then find
minimum for example
Rule 1 If(speed difference is NL) and (acceleration is ZE) then (throttle control is PL)
Here Speed difference is NL as we computed early µNL=0, Acceleration is ZE as we computed
early µZE=0
min (µNL=0, µZE=0) =min (0, 0) =0)
The fuzzy output of the system is the ‘fuzzy OR’ of all fuzzy outputs of the rules with non-zero
strengths. In the event of more than one rule qualifying for the same fuzzy output, the stronger
among them is chosen.
Example
In the given rule base R, the competing fuzzy outputs are those of Rule 7 and 8 with strengths of
each are 0.1563. However, the fuzzy outputs computed here do not aid clear-cut decision on the
throttle control. Hence the need for defuzzyfication arises.
Defuzzification
The centre of gravity method is applied to defuzzify the output. Initially the centroid is computed
for each of computing output membership function. Then, the new output membership areas are
determined by shortening the height of the membership value on the Y axis as dictated by the
rule strength value. Finally, the Centre of Gravity (CG) is computed using the weighted average
of the X-axis centroid points with the newly computed outputs area, the letter serving as weights.
Example
Figure 5.10 illustrates the computation of CG for the two competing outputs of rule 7 and 8 with strength
of 0.1563 each
PS PM
Degree of membership
b1 b2
0.1563 h1
9.99×159+9.99×191
Weighted average (CG) = = 175
9.99+9.99