Fuzzy Logic Control With PSO Tuning
Fuzzy Logic Control With PSO Tuning
5,500
Open access books available
136,000
International authors and editors
170M
Downloads
154
Countries delivered to
TOP 1%
most cited scientists
12.2%
Contributors from top 500 universities
Abstract
1. Introduction
FLC represents a family of intelligent controllers with a lot of potential for use in
the world for industrial control systems. Its popularity is mainly due to its perfor-
mance being robust in several operating conditions and its functional simplicity, in
addition to its ease of implementation, allowing engineers to operate them in a
simple and direct way. Even with the emergence of new control techniques, FLC
controllers will still be on the market for a long time in industrial plants [1].
A good parameterization of the FLC inference functions is essential to allow a
good performance of this type of closed loop controller. The tuning of the controller
is a persistent problem in the area of control and automation, from the initial
approach of this topic to the present day; a definitive solution has not yet been
reached, being a subject constantly addressed in several works in the field of control
engineering. However, it is important to note that despite the various techniques
that produce adjustments in the FLC parameters, it is still necessary to assess the
designer regarding the result of the parameterization of this controller [2].
In recent years, the computational capacity available allows optimization tech-
niques developed in the field of artificial intelligence to gain space in the solution of
several engineering problems [3, 4]. In this context, algorithms based on
metaheuristics can provide adequate solutions to the FLC parameterization prob-
lem. Since the parameters necessary for the proper functioning of the FLC can be
numerous and often complex, techniques based on intelligent computing provide
an alternative solution to this type of problem.
1
Fuzzy Systems
where x is the position of the particle; v is the velocity of the particle; w is the
inertial weight, controlling the impact of the previous speed at the current speed; c1
and c2 are positive constants, controlling the social and individual behavior of each
particle; r1 and r2 are random numbers in the interval [0.1], contributing to
diversify the exploration of the problem search space.
The basic PSO algorithm can be defined as follows.
Randomly initialize the particle positions xik and speeds vik within the search
space at k = 0.
2
Fuzzy Logic Control with PSO Tuning
DOI: http://dx.doi.org/10.5772/intechopen.96297
Similar to what happens in fuzzy logic applications in other areas, the FLC
project requires several operational requirements that must be adequately dimen-
sioned for the correct functioning of this type of control. An important choice as to
how the final control signal will take place is the decision between the TSK or
Mamdani FLC. The general rule model is given as:
where, A is a fuzzy set of X, B is one of the fuzzy set of Y and C is fuzzy set U
(signal of controller).
In the case of the FLC of the Mamdani type, each rule is a conditional fuzzy
proposition, and different fuzzy relationships in A x B x C can be derived from it.
The implementation of each rule is done by defining operators to process the rule’s
antecedent and the implication function that will define its consequent. In this case,
the action of the FLC is defined based on the aggregation of rules that make up the
algorithm. This aggregation results in the fuzzy set C, which defines the output of
controller C. The effective output of the controller is then obtained through a
defuzing process applied to set C.
The TSK FLC is a simplified model of the Mamdani controller, where the conse-
quent of each rule is defined as a function of the linguistic input variables.
3
Fuzzy Systems
Each rule results in no longer a numerical value but a fuzzy set. The weight
assumes the pertinence value resulting from processing the rule’s antecedent. The
value of u can be defined as a constant (single value with relevance equal to one) -
singleton. From a singleton it is possible define rules with output values that
represent a classification of the controller response, without changing the simplified
way of determining the final controller response.
In many practical situations of real controllers trapezoidal MFs are used for the
function inputs. The reason is that several sensors installed in the system can
present different noise in the measurement and as a consequence change some
conditional rule in the operation of the FLC.
Regarding the design of the basic FLC rules, the expert needs to decide the total
number of rules and how these operational conditions are related.
The central idea of using metaheuristics in the pursuit of optimizing FLC per-
formance is in the design characteristic of this controller. The various parameters
and variables that are necessary for the good functioning of the FLC do not present
general rules, making the role of the operator essential in the analysis and dimen-
sioning of these terms [11].
Despite the specialist’s knowledge, the resulting FLC may not perform as opti-
mally. Metaheuristics, on the other hand, can function as an intelligent search
engine for the various possible architectures for the FLC, without the need for the
exhaustive work of trial and error on the part of an expert control engineer [11–13].
The use of a metaheuristic for the optimization of the FLC needs to be correctly
dimensioned for its proper and effective functioning. There are different architec-
tures to be explored when using these techniques despite an FLC [13]. Figure 1
presents an FLC architecture using metaheuristics for its optimization.
From the observation of Figure 1, it is possible to notice that metaheuristics can
help in the solutions of different areas of the FLC. There are several options for the
parametric optimization of the FLC, therefore, the designer needs to define what
one wants to obtain or which are the important parameters to be defined in his
control project.
Figure 1.
FLC optimization scheme.
4
Fuzzy Logic Control with PSO Tuning
DOI: http://dx.doi.org/10.5772/intechopen.96297
objective is to find the values of each MF individually that allows to obtain a better
performance of this controller [14].
Assume that you have determined a set of rules and chosen all the MFs in your
project. A common application of a metaheuristic algorithm in this case is to deter-
mine the ideal positioning of the MFs. In this particular context, the MF designer is
a time-consuming exercise and it is usually possible to achieve good results. For this
reason, some techniques offer benefits to develop such functions. In this case, it is
necessary to turn the positions of each MF into optimization variables of the algo-
rithm. Figure 2 presents a representation of this application.
Figure 2 presents a possible model for the application of metaheuristic optimi-
zation of MFs. From a set of previously selected MFs, it is assumed that the posi-
tions of these functions are the variables (xi ) of the optimization problem. In this
way, the algorithm seeks to select such parameters, increasing or decreasing the
space of each one in the possible set. The position and size of each MF is important
since this has a direct influence on the output of the FLC system.
In this FLC optimization application, it is necessary to define which MFs are
involved and the respective definition limits. In practice, it is necessary to limit the
range of values for each variable (xi ), thus avoiding that the optimization does not
result in inadequate results.
The optimization of the FLC rules is also an interesting application on this topic.
Determining the rules of an FLC is naturally an empirical process, since trial and
error are very necessary in order to be successful in these rules [15].
The application of metaheuristics in this case is configured to determine the best
rules that, when combined in the logic of the FLC, optimize its operation. The
variables in this situation are the defining set of MFs and can be combined in
different ways to compose the rules. In this case, based on a previous set of infor-
mation, it is possible to determine which variables will be part of a given rule and
even how many rules should drive the FLC. Figure 3 shows a metaheuristic scheme
for the determination of a specific rule of the IF-THEN type.
Figure 3 shows an optimization of rules based on IF - THEN. From the set of
MFs (NB, NS, NM, Z, PS, PM, PB), the subsequent terms y1 ðiÞ (de/dt) and y2 ð jÞ (e),
as well as the consequent term zðkÞ can be defined appropriately for the formation
of FLC rules. In this example, i = 7 and j = 7, totaling 49 possible rules to be
determined by metaheuristic optimization.
Figure 2.
MF optimization scheme.
5
Fuzzy Systems
Figure 3.
Optimization scheme for fuzzy rule conditionals.
J ¼ C1 X 1 þ C2 X 2 þ … þ Cn X n , (4)
where Ci represents the constants that are associated with the variables of
interest X i . The designer must determine how many variables one wishes to com-
pose the function such that it achieves its final FLC performance objective. How-
ever, some variables in the function can be redundant and not affect the overall
performance of the optimization. In this way, the designer’s expertise is essential to
obtain a function that allows an effective optimization of the FLC.
6
Fuzzy Logic Control with PSO Tuning
DOI: http://dx.doi.org/10.5772/intechopen.96297
For each new population resulting from the PSO swarm, the variables from the
algorithm are stored and inserted in the FLC and, from that, the result of the fitness
function (J) is estimated. This is done until reaching the stopping criterion. In this
example, add the value of J < 102 as the main stop criterion for the algorithm. The
code that presents the implementation of the objective function is shown below.
Figure 4.
FLC scheme for optimization by PSO in MATLAB.
7
Fuzzy Systems
Figure 5.
FLC code in MATLAB.
Figure 6.
Fitness function code in MATLAB.
For the application of the PSO, it is first necessary to initialize the algorithm
parameters. In this case, initially the value of the particle positions in the swarm is
randomly defined. The position of all particles is usually started with some speed, in
this example all speeds are started at zero. Finally, it is defined as a minimum value
of the best initial particle in 1000. The particles in the swarm must reach and exceed
at least this value of the “best initial particle”. Figure 7 shows the code used.
The operation of the PSO is simple, the population is evaluated and its position is
updated based on its position and previous speeds. The swarm positions are then
entered in the X variables, which in turn are the inputs for the “OptFuzzy” optimi-
zation function. The X values are actually the values that will adjust the positions of
the FLC’s input MFs. If the value obtained in the optimization is less than the
current value of the objective function, the best individual particle values and the
best global value are increased. This is done until reaching the stopping criterion.
Figure 8 shows the PSO operation code in this FLC optimization example.
In order to test the PSO in the optimization of the FLC MFs of the present example,
we try to test the algorithm with 10, 20, 50, 100, 200 and 500 particles in the swarm.
Figure 9 shows the behavior of the objective function “OptFuzzy” over 50 iterations.
8
Fuzzy Logic Control with PSO Tuning
DOI: http://dx.doi.org/10.5772/intechopen.96297
In general, the greater the amount of swarms in the PSO, the faster the minimi-
zation of the objective function will occur, since this way there will be a greater
exploration of the search space of the algorithm.
Figure 7.
PSO parameters.
Figure 8.
PSO code in MATLAB.
Figure 9.
Fitness function optimization.
9
Fuzzy Systems
In addition to optimizing the FLC’s input (e and de/dt) and output via PSO,
manual tuning is also applied to these MFs. The manual tuning basically consists of
determining “manually” the positional values of the triangular functions of the MFs
Figure 10.
MFs manual tuning vs. MFs PSO tuning.
Figure 11.
FLC manual tuning vs. FLC PSO tuning.
10
Fuzzy Logic Control with PSO Tuning
DOI: http://dx.doi.org/10.5772/intechopen.96297
Table 1.
Comparison between the different tunings of the FLC.
and the value of the MFs at the output. This choice is empirical and is based on the
operator’s knowledge and experience regarding the control system. The result of the
MFs tuning process in different ways is shown in Figure 10.
From the MFs resulting from the tuning processes discussed above (Figure 4),
the FLC controller is simulated in both tuning situations (Manual and PSO) by
applying different steps to the control system input. Figure 11 shows the result of
the behavior of the FLC resulting from the different synotnias mentioned above.
From Figure 11 it is possible to notice that the FLC obtained from the PSO
presented a much more satisfactory performance in terms of dynamic behavior.
Table 1 presents detailed values of the performance indices for both processes.
6. Conclusions
Abbreviations
11
Fuzzy Systems
Author details
© 2021 The Author(s). Licensee IntechOpen. This chapter is distributed under the terms
of the Creative Commons Attribution License (http://creativecommons.org/licenses/
by/3.0), which permits unrestricted use, distribution, and reproduction in any medium,
provided the original work is properly cited.
12
Fuzzy Logic Control with PSO Tuning
DOI: http://dx.doi.org/10.5772/intechopen.96297
References
13
Fuzzy Systems
14