Parameter Tuning of PID Controller for Beer Filling Machine Liquid Level Control Based on Improved Genetic Algorithm

Parameter tuning of PID controller for liquid level control of beer filling machine was studied in this paper, which can meet the demand of accurate controlling in beer production and improve the rapidity under the same conditions. Firstly, an improved genetic algorithm was proposed which has been verified by eight kinds of test functions. Simulation results revealed that, in comparation with other modified particle swarm optimization algorithm and modified genetic algorithm, the algorithm proposed in this work is not only capable to improve the convergence speed and precision under the same experimental conditions but also to improve the probability to converge to the optimal value. Finally, the proposed algorithm was applied to the parameter tuning of the PID controller of beer filling machine for liquid level control. Superior property had been obtained, which implied an effective improvement in the rapidity with the premise of steady-state error exclusion.


Introduction
Usually, in order to improve the performance of the control systems, various measures need to be taken [1,2]. PID controller has been widely employed in control systems due to its basal principle, excellent robustness, and considerable reliability [3][4][5][6][7]. Nevertheless, the controlling performance of PID controller relies on the value selection of scale coefficient, integral coefficient, and differential coefficient. With the purpose to improve the performance of the control system as possible, the parameter tuning of PID controller has become one of the research hotspots currently [8][9][10].
e quantization factor and scaling factor were iteratively optimized in the offline state by using particle swarm optimization algorithm approach to adjust the fuzzy PID parameters rapidly, and the control system was simulated and analyzed by MATLAB, which has been reported in pervious literature [11]. Furthermore, Gao et Al. proposed a new objective function construction method according to the control system overshoot based on the conventional genetic algorithm to realize the parameter optimization of PID [12]. As presented in literature [13], aiming to overcome the shortages of the traditional quantum genetic algorithm, Jian-xin FENG et al. had addressed the premature problem of the traditional quantum genetic algorithm and improved the convergence speed through the following five aspects including coding method, population initialization, quantum revolving gates, quantum mutation, and the increase of quantum catastrophe. e optimized algorithm presented above had been applied to the parameter optimization of fuzzy self-tuning PID controller. Moreover, in order to deal with the complexity of parameter tuning of the fractionalorder PID controller, Su WANG et al. had introduced the chaotic perturbation into the Beetle Antennae Search algorithm and promoted a parameter tuning approach of fractional-order PID controller to enhance optimization performance of algorithm according to the random perturbation of individual positions resulted from the logistic mapping formula [14]. As known that, BAS had been challenged by the local optimum and low precision due to its prematurity, Shijiao SHAN et al. had integrated the efficient BAS algorithm with the traditional bat algorithm and used it for the PID parameter optimization to achieve a faster response [15]. In addition, aiming at the problem of oscillation caused by excessive selection of learning rate in the learning process of the traditional BP neural network, Huangshui HU et al. had proposed a new adaptive tuning algorithm for PID parameters of BP neural network to alleviate the oscillation phenomenon effectively and accelerate the convergence speed of the algorithm [16].. e convergence speed and stability of the genetic algorithm were improved in literature [17] to realize the online adjustment of PID control parameters with the optimized initial weight of BP neural network employed. Liu and Chen [18] presented tuned PID parameters with high convergence accuracy and fast convergence speed by using cellular genetic algorithm (CGA). Cao and Feng [19] designed an adaptive fuzzy PID controller based on particle swarm optimization algorithm according to the urban rail train braking model. Ye [20] improved the searching ability of the particle swarm optimization algorithm by adjusting the adaptive inertia factor, which has been applied to adjust the PID parameters of the temperature control system of injection molding machine online and further improve the control accuracy. Considering the limitations of the conventional PID controller, Zhao and Fu proposed a scheme combining the fuzzy system and BP neural network [21]. Meanwhile, whale optimization algorithm (WOA) was adopted for further optimization in the improvement of dynamic performance and steady-state accuracy of the control system.

Improved Genetic Algorithm
e improved genetic algorithm refers to the random division of variable interval according to the setting interval number, while the initial population is generated according to the fitness value of the midpoint of the interval and roulette wheel selection. In the iterative process of the algorithm, the PSO algorithm was introduced into the crossover operation according to the probability. e individual with the lowest fitness value would be substituted by random individuals generated via the same method in developing the population.

Flow Diagram of Improved Genetic Algorithm
Step 1: setting the parameters in the improved genetic algorithm, including population numbers, interval numbers, maximum iterations, crossover probability, mutation probability, introduction probability of particle swarm optimization algorithm, learning factor, maximum inertia weight, minimum inertia weight, allowable error, etc.
Step 2: dividing the variable intervals randomly according to the interval number settings in Step 1 and substituting the midpoint of the intervals into the fitness function of the algorithm to estimate the fitness value. On this basis, according to the algorithm parameters set in Step 1 and the roulette selection, the initial population of the algorithm has been generated.
Step 3: calculating the fitness value of each individual among population to evaluate each individual and to complete the selection operation.
Step 4: executing the crossover operation according to the crossover probability and the introduction probability of the particle swarm optimization algorithm which has been set in Step 1. e particle swarm optimization algorithm updates the speed and position abiding to equation (1).
where the optimum algorithm population, global optimum, speed, and position of population size were denoted as pbest i , gbest g , V, and X, respectively. k referred to the iterations of the improved genetic algorithm, while c 1 and c 2 referred to the learning factors. rand 1 and rand 2 represented the random numbers uniformly distributed within (0, 1). e inertia weight has been labeled as ω, which diminished with four different strategies associated to the probability to enhance the optimization ability during the iterative process in improved genetic algorithm, as revealed in equations (2)-(5) [22].
e maximum and minimum of inertia weights were marked as ω max and ω min , where max e and era represented the maximum and the current number of iterations in the improved genetic algorithm, respectively.
Step 5: executing mutation operation according to the mutation probability set in Step 1.
Step 6: calculating the fitness value for each individual in population and generating a random individual with the same method in generating the initial population of the algorithm described in Step 2, which would be used to substitute the individual with the lowest fitness value at present.
Step 7: determining whether the termination condition of the algorithm has been met based on the number of iterations and the allowable error of the algorithm. And the algorithm would terminate or skip to Step 3 for cyclic calculation.

Experimental Results of Improved Genetic Algorithm.
In order to verify the performance under the same experimental conditions, the improved genetic algorithm had been applied to the optimization of eight different kinds of typical test functions. e simulation experimental environment is MATLAB R2009 B version, in which numbers including 50 in the population of the algorithm, 12 in the number of intervals, 200 in the maximum number of iterations, 0.90 in the crossover probability, 0.01 in the mutation probability, 2 × 10 −15 in the allowable error, 0.5 in the introduction probability of particle swarm optimization algorithm, and 0.90 and 0.10 in the maximum and minimum inertial weight, respectively, had been set. Different algorithms had been run 100 times each. e expressions of the eight kinds of test functions had been demonstrated in equations (6)-(13), and corresponding function images are given in Figure 1. e average convergence curves of different algorithms are presented in Figure 2 with the average convergence precision of different algorithms shown in Table 1. e average convergence algebras and the probabilities of convergence to the optimal value are compared in Tables 2 and 3 .
Among them, the improved genetic algorithm proposed in this paper was presented as algorithm 1, while algorithm 2 was the modified particle swarm optimization algorithm based on interval algorithm and modified elite strategy, and algorithm 3 belonged to the improved genetic algorithm promoted in literature [22].
It is concluded that compared with algorithms 2 and 3, the improved genetic algorithm proposed in this paper improves the convergence accuracy, the convergence speed, and the probability of convergence to the optimal value of algorithm effectively, which is also implied in Figure 2.

Mathematical Modelling.
Considering of the balance between inflow and outflow volume of liquid, the height of liquid level (H), the cross-sectional area of the liquid storage tank (A), and the inflow (Q 1 ) and outflow (Q 2 ) liquid obey the equation as follows [23,24]: which can be rewritten in the following form of increment: To simplify the mathematical model of the control system, we assumed that the outflow increment was proportional to the liquid level increment and was inversely proportional to the valve resistance of the load valve, which has been shown in the following equation [ Based on equations (14) and (16), By using Laplace transformation, we get Considering the hysteresis of liquid level changes in realistic engineering problems, the liquid level control system can be approximately seen as a first-order inertial hysteresis system with the transfer function shown in the following equation [23,24]: where K, T, and τ are defined as 5, 160, and 3 in this paper.

Stability Analysis of Control
System. Stability laid the foundation for the operation of the control system. Hence, it is a priority to determine the stability of a certain control system. Since the control system consisted of a nonlinear delay part, the analysis of stability has to be realized via the observation of the unit step response curves and calculation of the amplitude and phase angle margin of a control system, instead of the Routh-Hurwitz stability criterion. e unit step response curve of the control system is shown in Figure 3, and the Bode diagram is shown in Figure 4. Figure 3 illustrates the convergence in unit step response curve of the control system. e amplitude margin of the control system (24.5 dB) and the phase angle margin (96.3°) were both larger than zero, as shown in Figure 4, which confirmed the stability of the control system.

Parameter Tuning of PID Controller.
In order to improve the performance of the control system, algorithms 1, 2, and 3 have been employed to correct PID controller parameters, and the fitness function is shown in the following equation: where X represented the variate of proportional coefficient (K P ), integral coefficient (K I ), and differential coefficient (K D ) of the PID controller. t s , σ% were denoted as the adjustment time and overshoot of the control system, respectively. P(X) referred to the penalty function. us, the expression is shown in the following equation:  Test function  Algorithm 1  Algorithm 2  Algorithm 3  Test function 1  88  159  160  Test function 2  21  59  62  Test function 3  56  152  161  Test function 4  110  200  200  Test function 5  88  181  197  Test function 6  111  196  195  Test function 7  63  121  136  Test function 8  75  175 160 where e ss is the steady-state error of the control system. e convergence curves of algorithms 1, 2, and 3 are presented in Figure 5. Figure 6 shows the unit step response curves of the control system corresponding to the optimal results. Performance indexes of the control system are shown in Table 4. e steady-state error (e ss ) of the control system had been eliminated effectively and the adjustment time (t s ) of the control system was reduced after PID correction, which were elucidated in both Figure 6 and Table 4. Moreover, among these three types of algorithms, algorithm 1 had been proved to have the most remarkable performance in this paper.     Computational Intelligence and Neuroscience However, it also caused a large oscillation which was responsible for a large overshoot. Moreover, fitness function presented in equation (22) can be applied to improve the stability of the control system.
Maintaining the simulation experimental environment and algorithm parameters, the convergence curves of algorithms 1, 2, and 3 are provided in Figure 7. e unit step response curves of the control system corresponding to the optimal results are shown in Figure 8. e overshoot of the control system corresponding to the optimal results for algorithms 1, 2, and 3 was 14.3807%, 20.2146%, and 19.1002%, respectively. For higher requirements in stability of the control system, the penalty function P(X) can be modified, which will reduce the accuracy requirements simultaneously.

Conclusion
Under the same experimental conditions, an improved genetic algorithm was proposed in this work to improve the convergence speed, accuracy, and the probability to converge to the optimal value. e performance of the proposed algorithm had been verified by eight different kinds of typical test functions. Furthermore, the improved genetic algorithm had been applied to the parameter tuning of PID controller for liquid level controlling of beer filling machine, which revealed the superiority in effectively improving the rapidity of the control system with the premise of steadystate error elimination.

Data Availability
e data used to support the findings of the study can be obtained from the author upon request.

Conflicts of Interest
e author declares that there are no conflicts of interest.    Computational Intelligence and Neuroscience 9