Está en la página 1de 50

PREFACE

Fuzzy logic has come a long way since it was first subjected to technical scrutiny
in 1965, when Dr. Lotfi Zadeh published his seminal work Fuzzy sets in the journal
Information and Control. Since that time, the subject has been the focus of many
independent research investigation by mathematicians, scientists, and engineers from
around the world. Unfortunately, perhaps because of the term’s connotations, fuzzy logic
did not receive serious notice in this country until the last decade. The attention currently
being paid to fuzzy logic is most likely the result of present popular consumer products
employing fuzzy logic. Over the last several years, the Japaness alone have field for well
over 1000 patents in fuzzy logic technology, and they have already grossed billions of
U.S dollars in the sales of fuzzy logic based products to consumers the world over.
This paper was written to provided engineers, lecturer, researcher and students
interested in fuzzy logic control systems, a systematic structure of concepts and
applications. The required mathematics for reading this paper are not beyond linear
algebra and engineering mathematics. In my paper, include case study and how to use the
fuzzy logic toolbox with MATLAB applications.
Furthermore, we hope that this paper will inspire further investigation, not only in
the area of fuzzy logic control but also in the more general area of intelligent control. For
further reading on the subject of fuzzy logic control, see the book and article cited in the
references. Of course, this paper can also be used as a self study and reference.

November 2002, Padang

Ir. Henry Nasution, M.T

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


ABSTRACTS

The fuzzy logic control system is expected to be able to reproduce the behavior of
the target system. The target system may be human operator in change of a processing
plant. Fuzzy logic control can be pursued in the following stages : select relevant input
and output variables, determine the number of linguistic terms associated with each input
and output variables, choose appropriate family of membership functions, interview
human expert who familiar with the target systems to determine the collection of fuzzy
If-Then rules and membership functions, and refine the membership functions and rules.

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


CONTENTS

PREFACE ii
ABSTACTS iii
LIST OF FIGURES v
LIST OF TABLES vi
I. INTRODUCTION 1
II. FUZZY LOGIC 5
2.1 What and Why Fuzzy Logic 5
2.2 Basics of Fuzzy Sets and Fuzzy Relation 6
2.2.1 Definition of fuzzy sets 6
2.2.2 Fuzzy set operation 8
2.2.3 Properties of fuzzy sets 8
2.2.4 Membership function 9
2.3 Linguistic Variables, Values and Rules 11
2.4 Fuzzy Logic Control 13
III. CASE STUDY 24
IV. BASICS USING MATLAB FUZZY TOOLBOX 30
4.1 The FIS Editor 31
4.2 The Membership Function Editor 33
4.3 The Rule Editor 37
4.4 The Rule Viewer 39
4.5 The Surface Viewer 41
V. CONCLUSION 43
REFERENCES 44

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


LIST OF FIGURES

2.1 Membership function for crisp and fuzzy set 7


2.2 Description of fuzzy membership function 10
2.3 The linguistic variable of temperature 12
2.4 Fuzzy control system 14
2.5 Type of membership function 15
2.6 Triangular membership function for H, N, and L 16
2.7 Rule of membership function 17
2.8 Correlation minimum inference 18
2.9 Procedure of centroid defuzzification 23
3.1 Block diagram of air conditioner temperature control system 24
3.2 Configuration of the fuzzy controller 24
3.3 Membership functions for three of the fuzzy variable 26
3.4 Value of membership which satisfied by e = -1.3 oC 28
3.5 Value of membership which satisfied by ∆e = -1.2 oC 28
3.6 Output of compressor motor 29
4.1 Fuzzy inference system 30
4.2 FIS editor 32
4.3 Membership function editor 34
4.4 The rule editor 37
4.5 Rule viewer 40
4.6 The surface viewer 42

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


LIST OF TABLES

1.1 Brief history of Fuzzy Technology 3


2.1 Fuzzy set and labels for control variable temperature 15
2.2 Fuzzy association memories (FAM) 18
3.1 Fuzzy variable being quantized into fuzzy subsets 25
3.2 Fuzzy association map 27

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


I. INTRODUCTION
Fuzzy logic was introduced by Professor Lotfi Zadeh in 1965. Not it the least
degree trying to undermine his achievements, this theory has its roots in the previous
history of science, particularly in logic science. Although logic as a branch of Western
science had been developing as binary logic, there were some famous paradoxes that
could not be solved by binary logic. These paradoxes are as follows :
1. Falakros : Pluck a hair from a man’s head and he does not suddenly become
bald. Pull out another, and a third, and a fourth, and he still is not bald. Keep
plucking and eventually the wincing man will have no hair at all on his head,
yet he is not bald.
2. The paradox of the Millet Seeds : Drop a millet seed on the ground and it
makes no sound. But why is that dropping a bushel of millet seeds make a
sound, since it contains only millet seeds. (After Zeno the Eleatic)
3. Theseus’ Ship : When Theseus returned from slaying the Minotaur, says
Plutarch, the Athenians preserved his ship, and as planks rotted, they replaced
them with new ones. When the first plank was replaced, everyone agreed it
was still the same ship. Adding a second plank made no difference either. At
some point the Athenians may have replaced every plank in the ship. Was it a
different ship ? At what point did it become one ?
4. Wang’s Paradox : If a number x is small, then x + 1 is also small. If x + 1 is
small, then x + 1 + 1 is also small. Therefore five trillion is a small number
and so is infinity. (After mathematician Hao Wang)
5. Woodger’s Paradox : An animal can belong to only one taxonomic family.
Therefore, at many points in evolution a child must have belonged to a
completely different family from its parents. But genetically, this feat is
basically impossible. (After biologist John Woodger)

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


When the concepts of fuzzy logic were first published in the U.S., they faced a lot
of critics. One example from Zadeh’s colleagues :
“ …. I would like to comment briefly on Prof. Zadeh’s presentation. His
proposals could be severely, ferociously, even brutally criticized from a
technical point of view. This would be out of place here. But a blunt
question remains : Is Zadeh presenting important ideas or is he indulging
in wishful thinking ? The most serious objection of “Fuzzification” of
system analysis is that lack of methods of system analysis is not the
principal scientific problem in the ‘system’ field. That problem is one of
developing basic concepts and deep insight into the nature of ‘system’,
perhaps trying to find something akin to the ‘laws’ of Newton. In my
opinion, Zadeh’s suggestion have no chance to contribute to the solution
of this problem ….” (R.E. Kalman, 1972).

Even today, where hundreds of successful fuzzy logic application have proved the
value of this technology, some scientists still condemn the concept, as this more recent
example shows :
“… Fuzzy logic is based on fuzzy thinking. It fails to distinguish between
the issues specifically addressed by the traditional methods of logic,
definition and statistical decision making …” (Jon Konieki in AI Expert,
1991)

Toshiro Terano (1994) pointed out that three conditions necessary for a new
theory :
• A societal need.
• A new methodology (both ideas and techniques).
• An attractiveness to researchers.
Table 1.1 describes the modern history of fuzzy logic after its invention by Zadeh.
It is incomprehensive and includes just some events but hopeful can be used for
illustration of the fuzzy logic development.

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


Table1.1 Brief history of Fuzzy Technology
1965 Concept of fuzzy sets theory by Lotfi Zadeh (USA)
1966 Fuzzy logic (P. Marinos, Bell Labs.)
1972 First working group on fuzzy systems in Japan by Toshiro Terano
Fuzzy Measure (M. Sugeno, TIT)
1973 Paper about Fuzzy algorithm by Zadeh (USA)
1974 Steam engine control by Ebrahim Mamdani (UK)
1977 First Fuzzy expert system for loan applicant evaluation by Hans
Zimmerman (Germany).
1980 Cement kiln control by F.L. Smidth & Co. - Lauritz P. Holmblad
(Denmark) – the first permanent industrial application.
Fuzzy logic chess and backgammon program – Hans Berliner (USA)
1984 Water treatment (chemical injection) control (Japan)
Subway Sendai Transportation system control (Japan)
1985 First fuzzy chip developed by Masaki Togai and Hiroyuke Watanabe
in Bell Labs (USA)
1986 Fuzzy expert system for diagnosis illnesses in Omron (Japan)
1987 Container crank control
Tunnel excavation
Soldering robot
Automated aircraft vehicle landing
Second IFSA Conference in Tokyo
Togai InfraLogic Inc. – first fuzzy company in Irvine (USA)
1988 Kiln control by Yokogawa
First dedicated fuzzy controller sold – Omron (Japan)
1989 Creation of Laboratory for International Fuzzy Engineering Research
(LIFE) in Japan
First Fuzzy Logic Air Conditioner
1990 Fuzzy TV set by Sony (Japan)
Fuzzy electronic eye by Fujitsu (Japan)
Fuzzy logic systems institute (FLSI) by Takeshi Yamakawa (Japan)
Intelligent system control laboratory in Siemens (Germany)
1991 Fuzzy AI Promotion Centre (Japan)
Educational kit by Motorola (USA)
Source : Fuzzy Controller (Leonid Reznik, 1997) and Fuzzy Logic (Marzuki,
1996)

After 1991 fuzzy technology came out of scientific laboratories and became an
industrial tool (Reznik, 1997 ; Altrock, 1995 ; Zilouchian & Jamshidi, 2001 ; Marzuki,
1996). Application of fuzzy logic are as follows :
• Automatic control of dam gates for hydroelectric power plants (Tokyo Electric
Power)

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


• Simplified control of robots (Horita, Fuji Electric,Toshiba, Omron)
• Camera-aiming for the telecast of sporting events (Omron)
• Efficient and stable control of car engines (Nissan)
• Cruise-control for automobiles (Nissan, Subaru)
• Substitution of an expert for the assessment of stock exchange activities
(Yamaichi, Hitachi)
• Optimized planning of bus timetables (Toshiba, Nippon System, Kaihan-Express)
• Archiving system for documents (Mitsubishi Elec.)
• Prediction system for early recognition of earthquakes (Seismology Bureau of
Metrology, Japan)
• Medicine technology : cancer diagnosis (Kawasaki Medical School)
• Recognition of motives in pictures with video cameras (Canon, Minolta)
• Automatic motor-control for vacuum cleaners with a recognition of a surface
condition and a degree of soiling (Matsushita)
• Back light control for camcorders (Sanyo)
In the last two decades, the fuzzy sets theory has established itself as a new
methodology for dealing with any sort of ambiguity and uncertainty. An underlying
philosophy of the theory is a mathematical framework where imprecise conceptual
phenomena in modeling and decision making may be precisely and rigorously studied. It
lets mathematical models describe rather unmodelled situation and finds solution of
unsolvable problems. The theory includes a new mathematical apparatus and computer
realizable models.
Fuzzy logic is an innovative technology that enhances conventional system design
with engineering expertise. Using fuzzy logic, you will circumvent the need for rigorous
mathematical modeling. Fudge factors in your control system will be replaced by a self
explanatory linguistic description of the control strategy (Altrock, 1995).

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


II. FUZZY LOGIC
One of the major development of fuzzy set theory, fuzzy logic was primarily
designed to represent and reason with some particular form of knowledge. It was
assumed that the knowledge would be expressed in a linguistic or verbal form,
conventional control system divide the world into yes and no (1,0), but by using fuzzy
logic, the true value are expressed by the world of natural language, e.g. true, more or
less true, rather false etc (1, 0.7, 0.5, 0.1, 0). Fuzzy logic put a scale between yes by the
side of no. Fuzzy logic translates qualitative strategy derived from human experience to a
formulation acceptable to a computer.

2.1 What and Why Fuzzy Logic


Fuzzy logic is powerful problem solving methodology with a myriad of
applications in embedded control and information processing. Fuzzy provides a
remarkably simple way to draw definite conclusions from vague, ambiguous or imprecise
information. In a sense, fuzzy logic resembles human decision making with its ability to
work from approximate data and find precise solutions.
Unlike classical logic which requires a deep understanding of a system, exact
equations, and precise numeric values, fuzzy logic incorporates an alternative way of
thinking, which allows modeling complex systems using a higher level of abstraction
originating from our knowledge and experience. Fuzzy logic allows expressing this
knowledge with subjective concepts such as very hot, bright red, and a long time which
are mapped into exact numeric ranges.
Fuzzy logic can (Marzuki, 1996) :
• Represent vague language naturally
• Enrich not replace crisp sets
• Allow flexible engineering design
• Improve model performance
• Are simple to implement
• And best of all they often work

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


Reznik (1997) reported, why fuzzy logic :
• Ability to translate imprecise/vague knowledge of human experts
• Simple, easy to implement technology
• Software design and hardware implementation support
• Results are easy to transfer from product to product
• Smooth controller behavior
• Robust controller behavior
• Ability to control unstable systems
Fuzzy logic is a paradigm for an alternative design methodology which can be
applied in developing both linear and non-linear systems for embedded control. By using
fuzzy logic, designer can realize lower development costs, superior, features, and better
end product performance.
With fuzzy logic the first step is to understand and characterize the system
behavior by using our knowledge and experience. The second step is to directly design
the control algorithm using fuzzy rules, which describe the principles of the controllers
regulation in terms of the relationship between its input and outputs. The last step is to
simulate and debug the design. If the performance is not satisfactory we only need to
modify some fuzzy rules and re-try.

2.2 Basics of Fuzzy Sets and Fuzzy Relation


2.2.1 Definition of fuzzy sets
In classical sets, or crisp sets, the transition between membership and non-
membership in a give set for an element in the universe is abrupt and well defined (said
to be “crisp”). For an element in a universe which contains fuzzy sets this transition can
be gradual. This transition among various degrees of membership can be thought of as
conforming to the fact that the boundaries of the fuzzy sets are vague and ambiguous.
Hence, membership of an element from the universe in this set is measured by a function
which attempts to describe vagueness and ambiguity.
A fuzzy set then is a set containing elements which have varying degrees of
membership in the set. This idea is contrasted with classical, or crisp, sets because
complete in that set (i.e., their membership is assigned a value of 1). Elements in a fuzzy

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


set, because their membership can be a value other than complete, can also be members
of other fuzzy sets on the same universe.
Elements of a fuzzy set are mapped to a universe of “membership values” using a
function theoretic form. Fuzzy sets are denoted by a set symbol with a tilde understrike,
so for example, A would be the “fuzzy set” A. This function maps elements of a fuzzy set
A to real numbered value on the interval 0 to 1. If an element in the universe, say x is a
member of fuzzy set A then this mapping is given as,
µA (x) ∈ [0,1]
A = (x, µA (x) | x ∈ X
These mapping are show in figure 2.1 membership function for crisp and fuzzy sets,
respectively.

A A
1 1

0 x 0 x
(a) Crisp set A (b) Fuzzy set A
Figure 2.1 Membership function for crisp and fuzzy set
A notation convention for fuzzy sets that is popular in the literature when the
universe of discourse, X, is discrete and finite, is given below for a fuzzy set A by,
µ A ( x1 ) µ A ( x2 ) µ A ( xi )
A = + + .......... = ∑
x1 x2 i xi
and, when the universe, X, is continuous and infinite, the fuzzy set A is denoted by,
µ A ( x)
A= ∫ x
In both notations, the horizontal bar is not quotient, but rather a delimiter. In both
notations, the numerator in each individual expression is the membership value in set A
associated with the element of the universe indicated in the denominator of each
expression. In the first notation, the summation symbol is not for algebraic summation,
but rather is denoting a fuzzy union, hence the “+” signs in the first notation are not

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


algebraic “add”, but rather function theoretic union. In the second notation the integral
sign is not an algebraic integral, but rather a set union notation for continuous variables.

2.2.2 Fuzzy set operation


The use of fuzzy sets provides a basis for the systematic manipulation of vague
and imprecise concepts using fuzzy set operations performed by manipulating the
membership functions. Let A and B be two point valued fuzzy sets in X with membership
functions µA and µB. For a given element x of the universe, the following function
theoretic operations for the set theoretic operation of equality, union, intersection, and
complement are defined,
• Equality : A = B iff µA (x) = µB (x) ∀x∈X
• Union : µA∪B (x) = max { µA (x) , µB (x)} ∀x∈X
• Intersection : µA∩B (x) = max { µA (x) , µB (x)} ∀x∈X
• Complement : µA’ (x) = 1 - µA (x) ∀x∈X
• Subset : A ⊆ B iff µA (x) ≤ µB (x) ∀x∈X
Some notes on the 5 fuzzy operations (Marzuki, 1996) :
• The above definitions of union, intersection and complement work equally well
for ordinary ‘crisp’ sets.
• Note that in the fuzzy case, if A and A’ complements, their intersection need not
be the empty set.
• The closer the sets are to being crisp, the closer their intersection will be to being
empty.
• Note also that if A and A’ are complements, their union is not necessarily equal to
the universe.
• The closer they are to being crisp, the closer their union will be to being the
universe.

2.2.3 Properties of fuzzy sets


Fuzzy sets follow the same properties as do crisp sets. Because of this and
because the membership values of a crisp set are a subset of the interval [0,1], classical

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


sets can be though of as a special case of fuzzy sets. Frequently used properties of fuzzy
sets are listed below.
• Commutativity :A∪B=B∪A
A∩B=B∩A
• Associativity :A∪(B∪C)=(A∪B)∪C
A ∩ ( B ∩ C ) = ( A ∩ B ) ∩C
• Distibutivity :A∪(B∩C)=(A∪B)∩(A∪C)
A∩(B∪C)=(A∩B)∪(A∩B)
• Idempotency : A ∪ A = A and A ∩ A = A
• Identity : A ∪ ∅ = A and A ∩ X = A and A ∩ ∅ = ∅
and A ∪ X = X
• Transitivity : If A ⊆ B ⊆ C, then A ⊆ C
• Involution :Ā=A

2.2.4 Membership function


Membership function characterize the fuzziness in a fuzzy set, whether the
elements in the set are discrete or continuous, in a graphical form for eventual use in the
mathematical formalism of fuzzy set theory. But the shapes used to describe the fuzziness
have very few restrictions indeed. It might be claimed that the rules used to describe
fuzziness graphically are also fuzzy. Nevertheless, as with any formal mathematical
structure, some standard terms related to the shapes of membership functions have been
developed over the years, and these terms are defined here. Since the membership
function essentially embodies all fuzziness for a particular fuzzy set, its description is the
essence of a fuzzy property or operation.
The membership functions for fuzzy sets can have many different shapes,
depending on definition. Some of the possible membership functions are shown :
• S – membership function : µA

1
0 for x < a

2 [( x − a ) /( c − a )] for a ≤ x ≤ b 0.5
S ( x ; a ,b ,c ) = 
1 − 2 [( x − c ) /( c − a )] for b ≤ x ≤ c
1 for x > c
x
a b c

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


• Phi – membership function :
µA

1
 S ( x ; c − b , c − b / 2 , c ) for x ≤ c
π ( x; b , c ) = 
1 − S ( x ; c , c + b / 2 , c + b for x ≥ c 0.5 b

c
c-b c-b/2 c+b/2 c+ b x

• Triangular membership function :


µA

0 for x < a 1
(x - a)/(b - a) for a ≤ x ≤ b

T ( x; a, b, c) = 
(c - x)/(c - b) for b ≤ x ≤ c
 0 for x > c

a b c x

• Trapezoidal membership function :


0 for x < α
µA
(x - α )/( β - α ) for α ≤ x ≤ β

Π (x; α , β , γ , δ ) = 1 for β ≤ x ≤ γ 1
(δ - x)/(δ - γ ) for γ ≤ x ≤ δ

0 for x > δ

α β γ δ x

Since all information contained in a fuzzy set is described by its membership


function, it is useful to develop a lexicon of terms to describe various special features of
this function. For purpose of simplicity, the function shown in the following figures will
all be continuous, but the terms apply equally for both discrete and continuous fuzzy sets.
Figure 2.2 assists in this description.

µ(x) Core

1 a : Boundary

0 x
a a
Support

Figure 2.2 Description of fuzzy membership function

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


The core of a membership function for some fuzzy set A is defined as that region
of the universe that is characterized by complete and full membership in the set A. That
is, the core comprises those elements x of the universe such that µA (x) = 1.
The support of a membership function for some fuzzy set A is defined as that
region of the universe that is characterized by nonzero membership in the set A. That is,
the support comprises those elements x of the universe such that µA (x) > 0.
The boundaries of a membership function for some fuzzy set A are defined as that
region of the universe containing elements that have a nonzero membership but not
complete membership. That is, the boundaries comprise those elements x of the universe
such that 0 < µA (x) < 1. These elements of the universe are those with some degree of
fuzziness, or only partial membership in the fuzzy set A. Figure 2.2 illustrates the regions
in the universe comprising the core, support, and boundaries of a typical fuzzy set.

2.3 Linguistic Variables, Values and Rules


• Linguistic Variables
To specify rules for the rule base, the expert will use a “linguistic description”,
hence, linguistic expressions are needed for the inputs and outputs and characteristics of
the inputs and outputs. We will use “linguistic variables” (constant symbolic descriptions
of what are in general time varying quantities) to describe fuzzy system inputs and
outputs. For our fuzzy system, linguistic variables denoted by ūi are used to describe the
inputs. Similarly, linguistic variables denoted by ỹi are used to describe outputs yi. For
instance, an input to the fuzzy system may be described as ū1 = ‘temperature error’ or
ū2=’derivative of temperature error’, and an output from the fuzzy system may be
ỹ1=’change of compressor motor speed’.
ū1
Fuzzy System ỹ1
ū2

• Linguistic Values
As we saw in the previous section, a linguistic variable is a variable whose
arguments are fuzzy number and more generally words represented buy fuzzy sets. For
example, the arguments of the linguistic variable temperature may be LOW, MEDIUM,

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


and HIGH . We call such arguments fuzzy values. Each and every one of them is modeled
by its own membership function. The fuzzy values LOW, MEDIUM, and HIGH may be
modeled as shown in figure 2.3, in this figure we have three discrete fuzzy values.

FUZZY VARIABLE Temperature

FUZZY VALUE LOW MEDIUM HIGH

MEMBERSHIP 1.0 0.9 0.7 0.4 0.4 0.8 1.0 0.8 0.4 0.7 0.9 1.0

UNIVERSE OF
DISCOURSE 0 12.5 25 37.5 50 62.5 75 87.5 100 T( oC)

Figure 2.3 The linguistic variable of temperature

• Linguistic Rules
The mapping of the inputs to the outputs for a fuzzy system is in part
characterized by a set of condition → action rules, or in modus ponens (If – Then) form,
If premise Then consequent.
Usually, the inputs of the fuzzy system are associated with the premise, and the outputs
are associated with consequent. These If-Then rules can be represented in many forms.
Two standard forms, multi-input multi-output (MIMO) and multi-input single-output
(MISO), are considered here. The MISO form of a linguistic rule is :
“ If temperature error is LOW and derivative of temperature error is
NEGATIVE Then change of compressor motor speed is FAST.”
A valid If-Then rule could be even though it does not follow the format of a MISO rule
given above. In this case, one premise term (linguistic variable) has been omitted from
the If-Then rule. We see that we allow for the case where the expert does not use all the
linguistic terms (and hence the fuzzy sets that characterize them) to state some rules.

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


2.4 Fuzzy Logic Control
The primary goal of control engineering is to distill and apply knowledge about
how to control a process so that the resulting control system will reliably and safely
achieve high performance operation. In this section we show how fuzzy logic provides a
methodology for representing and implementing our knowledge about best to control
process.
Why fuzzy logic control (Marzuki, 1996) :
• During the past decade, fuzzy logic control has emerged as one of the
most active and fruitful research areas in the application of fuzzy set
theory, fuzzy logic and fuzzy reasoning.
• The idea was first proposed by Mamdani and Assilian around 19972.
• Many industrial and consumer product using fuzzy logic technology
have been built, especially in Japan.
• In contrast to conventional control techniques, fuzzy logic control is
best utilized in complex ill-defined processes that can be controlled by
a skilled human operator without much knowledge of their underlying
dynamics.
• The basic idea behind fuzzy logic control is to incorporated the expert
experience of human operator in the design of a controller in
controlling a process whose input-output relationship is described by a
collection of fuzzy control rules involving linguistic variables.
• This utilization of linguistic variables, fuzzy control rules, and
approximate reasoning provides a means to incorporate human expert
experience in designing the controller.
A block diagram of fuzzy control system is shown in figure 2.4. Basically in
fuzzy control system, there are four major stages to accomplish the control process :
• Choosing fuzzy controller inputs and outputs.
• Fuzzification.
• Inference mechanism.
• Defuzzification.

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


Fuzzy Controller

Inference

Defuzzification
Reference Mechanism

Fuzzification
Input Input Process Output

Rule-base

Figure 2.4 Fuzzy control system

• Choosing fuzzy controller inputs and outputs


The objective of the first stage is to study the system where we want to place our
control system. From that, we have to identify and establish the architectural
characteristics of the systems. What is the fuzzy input and output variable to our control
system.
For more complex application, the choice of the inputs to controller and output of
the controller (inputs to the plant) can be more difficult. Essentially, you want to make
sure that the controller will have the proper information available to be able to make good
decisions and have proper control inputs to be able to steer the system in the direction
needed to be able to achieve high performance operation. Practically speaking, access to
information and the ability to effectively control the system often cost money. In some
academic problems you may be given the plant inputs and outputs, in many practical
situations you may have some flexibility in their choice. These choice affect what
information is available for making on-line decisions about the control of a process and
hence affect how we design a fuzzy controller.
Once the fuzzy controller inputs and outputs are chosen, you must determine what
the reference inputs are. After all the inputs and outputs are defined for the fuzzy
controller, we can specify the fuzzy control system.

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


• Fuzzification
Fuzzy sets are used to quantify the information in the rule base, and the inference
mechanism operators on fuzzy sets to produce fuzzy sets, hence, we must specify how
the fuzzy system will convert its numeric inputs ui ∈ Ui into fuzzy sets (a process called
fuzzification) so that they can be used by the fuzzy system.
Each input and output variable in the fuzzy model which are given unique names
called labels (Table 2.1), within the domain of the variable.
Table 2.1 Fuzzy set and labels for control variable temperature
Control Variable Fuzzy Set (Subsets) Labels
Temperature Very Hot VH
Hot HT
Less Hot LH
Normal NR
Cool CL
Cold CD
Very Cold VC

Membership function need to be assigned ( m = Z → [0,1] ) to each fuzzy subset.


There are several kind of shape or size of the membership function as shown in figure
2.5, i.e. :

(a) Triangular (b) Trapezoidal (c) Gaussian


Figure 2.5 Type of membership function
Reznik (1997) reported that, Triangular or Trapezoidal functions have proved to
be more popular with fuzzy logic theoretic and practitioners rather than higher order
based functions such as Gaussian, etc. A possible reason for this is simplicity of this
function often allowing for the prediction and calculation of an output of the fuzzy

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


system. Another reason is that the extra smoothness introduced by higher order fuzzy sets
and demanding higher computational consumption is not strongly reflected in the output
quality of a fuzzy model. However, the problem of the membership function choice has
not yet been solved theoretically. Different researchers choose numerous shapes in
various application problems.
Let say the labels for input variables H and N is {A,B,C,D,E,F,G} and {a,b,c,d,e,
f,g} respectively while the labels for output variable L is {1,2,3,4,5,6,7}. Then the
membership functions may be presented as in figure 2.6.
µH
A B C D E F G
1

µN
a b c d e f g
1

µL
1 2 3 4 5 6 7
1

Figure 2.6 Triangular membership functions for H, N and L

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


There are some rules of thumb which are helpful in defining fuzzy set (Lim, 1998
; Ong, 1999) :
• The number of labels (unique names of fuzzy subset) with variable should
generally be an odd number between 5 and 9. And the amount is very much
depends on the complexity on the control system.
• Each should overlap somewhat with its neighbors. The overlap should be between
10 % and 50 % of the neighbors space. And the sum of the vertical points of the
overlap should always be less than 1 as shown in figure 2.7.

X X+Y<1
Y

Figure 2.7 Rule of membership function


• The density of the fuzzy sets should be highest around the optimal control point of
the system and should thin out as the distance from that point increases. This rule
brings about a condition where the labels are bunched together in the middle of
the domain but are more widely spaced toward the edges.

• Inference mechanism
An inference mechanism also called an inference engine or fuzzy inference
module, which emulates the expert’s decision making in interpreting and applying
knowledge about how best to control the plant (Passino, 1998).
In the inference mechanism, rules If-Then need to be developed to control the
process. Expert’s knowledge and experience should take place home to develop the
appropriate rule in order to perform an ideal control system. The rules that have been
developed by the expert can be simply by constructing the fuzzy associative memories
(FAM), which associate fuzzy set of output fuzzy variable L with fuzzy sets of input
variables H and N.
For example, by implementing example of figure 2.6, a FAM with 7 times 7-bank
matrix has been construct as in Table 2.2.

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


Table 2.2 Fuzzy associative memories (FAM)

N
H

}
a b c d e f g
A 1 2 2 3 3 2 1
B 1 2 3 3 3 2 1
C 2 2 3 4 4 3 2
D 3 3 3 5 5 5 3 Consequents (Outputs)
E 6 5 4 4 5 6 6
F 7 6 5 5 5 6 7
G 7 6 5 5 6 6 7

H and N : Antecedents (Inputs)

After developing the FAM, the next stop is the inference engine, the objective of
the inference engine is to make a choice when there are an output variable fuzzy set with
different values. Normally, we can use the Correlation Minimum Encoding technique to
do the inferencing (Ong, 1999). The procedure or the correlation minimum encoding
technique is to choose the minimum value among all the values in a single input variable
fuzzy set, to insert the minimum value to the output variable fuzzy set as shown in figure
2. 8. The figure shows that when the membership function value of the input variable “H”
and “N” is 0.7 at membership function “C” and 0.4 at membership function “d”
respectively, the membership value of the output variable “L” will be 0.4 at membership
function “4”.
Input Fuzzy Variable Output Fuzzy Variable

µH H = C at 0.7
µN µL
N = d at 0.4 L = “4” at 0.4

H N L

Figure 2.8 Correlation minimum inference

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


• Defuzzyfication
As mentioned in the introduction, there may by situations where the output of a
fuzzy process needs to be a single scalar quantity as opposed to a fuzzy set.
Defuzzification is the conversion of a fuzzy quantity to a precise quantity, just as
fuzzification is the conversion of a precise quantity to a fuzzy quantity. The output of a
fuzzy process can be the logical union of two or more fuzzy membership function defined
on the universe of discourse of the output variable.
At least seven methods in the literature, among the many that have been proposed
by investigators in recent year, are popular for defuzzifying fuzzy output functions
(membership functions).
o Max membership principle, Also known as the height method, this scheme
is limited to peaked output function. This method is given by the algebraic
expression :
µx (z*) ≥ µx (z) for all z ∈ Z
µ
1

z* z

o Centroid method, This procedure (also called center of area, center of


gravity) is the most prevalent and physically appealing of all the
defuzzification methods, it is given by the the algebraic expression :

z* =
∫ µ ( z ).zdz
x

∫ µ ( z )dz
x

where ∫ denotes an algebraic integration.


µ
1

z* z

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


o Weighted average method, This method is only valid for symmetrical
output membership function. It is given by the algebraic expression :

z* =
∑ µ ( z ).z
x

∑ µ ( z) x

µ
1
0.9

0.5

z
a b

where Σ denotes an algebraic sum. The weighted average method is


formed by weighting each membership function in the output by its
respective maximum membership value. Since the method is limited to
symmetrical membership functions, the values “a” and “b” are the means
of their respective shapes.
o Mean-max membership, This method (also called middle-of-maxima) is
closely related to the first method, excerpt that the locations of the
maximum membership can be non unique (i.e., the maximum membership
can be a plateau rather than a single point). This method is given by the
expression :
a+b
z* =
2
µ
1

z
a z* b

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


o Center of sums, This faster than many defuzzification methods that are
presently in use. This process involves the algebraic sum of individual
output fuzzy sets, say C1 and C2, instead of their union. One drawback to
this method is that the intersecting areas are added twice. The defuzzified
value z* is given by the following equation :

∫ z∑
n
k =1
µC k ( z )dz
z =
* z

∫∑
n
k =1
µC k ( z )dz
z

C2
C1
z

z*

This method is similar to the weighted average method, except in the


center of sums method the weights are the areas of the respective
membership functions whereas in the weighted average method the
weights are individual membership values.
o Center of largest area, If the output fuzzy set has at least two convex sub-
regions, then the center of gravity (i.e., is calculated using the centroid
method) of the convex fuzzy sub-region with the largest area is used to
obtain the defuzified value z* of the output.

z* =
∫µ xm ( z ) z.dz

∫µ xm ( z )dz

where xm is the convex sub-region that has the largest area making up xk.
This condition applies in the case when the overall output xk is non
convex, and in the case when xk is convex, z* is the same quantity as

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


determined by the centroid method or the center of largest area method
(because then there is only one convex region).

µ
1

z*

o First (or last) of maxima, This method uses the overall output or union of
all individual output fuzzy sets xk to determine the smallest value of the
domain with maximized membership degree xk. The equation of for z* are
as follow.
First, the largest height in the union [denoted hgt(xk)] is determined,
hgt(xk) = sup µ Xk ( z)
z∈Z

Then the first of the maxima is found,


{
z * = inf z ∈ Z µ x k ( z ) = hgt( xk )}
z∈Z

An alternative to this method is called the last of maxima, and it is given


by,
{
z * = sup z ∈ Z µ x k ( z ) = hgt( xk )}
z ∈Z

sup : supremum (is the least upper bound), inf : infimum (is the greatest
lower bound).
µ

z*

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


Figure 2.9 shows procedure for centroid defuzzification. The figure shows that the
input variable H satisfies both membership function C and D at value 0.7 and 0.3
respectively. Whereas, input variable N only satisfies membership function “d” at value
0.4. After using correlation minimum encoding technique to do inferencing, the
membership value of output variable L are 0.4 at membership function “4” and 0.3 at
membership function “5”.

Input fuzzy variables Output fuzzy variable

µH C
µN µL
d “4”

0.7
0.4
0.4
H N L

µH D
µN µL
d “5”

0.4
0.3
0.3
H N L

µL
“4” “5”

0.4
0.3
L
Centroid

Figure 2.9 Procedure of centroid defuzzification

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


III. CASE STUDY
The following example shows how fuzzy logic technology can be developed for
an air conditioner temperature control system. The block diagram of the control system is
shown in figure 3.1.
Error Control
Signal Signal

Output
Set point + e Fuzzy ∆Z Air Temperature
Temperature Controller Conditioner
-

Sensor

Figure 3.1 Block diagram of air conditioner temperature


Control system

Error (e) Fuzzy Change of Motor Speed


Derivative of error (∆e) Controller (∆Z)

Figure 3.2 Configuration of the fuzzy controller


There are two inputs and one output to the fuzzy controller as shown in figure 3.2.
Suppose the inputs i.e., error (e) and derivative of error (∆e) ranges from –2 to 2 OC
respectively while the output, i.e., change of compressor motor speed (∆Z) ranges from
–50 to 50 rpm.
The performance measurement is as follows :
e(k) = set point(k) – y(k)
∆e(k) = e(k) – e(k – 1)
Z(k) = Z(k – 1) + ∆Z(k)
where y(k) is the actual speed at time k, and Z(k) is the manipulated output variable at
time k.
For the fuzzufication of fuzzy controller, each input and output in the fuzzy model
is quantized into fuzzy subsets. Table 3.1 shows how fuzzy variable being quantized into
fuzzy subsets and labeled.

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


Table 3.1 Fuzzy variable being quantized into fuzzy subsets.
Fuzzy Variable Fuzzy Set Linguistic Term Label
Input e Very Hot VH
Hot HT
Less Hot LH
Normal NR
Cool CL
Cold CD
Very Cold VC
∆e Positive Large PL
Positive Medium PM
Positive Small PS
Neutral NU
Negative Small NS
Negative Medium NM
Negative Large NL
Output ∆Z Very Fast VF
Fast FT
Less Fast LF
Normal NO
Less Slow LS
Slow SL
Very Slow VS

Then, membership functions need to be developed. For computational simplicity,


we use triangular membership function as shown in figure 3.3. Each universe of
discourse need to be quantified within the range of the respective variables.

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


µe

e (oC)

µ∆e

∆e (oC)

µ∆Z

∆Z (rpm)

Figure 3.3 Membership functions for three of the fuzzy variable

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


The next step is to develop fuzzy If – Then form to control the process. For
example, If error in temperature is about VC (very cold) and derivative of error is about
NL (negative large) Then the change of compressor motor speed is about VS (very
small), i.e. :
If (e = VC And ∆e = NL) Then ∆Z = VS
A 49 bank matrix as shown in table 3.2 is used for simplicity to observe the developed
fuzzy rules.
Table 3.2 Fuzzy association map
e
∆e
VC CD CL NR LH HT VH
NL VS VS SL LS FT VF VF
NM SL SL SL LS LF FT FT
NS SL LS LS LS NO LF LF
NU LS LS NO NO NO LF LF
PS LS LS NO NO LF FT FT
PM SL SL LS LF LF FT FT
PL VS VS SL LS FT VF VF

Therefore, if given :
e = -1.3 oC and ∆e = -1.2 oC
value of e = -1.3 oC satisfies two membership functions i.e. VC and CD with the value of
membership as shown in figure 3.4. Whereas, value of ∆e = -1.2 oC satisfies two
membership functions i.e. NL and NM with the value of membership as shown in figure
3.5.
(c − x) − 1 − (−1.3)
µVC = = = 0.6
(c − b) − 1 − (−1.5)
( x − a) − 1.3 − (−1.5)
µCD = = = 0.4
(b − a) − 1 − (−1.5)
(c − x) − 1 − (−1.12)
µ NL = = = 0.24
(c − b ) − 1 − (−1.5)
( x − a) − 1.12 − (−1.5)
µ NM = = = 0.76
(b − a) − 1 − (−1.5)

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


µe

0.6

0.4

e (oC)

Figure 3.4 Value of membership which satisfied by e = -1.3 oC

µ∆e

0.76

0.24

∆e (oC)

Figure 3.5 Value of membership which satisfied by ∆e = -1.2 oC


After developing the fuzzy rules, correction minimum encoding technique is used
to do inferencing. The results are summarized as below :
1. If e = VC µVC (0.6) And ∆e = NL µNL (0.24) Then ∆Z = VS µVS (0.24)
2. If e = VC µVC (0.6) And ∆e = NM µNM (0.76) Then ∆Z = SL µSL (0.6)
3. If e = CD µCD (0.4) And ∆e = NL µNL (0.24) Then ∆Z = VS µVS (0.24)
4. If e = CD µCD (0.4) And ∆e = NM µNM (0.76) Then ∆Z = SL µSL (0.4)
where,
∆Z = VS µVS (0.24)
∆Z = SL µSL (0.6)

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


Finally, the output fuzzy set is converted into a numerical solution variable using
Centroid defuzzification. Figure 3.6 shows the function of the output satisfied by the
given e and ∆e value. Therefore, the centroid is obtained as :
(−35) * 0.24 + (−20) * 0.6
∆Z = = −24.29 Rpm
0.24 + 0.6
That means compressor motor should decreases its speed to 24.29 rpm.
µ∆Z

0.6
0.4

0.24
∆Z (rpm)

Center of Gravity

Figure 3.6 Output of compressor motor

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


IV. BASICS USING MATLAB FUZZY TOOLBOX
Now we are going to work through a similar Aircond example, only we’ll be
building it using the graphical user interface (GUI) tools provided by the fuzzy logic
toolbox. Although it’s possible to use the fuzzy logic toolbox by working strictly from
the command line, in general it’s much easier to build a system graphically. There are
five primary GUI tools for building, editing, and observing fuzzy inference systems in the
fuzzy logic toolbox :
1. The fuzzy inference system (FIS Editor).
2. The membership function editor.
3. The rule editor.
4. The rule viewer.
5. Surface viewer.
These GUIs are dynamically linked, in that changes you make to the FIS using one of
them, can affect what you see on any of the other open GUIs. You can have any or all of
them open for any given system. In addition to these five primary GUIs, the toolbox
includes the graphical ANFIS Editor GUI, which is used for building and analyzing
Sugeno-type adaptive neural fuzzy inference systems.

Figure 4.1 Fuzzy inference system

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


The FIS Editor handles the high level issues for the system: How many input and
output variables? What are their names? The Fuzzy Logic Toolbox doesn’t limit the
number of inputs. However, the number of inputs may be limited by the available
memory of your machine. If the number of inputs is too large, or the number of
membership functions is too big, then it may also be difficult to analyze the FIS using the
other GUI tools. The Membership Function Editor is used to define the shapes of all the
membership functions associated with each variable. The Rule Editor is for editing the
list of rules that defines the behavior of the system. The Rule Viewer and the Surface
Viewer are used for looking at, as opposed to editing, the FIS. They are strictly read-only
tools. The Rule Viewer is a MATLAB-based display of the fuzzy inference diagram
shown at the end of the last section. Used as a diagnostic, it can show (for example)
which rules are active, or how individual membership function shapes are influencing the
results. The Surface Viewer is used to display the dependency of one of the outputs on
any one or two of the inputs—that is, it generates and plots an output surface map for the
system.

4.1 The FIS Editor


The FIS Editor displays general information about a fuzzy inference system.
There’s a simple diagram at the top that shows the names of each input variable on the
left, and those of each output variable on the right. The sample membership functions
shown in the boxes are just icons and do not depict the actual shapes of the membership
functions.
Below the diagram is the name of the system and the type of inference used. The
default, Mamdani-type inference, is what we’ve been describing so far and what we’ll
continue to use for this example. Another slightly different type of inference, called
Sugeno-type inference, is also available. Below the name of the fuzzy inference system,
on the left side of the figure 4.2 , are the pop-up menus that allow you to modify the
various pieces of the inference process. On the right side at the bottom of the figure is the
area that displays the name of either an input or output variable, its associated
membership function type, and its range. The latter two fields are specified only after the
membership functions have been. Below that region are the Help and Close buttons that

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


call up online help and close the window, respectively. At the bottom is a status line that
relays information about the system.

Figure 4.2 FIS editor


To start this system from scratch, type “ fuzzy “ at the MATLAB prompt. The
generic untitled FIS Editor opens, with one input, labeled input1, and one output, labeled
output1. For this example, we will construct a two-input, one output system, so go to the
Edit menu and select Add input. A second yellow box labeled input2 will appear. The
two inputs we will have in our example are error and deltaerror. Our one output is
Speedcompressor . We’d like to change the variable names to reflect that, though :
1. Click once on the left-hand (yellow) box marked input1 (the box will be
highlighted in red).
2. In the white edit field on the right, change input1 to error and press Return.
3. Click once on the left-hand (yellow) box marked input2 (the box will be
highlighted in red).
4. In the white edit field on the right, change input2 to deltaerror and press
Return.
5. Click once on the right-hand (blue) box marked output1.

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


6. In the white edit field on the right, change output1 to Speed compressor.
7. From the File menu select Save to workspace as ……..

8. Enter the variable name Aircond and click on OK.

You will see the diagram updated to reflect the new names of the input and output
variables. There is now a new variable in the workspace called Aircond that
contains all the information about this system. By saving to the workspace with a
new name, you also rename the entire system. Your window will look something
like this.

4.2 The Membership Function Editor


Leave the inference options in the lower left in their default positions for now.
You’ve entered all the information you need for this particular GUI. Next define the
membership functions associated with each of the variables. To do this, open the
Membership Function Editor. You can open the Membership Function Editor in one of
three ways:
• Pull down the View menu item and select Edit Membership Functions....
• Double-click on the icon for the output variable, Speedcompressor.

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


• Type mfedit at the command line.
Click on a line to select it
These menu items allow you This is the “Variable Palette” This graph field displays all and you can change any of
to save, open, or edit a fuzzy area. Click on a variable here the membership functions of its attributes, including
system using any of the five to make it current and edit its the current variable. name, type and numerical
basic GUI tools. membership function. parameters. Drag your
mouse to move or change
the shape of a selected
membership function

This edit field lets you


These next fields change the name of the
display the name current membership
and type of the function.
current variable

This edit field


This pop-up menu lets
lets you set the
you change the type of
range of the
the current membership
current variable.
function.

This edit field


lets you set the
display range of This edit field lets you
the current plot. change the numerical
parameters for the
current membership
function.

Figure 4.3 Membership function editor


The Membership Function Editor shares some features with the FIS Editor. In
fact, all of the five basic GUI tools have similar menu options, status lines, and Help and
Close buttons. The Membership Function Editor is the tool that lets you display and edit
all of the membership functions associated with all of the input and output variables for
the entire fuzzy inference system.
When you open the Membership Function Editor to work on a fuzzy inference
system that does not already exist in the workspace, there are not yet any membership
functions associated with the variables that you have just defined with the FIS Editor.
On the upper left side of the graph area in the Membership Function Editor is a
“Variable Palette” that lets you set the membership functions for a given variable. To set
up your membership functions associated with an input or an output variable for the FIS,
select an FIS variable in this region by clicking on it.
Next select the Edit pull-down menu, and choose Add MFs.... A new window
will appear, which allows you to select both the membership function type and the
number of membership functions associated with the selected variable. In the lower right

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


corner of the window are the controls that let you change the name, type, and parameters
(shape), of the membership function, once it has been selected.
The membership functions from the current variable are displayed in the main
graph. These membership functions can be manipulated in two ways. You can first use
the mouse to select a particular membership function associated with a given variable
quality, (such as VC, for the variable, error), and then drag the membership function from
side to side. This will affect the mathematical description of the quality associated with
that membership function for a given variable. The selected membership function can
also be tagged for dilation or contraction by clicking on the small square drag points on
the membership function, and then dragging the function with the mouse toward the
outside, for dilation, or toward the inside, for contraction. This will change the
parameters associated with that membership function.
Below the Variable Palette is some information about the type and name of the
current variable. There is a text field in this region that lets you change the limits of the
current variable’s range (universe of discourse) and another that lets you set the limits of
the current plot (which has no real effect on the system). The process of specifying the
input membership functions for this two input Aircond problem is as follows:

1. Select the input variable, error, by double-clicking on it. Set both the Range and
the Display Range to the vector [-2 2].
2. Select Add MFs... from the Edit menu. The window below pops open.

3. Use the pull-down tab to choose trimf for MF Type and 7 for Number of MFs.
This adds seven Triangular curves to the input variable error.
4. Click once on the curve with the leftmost hump. Change the name of the curve to
VC. To adjust the shape of the membership function, either use the mouse, as
described above, or type in a desired parameter change, and then click on the

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


membership function. The default parameter listing for this curve is [-2 –1.5
-1].
5. Name the curve with the middle hump, CD, and the curve with the rightmost
hump, CL. Reset the associated parameters if desired.
6. Select the input variable, deltaerror, by clicking on it. Set both the Range and
the Display Range to the vector [-2 2].
7. Select Add MFs... from the Edit menu and add seven trimf curves to the input
variable deltaerror.
8. Click once directly on the curve with the leftmost triangular. Change the name of
the curve to NL. To adjust the shape of the membership function, either use the
mouse, as described above, or type in a desired parameter change, and then click
on the membership function. The default parameter listing for this curve is [-2
–1.5 -1].
9. Name the curve with the rightmost triangular, delicious, and reset the
associated parameters if desired.
Next you need to create the membership functions for the output variable,
Speedcompressor. To create the output variable membership functions, use the Variable
Palette on the left, selecting the output variable, Speedcompressor. The inputs ranged
from -50 to 50. Use triangular membership function types for the output. First, set the
Range (and the Display Range) to [-50 50], to cover the output range. Initially,
membership function will have the parameters VS = [-50 -35 -20], SL = [-35 –20 –
10], LS = [-20 –10 0], NO = [-10 0 10], LF = [0 10 20], FT = [10 20 35], VF = [20 35
50]. Your system should look something like this.

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


4.3 The Rule Editor
Now that the variables have been named, and the membership functions have
appropriate shapes and names, you’re ready to write down the rules. To call up the Rule
Editor, go to the View menu and select Edit rules..., or type ruleedit at the
command line.

Figure 4.4 The rule editor


Constructing rules using the graphical Rule Editor interface is fairly self-evident.
Based on the descriptions of the input and output variables defined with the FIS Editor,
the Rule Editor allows you to construct the rule statements automatically, by clicking on
and selecting one item in each input variable box, one item in each output box, and one
connection item. Choosing none as one of the variable qualities will exclude that variable
from a given rule. Choosing not under any variable name will negate the associated
quality. Rules may be changed, deleted, or added, by clicking on the appropriate button.
The Rule Editor also has some familiar landmarks, similar to those in the FIS
Editor and the Membership Function Editor, including the menu bar and the status line.
The Format pop-up menu is available from the Options pull-down menu from the top
menu bar — this is used to set the format for the display.

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


Similarly, Language can be set from under Options as well. The Help button
will bring up a MATLAB Help window. To insert the first rule in the Rule Editor, select
the following:
• VC under the variable error
• NL under the variable deltaerror
• The radio button, and, in the Connection block
• VS, under the output variable, Speedcompressor.
The resulting rule is
1. If (error is VC) And (deltaerror is NL) Then (Speedcompressor is VS) (1)

The numbers in the parentheses represent weights that can be applied to each rule
if desired. You can specify the weights by typing in a desired number between zero and
one under the Weight setting. If you do not specify them, the weights are assumed to be
unity (1).
To change a rule, first click on the rule to be changed. Next make the desired
changes to that rule, and then click on Change rule. For example, to change the first rule
to :
1. If (error not VC) Or (deltaerror not NL) Then (Speedcompressor is not VS) (1)
click not under each variable, and then click Change rule.
The Format pop-up menu from the Options menu indicates that you’re looking
at the verbose form of the rules. Try changing it to symbolic. You will see
1. (error==VC) => (Speedcompressor=VS) (1)
2. (error==CD) => (Speedcompressor=SL) (1)
3. (error==CL) => (Speedcompressor=LS) (1)
There is not much difference in the display really, but it’s slightly more language neutral,
since it doesn’t depend on terms like “if” and “then.” If you change the format to
indexed, you’ll see an extremely compressed version of the rules that has squeezed all the
language out.
1, 1 (1) : 1
2, 2 (1) : 1
3, 3 (1) : 1

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


This is the version that the machine deals with. The first column in this structure
corresponds to the input variable, the second column corresponds to the output variable,
the third column displays the weight applied to each rule, and the fourth column is
shorthand that indicates whether this is an OR (2) rule or an AND (1) rule. The numbers
in the first two columns refer to the index number of the membership function. A literal
interpretation of rule 1 is: “if input 1 is MF1 (the first membership function associated
with input 1) then output 1 should be MF1 (the first membership function associated with
output 1) with the weight 1.” Since there is only one input for this system, the AND
connective implied by the 1 in the last column is of no consequence.
The symbolic format doesn’t bother with the terms, if, then, and so on. The
indexed format doesn’t even bother with the names of your variables. Obviously the
functionality of your system doesn’t depend on how well you have named your variables
and membership functions. The whole point of naming variables descriptively is, as
always, making the system easier for you to interpret. Thus, unless you have some special
purpose in mind, it will probably be easier for you to stick with the verbose format.
At this point, the fuzzy inference system has been completely defined, in that the
variables, membership functions, and the rules necessary to calculate tips are in place. It
would be nice, at this point, to look at a fuzzy inference diagram like the one presented at
the end of the previous section and verify that everything is behaving the way we think it
should. This is exactly the purpose of the Rule Viewer, the next of the GUI tools we’ll
look at. From the View menu, select View rules....

4.4 The Rule Viewer


The Rule Viewer displays a roadmap of the whole fuzzy inference process. It’s
based on the fuzzy inference diagram described in the previous section. You see a single
figure 4.5, window with 10 small plots nested in it. The three small plots across the top of
the figure represent the antecedent and consequent of the first rule. Each rule is a row of
plots, and each column is a variable. The first two columns of plots (the six yellow plots)
show the membership functions referenced by the antecedent, or the if-part of each rule.
The third column of plots (the three blue plots) shows the membership functions
referenced by the consequent, or the then-part of each rule. If you click once on a rule

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


number, the corresponding rule will be displayed at the bottom of the figure. Notice that
under deltaerror, there is a plot which is blank. This corresponds to the characterization
of none for the variable deltaerror in the second rule. The fourth plot in the third column
of plots represents the aggregate weighted decision for the given inference system. This
decision will depend on the input values for the system.

Figure 4.5 Rule viewer


There are also the now familiar items like the status line and the menu bar. In the
lower right there is a text field into which you can enter specific input values. For the
two-input system, you will enter an input vector, [-1.3 –1.2], for example, and then
click on input. This will move the red index line horizontally, to the point where you
have clicked. You can also just click and drag this line in order to change the input
values. When you release the line, (or after manually specifying the input), a new
calculation is performed, and you can see the whole fuzzy inference process take place.
Where the index line representing service crosses the membership function line “error is
VC” in the upper left plot will determine the degree to which rule one is activated. A
yellow patch of color under the actual membership function curve is used to make the
fuzzy membership value visually apparent. Each of the characterizations of each of the
variables is specified with respect to the input index line in this manner. If we follow rule

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


1 across the top of the diagram, we can see the consequent “Speedcompressor is VS” has
been truncated to exactly the same degree as the (composite) antecedent—this is the
implication process in action. The aggregation occurs down the third column, and the
resultant aggregate plot is shown in the single plot to be found in the lower right corner of
the plot field. The defuzzified output value is shown by the thick line passing through the
aggregate fuzzy set.
The Rule Viewer allows you to interpret the entire fuzzy inference process at
once. The Rule Viewer also shows how the shape of certain membership functions
influences the overall result. Since it plots every part of every rule, it can become
unwieldy for particularly large systems, but, for a relatively small number of inputs and
outputs, it performs well (depending on how much screen space you devote to it) with up
to 30 rules and as many as 6 or 7 variables.
The Rule Viewer shows one calculation at a time and in great detail. In this sense,
it presents a sort of micro view of the fuzzy inference system. If you want to see the
entire output surface of your system, that is, the entire span of the output set based on the
entire span of the input set, you need to open up the Surface Viewer. This is the last of
our five basic GUI tools in the Fuzzy Logic Toolbox, and you open it by selecting View
surface... from the View menu.

4.5 The Surface Viewer


Upon opening the Surface Viewer, we are presented with a two-dimensional
curve that represents the mapping from service quality to Aircond amount. Since this is a
one-input one-output case, we can see the entire mapping in one plot. Two-input one-
output systems also work well, as they generate three-dimensional plots that MATLAB
can adeptly manage. When we move beyond three dimensions overall, we start to
encounter trouble displaying the results. Accordingly, the Surface Viewer is equipped
with pop-up menus that let you select any two inputs and any one output for plotting. Just
below the pop-up menus are two text input fields that let you determine how many x-axis
and y-axis grid lines you want to include. This allows you to keep the calculation time
reasonable for complex problems. Pushing the Evaluate button initiates the calculation,
and the plot comes up soon after the calculation is complete. To change the x-axis or y-

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


axis grid after the surface is in view, simply change the appropriate text field, and click
on either X-grids or Y-grids, according to which text field you changed, to redraw the
plot.

Figure 4.6 The surface viewer

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


V. CONCLUSION
In this chapter we have provided an “Introduction” to direct fuzzy logic control.
In our introduction we provided a step by step overview of the operation of the fuzzy
logic control. We provided an Air conditioner temperature control system problem for
which we discussed several basic issues in the design of fuzzy controllers. Moreover, we
discussed basics using matlab fuzzy toolbox. Our introduction is designed to provide the
reader with an intuitive understanding of mechanics of the operation of the fuzzy logic
control.
Our mathematical characterization served to show how the fuzzy logic control can
handle more inputs and outputs, the range of possibilities for the definition on universes
of discourse, the membership functions, the rules, the inference mechanism, and
defuzzification methods.
The design example for the air conditioner temperature control system problem is
meant to be an introduction to basic design methods for fuzzy logic control. The section
on coding is meant to help the reader bridge the gap between theory and application so
that you can quickly get a fuzzy logic control implemented.

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


References
Altrock, Constantin Von (1995). “Fuzzy Logic & NeuroFuzzy Applications Explained.”
New Jersey : Prentice Hall.
Bojadziev, George and Bojadziev, Maria (1998). “Fuzzy Sets, Fuzzy Logic,
Applications.” Singapore : World Scientific.
Carvajal, J., Chen, Guanrong and Ogmen, Haluk (2000). “ Fuzzy PID Controller : Design
Performance Evaluation, and Stability Analysis.” Information Sciences. 123. 249-
270.
Henry Nasution (2002). Fuzzy Logic for Air Conditioner, of a Report by the Faculty of
Mechanical Engineering Universiti Teknologi Malaysia.
Huang, S. and Nelson, R. M. (1991). “ A PID Law Combining Fuzzy Controller for
HVAC Applications.” ASHRAE Transactions 97. 2. 768-774.
_______________________ (1994). “ Rule Development and Adjustment Strategies of A
Fuzzy Logic Controller for an HVAC System : Part One – Analysis.” ASHRAE
Transactions 100. 1. 841-850.
_______________________ (1994). “ Rule Development and Adjustment Strategies of A
Fuzzy Logic Controller for an HVAC System : Part Two – Experiment.” ASHRAE
Transactions 100. 1. 851-856.
Jamshidi, Mohammad, Vadiee, Nader and Ross, Timothy J. (1993). “Fuzzy Logic and
Control.” New Jersey : Prentice Hall.
Klir, George J., and Bo, Yuan (1996). “ Fuzzy Sets, Fuzzy Logic, And Fuzzy Systems.”
Singapore : World Scientific.
Lim, Huey Yi (1998). “ On-Line Fuzzy Control for Motor Control.” Universiti Teknologi
Malaysia : Degree Thesis.
Li-Xin, Wang (1997). “ A Course in Fuzzy Systems and Control.” United State of
America : Prentice Hall.
Masjuki Khalid (1996). “ A Hand On Fuzzy Logic.” Universiti Teknologi Malaysia.
Ong, Song Ping (1999). “On Line Fuzzy Logic Control.” Universiti Teknologi Malaysia :
Degree Thesis.
Passino, Kevin M., and Yurkovich, Stephen (1998). “Fuzzy Control.” California :
Addison Wesley.
Reznik, Leonid (1997). “Fuzzy Controller.” Oxford : Newnes.
Ross, Timothy J. (1997). “ Fuzzy Logic With Engineering Applications.” Singapore :
McGraw Hill.
The Math Works (2001). “Fuzzy Logic Toolbox for Use With Matlab.”
Tsoukalas, Lefteri H., and Uhrig, Robert E. (1997). “Fuzzy and Neural Approach In
Engineering.” United States of America : John Wiley & Sons.
Yen, John., Langari, Reza., and Zadeh, Lotfi A. (1995). “ Industrial Applications of
Fuzzy Logic and Intelligent Systems.” In. Mohammad Jamshidi. “ On Fuzzy Control
of Nonchlorofluorocarbon Air Conditioning Systems.” New York : IEEE Press.
Zi-Xing, Cai (1997). “ Intelligent Control : Principles, Techniques and Applications.”
Singapore : World Scientific.

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.


Zilouchian, Ali and Mo Jamshidi (Ed.) (2001).” Intelligent Control Systems Using Soft
Computing Methodologies.” In . Talebi – Daryani, Reza. “ Application of Fuzzy
Logic for Control of Heating, Chilling, and Air Conditioning Systems.” Boca Raton,
Florida : CRC Press.

Mechanical Engineering Faculty of Industrial Technology, Bung Hatta University : 2002.

También podría gustarte