Artigo MESA - Paper

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Nonlinear Studies - www. nonlinearstudies.

com
MESA - www.journalmesa.com

Preprint submitted to Nonlinear Studies / MESA

Comparison between genetic algorithm and differential


evolution tuning a fuzzy controller / MESA
Lenon Diniz Seixas 1? Fernanda Cristina Correa 1

1 Universidade Tecnológica Federal do Parana

? Corresponding Author: lenon.dseixas@gmail.com

Abstract. This work brings a performance comparison in between genetic algorithm (GA) and differ-
ential evolution (DE) in tuning the parameters of a Fuzzy controller applied to an armature-controlled
DC motor. Both heuristics are consolidated, being GA the most popular in tuning fuzzy parameters.
To make the comparison, the results found after 10 iterations are presented, as well as the box plots
obtained from the collected data. The methodologies presented satisfactory answers, showing punc-
tual differences between one and the other for the presented problem: the AG depends more on an
assertive initial population, while the ED does not, managing to do better local searches.

1 Introduction

In industrial control systems, the use of PID (Proportional Integral Derivative) controllers is very
common, due to the ease of implementation, maintenance and low cost, however, it is always wanted
greater robustness and better response time. The fuzzy logic comes with the intention of allowing
non-quantifiable states to also be evaluated by control devices, with the possibility of interpreting
ambiguous and inaccurate expressions, and being able to relate a specialist’s human knowledge to the
reactions of a machine through a set of rules [1]. These sets of rules, based on if-then conditionals,
are difficult to be perfectly empirically examined in more complex systems. To deal with this, it is
proposed to tune the fuzzy parameters using evolutionary metaheuristics. Meta-heuristics are com-
putational intelligence methods that search for optimum using populations and concepts inspired by
nature, such as the genetic algorithm (GA).
Charles Darwin (1859) published ”The Origin of Species”, stating that more adapted individuals
are more likely to survive and thus perpetuate their genes. These concepts were the basis for Holland
(1975) to shape the GA [2, 3]. In other words, by means of an initial population, a selected generation
of new individual children – obtained through crossover –, and using mutations for greater variety,
the algorithm searches for the optimum.
2010 Mathematics Subject Classification
Keywords: fuzzy; genetic algorithm; differential evolution.
2 L. D. Seixas and F. C. Correa

Another method, presented in this work, is the differential evolution (ED), presented by Storn and
Price (1995) [4]. It works similarly to the genetic algorithm, using iterative processes in which a pop-
ulation of individuals (solutions) seeks the optimum, however the main operator is not the crossover
but the mutation [5].
Thus, the objective of this work is the optimization of a closed-loop Fuzzy controller applied to
an armature-controlled DC motor.

2 Methods

To control the speed of a DC motor, it is possible to act on the voltage applied in the armature
circuit, as the model shown in figure 1. The circuit relates in series the voltage applied to the armature
(Va ), armature resistance (Ra ) and armature inductance (La ) to the motor, which, to develop speed,
undergoes an electric torque (Te ), which must overcome the moment of inertia of the motor and the
load (J) on a surface with coefficient friction B.

Fig. 1 DC motor model

From the mathematical modeling of this system, equation 2.1 is obtained.

1
G(s) =   (2.1)
La J 2 La B Ra J Ra B
s + + s+ + Kv
Kt Kt Kt Kt
in which:
La is the inductance of the armature (H);
Ra is the reinforcement strength (Ω);
Kt is the torque constant (Nm/A);
Kv is the voltage constant (V /rad/s);
J is the moment of inertia of the motor and load (kgm2 );
B is the viscous friction coefficient (kgm2 /s).
Using the MATLAB Simulink tool and the system blocks, the closed-loop control system, shown
in figure 2, was built. The Fuzzy controller was tuned to meet an input step of amplitude 8 rps, or 480
rpm, controlling the DC motor through the armature voltage Va .
For the implementation of the Fuzzy controller, the variables that determine the membership func-
tions and the inference rules were defined. The first set, of 9 parameters to be optimized, are those
that form triangular functions that quantify fuzzy values for each type of input or output. In table 1, it
is possible to visualize each type of input and output and their respective pertinence functions.
Comparison between genetic algorithm. . . 3

Fig. 2 Block diagram

Table 1 Membership functions


Inputs Membership functions
Error Negative, Little Negative, Zero, Little Positive, Positive
Error derivative Negative, Zero, Positive
Output Membership functions
Voltage Zero, Little Positive, Positive, Very Positive

Inference rules are formed by combining one type of input with another, generating an output,
defined in an if-then logic, as follows: ”If (Error is Negative) and (Error Derivative is Negative),
then (Voltage is Little Positive)”.
The combination of all input possibilities generates a set of 15 rules, in other words, 15 parameters
to optimize. Those parameters represent the outputs, each varying between “Zero”, “Little Positive”,
“Positive”, “Very Positive”; quantified respectively from 1 to 4.
The two set combined forms a problem of 24 dimensions, with the limits defined in two vectors,
in which the first 9 parameters to be optimized are related to the pertinence functions, and the other
15 to build the rules base.
In sequence, a genetic algorithm was implemented using an 8-round tournament selection, chosed
after testing with other methods, such as roulette and other types of tourneys. It is a simple tournament
without elimination, where two individuals from the group are randomly selected and their fitness is
compared. The best individual is selected and saved in a vector. Using this method, an amount of
individuals equivalent to the number of defined rounds is chosen, and the best individual who has
passed through these tournaments is subsequently selected. This method provides a greater chance of
selecting a greater fitness, maintaining randomness.
The crossover method used was 3 points. The first fixed point divides the sets of variables of the
vector, since the problem has two distinct variables: the variables related to the membership functions,
and those related to the rules; and the second and third are random points within the limits of each set
of variables. In this way it is possible to converge each type of variable independently from the other
[6, 7].
The mutation is random. An individual is randomly selected and, within that individual, a variable
is randomly selected, reinitializing it within its limits.
In figure 3, a flow chart of the GA operation is shown.
The implementation of DE is relatively simple. Each generation a Donor Vector is created for each
individual who then undergoes a recombination process, equivalent to crossover, with Target Vector
(the vector of variables of the individual under analysis). After recombination, the fitness of this new
vector, called Trial Vector, is evaluated and if its fitness is greater than that of Target Vector, it replaces
it [8].
4 L. D. Seixas and F. C. Correa

Fig. 3 GA flow chart

Within its classifications, DE is usually represented as follows: Type of Mutation / Number of


weighted differences in the mutation / Type of crossover. For this work, previous tests were performed
using Best/1/Bin, Best/1/Exp, Target-to-Best/1/Bin and Target-to-Best/1/Exp. The best performance
came from Target-to-Best/1/Exp, presented in equation 2.2, which was subjected to iterative tests to
compare performance with GA [9].

Vi,G = Xi,G + F · (Xbest,G − Xi,G ) + F · (Xr1,G − Xr2,G ) (2.2)


in which: Vi,G is Donor Vector; F is the weighting factor; Xbest,G is the vector of the most fitness
individual; Xi,G is the Target Vector; Xr1,G is an individual selected at random; Xr2,G is an individual
selected at random.
For exponential recombination, equation 2.3 is used.

Vi,G , if i = n, n+1, ... , n+L
Xi,G = (2.3)
Xi,G , otherwise
in which: n is an index chosen randomly from [1, D]; Vi,G is the mutated vector; Xi,G is the Target
Vector; L, the number of components to be exchanged, is obtained from the pseudocode 2.

Algorithm 1 Number of components to be exchanged


L=0
while r[0,1] ≤ CR & L ≤ D do L=L+1

in which:
CR is the crossover rate;
r[0,1] is a random value between 0 and 1.
Comparison between genetic algorithm. . . 5

Fig. 4 DE flow chart

Figure 4 shows the DE operation flow chart.


To calculate the fitness function of both algorithms, the Integral of Absolute Error is used, pre-
sented in equation 2.4, which is equivalent to the sum of the areas above and below the reference
value in time. As the aim is to minimize the error, the fitness function is then defined according to
equation 2.5 [10].
z
erro(k) + erro(k − 1)
Ik = | ∑ (tempo(k) − tempo(k − 1))| (2.4)
k=2 2
1
Fit = (2.5)
1 + Ik

3 Results

3.1 Genetic Algorithm

The initial parameters, defined after previous tests, for the GA were: population size = 30,
crossover rate = 90%, mutation rate = 8%, generation limit = 20. The other stopping criterion is
in case the entire population converges at the same fitness value. The algorithm was iterated 10 times
to obtain concrete answers and present them in the form of boxplot graphics.
In figure 5, the best result obtained by the AG in all iterations is shown. The two above graphics
shows the best global fitness and the best fitness of the generation throughout the generations for the
present iteration. The graphic below shows the step response for the 8 rps reference signal, as the red
line represents the reference signal and the bluecurve represents the system’s response to this step.
6.a and 6.b show the fitness dispersion and convergence generation boxplots, respectively. The
upper mark on the graph indicates the maximum value that the sample has reached, while the lower
one indicates the minimum. In the blue box, the centralized red mark indicates the median, while the
6 L. D. Seixas and F. C. Correa

Fig. 5 GA result

boundaries of the box represent the dispersion quartiles, with the upper one corresponding to 75% of
the data, and the lower quartile 25% of the data.

Fitness box plot Convergence box plot


0.2 6

0.18
5.5
Generations

0.16
Fitness

5
0.14

4.5
0.12

0.1 4
1 1
[a] Genetic Algorithm [b] Genetic Algorithm

Fig. 6 GA box plots

In the fitness dispersion graph, the maximum value was 0.1964, while the minimum was 1.1033.
The median of the sampled values was 0.1501.
In the convergence dispersion, it is noticed that the algorithm was stopped several times by the
criterion of the entire population converging to the same fitness value in generation 6, indicating a
possible premature convergence due to excessive selective pressure. However, analyzing the fitness
dispersion in parallel, it is clear that the GA was still able to find good solutions.
The figures 7 and 8 show the triangular membership functions disposal, from Negative to Positive.
The figure 9 shows the surface chart of the rules, being the z axis the Voltage output, x the Error
Derivative and y the Error.
Comparison between genetic algorithm. . . 7

Fig. 7 GA inputs: membership functions disposal

Fig. 8 GA output: membership functions disposal

Fig. 9 GA rules surface

3.2 Differential Evolution

The initial parameters defined for the DE were: population size = 30, F = 0.8 (weighting coef-
ficient), Crossover Rate = 0.2, generation limit = 600 [11]. For the DE does not converge its entire
population to an answer, the other stopping criterion is to reach the predefined number of fitness cal-
culation operations. A limit of 180 fitness calculations was defined, the respective value the highest
amount of fitness calculated by the AG in an iteration, that is 6 generations. This makes it possible to
make a fair comparison between the codes.
The algorithm was iterated 10 times to obtain concrete answers and to present them in the form of
boxplot graphics.
In figure 10, the best result obtained by DE in all iterations is shown. The two above graphics
shows the best global fitness and the best fitness of the generation throughout the generations for the
8 L. D. Seixas and F. C. Correa

present iteration. The graphic below shows the step response, as the red line represents the reference
signal and the blue curve represents the system’s response to this step.

Fig. 10 DE result

The figures 11.a and 11.b below show the fitness dispersion and convergence generation boxplots,
respectively. The DE reached a maximum value of 0.2011, with a median of 0.1669. The convergence
dispersion graph shows that the DE cannot converge the entire population to a value, being stopped
by the defined generation limit criterion.

Fitness box plot Convergence box plot


6.5
0.2

0.19

0.18
Generations
Fitness

0.17 6

0.16

0.15

0.14
5.5
1 1
[a] Differential Evolution [b] Differential Evolution

Fig. 11 DE box plots

The figures 12 and 13 show the triangular membership functions disposal, from Negative to
Positive. The figure 14 shows the surface chart of the rules, being the z axis the Voltage output, x
the Error Derivative and y the Error.
Comparison between genetic algorithm. . . 9

Fig. 12 DE inputs: membership functions disposal

Fig. 13 DE output: membership functions disposal

Fig. 14 DE rules surface

3.3 Discussion

With the results presented it is possible to discuss them in order to obtain a performance evaluation.
Table 2 presents a summary of the fitness obtained by the optimizations, showing the best fitness
obtained and the fitness dispersion, while figure 15 shows the dispersion of each heuristic side by
side. In table 3, the information obtained from the response to the step of the best results obtained
with each proposal is presented in detail.
It is seen that both codes are really accurate and robust, as the difference between the best fitness
found is very small. A fitness above 0.15 for this problem would already present a satisfactory answer
to the step. The difference, as detailed in table 3, is relatively low. It is noticed, however, that the rise
time, which decreased approximately 8% from GA to DE; and the peak time, which decreased by
about 15%, were crucial for improving the performance of one controller in relation to the other.
10 L. D. Seixas and F. C. Correa

Fig. 15 Fitness box plot comparison

Table 2 Fitness comparison


Algorithm Fitness
Genetic Algorithm 0.1964
Differential Evolution 0.2011
Algorithm Median Fitness
Genetic Algorithm 0.1501
Differential Evolution 0.1669

Table 3 Step response comparison


GA DE
Rise time (s) 0.7805 0.7190
Settling time (s) 1.0961 1.0557
Settling minimum (rps) 7.2016 7.1987
Settling maximum (rps) 8.0487 8.2113
Overshoot (%) 0.6026 2.6711
Undershoot (%) 0 0
Peak (rps) 8.0487 8.2113
Peak time (s) 1.1980 1.0150
Fitness 0.1964 0.2044

Analyzing the fitness dispersion shown in figure 15, it is observed that although the algorithms
present a close maximum result, the genetic one had a greater dispersion, from 0.1033 to 0.1964,
while the DE had a dispersion of 0.1359 to 0.2011. As a result, the DE shows greater consistency, in
addition to the fact that the highest concentration of results, as well as its median, is found in a region
higher than the GA, ranging from about 0.15 to 0.18, while the GA ranges from 0.14 to 0.16. The
GA shows itself with more dispersed extremes, confirming how it depends more on the quality of the
individuals in its initial population.
It is interesting to note that both proposals, with the opportunity to move pertinent functions,
practically eliminate the triangular “Zero” from the entry “Error”. This shows that, despite designing
Fuzzy with 5 pertinence functions for the entry “Error”, 3 are sufficient to represent the space. The
other functions obtained by the algorithms are very similar, showing that the responses are at the same
maximum peak for the functions.
The rules obtained are quite different, showing that there is not only one solution to the problem.
The rules surface found by the DE tend to be more linear, much due to the calculation of the mu-
Comparison between genetic algorithm. . . 11

tation vector that only accept integer values. The GA rules reflect the randomness of the crossover
implemented.
Finally, it is noted that the results found touch the physical limitation of the plant, being difficult
to find a much better result than the one presented.

4 Conclusion

Evolutionary computing is a huge leap that has brought exceptional tools for technological devel-
opment. The meta-heuristics presented in this work are robust and frequently used in complex and
non-linear problems, and thus, they presented excellent results for the problem in question.
When removing the empiricism of a Fuzzy controller, one easily has a problem with several di-
mensions, but it is noted that both algorithms, making use of their advantages, achieved answers that
empirically would be very difficult to achieve, requiring a lot of time to adjust.
The differential evolution is marked by being able to perform a more sophisticated local search,
due to the recombination method and, mainly, the way in which the mutated vector is calculated.
This makes the algorithm less dependent on a more assertive initial population, and even the number
of initial individuals to search for the solution can be reduced. Despite having a faster convergence,
the opposite happens with the genetic algorithm, which is an algorithm very dependent on the initial
population, requiring a larger population.

References
[1] I. S. Shaw and M. G. Simões. Controle e modelagem Fuzzy. EDITORA EDGARD BLÜCHER LTDA, 1st edition,
1999.
[2] Charles Darwin. On the Origin of Species by Means of Natural Selection. Murray, London, 1859. or the Preservation
of Favored Races in the Struggle for Life.
[3] J. H. Holland. Adaptation in Natural and Artificial Systems. MIT Press, 1st edition, 1975.
[4] Rainer Storn and Kenneth Price. Differential evolution: A simple and efficient adaptive scheme for global optimization
over continuous spaces. Journal of Global Optimization, 23, 01 1995.
[5] France Cheong and Richard Lai. Designing a hierarchical fuzzy logic controller using the differential evolution
approach. Applied Soft Computing, 7(2):481–491, March 2007.
[6] L. da C. M. Leite. Geração e simplificação da base de conhecimento de um sistema hı́brido fuzzy-genético.
Dissertação, UERJ, 2009.
[7] A. S. KOSHIYAMA, M. M.B.R. VELLASCO, and R. TANSCHEIT. Gpf-control: Um modelo fuzzy-genÉtico para
problemas de controle. Proceeding Series of the Brazilian Society of Applied and Computational Mathematics, 1:1–6,
2013.
[8] Daniel da Costa e Silva Coutinho. TRATAMENTO DO PROBLEMA DE OTIMIZAÇÃO COM RESTRIÇÕES USANDO
EVOLUçAO DIFERENCIAL. PhD thesis, UFRJ, September 2013.
[9] M. Prauzek, P. Krömer, J. Rodway, and P. Musilek. Differential evolution of fuzzy controller for environmentally-
powered wireless sensors. Applied Soft Computing, 48:193–206, November 2016.
[10] D. Maiti, A. Acharya, M. Chakraborty, A. Konar, and R. Janarthanan. Tuning pid and pi/λdδ controllers using
the integral time absolute error criterion. In 2008 4th International Conference on Information and Automation for
Sustainability, pages 457–462, Dec 2008.
[11] Marco Antonio Itaborahy Filho. Algoritmos Evolutivos para Otimização de Funções. page 60, 2018.

You might also like