You are on page 1of 41

Adama Science andTechnology

University

EPCE6202 Intelligent Control


and Its Applications
(Fuzzy Logic Controller)

ASTU
School of EEC

www.hhu.ac.kr

1. Fuzzy Logic Controller(FLC)


Features of FLC
• Helpful approach in controller design
since Mamdani's first use of fuzzy
L. A. Zadeh
theory in process control
• Generally, doesn't require
mathematical model of the controlled
object
• Expert control strategies that are in the E. H. Mamdani
form of fuzzy control rules, usually
described by fuzzy sets and their MFs,
can be applied directly to control
problems.
M. Sugeno

1
Contd
Structure of FLC

(2)

(1) (4)

(3)
(1) Fuzzification interface
(2) Knowledge base
(3) Decision-making logic
(4) Defuzzification interface

2. Fuzzification interface
Designing steps
• Identification of variables− input, output and state
variables must be identified of the plant which is
under consideration.
• Fuzzy subset configuration− The universe of
information is divided into number of fuzzy subsets
and each subset is assigned a linguistic label.
• Obtaining membership function− obtain the
membership function for each fuzzy subset.
• Fuzzification− The fuzzification process is initiated
in this step.

2
Contd
• Fuzzy rule base configuration− formulate the
fuzzy rule base by assigning relationship between
fuzzy input and output.
• Combining fuzzy outputs− By applying fuzzy
approximate reasoning, locate the fuzzy output and
merge them.
• Defuzzification− Finally, initiate defuzzification
process to form a crisp output.

Contd
Fuzzification interface
Crisp Scaling -1~1 Fuzzy
Fuzzifier
-5~5 factor 0~1
• Consists of the scaling factor and fuzzifier.
• Multiply the scaling factor so that the input value is
mapped to a predetermined set.
• The scaling factor is divided into linear, and
nonlinear which divides into several intervals and
multiplies different values.
• Converts input values into fuzzy values for use by
the fuzzy controller.

3
Contd
 A (u ) fuzzy set A

u
-1 0 0.2 0.6 1

scaling factor
crisp
input 0.2
u 0= 2

Contd
When the measured value(u0) is reliable, u0 is
converted into a fuzzy singleton.

1 u  u0
 A (u )  
0 u  u0

4
Contd
When the measured value(u0) is not reliable, u0 is
converted into a fuzzy set.
If the error range of the sensor is ±, then u0 is
generally converted to a triangular fuzzy set with
widths of 1, 2, and 3 times as .

3. Knowledge base
Knowledge Base (KB)
• KB consists of database(DB) and rule base(RB).
• The DB provides necessary definitions, which are
used to define linguistic control rules and fuzzy data
manipulation.
- Discretization and normalization method of the
whole set of input variables, for example,
normalized to the interval [-1, 1] and discretized
- The form of an MF to define a fuzzy set
• The RB characterizes the control goals and control
policy of the domain experts.

5
Contd
• The number of levels nlevel is the number of levels to
discretize a variable.
• nlevel should be odd considering precision and
computational load.
• Precision= (b-a) / (nlevel-1), where a and b are end
points.
A B

u
-1 0 1
mfA= [0, 0, 0, 0, 0.3, 1, 0.3, 0, 0, 0, 0]
mfB= [0, 0, 0, 0, 0, 0, 0.3, 0.6, 1, 1, 1]

Contd
(Definition) Trapzoidal MF
Its shape is determined by four parameters a, b, c, d
(abcd). If a, b, or c, d are the same, one side
becomes vertical MF.
 0 xa
xa
 a xb
ba

 A ( x)   1 bxc
d  x
 cxd
d c
 0 dx

6
Contd
% Trapezoidal MF
function mf= trapmf(x, para)
a= para(1); b= para(2); c= para(3); d= para(4);
if a > b | b > c | c > d | a > d
error('Check the parameters a, b, c and d');
end

mf= ones(size(x));
index= find(x <= a | x >= d);
mf(index)= zeros(size(index));

Contd
if a ~= b
index= find(a < x & x < b);
mf(index)= (x(index)-a)/(b-a);
end

if c ~= d
index= find(c < x & x < d);
mf(index)= (d-x(index))/(d-c);
end

7
Contd
% Primary function calling trapmf
x= -1:0.01:1;
A1= trapmf(x, [-1 -1 -0.5 0]);
A2= trapmf (x, [-0.5 -0.1 0.1 0.5]);
A3= trapmf (x, [0 0.5 1 1]);
plot(x,[A1; A2; A3], 'k', 'linewidth',2)
axis([-1 1 0 1.2])
xlabel('x'), ylabel('\mu(x)')
box off

Contd

A1 A2 A3
1
0.8
(x)

0.6
0.4
0.2
0
-1 -0.5 0 0.5 1
x

8
Contd
(Definition) Triangular MF
Its shape is determined by three parameters a, b and c
(abc). Likewise, if a and b or b and c are the same,
one side becomes vertical MF.

 0 xa
xa
 a xb
b  a
 A ( x)  
c x bxc
c b
 0 cx

Contd
% Triangular MF
function mf= trimf(x, para)
a= para(1); b= para(2); c= para(3);
if a > b | b > c | a > c
error('Check the parameters a, b and c');
end

mf= zeros(size(x));
index= find(x < a | x > c);
mf(index)= zeros(size(index));

9
Contd
if a ~= b
index= find(a < x & x < b);
mf(index)= (x(index)-a)/(b-a);
end

if b ~= c
index= find(b < x & x < c);
mf(index)= (c-x(index))/(c-b);
end

index= find(x == b);


mf(index)= ones(size(index));

Contd
% Primary function calling trimf
x= -1:0.01:1;
A1= trimf(x, [-0.5 0 0.5]);
A2= trimf(x, [0 1 1]);
A3= trimf(x, [-1 -1 0]);
plot(x,[A1; A2; A3], 'k', 'linewidth',2)
axis([-1 1 0 1.2])
xlabel('x'), ylabel('\mu(x)')
box off

10
Contd

A1 A2 A3
1
0.8
(x)

0.6
0.4
0.2
0
-1 -0.5 0 0.5 1
x

Contd
(Definition) Gauss MF
This function is determined by the two parameters 
and c where c is the mean and  the standard
deviation. The larger , the wider the MF.

 ( x  c )2
 A ( x) 
2
e 2

11
Contd
% Gaussian curve MF
function mf= gaussmf(x, para)
sigma= para(1); c= para(2);
mf= exp(-0.5*(x-c).^2/sigma^2);

% Primary function calling gaussmf


x= -1:0.01:1;
A1= gaussmf(x, [0.2 -0.5]);
A2= gaussmf(x, [0.2 0.0]);
A3= gaussmf(x, [0.2 0.5]);
plot(x,[A1; A2; A3], 'k', 'linewidth',2)
axis([-1 1 0 1.2]), xlabel('x'), ylabel('\mu(x)'), box off

Contd

A1 A2 A3
1
0.8
(x)

0.6
0.4
0.2
0
-1 -0.5 0 0.5 1
x

12
Contd
(Definition) Sigmoid curve MF
Its shape is determined by two parameters a and c. c
is the inflection point and if the sign of a is negative,
the left side is open, and if it is positive, the right side
is open. The larger the absolute value of a, the steeper
the curve near the inflection point.

1
 A ( x) 
1  e a ( x c )

Contd
% Sigmoid curve MF
function mf= sigmf(x, para)
a= para(1); c= para(2);
mf= 1./(1+exp(-a*(x-c)));

% Primary function calling sigMF


x= -1:0.01:1;
A1= sigmf(x, [-10 0]);
A2= sigmf(x, [10 0]);
plot(x,[A1; A2], 'k', 'linewidth',2)
axis([-1 1 0 1.2]), xlabel('x'), ylabel('\mu(x)'), box off

13
Contd

A1 A2

1
0.8
(x)

0.6
0.4
0.2
0
-1 -0.5 0 0.5 1
x

Contd
(Definition) S-shaped curve MF
Its shape is determined by two parameters, l and r
where c = (l + r) / 2. The following is an example of
this function:
 0 xl

 2( x  l )2 lxc
 r l
 A ( x)  
1  2( x  r )2 cxr
 r l
 1 xr

14
Contd
% S-shaped curve membership function.
function mf= smf(x, para)
L= para(1); R= para(2);
if L >= R
error('Check the parameters');
end
C= (L+R)/2;
mf= zeros(size(x));

Contd
index= find(x <= L);
mf(index)= zeros(size(index));

index= find((x > L) & (x <= C));


mf(index)= 2*(x(index)-L).^2/(R-L)^2;

index= find((x > C) & (x <= R));


mf(index)= 1-2*(x(index)-R).^2/(R-L)^2;

index= find(x > R);


mf(index)= ones(size(index));

15
Contd
% Primary function calling sMF
x= -1:0.01:1;
A1= smf(x, [0 1]);
A2= 1-smf(x, [-1 0]);
plot(x,[A1; A2], 'k', 'linewidth',2)
axis([-1 1 0 1.2])
xlabel('x'), ylabel('\mu_A(x)')
box off

Contd

A1 A2
1
0.8
(x)

0.6
0.4
0.2
0
-1 -0.5 0 0.5 1
x

16
Contd
(Definition) Generalized bell curve
Its shape is determined by three parameters: a, b, and
c. c is the center of the curve, and the larger a, the
flatter the nipple, and the larger the value of b, the
steeper the inflection point.

1
 A ( x)  2b
xc
1
a
, (b>0)

Contd
% Generalized bell curve MF
function mf= gbellmf(x, para)
a= para(1); b= para(2); c= para(3);
mf= 1./(1+abs((x-c)/a).^(2*b));

% Primary function calling gbellmf


x= -1:0.01:1;
A1= gbellmf(x, [0.2 3 -0.5]);
A2= gbellmf(x, [0.2 3 0]);
A3= gbellmf(x, [0.2 3 0.5]);
plot(x,[A1; A2; A3], 'k', 'linewidth',2)
axis([-1 1 0 1.2]), xlabel('x'), ylabel('\mu(x)'), box off

17
Contd

A1 A2 A3

1
0.8
(x)

0.6
0.4
0.2
0
-1 -0.5 0 0.5 1
x

Contd
Examples of discrete MFs

18
Contd
Fuzzy Partition of Input Space
• Fuzzy partition divides the input space into several
fuzzy slices, each of which is specified by a MF.
• Fuzzy partition should allow overlap between
adjacent fuzzy sets.
• For example, if three fuzzy values are set for input
variables x1 and x2, the input space consisting of up
to 33= 9 can be divided, and up to 9 different
control rules can be generated in terms of the input
space.

Contd
For example, 2-inputs and x1
1-output FLC u
x2 FLC
A1 A2 A3

C1 C2 C3
x1
-1 0 1
B1 B2 B3 u
0 0.5 1

x2
-1 0 1

19
Contd
Overlap of MFs
A1 A2 A3

No overlap x
A1 A2 A3 A1 A2 A3

x x
Moderate overlap Too much overlap

Contd
x1
u
x2 FLC
x2
R1: if x1 is A1 and x2 is B1, then u
B3 C2 C2 is C1 also
R2: if x1 is A1 and x2 is B2, then u
B2 C1 C1 is C1 also
B1 C1 C3 C4 .
x1 ..
A1 A2 A3
R7: if x1 is A3 and x2 is B3, then u
is C2

20
Contd
x1
u
x2 FLC

x2 R1: if x1 is A1 and x2 is B1, then


u is C1 also
B3 C2 R2: if x1 is A2 and x2 is B1, then
B2 C3 u is C3 also
R3: if x1 is A1 or x1 is A2 and x2
B1 C1 C3
x1 is B3, then u is C2 also
A1 A2 A3 R4: if x1 is A3, then u is C3

Contd
Fuzzy Control Rules
The rules are generally described by if-then statements.
Mamdai-type
R1: if x is A1 and y is B1, then z is C1 also
R2: if x is A2 and y is B2, then z is C2 also

Rn: if x is An and y is Bn, then z is Cn
Sugeno-type
R1: if x is A1 and y is B1, then z = f1(x,y)
R2: if x is A2 and y is B2, then z = f2(x,y)

Rn: if x is An and y is Bn, then z = fn(x,y)

21
Contd
Derivation of Fuzzy Control Rules
• Expert's experience and knowledge
- Many experts have found that fuzzy control rules
provide a convenient way to express their knowledge
and experience in the form of fuzzy if-then rules
• Based on operator's control actions
- Skilled human operators can control such systems quite
successfully without having any quantitative models in
mind.
- Control rules can be deduced from the observation of
human controller’s actions in terms of the input-output
operating data

Contd

22
Contd

Contd
• Based on the fuzzy model of a process
- The linguistic description of the dynamic
characteristics of a process may be viewed as a fuzzy
model. Based on the fuzzy model, we can generate a
set of fuzzy control rules.
• Based on learning
- Many FLCs have been built to emulate human
decision-making behavior, but few are focused on
human learning, namely, the ability to create fuzzy
control rules and to modify them based on experience.
- Procyk and Mamdani described the first self-
organizing controller (SOC).

23
4. Decision-Making

• Mechanism to infer fuzzy output using the inputs


and fuzzy rules defined by the database and rulebase.
• This is called fuzzy inference and is based on the
concept of fuzzy logic and approximate reasoning.
• We discussed the inference of the Mamdani fuzzy
system and the Sugeno fuzzy system.

Contd
Mamdani-type Inference
input : x1 is A' (u0 ) and x2 is B ' (v0 )
rule R1: if x1 is A1 and x2 is B1, then z is C1 also
rule R2: if x1 is A2 and x2 is B2 , then z is C2
result : z is C '

where AiU, BiV, CiW, uU, vV, wW


• inputs A' and B' : fuzzy singletons
• inplication and 'and': min operators
• 'also' : max operator

24
Contd
input : x1 is u0 and x2 is v0
rule R1: if x1 is A1 and x2 is B1 , then z is C1

   1   C1 ( w )
 (w)
(w) C1'
C1'
w here  1   A1 ( u 0 )   B 1 ( v 0 )

Contd
input : x1 is u0 and x2 is v0
rule R2: if x1 is A2 and x2 is B2 , then z is C2

 ( w)   2  C2 ( w)
 (w)
C 2'
C 2'
w here  2   A2 ( u 0 )   B 2 ( v 0 )

25
Contd

 (w)   (w)   (w)


C' C1' C 2'

Contd
Sugeno-type Inference
input : x1 is u0 and x2 is v0
rule R1: if x1 is A1 and x2 is B1 , then z  f1 ( x1, x2 )

rule R2: if x1 is Ai and x2 is Bi , then z  f 2 ( x1 , x2 )
result : z= w0

where AiU, BiV, uU, vV


• 'and': min operator

26
Contd

Contd
For fuzzy singletons x1= u0 and x2= v0,  i is
calculated as Sugeno-type inference, the final result
is calculated by

 1 f1 ( u 0 , v 0 )   2 f 2 ( u 0 , v 0 )
z
1   2

27
5. Defuzzification

• An FLC with Mamdani-type fuzzy rules outputs


fuzzy value after inference.
• For control, fuzzy values are converted to crisp
values, called defuzzification, as
w0= defuzzifier(C)
where C is the inferred fuzzy set and w0 is the
defuzzified crisp value.

Contd
Center Of Gravity(COG) Method

COG is a method to generate the element where the


center of gravity of the fuzzy set is located. It is
most commonly used.

w0 
 w   ( w)dw
c'

  (w)dw
c'

28
Contd
For example, the inferred result of a fuzzy system is
as follows:
C'= 0.1/-1+0.5/-0.5+0.3/0+0.2/0.5, wC'
C ' ( w)

w
-1 -0.5 0 0.5
By the COG method
0.1 (1)  0.5  (0.5)  0.3  0  0.2  0.5
w0 
0.1  0.5  0.3  0.2
0.1  0.25  0  0.1
  0.227
1.1

Contd
For example, the inferred result of a fuzzy system is as
follows: C ' ( w)
0.5

w
-1 0
By the COG method 01 1 0
C' 0.5   w2 dw   w3 
w0  01 2  6
1
 
2
1 1  2 0 3
  wdw
1 2 4 
w
 1
dw w
-1 0

29
Contd
Bisector Of Area(BOA) Method
BOA generates the element at the point where the left
and right MF areas of the fuzzy set are equal
w0 w(U )
w( L )
C ' ( w)dw  
w0
C ' ( w)dw

Contd
For example
C'= 0.1/-1+0.5/-0.5+0.3/0+0.2/0.5, C'W
C ' ( w)

w
-1 -0.5 0 0.5
when w= -1, the left and right MGs are
Left= 0.1, Right= 0.5+0.3+0.2= 1.0
when w= -0.5
Left= 0.1+0.5= 0.6, Right= 0.3+0.2= 0.5
w0= -0.5

30
Contd
C ' ( w)
For example,
0.5

w
-1 0 0.5 1
By the BOA method
w0 0.5

C ' ( w) 0
(w  0.5)dw   w0
(w  0.5)dw

0.5 1
w02  w0   0  w0  0.146
8
w
-1 0 w0 0.5 1

Contd
(Quiz 1) Consider the inferred result C' of a fuzzy
system. Determine w0 using the COG and BOA
methods, where C'W
C'= {(-1.5,0.1), (-1.0,0.1), (-0.5,0.7), (0,0.5), (0.5,
0.2), (1,0.2)}
C ' ( w)

w
-1.5 -1.0 -0.5 0 0.5 1.0
COG method BOA method
 w  c' ( w)dw w0 w(U )
w0 
 c' ( w)dw w( L )
C ' ( w)dw  w0
C ' ( w)dw

31
Contd
Answer: COG method
C'= {(-1.5,0.1), (-1.0,0.1), (-0.5,0.7), (0,0.5), (0.5, 0.2),
(1,0.2)} C ' ( w)

w
-1.5 -1.0 -0.5 0 0.5 1.0

1.5  0.1  1 0.1  0.5  0.7  0.5  0.2  1 0.2


w0 
0.1  0.1  0.7  0.5  0.2  0.2
0.3
  0.1667  w0  0.1667
1.8

Contd
BOA method
C'= {(-1.5,0.1), (-1.0,0.1), (-0.5,0.7), (0,0.5), (0.5, 0.2),
(1,0.2)} C ' ( w)

w
-1.5 -1.0 -0.5 0 0.5 1.0

When w= -0.5, the left and right MGs are


Left= 0.1+0.1+0.7= 0.9
Right= 0.5+0.2+0.2= 0.9
w0= -0.5

32
Contd
(Quiz 2) Consider the inferred result of a fuzzy
system. Determine w0 using the COG and BOA
methods, where C'W
C ' ( w)
0.5
0.3
w
-0.5 0 0.5 1
COG method BOA method

 w   ( w)dw c' w0 w(U )


w0 
  (w)dw
c '
 w( L )
C ' ( w)dw  
w0
C ' ( w)dw

Contd
Answer: C ' ( w)
0.5
COG method 0.3
w
-0.5 0 0.5 1

0.5 1

w0 
0 
0.5wdw 
0.5
0.3wdw
0.5 1
 0.5dw  
0 0.5
0.3dw

1  2  0.5 0.3  2 1
w  w
4  0 2   0.5 0.175
   0.4375
0.5  0.5  0.5  0.3 0.4

33
Contd
C ' ( w)
BOA method 0.5
0.3
w
-0.5 0 0.5 1

w0 0.5 1

0
0.5dw  w0
0.5dw  
0.5
0.3dw

0.5w0  0.5(0.5  w0 )  0.3(1  0.5)  w0  0.4

Contd
Smallest Value Of Maximum(SOM) Method
If the MF of the fuzzy set has the maximum element
as
w j  arg max C ' ( w)
w
SOM generates the smallest of wj.

w0  min( w j )
j

34
Contd
For example, we have C'W
C ' ( w)
0.5
0.3
w
-1 0 0.5 1

Applying SOM yields


w j  arg max C ' ( w)  {w | 0  w  0.5}
w
 w0  0

Contd
Largest Value Of Maximum(LOM) Method
If the MF of the fuzzy set has the maximum element
as
w j  arg max C ' ( w)
w
LOM generates the largest of wj.
w0  max( w j )
j

35
Contd
For example, we have C'W

C ' ( w)
0.5
0.3
w
-1 0 0.5 1
Applying LOM yields
w j  arg max C ' ( w)  {w | 0  w  0.5}
w
 w0  0.5

Contd
Mean Value Of Maximum(MOM) Method
If the MF of the fuzzy set has the maximum element
as
w j  arg max C ' ( w)
w
MOM generates the mean of wj.
n
1
w0  
n j 1
wj

36
Contd
For example, consider the inferred fuzzy set C'= 0.1/-
1+0.5/-0.5+0.5/0+0.2/0.5 where C'W

C'
w
-1 -0.5 0 0.5
Applying MOM yields

w j  arg max C ' ( w)  {0.5, 0}


w

w0= (-0.5+0)/2= -0.25

Contd
For example,
C ' ( w)
0.5
0.3
w
-1 0 0.5 1
Applying MOM yields
w j  arg max C ' ( w)  {w | 0  w  0.5}
w
 w0  (0  0.5) / 2  0.25

37
Contd
(Quiz 3) Given the inferred fuzzy set C', defuzzify C'
to the corresponding crisp value w0 using COG,
BOA, SOM, LOM, and MOM, where C'W
C'= 0.1/-1+0.6/-0.5+0.6/0+0.3/0.5+0.1/1

C'

w
-1 -0.5 0 0.5 1

Contd
Answer: (1) COG method
C'= 0.1/-1+0.6/-0.5+0.6/0+0.3/0.5+0.1/1

0.1 (1)  0.6  (0.5)  0.6  0  0.3  0.5  0.11


 w0 
0.1  0.6  0.6  0.3  0.1
0.1  0.3  0.15  0.1
  0.09
1.7

38
Contd
(2) BOA method
C'= 0.1/-1+0.6/-0.5+0.6/0+0.3/0.5+0.1/1
C'

w
-1 -0.5 0 0.5 1
w= -0.5, the left and right MGs are
Left= 0.1+0.6= 0.7
Right= 0.6+0.3+0.1= 1.0
w0= -0.5

Contd
(3) SOM method
w j  arg max C ' ( w)  {0.5, 0}
w
 w0  0.5
C'
(4) LOM method
 w0= 0 w
-1 -0.5 0 0.5 1
(5) MOM method
 w0= (-0.5+0)/2= -0.25

39
6. Advantages & Disadvantages
Advantages of FLC
• Robust− FLCs are more robust than PID controllers
because of their capability to cover a huge range of
operating conditions.
• Customizable− FLCs are customizable.
• Emulate human deductive thinking − Basically
FLC is designed to emulate human deductive
thinking, the process people use to infer conclusion
from what they know.
• Reliability − FLC is more reliable than conventional
control system.
• Efficiency − Fuzzy logic provides more efficiency
when applied in control system.

Contd
Disadvantages of FLC
• Requires lots of data − FLC needs lots of data to be
applied.
• Useful in case of moderate historical data − FLC
is not useful for programs much smaller or larger
than historical data.
• Needs high human expertise − This is one
drawback as the accuracy of the system depends on
the knowledge and expertise of human beings.
• Needs regular updating of rules − The rules must
be updated with time.

40
Q&A

41

You might also like