You are on page 1of 20

Chapter Four: Fuzzy Logic and Fuzzy Control .

4 Chapter Four
Fuzzy Logic and Fuzzy Control

This chapter reviews the history of Fuzzy Logic and Fuzzy systems. A brief
explanation of fuzzy sets, fuzzy operators and fuzzy relations will be given.
Different methods of Defuzzifiction methods will be explained and a comparison
between these methods will be done. This chapter also explains how to construct a
Fuzzy Logic Controller (FLC). The aim of this chapter is not to be complete in
itself, but to provide the parts of fuzzy set theory which are necessary to
understand the remainder of this thesis.

4.1 Introduction
This chapter contains the basics of fuzzy set theory that are necessary for a
correct understanding of the rest of this thesis. If the reader is already familiar
with the field of fuzzy set theory, this chapter may contain nothing new. It serves
as an introduction to fuzzy set theory. It starts with a section about what fuzzy sets
are and how they are related to classical (conventional) set theory. After this, a
number of properties of fuzzy sets are given. Important definitions related to fuzzy
sets are explained. The union and intersection of fuzzy sets, and the complement
of fuzzy sets, are presented. A final section summarizes this chapter

4.2 Fuzzy Sets and Fuzzy Operations


One of the key features of fuzzy control systems is “fuzzy sets” and “fuzzy
operations”. What does a linguistic fuzzy set “Tall” mean? And what does the
fuzzy operator “OR” mean? What is the difference between fuzzy logic and
conventional logic? Answering these questions helps to give the reader an
understanding for fuzzy logic.

4.2.1 Fuzzy sets


The term “Fuzzy sets” was introduced by L. Zadeh [1] in 1965, although the
underlying idea or ideas close to it had already been recognized earlier by others,

.
.
28
Chapter Four: Fuzzy Logic and Fuzzy Control .

mainly by philosophers. To clarify the difference between fuzzy sets and


conventional sets consider this example. To classify a group of people according
to their heights there are two ways of classifications. Conventional logic (or
Boolean Logic) can assign a certain height as the border between “Tall” people
and “Short” people. Suppose 170 cm is that border. Now any person taller than
170 cm is classified as a person belongs to the “Tall” set of people and any person
shorter than 170 cm is classified as a member of the “Short” set of people. This
can be represented by the following equation:

1 iff x >= 170 cm


MTall(x) = { 0 iff x < 170 cm
(4.1)

Where:
x : is the height of a person.
MTall(x): is the membership of a person of the height x to the set “Tall”.

Assume there are two persons one with the height of 169.5 cm while the
other has the height 170.5 cm. According to this method of classification it is clear
that the first person is classified as “Short” while the second person is classified as
“Tall”. This seems unreasonable because the difference in height between those
two persons is only 1 cm. This problem can be solved by introducing a region of
uncertainty between the two sets as shown in figure 4.1. But a new problem
appears. Those people with heights within this region will not be classified as a
member of either set.

In fuzzy logic there is no sharp boundary between different sets. As shown


in figure 4.2, it is more reasonable to classify the first person as belonging to the
“Short” set with a membership degree of 0.55 and belonging to the “Tall” set with
a membership degree of 0.45. While the second person is classified as belonging
to the “Short” set with a membership degree of 0.45 and belonging to the “Tall”
set with a membership degree of 0.55.

.
.
29
Chapter Four: Fuzzy Logic and Fuzzy Control .

1
Tall
Membership

0
150 160 170 180 190
Hieght (cm)

(a) Boolean representation of “Tall” set of people.

1
Short Tall
Membership

0
150 160 170 180 190
Height (cm)

(b) Boolean representation with uncertainty gap.


Fig. 4.1 Conventional Logic (Boolean Logic).

.
.
30
Chapter Four: Fuzzy Logic and Fuzzy Control .

1 Short Tall
Membership

0
150 160 170 180 190
Height (cm)

Fig. 4.2 Example of Fuzzy Sets representing “Height”.

This new term called the membership degree that shows to which degree a
certain element belongs to a certain set. An element with membership degree of
“1” completely belongs to the set while an element with membership of “0” does
not belong at all to that set. And other elements will have a membership degree
between 0 and 1 as shown in figure 4.2.

4.2.1.1 Different shapes of Fuzzy Sets


Fuzzy sets can have different shapes such as triangular shape, trapezoidal
shape, exponential L shape and exponential Bell shape as shown in figure 4.3. In
fact the exponential shapes are frequently used in fuzzy logic but seldom used in
fuzzy control [3]; on the other hand the triangular and trapezoidal shapes are
widely used in fuzzy control.

.
.
31
Chapter Four: Fuzzy Logic and Fuzzy Control .

Decreasing Triangular Trapezoidal Increasing


1

Membership

0
0 1 2 3 4 5 6
Universe of Discourse

(a) Different shapes of Linear Fuzzy Sets

Decreasing Bell Increasing


1
Membership

0
0 1 2 3 4 5 6
Universe of Discourse

(b) Different shapes of Exponential Fuzzy Sets


Fig. 4.3 Different Shapes of Fuzzy Sets.

4.2.1.2 Important definitions for Fuzzy Sets


There are important terms to be defined to describe any fuzzy set. Here are a
list of these terms and their definitions [3]:
Support of a fuzzy set: is defined as the interval of all elements with
membership degree larger than zero. As shown in figure 4.4, the
“Support” of the fuzzy set “Normal” is the interval (18,22). The
Support of a fuzzy set could be mathematically represented by the
following equation:
.
.
32
Chapter Four: Fuzzy Logic and Fuzzy Control .

Supp (A) = { x  X | MA(x) > 0 } (4.2)


Where:
A: is a fuzzy set.
X: is the universe of discourse.
x: is an element which belongs to X; the term  signifies this also.
MA: is the membership degree of the fuzzy set A.

Width of a fuzzy set: is defined as the length of its support. In figure 4.4,
the “Width” of the fuzzy set “Normal” is equal to 22-18=4.
Nucleus (Core) of Fuzzy Set: is defined as the interval of all elements with
membership degree equal to one. In figure 4.4, the “Core” of the fuzzy
set “Normal” is the interval [19,21]. The “Core” of a fuzzy set could be
mathematically represented by the following equation:
Core (A) = { x  X | MA(x) = 1 } (4.3)
Where:
A: is a fuzzy set.
X: is the universe of discourse.
MA: is the membership degree of the fuzzy set A.

Peak of Fuzzy Set: if the fuzzy set has only one element with membership
degree equal to one, then this element is called the “Peak” of that set.
In figure 4.4, the “Peak” of the fuzzy set “Warm” is 22 ºC.

Cold Cool Normal Warm Hot

1
Membership

0
16 17 18 19 20 21 22 23 24
Temperature (°C)

Fig. 4.4 Definitions for Fuzzy Sets.


.
.
33
Chapter Four: Fuzzy Logic and Fuzzy Control .

4.2.2 Fuzzy Operations


As in conventional logic theory, fuzzy logic uses the operations
“Intersection”, “Union” and “Complement” to represent the logical operators
“AND”, “OR” and “NOT” respectively. The meaning of each one of these
operations and how it is represented in fuzzy logic theory is discussed below.

4.2.2.1 Intersection operation


There are many ways to represent the “Intersection” operation in fuzzy logic
theory. If there are two fuzzy sets A and B with membership functions MA and
MB respectively, then the “Intersection” of these two fuzzy sets can be calculated
using one of the following three methods:

min ( MA , MB ) -- a
MA  MB =
{ .
MA MB
max ( 0, MA + MB -1 )
-- b
-- c
(4.4)

Where: min: is the minimum function.


(. ): is the product of the two membership degrees.
max: is the maximum function

Equations 4.4.a and 4.4.b are more frequently used than other methods of
calculation. General forms of “Intersection” are represented by triangular norm
(T-norms) see appendix B fore more details. Figure 4.5 shows the “Intersection”
of two fuzzy sets using the frequently used representations given in equations 4.4.

.
.
34
Chapter Four: Fuzzy Logic and Fuzzy Control .

A B
1

Membership
0.5

0
0 1 2 3
Universe of Discourse

c
1
Membership

b
0
0 1 2 3
Universe of Discourse

Fig. 4.5 Intersection of two Fuzzy Sets.

4.2.2.2 Union operation


As with intersection, there are many ways to represent the “Union”
operation as well in fuzzy logic theory. If there are two fuzzy sets A and B with
membership functions MA and MB respectively, then the “Union” of these two
fuzzy sets can be calculated using one of the following three methods:
max (MA , MB ) -- a
MA  MB =
{ MA + MB - MA . MB
min (1, MA + MB )
-- b
-- c
(4.5)

Where: min: is the minimum function.


(. ): is the product of the two membership degrees.
max: is the maximum function
.
.
35
Chapter Four: Fuzzy Logic and Fuzzy Control .

Equations 4.5.a and 4.5.b are more frequently used than other methods of
calculation. General forms of “Union” are represented by triangular conorms (T-
conorms or S-norms) see appendix B for more details. Figure 4.6 shows the
“Union” of two fuzzy sets using the frequently used representations given in
equations 4.5.

A B
1
Membership

0.5

0
0 1 2 3
Universe of Discourse

1
c
Membership

0.5 a

0
0 1 2 3
Universe of Discourse

Fig. 4.6 Union of two Fuzzy Sets.

4.2.2.3 Complement operation


If there is a fuzzy set A with membership function MA, then the
“Complement” of this fuzzy set can be calculated using “one minus” operator
using Equation 4.6.

.
.
36
Chapter Four: Fuzzy Logic and Fuzzy Control .

Comp(A) = A = 1 - MA (4.6)

Where:
A : is the complement of the fuzzy set A.

Figure 4.7 shows the “Complement” of a fuzzy set.

A
1
Membership

0.5

0
0 1 2 3 4
Universe of Discourse

Complement of A
1
Membership

0.5

0
0 1 2 3 4
Universe of Discourse

Fig. 4.7 Complement of a Fuzzy Set.

.
.
37
Chapter Four: Fuzzy Logic and Fuzzy Control .

4.3 If-Then Rules


The basic element of fuzzy logic is fuzzy proposition. An example of a
fuzzy proposition is (Error is Small) where “Error” is a linguistic variable and
“Small” is a fuzzy set. Fuzzy rules are if-then statements with fuzzy propositions
in the antecedent and consequence of the rules. Fuzzy operators may be used to
connect different fuzzy propositions. Each rule represents a relation between its
input(s) (antecedents) and its output(s) (consequences). A simple example of the
if-then rules is:
If Error is PB and Change of Error is PS then Control Signal is PB
Where:
PB and PS: are fuzzy sets representing Positive-Big and Positive-Small
respectively.
Error: is the difference between the process output and the desired output.
Change of Error: is the derivative of Error.

The previous rule represents a part of the relation between the “Error” and
the “Change of Error” as inputs to the controller, and the “Control Signal” as an
output of the controller. It is clear that this rule has a similar action to the
conventional PD controller. Of course this rule is not enough to represent all the
states of inputs, so a group of rules are used to represent most (if not all) the
possible states of inputs. These rules are referred to as the rule-base.

4.3.1 Fuzzy Inference


To obtain the output of a fuzzy rule-base there are two different methods.
The first is called composition based inference, which first combines all rules into
one relation then this relation is fired with the fuzzy input to obtain the fuzzy
output [3]. The other way is termed individual-rule based inference in which each
rule is fired individually with the input this yields some modified fuzzy sets that
are combined into one overall fuzzy set represents the output.
The two most popular fuzzy inference methods are the Max-Min inference
and the Max-Product inference. These two methods are explained below.

.
.
38
Chapter Four: Fuzzy Logic and Fuzzy Control .

4.3.1.1 Max-Min Inference


In this inference method, the antecedent of the if-then rule is combined using
the “Min” operator to have a modified fuzzy set for the output, then these
modified fuzzy sets are combined with each other using the “Max” operator.
The following example is used to give more explanation. For the following
rules which represent a PD-like fuzzy controller:
Rule-1: If Error is PB and Change of Error is PS then Control Signal is PB
Rule-2: If Error is PS and Change of Error is PS then Control Signal is PS
To use these rules to calculate the “Control signal”, “U” for a certain crisp value
of “Error”, “E” and a crisp value of “Change of Error”, “CE” the “Min” operator
is used to combine the fuzzy set of error PB with the fuzzy set of Change of error
PS. The same operator is used with the second rule and the outputs of the two
rules are finally combined using the “Max” operator. Figure 4.8 explains the Max-
Min inference method.

Error (E) Change of Error (CE) Control (U)


PS PB PS PB
PS PB

Rule-1

E CE .

Min
PS PB PS PB
PS PB

Rule-2

E CE .
Max
Min
PS PB

Output

Fig. 4.8 Max-Min inference method.

.
.
39
Chapter Four: Fuzzy Logic and Fuzzy Control .

4.3.1.2 Max-Product Inference


In this inference method, the antecedent of the if-then rule is combined using
the “Product” operator to have a modified fuzzy set for the output, then these
modified fuzzy sets are combined each other using the “Max” operator.
For more explanation the last example is repeated, for the following rules
which represent a PD-like fuzzy controller:
Rule-A: If Error is PB and Change of Error is PS then Control Signal is PB.
Rule-B: If Error is PS and Change of Error is PS then Control Signal is PS.
To calculate the “Control signal”, “U” for a certain crisp value of “Error”, “E” and
a crisp value of “Change of Error”, “CE” the “Product” operator is used to
combine the fuzzy set of error PB with the fuzzy set of Change of error PS. The
same operator is used with the second rule and the outputs of the two rules are
finally combined using the “Max” operator. Figure 4.9 explains the Max-Product
inference method.

Error (E) Change of Error (CE) Control (U)


PS PB PS PB
PS PB

Rule-
A

E CE .

Product
PS PB
PS PB PS PB

Rule-
B

CE .
E
Max
Product
PS PB

Output

Fig. 4.9 Max-Product inference method.

.
.
40
Chapter Four: Fuzzy Logic and Fuzzy Control .

4.3.2 Fuzzy Control Rules


In fuzzy control two types of fuzzy rules can be distinguished: Mamdani
rules and Sugeno rules. The Mamdani rules are the rules considered thus far in
this thesis which have fuzzy propositions in their consequences part. The Sugeno
rules are based on a different principle, the consequents of those rules are (linear)
functions of the controller inputs. These two types of fuzzy rules are described in
the following sections.

4.3.2.1 Mamdani Fuzzy Rules


This type of fuzzy rule was used in the first reported applications of fuzzy
control [4-6]. It can be described by the following general form:

If x1 is A1 and x2 is A2 and ……. and xn is An then y1 is B1, ….. , yk is Bk


Where: x1 ,… xn : are linguistic variables representing the inputs.
A1 ,… An : are fuzzy sets for the inputs.
y1 ,… yk : are linguistic variables representing the outputs.
B1 ,… Bk : are fuzzy sets for the outputs.

This is the same type of fuzzy rule considered thus far in this thesis. An
example of such a fuzzy control rule is:
If Error is PBig and Change of Error is PSmall then Control Signal is PBig

Mamdani and co-workers used this type of fuzzy rules and were the first
ones to report in literature on the applications of fuzzy logic in control and
therefore this type is termed as “Mamdani-rules”.

4.3.2.2 Sugeno Fuzzy Rules


The other fuzzy rule type is termed as “Sugeno-rules” since it was firstly
introduced by Takagi and Sugeno (1983) [7] and further exploited by Sugeno and
co-workers. This type of rules is also referred to as “Takagi-Sugeno rules”. The
general form of this type of rules is as follows:

If x1 is A1 and x2 is A2 and ……. and xn is An then


y1 = f1 (x1 , x2 ,…., xn ) ,…., yk = fk (x1 , x2 ,…., xn )

.
.
41
Chapter Four: Fuzzy Logic and Fuzzy Control .

where: x1 ,… xn : are linguistic variables representing the inputs.


A1 ,… An : are fuzzy sets for the inputs.
y1 ,… yk : are linguistic variables representing the outputs.
f1 ,… fk : are functions of the inputs xi .

It is noted that the consequents of these fuzzy rules are functions (fk) of the
inputs xi. An example of the Sugeno type of rules is:

If E is PBig and CE is PSmall then U= 3E + 2 CE


where: E : is the Error.
CE: is the Change of Error.
U : is the Control Signal.

4.3.3 Rules Properties


“What are the properties which should be satisfied by the rules?” is one of
the most important questions. For a rule-base to be robust there are some
properties should be fulfilled. These properties are:
- Completeness: a set of if-then rules is called to be complete if for any
combination of input values there is an output value. i.e. the rules cover
all possible situations of the inputs. So the incomplete rule-base has what
are called blank spots. This means for certain situations of the inputs
there is no output. Incompleteness of fuzzy rules may lead to undesired
control behavior in fuzzy control. In practice there are many applications
with incomplete rules but which still have a good performance. This is
because certain regions of the input domain are not of interest and
therefore do not have to be defined. An example of this is the well
known inverted pendulum problem which performs optimally with only
ten to twelve out of twenty five rules [3]. There has been much work on
the redundancy of fuzzy rules.
- Consistency: a set of if-then rules is said to be consistent if it does not
contain contradictions. If there are two rules with the same antecedents
but different consequences this means these rules are inconsistent. A
well-known example of an inconsistent rule-base in the case of robot
.
.
42
Chapter Four: Fuzzy Logic and Fuzzy Control .

control is where two fuzzy rules co-exist in the rule-base used for the
control of a robot and the input “obstacle in front” is considered:
-if obstacle in front then go left
-if obstacle in front then go right
It is clear that a major confusion will occur due to this inconsistency.
- Continuity: for a rule base to be continuous its rules should fulfil the
following condition: (rules with “adjacent” antecedents have “adjacent”
consequences). Two fuzzy sets are called “adjacent” to each other if they
are overlapping. This means if there is a small change in the inputs this
leads to a corresponding small change in the outputs and vice versa.

4.4 Defuzzification methods


There are many methods used to calculate a crisp value from a fuzzy set.
More research has to be done to study the influence of these different methods of
defuzzification on the controller performance. An explanation of these methods
and the differences between them is given in the following sections [3].

4.4.1 Centre of Area (Gravity) Method (CoA)


Centre of Area (COA) (sometimes referred to as Centre of Gravity COG) is
the best well known defuzzification method. It uses the mathematical equations
used to determine the centre of gravity of the flat surfaces with homogenous
thickness. In case of overlapping areas between fuzzy sets, the area of overlapping
is calculated once. This method is also known as (Centroid).

4.4.2 Centre of Sums Method (CoS)


Centre of Sums (COS) is one of the frequently used defuzzification
methods. It uses the same method as the Centre of Area but the overlapping areas
between fuzzy sets are calculated twice.

4.4.3 Height Method (HM)


The Height method is a very simple and very quick technique. It does not
calculate the areas like the previous two methods. It uses only the peak value and
the centre of each set to calculate the crisp output.
.
.
43
Chapter Four: Fuzzy Logic and Fuzzy Control .

4.4.4 Centre of Largest Area Method (CLA)


In this method, if the output fuzzy set is consisted of two areas then it
calculates the centre of gravity for the largest area only and this represents the
crisp output.

4.4.5 First of Maxima Method (FoM)


This method of defuzzification uses the smallest value of the output domain
which has the maximum membership degree.

Figure 4.10 gives examples of the different defuzzification methods


mentioned before [8].

0.5

centroid

bisector

LOM
MOM
SOM

-10 -8 -6 -4 -2 0 2 4 6 8 10

Fig. 4.10 Different Defuzzification methods.

.
.
44
Chapter Four: Fuzzy Logic and Fuzzy Control .

4.4.6 Comparison between Defuzzification Methods


To compare the defuzzification methods some criteria should be used to be
satisfied by a good defuzzification method. These criteria could be summarized
as follows:
- Continuity: the defuzzification method is said to be continuous if a small
change in the inputs does not lead to a large change in the output. The
first of Maxima method does not fulfil this criterion.
- Disambiguity: If there are two equally large areas then Centre of Largest
Area method can not choose between these two areas. This means it is
ambiguous. i.e. the Centre of Largest Area method does not fulfil this
condition.
- Plausibility: the output of a defuzzification method is said to be plausible if
it lies in the centre of the support of the output fuzzy set and has the
highest degree of membership.
- Computational Complexity: for practical applications computational
complexity and computational time are very important. So it is better to
use the defuzzification method with less complexity and fast
computational time.
Table 4.1 summarizes the comparison between defuzzification methods.

CoA CoS HM CLA FoM MoM


Continuity Yes Yes Yes No No No
Disambiguity Yes Yes Yes No Yes Yes
Plausibility Yes Yes Yes Yes No No
Computational
Bad Good Good Bad Good Good
Complexity
MoM: is Middle of Maxima
Table 4.1 Comparison between Defuzzification Methods.

4.5 When to use Fuzzy Control?


One of the important questions about fuzzy control is “When to use Fuzzy
Control?”[3]. Although it is difficult to give a clear answer to this question, a

.
.
45
Chapter Four: Fuzzy Logic and Fuzzy Control .

systematic decision procedure should be available to analyze the given problem


and decide whether to use fuzzy control to solve it or not. It is important to have
some guide lines on whether to use fuzzy control or not.
Firstly, if there is a successful fuzzy control solution to a similar problem,
this may indicate that a suitable fuzzy controller to this problem is possible.
Secondly, if there is a conventional PID controller for the process with a
robust performance and economic cost, then it is better to stick with it.
And lastly, if there is knowledge available about the process and how to
improve its performance but it is difficult to express this knowledge in the
conventional way with differential equations – such are used with conventional
PID controllers – then fuzzy control can be used to represent this linguistic
information and use it to build a suitable control system for the process. Hence
fuzzy control could be the better solution for ill-structured processes.
An example when it is difficult to have exact and complete mathematical
equations to describe the process is the case of cooling systems. It may be easy to
find an expert operator who can monitor the system and take a suitable control
decision according to the situation. If an operator is been asked to describe the
situation on which he/she builds the control decision, this could be the reply “the
Temperature is Normal, but Quickly Increasing”. This expression can be
represented in fuzzy terms and a complete fuzzy controller can be built to control
this process.

4.6 Summary
Fuzzy sets are sets without sharp (crisp) boundaries. Membership of a fuzzy
set is a grade in the interval [0, 1]. Fuzzy sets can be used to model linguistic
labels, where the “vagueness” of the label is modelled by the non-crisp boundaries
of the fuzzy set used to represent that label.
The history of Fuzzy Logic and Fuzzy systems has been reviewed. Fuzzy
sets, fuzzy operators and fuzzy relations are explained. Different methods of
Defuzzifiction methods are shown and a comparison between these methods is
done. This chapter also explained how to construct a Fuzzy Logic Controller
(FLC).

.
.
46
Chapter Four: Fuzzy Logic and Fuzzy Control .

4.7 References
1 L.A. Zadeh (1965). Fuzzy sets. Information and control, 8, pp 338-353.
2 L.A. Zadeh (1994). Soft computing and fuzzy logic. IEEE Software, pp
48-56.
3 D. Driankov, et al, (1993). An Introduction to Fuzzy Control. Springer-
Verlag.
4 E.H. Mamdani, (1974). Applications of fuzzy algorithm for simple
dynamic plant. Proceedings IEE, 121, 12, pp 1585-1588.
5 S. Assilian, (1974). Artificial Intelligence Techniques in the Control of
Real Dynamic Systems. PhD Thesis, Queen Mary College, University of
London, London, UK.
6 E.H. Mamdani and S. Assilian, (1975). An experiment in linguistic
synthesis with a fuzzy logic controller. International Journal of Man-
Machine Studies, Vol. 7, pp 1-13.
7 T. Takagi and M. Sugeno, (1983). Derivation of fuzzy control rules from
human operator’s control actions. E.Sanchez and Gupta , pp. 55-60.
8 Matlab, (2006). Fuzzy Logic ToolBox user’s guide, Matlab ver 7.3, The
MathWorks, Inc.

.
.
47

You might also like