Speed Proportional Integrative Derivative Controller: Optimization Functions in Metaheuristic Algorithms

Recent advancements in computer science include some optimization models that have been developed and used in real applications. Some metaheuristic search/optimization algorithms have been tested to obtain optimal solutions to speed controller applications in self-driving cars. Some metaheuristic algorithms are based on social behaviour, resulting in several search models, functions, and parameters, and thus algorithm-specific strengths and weaknesses.,e present paper proposes a fitness function on the basis of the mathematical description of proportional integrative derivate controllers showing that mean square error is not always the best measure when looking for a solution to the problem. ,e fitness developed in this paper contains features and equations from the mathematical background of proportional integrative derivative controllers to calculate the best performance of the system. Such results are applied to quantitatively evaluate the performance of twenty-one optimization algorithms. Furthermore, improved versions of the fitness function are considered, in order to investigate which aspects are enhanced by applying the optimization algorithms. Results show that the right fitness function is a key point to get a good performance, regardless of the chosen algorithm. ,e aim of this paper is to present a novel objective function to carry out optimizations of the gains of a PID controller, using several computational intelligence techniques to perform the optimizations. ,e result of these optimizations will demonstrate the improved efficiency of the selected control schema.


Introduction
Many optimization problems are nondeterministic polynomial-time (NP) or NP-hard, and a high computing power is required when trying to solve them [1,2]. An NPhard problem "is a problem where a solution for it is at least as hard as finding a solution for the hardest problem whose solution can quickly be checked as being true. Some NPhard problems are ones in which a working solution can be checked quickly (NP problems) and some are not. NP-hard problems are also NP problems fit into a label called NPcomplete" [3]. Many of the problems arising in present-day applications from scientific fields belong in NP-hard problems: they involve search spaces with many dimensions, they are multimodal or multiobjective, and the optimization functions are hard to compute or are applied on large volumes of data. Classical optimization methods from operation research make it possible to find optimal solutions for complex problems, but are not useful in practice due to their excessive computational load when applied to real-world systems [4]. For NP-hard problems, the time required to solve a problem grows exponentially with respect to the size of the problem, making the exact methods unpractical.
Each of these algorithms has its own peculiarities, and they can be used to solve various categories of optimization problems. e performance of evolutionary algorithms depends on the choice of their control parameters, which must be tuned for each specific problem. Population-based metaheuristic algorithms generally include two processes: exploration and exploitation. e exploration process attempts to analyse a wide variety of solutions and must be random enough to ensure that it covers a large area of the problem space. e exploitation process tries to improve, through a local search, the solutions found in the exploration process. In this phase, the optimizer focuses on the neighborhood of the highest quality solutions found by the exploration process, rather than the entire solution space. In any optimization process, it is essential to find an adequate balance between exploration and exploitation, a balance that depends on the nature of the specific problem to be solved.
Hybrid optimization techniques are available in the state of the art for solving complex engineering problems, which combine several simple algorithms to obtain better optimization efficiency.
In the automotive industry, especially for vehicle design and optimized components, the Butterfly Optimization Algorithm (BOA) is a widely used hybrid optimization technique. Also, other hybridization proposals are available for similar purposes, such as Harris Hawk optimization with simulated annealing (HHOSA), which provides an accelerated convergence. Additionally, a hybridization of the interior search algorithm with the hill climbing algorithm (H-ISA) has been used to optimize structural and mechanical design problems, among others. is algorithm has been proven to work better in those cases than the ant lion optimizer (ALO), gravitational search algorithm (GSA), firefly algorithm (FFA), league championship algorithm (LCA), bat algorithm (BAT), symbiotic imperialist competitive algorithm (ICA), organisms search (SOS), and charged system search algorithm (CSS).
e key element for any of these algorithms is the fitness function, which must meet the following conditions: (a) the function must be clearly defined; (b) the implementation of fitness must be as efficient as possible; since it will be evaluated many times in the optimization process, its efficiency has a strong impact on the overall performance of the algorithm; (c) fitness must provide a quantitative measure of the quality of a given solution; (d) the best individuals must produce the best values of fitness function and vice versa. e fitness function is dependent on the problem domain.
e implementation of this fitness function is the main part when you want to apply a nature-based algorithm to a problem, and it must be built for each specific problem. For certain types of problems, for example, for classification tasks with supervised learning, error metrics, such as the Euclidean distance or the Manhattan distance, are often used. For other optimization problems, the summation of a set of quality indicators related to the application domain can be used.
is paper shows the importance of choosing a right fitness function; it is a key point to get a good performance regardless of the chosen algorithm. Discussion about whether a given algorithm obtains a better result than others is not addressed in this study. e main highlights of the paper are (i) e evaluation of different metaheuristics techniques applied to PID controllers (ii) Showing the importance of choosing the right fitness function (mean squared error is not always the best choice) (iii) Final fitness function that improves the mean squared error achieving a quasi-perfect fit of desired signal

Proportional Integrative Derivative Controller
Proportional integrative derivative controllers are the controllers par excellence, as well as the most studied. is type of controllers is based on the old proportional controls, such as the centrifugal regulator of Watt's machine (1788). One important thing is that knowledge about the process to control is not really needed when using it with a PID controller, which is the reason why such a mathematical model is so broadly used. e PID equation describes how to control the system: it receives an error calculated from the desired/obtained output, using this error to feed the control loop in the next iteration. e aim of the controller is to minimize this calculated error by adjusting the gains of the PID.
e PID controller is based on the relation of three components: the proportional, the integral, and the derivative. e tune of the gains of these components not only generates the behaviour of the output of the controller but also influences the others. Although those parameters are tuned, it is quite difficult to manually define the values of the PID gains that generate the values tending to zero of the performance metrics (establishment times, over-oscillation, settling, etc.). However, the best tuning of the controller tries to get a trade-off among those error metrics, adjusting them according to the requirements of the application.
A PID controller outputs a signal using a weighted sum of three terms: (i) Proportional: error between the defined setpoint and the actual process value (ii) Integral: how much error has been accumulated over time (iii) Derivative: how rapidly the error is changing is naturally leads to P (Proportional), I (Integral), and D (Derivative) in PID and the three weighting parameters (K p , K i , K d ) that need to be computed. By modifying these control parameters, the behaviour of these on the system will be modified, and it will be possible to obtain a controller that satisfies the design criteria established for a specific application.
Each control action is responsible for producing a specific effect on the transitional or permanent regime, or on both at the same time. erefore, when it comes to achieving better control over the system, it is necessary to know which aspect of the control is to be improved, to modify a specific action and not to disrupt the rest of the system.
One must be aware that proportional action affects both the transitional and the permanent regime, tending to reduce the error in the permanent regime when its action increases. On the contrary, when this action increases the system will tend to increase the oscillations in the process variable. e integral action affects the permanent regime, annulling the error. e error could be understood as the difference between the reference and the value read by the sensor. If the error is greater than zero, this means that the value read by the sensor will be below the reference, meaning that the control action will increase, while if the error is less than zero, the value read by the sensor will be greater than the reference, and therefore, the action on the system will decrease. e last control action is the derivative action. is action is mainly focused on the transitional regime, improving the stability of the system. It can also be found in some articles as a predictive action, and this is because this control action is of an anticipatory nature, i.e., it anticipates the behaviour of the system to improve its performance. e main disadvantage of this action is that it amplifies the noise of the signal and saturates the actuators in the event of sudden changes in the set point.
When designing a PID controller, several methods can be found in the literature. One of the most famous methods is the Ziegler-Nichols method [49], which is proposed by Ogata [50]. Other methods can also be found, such as those Chien-Hrones-Reswick methods proposed by [51] and the Cohen-Coon method proposed by [52]. In order to tune the PID controller, using these methods, it will be necessary to know the behavior of the system. To do this, the corresponding actuator will be put into operation and wait until the variable in question is stabilized in a permanent state. Observing the variable to control shape (see Figure 1), the values of the gain K, the delay L, and the time constant T (with a � L/T) could be calculated depending on the chosen method (see Tables 1-4).
Some authors focus on improving the response of the PID controllers using metaheuristics, especially in problems with a highly nonlinear behaviour, because, for them, the traditional methods of adjusting the gains are inefficient, obtaining results comparable or superior to conventional techniques [53]. Valluru and Singh [54] show that the efficiency of tuning nonlinear drivers using particle swarm optimization and other bioinspired techniques is superior to the results with traditional tuning techniques. e experimental results show that the overshoot and settling time of a nonlinear PID controller can be improved while maintaining a satisfactory system response. Recent research [55] shows that the performance of a PID control system with gains calculated by a symbiotic organism search algorithm manages to minimize the steady-state error. When the system is subjected to disturbances, this controller is capable of reaching the set point in any situation.
is paper does not take disturbance into account; it only shows the importance of choosing a right fitness function. Talking about exogenous disturbance (input disturbance) that affects model (physical or mathematical) behaviour is most probably assimilated to account for model-uncertainty (inaccuracy), time-varying parameters, perturbation (as wind-gust in aircrafts), actuator unmodelled dynamics, and the same ilk. Input disturbance could be modelled as a constant signal D(s) � 1/s, in Laplace domain, or d(t) � 1 in time domain, or a sinusoidal signal, or a stochastic process, or something like that.

Problem Description
ere is an electric vehicle with cameras and sensors for speed, acceleration, LiDaR, etc. (see Figure 2). is vehicle can be driven remotely through the ODBII port (see Figure 3) by adjusting the cruising speed, acceleration, and turning the steering wheel. e problem is to set a cruising speed (higher or lower than the current one) and see the vehicle's response under real conditions. e cruise control is based on a PID. A manual adjustment of the parameters (K p , K i , K d ) could be done, but the idea is to try to find a better solution than the manual operator or expert could achieve. e problem can be formulated as a model of optimization in a three-dimensional space.
e optimization process requires an objective function (fitness) to be minimized depending on the parameters (K p , K i , K d ). Mean square error is the classical fitness function in optimization problems, but there are other approaches depending on the problem to solve. A good performance can be obtained, when dealing with PID, using a linear combination of overshoot, decay, setting time, and steady-state error as proposed by [56,57]. is paper uses the same mathematical model of the system/process for which the controller described in [56,57] is employed.
A fractional-order PID controller has better control performance than classical PID controllers. A fractionalorder controller includes the capacity of adjusting responses  Tables 1-4).    Table 4: e Cohen-Coon tuning rules (0% overshoot). Note that these rules produce a quarter-amplitude damping response [52]. of the control system in time and frequency. is feature grants a better and more robust performance than classical PID controllers. It is not always the case in which a fractional-order PID controller used for integer-order plants will be better than an integer-order PID. However, it has been shown in [58,59] that the use of a fractional-order PID could make the entire control system perform better. is is because using a fractional one could satisfy 5 robustness criteria (K p , K i , K d , μ, δ) at most as compared to the usual classical PID controller which only has 3 parameters to be tuned for 3 robustness criteria. is paper uses a PID controller with precalculated μ and δ values from [56,57].
e first fitness function f 1 , see equation (1), is based on the mean square error (MSE), that is, the average squared difference between the estimated/target speed signal and the actual speed signal: (1) e second fitness function f 2 , see equation (2), uses a lineal combination of the overshoot and decay of the signal to avoid large peaks and oscillation in the control response, with precomputed values of α and β [56,57]: And the third one f 3 , see equation (3), uses a lineal combination of the overshoot, decay, setting time, and steady-state error of the signal to avoid large peaks and oscillation in the control response and get an almost fit response to the original signal: e overshoot Ω can be defined as the gap between the outputs of the controller from the set point steady-state value. Following [50], a controller gain tuning is considered good in the case of an overdamped response with a minimum overshoot, according to the application. e value of the overshoot, see (4), is the difference between the system output and the target value (with α � 10 and β � 0.9, to obtain better results): Ω � max(signal(t)) − target, when e(t) > 0, target − min(signal(t)), when e(t) < 0.
e decay ratio Δ is the value between two consecutive maxima of the controller output for a step change in the set point. is ratio is shown as where the parameter a is the amplitude of the oscillations in the instant t − 1 and c the amplitude of the oscillation in the time t.
Let Γ be the settling time, that is, the time required for the controller output to stabilize at p% of the set point. According to literature, the recommended value of p is 0.02% [56,57]: where the parameter t is the amount of time in which the output signal is below p and T max is the maximum value of the sampling time, considering the signal as the output value of the system. e steady-state error Θ is the gap between the stabilized output signal of the system and the set point, after N controller iteration. In this paper, the selected value of N is 350, time enough for the controller to reach the set point (target): Θ � |signal(N) − target|.
(7) Figure 4 shows the desired (blue) signal and the estimated/ target (red) signal using the parameters computed by a particle swarm optimization algorithm: (K p � 14.1300, K i � 4.6007, K d � 0.00100000) with fitness f 1 value of 48.47595, (K p � 10.899968, K i � 51.6346372, K d � 0.001000000) with fitness f 2 value of 103.0716, and (K p � 10.901181, K i � 100.000 0000, K d � 0.001000000) with fitness f 3 value of 26.21848. It can be seen that, in Figure 4(b), the peaks are smaller and the changes in signal are not as abrupt as in Figure 4(a), but Figure 4(c) shows the best results if using the full fitness function with all terms (overshoot, decay, setting time, and steady-state error), which is the expected and desired behaviour of the PID controller. Figure 4(c) is equivalent to the classical computation of PID.

Results
e particle swarm optimization algorithm has shown good results, see Figure 4, combined with an objective function f 3 . is section shows the results obtained using other metaheuristics (particle swarm optimization, whale optimization algorithm, differential evolution, clonal selection algorithm, cat swarm optimization, artificial bee colony algorithm, shuffled frog leaping, grey wolf optimizer, ant lion optimizer, firefly algorithm, dragonfly algorithm, harmony search algorithm, genetic algorithm, grasshopper optimization algorithm, sine cosine algorithm, moth flame optimizer, cuckoo search, bat algorithm, gravitational based search and black hole optimization, and krill herd algorithm) and the proposed three fitness functions f 1 , f 2 , and f 3 . Optimization parameters have been set to the same values for all algorithms, 100 iterations, and a population size of 15 individuals with (K p , K i , K d ) ∈ [0.001, 100], in order to get a similar testing environment for all algorithms. e first approach consists in using the mean square error as a fitness function (see Table 5, equation (1), and Figure 5). In this case, some algorithms do not get a right solution since the output signal has a great oscillation pattern, but the ones that get good results produce peaks in the step function. is output is similar to the classical PID mathematical computation [49][50][51]. is behaviour could be considered a valid solution in other environments/problems but not in the case of a self-driving car with autonomous or remote speed controller as there are peaks and the car speed is not controlled in the transitions. e second approach consists in using the overshoot and decay parameters (see Table 6, equation (2), and Figure 6). Now, the results are better than in the previous case since peaks disappear and the speed is controlled in a less abrupt mode (smooth transitions). As in the other case, some algorithms present oscillations, which is due to the lack of iterations or population size.
Finally, fitness function f 3 , with the lineal combination of overshoot, decay, setting time, and steady-state error, is tested against the metaheuristics (see Table 7, equation (3), and Figure 7). e figure shows that the output signal fits the desired signal with no peaks and with an almost exact matching. e main contribution of this paper is the use of the weighted fitness function definition f 3 , as well as the use of this function as the basis to perform a metaheuristics optimization of the gains of a PID controller. e results of classical PID optimization usually generate controllers with an oscillating output. However, this oscillating output can be corrected using a low-pass filter, taking into account that the performance criteria always have less quality than metaheuristics optimization. is paper has presented the results of metaheuristic optimization algorithms, based on different error metrics (1)-(3). ese equations define the error as a lineal combination of the four estimators explained above. is error is calculated for a set point sequence instead of for a single set point; therefore, the controller obtained is more robust in new situations. In addition, the error is calculated over a different sequence than that used in the tuning, so the estimation of the controller error is more realistic.
Using these defined fitness functions and a randomly generated sequence of set points, a set of different gains has been obtained for the PID speed controller of an autonomous vehicle through a series of metaheuristics-based optimization techniques.
With most of the optimization algorithms studied, the ground truth error is improved. However, CS, CSO, and MFO perform worse than this ground truth. is fact could be due to the existence of multiple local minima in the parameter space for PID controller gains, which means that local search algorithms show premature convergence. In particular, the MFO algorithm finds different optima in some executions, seemingly indicating the existence of multiple local minima.  (1)). (b) Overshoot and decay (equation (2)). (c) Overshoot, decay, setting time, and steady-state error as fitness function (equation (3)).  Figure 5: Results of 21 optimization metaheuristics using the mean square error as the fitness/objective function f 1 : the red line is target/ output signal and the blue line is desired signal, see equation (1) and   Figure 6: Results of 21 optimization metaheuristics using a fitness/objective function f 2 with overshoot and decay components: the red line is target/output signal and the blue line is desired signal, see equation (2) and

Conclusions
is paper shows the performance of the computation power of several evolutionary algorithms to optimize the gains (K p , K i , K d ) of the speed PID controller of a self-driving vehicle. ree fitness functions have been used to optimize the controller gains. ose functions are based in a combination of classic error metrics of the controller: overshoot, decay ratio, settling time, and steady-state error. e results of the different optimizations of the PID speed controller gains have been compared with each other, both for the sequence of step set points uses as the target of the optimization and for a totally new randomly generated sequence, unknown by the system. is system has been implemented by means of a dynamic model of the vehicle in simulation that represents the speed behaviour in a realistic way. e fitness function proposed to measure the quality of a PID controller according to the traditional PID quality metrics reported by the literature, meaning that the minimization of this fitness implies the joint optimization of these metrics, since some can imply disturbances in the rest. e weight of each of them has been carefully tuned to find an optimal overall solution.

Future Research
As possible future research lines, coefficients in equation (3) could be tuned using different algorithms of literature, analysing the optimization rate compared to the methods presented in this paper. e results of this paper have been tested in simulation; as future work, we propose to test the optimized controllers in real physical autonomous vehicles as well as to implement an online optimization using the best techniques studied in this paper.
Some dynamic metaheuristic optimization models, such as multilayer neural networks (MLP), could be implemented using the particular structure of MLPs. e MLP benefits from the complex architecture of the neural networks and its transformations in order to achieve new optimal solutions. In terms of convergence, the relationship between random exploitation and each parameter under asymmetric interval is derived and an iterative convergence of neural networks is proved mathematically [60]. Other optimization techniques such as the water cycle algorithm could also be applied to solve the problem proposed [61].