Genetic Algorithms and Fuzzy Control 2003
Genetic Algorithms and Fuzzy Control 2003
Abstract
A way to automatically generate fuzzy controllers (FCs) that are optimized according to a merit figure is presented in this
article. To achieve this task, a procedure based on hierarchical genetic algorithms (HGA) was developed. This procedure and the
manner in which fuzzy controllers are codified into chromosomes is described. Resorting to this tool, several fuzzy controllers
were constructed. The best three solutions obtained during simulation were selected for testing using an experimental prototype,
which consists of an induction motor of variable load. These preliminary results are also included in the report. Based on these
results, it is concluded that hierarchical genetic algorithms, though not the only, is a suitable artificial intelligence technique to
face the problem of setting a fuzzy controller in a control loop without previous experience in controlling the plant. This is of
help in many situations at industrial environments.
# 2003 Elsevier B.V. All rights reserved.
Keywords: Fuzzy control; Genetic algorithms; Auto tuning fuzzy controller; Process control
0166-3615/$ – see front matter # 2003 Elsevier B.V. All rights reserved.
doi:10.1016/S0166-3615(03)00102-7
184 G. Acosta, E. Todorovich / Computers in Industry 52 (2003) 183–195
evolutionary algorithms (EA). EA are stochastic algo- A fitness function, including the control objectives
rithms where an objective function (called fitness) is for the plant under control. In order to build this
optimised. The inputs to such function are the solu- function it is necessary an approximate linear model
tions to the problem (called chromosome). GA operate of the plant to run simulations in an efficient way.
over a set of chromosomes (called population) where Thus, the obtained FC will be one optimum as
some recombination operators (such as crossing and regards as a predefined merit figure reflected in
mutation) are applied in an iterative way obtaining this fitness function.
new individuals (called generations) until an end
In the next section, a brief introduction on how the
criteria is fulfilled. This criterion may be a stop
structure of the FC is codified as a chromosome using
condition or finding a ‘‘good enough’’ individual.
HGA, is given. The experimental prototype used to
Then, the automatic generation of a FC optimising
test the generated FC is presented in Section 3. This
a merit figure may also be seen as a potential field of
prototype was selected because of its relevance to the
application of GA. Multiple approaches can be found
majority of industrial processes [13]. Some considera-
in this sense [6–9]. In [10], a hierarchical genetic
tions for the automatic generation of FC are discussed
algorithm (HGA) is used, where the genetic structure
in Section 4. Experimental results of these tests as well
of the chromosome is hierarchically organised. In
as some conclusions complete this article.
effect, the chromosome consists of parametric genes
and control genes. The activation of the parametric
genes is governed by the control genes value, yielding
2. Codifying the FC as a chromosome
more information than in conventional GA codifica-
tion and allowing the algorithm to explore a wider
2.1. The chromosome
space to obtain better solutions. A HGA may be
considered as a mechanism to self-adapt [11] the
As a first example to understand the hierarchical
chromosome representation. A first development in
codification of chromosomes, we considered a chro-
this sense [12] showed the feasibility of HGA
mosome formed by six control binary genes and six
approach to face the problem of building the FC.
parametric integer genes, as depicted in Fig. 1. The
A procedure for obtaining a FC using HGA without
first binary control gene determines the existence or
main prior knowledge on the plant is presented in this
not of the first parametric gene in the phenotype, and
article. As described later, the necessary specifications
so on with the rest of genes. The length of Xa and Xb
for this task are:
are, respectively, 4 and 3 for the example of Fig. 1.
The maximum number of membership functions This means that there may exists phenotypes of dif-
admitted in the inputs and in the outputs of the FC. ferent length within the same chromosome formula-
The resulting number of MF in the final FC is tion. As stated, the HGA not only explores the
normally lower than this maximum specification. parameters space but it also allows a subset of para-
The support of the linguistic variables representing meters to be considered. In the case of the FC, this
inputs and outputs, that is the range of the FCs input feature allows for the possibility of reducing the
and output variables. Like in any control problem, number of rules and membership functions, and con-
the range of involved variables must be known sequently, the necessary hardware and software
beforehand. resources for its implementation.
Descriptions of
Control Parameters
110101 351847 → Xa = (3, 5, 8, 7)
A change in the control genes affects the lower triplet characterising the mgk membership functions of
genes in the hierarchy when the genotype is being the kth fuzzy subset of the manipulated variable DU.
evaluated and decodificated. This is the reason why In Fig. 2, the codification done with Eq. (1) is
the HGA may reach a minimum system topology. illustrated, and a full example on how the FC is coded,
The FC used for this work has the structure proposed also with its corresponding fis file format is given in
in [14]. It has the error (E) and its derivative (DE) as Appendix A.
inputs, and its output is the manipulated variable (DU). The chromosome part corresponding to the rules of
For codifying such a controller, the parametric genes of the FC has the form of Eq. (2).
a chromosome comprises a part for representing the 8 9
< r11 ; r12 ; L; r1m =
membership functions and another part for representing
ZR ¼ L (2)
the rules. In Fig. 2, this codification is showed. A ‘1’ in a : ;
rn1 ; rn2 ; L; rnm
control gene activate the corresponding MF. Each MF is
a triangular function codified by three floating point This is a matrix of n m where each rij is an integer
numbers bounded by the user specified range. belonging to [1, p]; i and j belongs to [1, n], [1, m],
The chromosome part corresponding to the mem- respectively, and rij represents the fuzzy logic rule:
bership functions has the form of Eq. (1). if E is Ei and DE is DEj, then DU is Urij
8 9
>
< a1a ðEÞ; a1b ðEÞ; a1c ðEÞ; L; ama ðEÞ; amb ðEÞ; amc ðEÞ; >
=
ZM ¼ b1a ðDEÞ; b1b ðDEÞ; b1c ðDEÞ; L; bna ðDEÞ; bnb ðDEÞ; bnc ðDEÞ; (1)
>
: >
;
g1a ðDUÞ; g1b ðDUÞ; g1c ðDUÞ; L; gpa ðDUÞ; gpb ðDUÞ; gpmc ðDUÞ
where a, b and g are real numbers, bounded to the user Thus, the complete structure of the chromosome has
specified interval [amin, amax], [bmin, bmax] and [gmin, binary control genes represented in ZC, 0 for inactive
gmax], respectively. m, n and p are the upper bound of the MFs and 1 for active MFs; and parametric genes
acceptable fuzzy subsets of the error E, the error representing membership functions in ZM and rules
derivative DE and the manipulated variable variation ZR, as shown in Fig. 3.
DU. aia(E), aib(E), aic(E) a triplet characterising the mai
membership functions of the ith fuzzy subset of the 2.2. The genetic operators
error E. bja(DE), bjb(DE), bjc(DE) a triplet characteris-
ing the mbj membership functions of the jth fuzzy subset Several genetic operators were implemented and
of the error derivative DE. gka(DU), gkb(DU), gkc(DU) a tested in this work. The selection is done from the
186 G. Acosta, E. Todorovich / Computers in Industry 52 (2003) 183–195
1 ... 1 ... 1 ... α1a(E)α1b(E)α1c(E) ... β1a(∆E)β1b(∆E)β1c(∆E) ... γpa(∆U)γpb(∆U)γ pc(∆U) r11 … r1n … rmn
individual fitness in such a way that the better ones have where r is a random number in [0, 1], T is the
a greater probability to be selected, but avoiding an maximum number of generations, and b is a parameter
early convergence. In early convergence, the genetic that determines the non-uniformity degree. Six is the
diversity is slow: a mature enough population have not value used in this work. As the described operation is
evolved because the better young solutions were over applied several times to the MF parameters it is called
selected limiting the introduction of good characteris- multiple.
tics of not so good solutions, finally resulting at last sub- Other used operators are vastly explained in the
optimal solutions. Multiple genetic operators were literature [15].
tested for each part of the chromosome in this work.
A simple crossing was applied separately to the control
genes ZC and to rules ZR, while several crossing opera- 3. The laboratory prototype
tors (simple, heuristic, and arithmetic) were tested for
the membership functions part of the chromosome ZM. 3.1. Evaluation plant
For control genes, a bit mutation is applied, while a
delta shift is used for rules, resorting to the expression The evaluation plant of Fig. 4 consists of an ac
(3), where d has the same probability of being 1 or 1, motor of 1/4 HP, 3 220 V, 50 Hz, a dc generator
while rij is maintained between 1 and p. (dynamo) with separate exciting circuit with inter-
changeable resistors to emulate different loads. The
rij ¼ rij þ d (3)
induction-motor is actuated through a speed variator
For MF, uniform and non-uniform, multiple mutations Telemecanique1 ATV16, which allows feeding the
were employed and results will be presented in Sec- motor with pulse-width modulation (PWM) in three
tion 5. For non-uniform mutation, if the gene xk of the phases. It was set to 100 Hz corresponding to a
chromosome X is selected, the mutated chromosome synchronic speed of 3000 rpm. For the acceleration,
X 0 ¼ ðx1 ; . . . ; xk0 ; . . . ; xq Þ is obtained according the a minimum value (a frequency ramp generation of
Eq. (4): 0.1 s) was selected in the ATV16. This variator has a
Being t the generation number, the function D(t, y) voltage input which ranges from 0 to 10 volts, and the
returns a value in [0, y] so that the probability that mentioned PWM output, proportional to this input. The
D(t, y) is close to cero grows as t increases. This interaction between the PC and the ATV16 is done
behaviour makes the operator to search uniformly at through a D/A converter in the PC (a 12 bits PCL711B
the beginning of the evolutionary process, when t is low, of Advantech1 board), and power electronics devel-
and locally in the solutions space when the population is oped at our Lab. To measure the rotor speed, an induc-
mature. The function used in this work is: tive (position) sensor, generating pulses, were used,
t b with a transmitter in 4–20 mA. With the appropriate
Dðt; yÞ ¼ y r 1 (5) interface, it was connected to the same A/D converter
T
G. Acosta, E. Todorovich / Computers in Industry 52 (2003) 183–195 187
board in the PC. The PC is a 486 running Windows and Mutate support the genetic operators mentioned
3.11. The control algorithms were developed to run in in a previous section, and Evaluate computes the fitness
Matlab1, using the Fuzzy Logic Toolbox (FLT) facil- of individuals.
ities [16].
The whole system of Fig. 4 may be modelled by the 4.2. Writing the fitness function
recursive (linear) Eq. (6), relating voltage as input and
rotor speed as output. The design of the fitness function is a core question
for the successful running of any EA, so it deserves
nk ¼ 0:7061nk1 0:1755nk2 þ 0:2939uk2 some special comments. The fitness function must be
þ 0:1633uk3 (6) such that it distinguish among distinct individuals in a
population and more over, it must encourages fit indi-
vidual members of the population (according the fea-
4. The generation of a FC tures to improve) to combine with each other to produce
new (and hopefully better) individuals. But prior to
4.1. Developing environment evaluate the chromosome fitness, the corresponding
phenotype must be obtained. In many cases, a direct
A development environment (named FuzGen) for decodification of it may yield invalid FC. The observed
the construction of the FC was programmed in problems were:
Matlab1. The main functions of it comprises: Initi-
alize, Select, Cross, Mutate, and Evaluate. Each of the number of active membership functions for a
them was programmed modularly as a separate *.m variable is lower than two;
archive to facilitate debugging and future upgrades. there exists uncovered zones for the universes
For instance, Initialize set the initial population to of discourse of inputs and/or outputs: this problem
work with; Select selects the next population to is solved interchanging the last point of the pre-
work with employing three user defined methods vious triangular MF with the first point of the next
(tournament, ranking, and roulette rolling); Cross MF;
188 G. Acosta, E. Todorovich / Computers in Industry 52 (2003) 183–195
Table 3 Table 4
Fixed settings for FCB experiments Variable settings for FCB experiments
No. of generations 300 Test Selection type Selection MF part Rules part
Type of MF for E trimf no. parameter crossing type mutation type
Maximum allowed no. of MF for E 5
Range for E [3000, 3000] 1 Roulette rolling – Simple Uniforme
Type of MF for DE trimf 2 Roulette rolling – Heuristic Uniforme
Maximum allowed no. of MF for DE 5 3 Roulette rolling – Arithmetic Uniforme
Range for DE [1000, 1000] 4 Ranking 0.2 Simple Uniforme
Type of MF for DU trimf 5 Ranking 0.2 Simple Limit
Maximum allowed no. of MF for DU 7 6 Ranking 0.2 Heuristic Uniforme
Range for DU [1000, 1000] 7 Ranking 0.2 Heuristic Limit
Population size 70 8 Ranking 0.2 Arithmetic Uniforme
Model Elitist 9 Ranking 0.2 Arithmetic Limit
Control part crossing type Simple 10 Roulette rolling 20 Simple Uniforme
Rule part crossing type Simple 11 Roulette rolling 20 Simple Limit
Crossing probability 0.8 12 Roulette rolling 20 Heuristic Uniforme
Control part mutation type Uniform 13 Roulette rolling 20 Heuristic Limit
MF part mutation type Uniform 14 Roulette rolling 20 Arithmetic Uniforme
Mutation probability 0.07 15 Roulette rolling 20 Arithmetic Limit
Table 5
Summary of obtained FCs behaviour from the standpoint of the control system
2000
2000
1500
1500
1000
1000
500 500
0 0
0 50 100 150 200 250 300 0 50 100 150 200 250 300
(a) Time nxT, with T=0.2 sec. (b) Time nxT, with T=0.2 sec.
2000
1500
1000
500
0
0 50 100 150 200 250 300
(c) Time nxT, with T=0.2 sec.
Fig. 6. Step response for FCA7 (a); FCB2 (b); FCB15 (c).
G. Acosta, E. Todorovich / Computers in Industry 52 (2003) 183–195 191
CPU processor speed to be comparable. Besides, in section, the results following this working methodol-
FCB types the simulation time remains constant and ogy are shown.
equal to 40 s (200 iterations).
The proposed process to construct the fuzzy con- 5.1. Fuzzy controllers of type A
troller is then very simple. Some parameters must be
defined beforehand (those of Tables 1 and 2 or Tables 3 Fifteen simulations were done fixing the parameters
and 4, for FuzGen), and a simple linear approximate of Table 1 and varying the parameters of Table 2.
model of the plant to control must be given. Allowing
an adequate number of generations for the FC to 5.2. Fuzzy controllers of type B
evolve, the final controller is obtained. In the next
Other 15 simulations were done fixing the para-
meters of Table 3 and varying the parameters of
Table 6
Summary of obtained FCs behaviour from the standpoint of the Table 4.
evolving algorithm The final FC behaviours are summarized in Table 5,
while the analysis of its evolution is presented in
Controller Execution No. of Average Deviation
type time (pu) changes
Table 6.
There were three FC selected as the best controllers
FCB1 471.54 4 D I according to results stated in Tables 5 and 6. They
FCB2 470.83 5 O O
FCB3 478.19 2 O O
were FCA7, FCB2 and FCB15. They were tested in
FCB4 360.41 8 O O the prototype introduced in Section 3 (refer to Fig. 5).
FCB5 308.22 2 O O In Fig. 6, the step response of each controller is
FCB6 313.81 5 O O depicted.
FCB7 316.05 10 O O Some discrepancies may be found among results in
FCB8 348.91 8 O O
FCB9 387.7416 8 O O
Table 5 and features of temporal response of Fig. 6.
FCB10 324.6445 14 O O For example, FCB2 is reported to have an overshoot of
FCB11 408.8284 6 O O 19.31% and in Fig. 6(b) appears with no overshoot.
FCB12 286.2208 7 O O The reason is that Table 5 reports results from simula-
FCB13 314.8562 17 I O tion using Eq. (6) that is a linear model of the plant,
FCB14 344.1466 18 O O
FCB15 434.6806 6 O O
which is not the case of the real prototype of Fig. 5.
FCA1 363.0859 1 D I However, the better individuals in simulation per-
FCA2 351.3225 6 D I formed better also experimentally.
FCA3 362.6682 1 D I
FCA4 231.6473 12 D I
FCA5 273.6427 12 D I
FCA6 296.6589 14 D I
6. Conclusions
FCA7 321.6937 7 D I
FCA8 281.5081 3 D I A step by step process for the construction of a
FCA9 268.0511 7 D I fuzzy controller for industrial applications, was devel-
FCA10 335.7077 4 D I oped with FuzGen, a Matlab based software. The
FCA11 239.8376 11 D I
FCA12 321.0905 8 D I
results of obtaining several FC for a particular plant,
FCA13 310.4872 9 D I an induction motor, are presented in this article. The
FCA14 294.7796 3 D I best FC generated were tested over an experimental
FCA15 252.9699 11 D I prototype and performed well enough. However, in
Execution time: total amount of time consumed by the process of order to develop a useful tool for practical applica-
generating the FC, measured in pattern units (pu). Number of tions, FuzGen’s interface must be done friendly. Some
changes: the times that the fitness of the better individual changes of its parameters (i.e. Tables 1 and 2) might be set
during the execution. Average: the behaviour of the fitness average
during all generations of individuals (O: oscillate; I: increase; D:
beforehand. This selection is still a laboratory work.
decrease). Deviation: the behaviour of the fitness deviation during all Also to gain generality, this first version must be
generations of individuals (O: oscillate; I: increase; D: decrease). verified with other kind of processes, which lend
192 G. Acosta, E. Todorovich / Computers in Industry 52 (2003) 183–195
themselves to being linearly modelled, such as tem- different operation points of (non-linear) processes,
perature or pressure processes. Both of these, simpli- and degrades gracefully for every unforeseen situa-
fication of interface and tests over other processes are tion, which is not the case using conventional control
the current working lines. methods. Then, why it is not (yet) as popular as PID
Analyzing the obtained FC, some hints related to control? Perhaps because the programming and set-
knowledge system development arises. One of them tings of a fuzzy controller seem to be very complex for
was the rule consistency. An algorithm is yet to be the user at industrial environments. This work is an
designed in order to suppress from the knowledge attempt to simplify this task and may help when the
base the emergence of contradictory rules. Another user has a poor knowledge about the plant under
problem was the existence, for some FC generated, control.
of regions of the input or output variables that were Finally, it should be said that evolutionary algo-
not covered by any fuzzy set. In the present approach rithms are not the only way to adapt a fuzzy controller
this was overcome heuristically interchanging the according to a predefined merit figure. Nor even has
end/init points of adjacent but disjoint membership there been a demonstration to state they are the best
functions. approach for this problem. In this work, it is only
The core question a reader from the control area shown that they may be a useful artificial intelligence
may be asking is why using these approaches for a technique for this concrete application.
motor control if a simple PID or state vector feedback
is more than enough to achieve a good control. This is
the eternal tension between classical and fuzzy Acknowledgements
approaches, not only in control, for which there is
a great deal of literature [17], and beyond the scope Authors are grateful to students C. Natal and C.
of this paper. The attractive feature of fuzzy control Requena for their programming support and helpful
for industrial applications is that it works well for assistance during the experimental tests.
G. Acosta, E. Todorovich / Computers in Industry 52 (2003) 183–195 193
Appendix A
The example is a codified FC used in this work, with a maximum of 5, 5 and 7 MF for E, DE and DU; and values
in [3000, 3000], [1000, 1000] and [1000, 1000], respectively. The first three lines are the control genes for the
5, 5 and 7 MFs of E, DE and DU, respectively. The next 17 lines are the triple floating point numbers specifying the
triangular MFs. The last 25 unsigned numbers specify the rules.
194 G. Acosta, E. Todorovich / Computers in Industry 52 (2003) 183–195
The following specification corresponds with the previous coded FC in the fis format readable by the fuzzy logic
toolbox of Matlab. Observe that only four of the five MF of E, and five of the seven MF of DU are enabled. Also, 20
rules are defined because four of the five MF of E are enabled.
G. Acosta, E. Todorovich / Computers in Industry 52 (2003) 183–195 195