Academic Journal of Science and Technology ISSN: 2771-3032 | Vol. 12, No. 2, 2024 72 Simulation and Research on PID Parameter Tuning Based on Improved Beetle Antennae Search Algorithm Peng Zhang Xi 'an Shiyou University, Xi 'an Shanxi, 710000, China Abstract: The traditional PID parameter tuning method has the problem that it is difficult to achieve optimal performance and even lead to system instability. In order to overcome these problems, an improved Beetle Antennae Search (BAS) algorithm is proposed in this paper. By dynamically adjusting the step size, introducing random disturbance and elite reservation strategy, the global optimization ability and convergence speed of the algorithm are significantly improved. In this study, the improved BAS algorithm is applied to the parameter tuning of PID controller. By defining an objective function that comprehensively considers the performance indexes such as system overshoot, regulation time and steady-state error, the algorithm is used for iterative search to determine the optimal PID parameter combination. The experiment uses MATLAB/Simulink platform for simulation, taking the second-order system as the controlled object, and simulating different system dynamics by changing system parameters. The findings from the experiments indicate that the improved BAS algorithm outperforms traditional methods in terms of convergence speed, optimization outcomes, and stability. With an identical number of iterations, the refined algorithm yields a lower objective function value, reduced overshoot, shortened adjustment duration, and diminished steady-state error. The PID parameter tuning technique, grounded on the improved BAS algorithm presented in this research, not only maintains the simplicity inherent to the conventional BAS algorithm but also markedly boosts its global optimization capability and convergence rate. This offers innovative perspectives and techniques for optimizing industrial control systems. Keywords: PID Parameter Tuning; Simulation; Improved Beetle Antennae Search Algorithm. 1. Introduction As the core component in the field of automatic control, PID controller has always occupied a decisive position in industrial control system. It can effectively and accurately control all kinds of dynamic systems through the synergistic effect of proportion, integration and differentiation, thus ensuring the smooth operation of industrial processes. However, the performance of PID controller is highly dependent on the setting of its parameters, which include proportional coefficient, integral coefficient and differential coefficient. The conventional approach to PID parameter tuning, exemplified by the Ziegler-Nichols method, is straightforward and convenient; however, it frequently falls short in guaranteeing peak system performance and may, in certain instances, precipitate system instability [1-2]. In the recent past, coinciding with the evolution of intelligent optimization algorithms, an increasing number of researchers have started to delve into the potential of applying these algorithms to the PID parameter tuning process [3]. Among them, the Beetle Antennae Search (BAS) algorithm, as a new bionic optimization algorithm, has attracted wide attention for its unique search mechanism and global optimization ability. However, the traditional BAS algorithm still has some limitations in the process of optimization, such as easy to fall into local optimum and slow convergence. To address these challenges, this study advocates for a PID parameter tuning methodology grounded in an improved BAS algorithm. Through augmentations to the conventional BAS algorithm, the optimization efficacy and convergence velocity of the algorithm are heightened, enabling a more proficient determination of the optimal parameters for the PID controller. This investigation holds not only theoretical significance but also anticipates offering novel insights and techniques for the refinement of industrial control systems. 2. Introduction of Improved BAS Algorithm BAS algorithm is a bionic optimization algorithm based on the foraging behavior of longicorn beetles. In the process of foraging, longicorn beetles perceive the odor concentration around them through their antennae (i.e. "whiskers"), so as to determine the direction of progress. The algorithm simulates this process, and determines the search direction and step size by detecting the objective function value in the solution space with "left and right whiskers". The basic steps of the traditional BAS algorithm are as follows: 1. Initialize the position and step size of the longicorn beetle. 2. The objective function value is detected by the "left beard" and "right beard" of longicorn beetles. 3. According to the difference of function values detected by the two whiskers, the next moving direction and step size of the longicorn beetle are determined. 4. Repeat steps 2 and 3 until the stop condition is met. The advantage of traditional BAS algorithm is that it is simple and easy to realize, and it does not need gradient information of objective function, so it is suitable for nonconvex and nonlinear optimization problems and has a certain global search ability. However, the algorithm also has some shortcomings, such as easy to fall into local optimal solution, limited global optimization ability and slow convergence speed, especially when it is close to the optimal solution, the search efficiency will decrease, and the choice of step size has a great influence on the performance of the algorithm, so it is difficult to determine the appropriate step size. Aiming at the shortcomings of traditional BAS algorithm, 73 an improved BAS algorithm is designed in this study. While maintaining the simplicity of traditional BAS algorithm, this algorithm improves the global optimization ability and convergence speed [4-5]. The algorithm is more flexible and efficient by dynamically adjusting the step size, introducing random disturbance and elite retention strategy. Dynamically adjust the step size according to the search situation in the iterative process [6]. In the initial stage of search, a larger step size is adopted to speed up the global search; With the iteration, the step size is gradually reduced to improve the accuracy of local search. Step adjustment formula: t tt ss 1 (1) Where ts is the step size of t generation and  is the step size attenuation factor ( 10  ). In order to enhance the global search ability of the algorithm and avoid falling into local optimum, when the algorithm has not been improved obviously for many iterations, random disturbance is applied to the position of the longicorn beetle. Disturbance formula:  randβxx tt 1 (2) Where tx is the position of the t generation longicorn beetle, β is the disturbance coefficient, and  rand generates a random number. In the iterative process, the historical optimal solution is retained and used as a reference point to guide the longicorn beetle to search in a better direction. 3. PID Parameter Tuning Method based on Improved BAS Algorithm The improved BAS algorithm is applied to the parameter tuning of PID controller to optimize the performance of the controller. By combining dynamic step adjustment, random disturbance and elite retention strategy, the improved BAS algorithm not only retains the simplicity of the traditional algorithm, but also significantly improves the global optimization ability and convergence speed, making it more suitable for PID parameter optimization [7-8]. An objective function is defined, which comprehensively considers the performance indexes such as overshoot, regulation time and steady-state error of the system. eErrorSteadyStatωmeSettlingTiωOvershootωJ 321  (3) Among them, 321 ωωω ,, is the weight coefficient, which is used to balance the importance of different performance indicators. eErrorSteadyStatmeSettlingTiOvershoot ,, represents the maximum overshoot of the system, the time required to reach the steady state and the error in the steady state respectively. The improved BAS algorithm is used for iterative search. In each iteration, the value of the objective function is calculated according to the combination of PID parameters corresponding to the "left beard" and "right beard" of longicorn beetles. According to the difference of the objective function values detected by the two sensors, the next moving direction and step size of the longicorn beetle (PID parameters) are determined. The dynamic step size adjustment strategy is applied to gradually reduce the step size with the iteration to improve the search accuracy. If the objective function value of the algorithm has not improved obviously after repeated iterations, random disturbance is applied to the position of the longicorn beetle to enhance the global search ability. In the iterative process, the historical optimal solution (that is, the PID parameter combination with the minimum objective function value) is recorded and retained. Using the elite retention strategy, the historical optimal solution is taken as the reference point to guide the longicorn beetle to search in a better direction. When the maximum number of iterations is reached or a solution satisfying the accuracy requirement is found, the iteration is stopped. Output the optimal combination of PID parameters. The implementation of the algorithm mainly includes the following parts: 1. Set the initial position and step size of the longicorn beetle. 2. According to the current PID parameter combination, the response of the control system is obtained through simulation, and the value of the objective function is calculated. 3. According to the principle of BAS algorithm, the position (that is, PID parameters) of longicorn beetles is updated. 4. When necessary, random disturbance is applied to the position of longicorn beetles. 5. Record and update the historical optimal solution. The algorithm flow chart is shown in Figure 1 below: Figure 1. Algorithm flow 74 4. Simulation Experiment and Result Analysis The experimental environment adopts MATLAB/Simulink, which is a platform widely used for control system design and simulation. The controlled object is selected as a typical second-order system, and its transfer function is as follows:   22 2 2 nn n ss sG     (4) Where n is the natural frequency and  is the damping ratio. In order to simulate different system dynamics, these parameters are changed in the experiment. Specific parameter settings are as follows: Initial PID parameters range: pK : 0.1 to 10, iK : 0.01 to 1, dK : 0.01 to 1. Step adjustment strategy: initial step 10 S , step attenuation factor 95.0 Random disturbance mechanism: disturbance coefficient 1.0 , random number range -1 to 1. Elite retention strategy: record and retain the variables of historical optimal solution. In order to ensure the reliability of the results, experiments are repeated for each controlled object model, and the average value is taken as the final result. The improved BAS algorithm significantly improves the convergence speed by dynamically adjusting the step size, introducing random disturbance and elite retention strategy. Compared with the traditional method, the algorithm can find the near-optimal PID parameters in less iterations (Figure 2). The objective function value of the improved BAS algorithm decreases rapidly with the increase of iteration times, showing a faster initial convergence speed. The improved BAS algorithm keeps a lower objective function value in the later iteration, which shows that its optimization effect is better. There are fluctuations in the objective function curves of the two methods, but the fluctuation amplitude of the improved BAS algorithm is relatively small, showing better stability. Compared with the traditional method, the improved BAS algorithm not only has fast initial convergence speed, but also can stabilize near the optimal solution with a lower objective function value, showing better optimization performance. The curve fluctuation of the improved BAS algorithm is smaller, which means that it has stronger resistance to disturbance and better stability in the iterative process. In the optimization of PID parameters, the improved longicorn search algorithm has obvious advantages over the traditional methods, and shows better performance in convergence speed and stability. This provides a more efficient and stable parameter optimization approach for control system design. Figure 2. Comparison of convergence speed By comparing the performance of PID controller tuned by traditional method and improved BAS algorithm, it is found that the latter has better performance in overshoot, adjustment time and steady-state error (Table 1). Table 1. Performance comparison Iterations method Objective function value Overshoot (%) Adjustment time (s) Steady state error (%) 10 traditional method 0.85 25.0 6.0 3.0 Improved BAS algorithm 0.70 20.0 5.0 2.0 20 traditional method 0.80 23.0 5.5 2.8 Improved BAS algorithm 0.65 18.0 4.5 1.5 30 traditional method 0.77 22.0 5.2 2.6 Improved BAS algorithm 0.62 16.0 4.2 1.2 100 traditional method 0.72 20.0 4.8 2.2 Improved BAS algorithm 0.58 14.0 3.8 0.8 Judging from the objective function value, the improved BAS algorithm has achieved a lower objective function value than the traditional method in each iteration. The improved BAS algorithm demonstrates a superior capacity to fine-tune these metrics upon taking into account pivotal performance indicators such as overshoot, adjustment time, and steady- state error, thereby ensuring an elevated overall system performance. In the domain of overshoot, the improved BAS algorithm manifests a markedly lower overshoot compared to conventional methods. Overshoot represents the maximum variance beyond the steady-state value during system transition. A diminished overshoot signifies a smoother attainment of steady state, consequently mitigating system impact and oscillation. The adjustment period associated with the improved BAS algorithm is typically curtailed in comparison with traditional techniques. This adjustment time denotes the duration necessary for the system's transition from its initial to its steady-state configuration. A truncated adjustment duration indicates a swifter achievement of steady state, thus augmenting the system's response velocity. The 75 steady-state error observed in the refined BAS algorithm is minimized. Steady-state error is defined as the system's discrepancy from the anticipated value following the attainment of steady state. A reduced steady-state error signifies elevated control precision, enabling the system to cater to more exacting control specifications. Compared with the traditional PID controller, the improved BAS algorithm has obvious advantages, such as lower objective function value, smaller overshoot, shorter adjustment time and smaller steady-state error. This algorithm not only keeps the simplicity of traditional BAS algorithm, but also significantly improves the global optimization ability and convergence speed by introducing dynamic step adjustment, random disturbance and elite reservation strategy. Therefore, the improved BAS algorithm is expected to provide new ideas and methods for the optimization of industrial control systems. 5. Conclusion By dynamically adjusting the step size, introducing random disturbance and elite retention strategy, the improved BAS algorithm significantly improves the global optimization ability and convergence speed, while maintaining the simplicity of the algorithm. Simulation results show that compared with traditional methods, the improved BAS algorithm shows faster initial convergence speed and lower objective function value in PID parameter tuning, which means smaller overshoot, shorter adjustment time and smaller steady-state error. These results confirm the effectiveness and potential of the improved BAS algorithm in industrial control system optimization, and provide an efficient and stable parameter optimization approach for future control system design. References [1] Chu, P, Yu, Y. , Dong, D. , Lin, H. , & Yuan, J. (2020). Nsga- ii-based parameter tuning method and gm (1,1)-based development of fuzzy immune pid controller for automatic train operation system. Mathematical Problems in Engineering, 2020(6), 1-20. [2] Wakitani, S., Yamamoto, T. , & Gopaluni, B. (2019). Design and application of a database-driven pid controller with data- driven updating algorithm. Industrial And Engineering Chemistry Research, 58(26), 11419-11429. [3] Berkenkamp, F., Krause, A. , & Schoellig, A. P. (2023). Bayesian optimization with safety constraints: safe and automatic parameter tuning in robotics. Machine learning, 112(10), 3713-3747. [4] Paynter, A , & Willis, A. D. (2021). Tuning parameter selection for a penalized estimator of species richness. Journal of applied statistics, 48(6), 1053-1070. [5] Sugasawa, S., & Yonekura, S. (2021). On selection criteria for the tuning parameter in robust divergence. Entropy, 23(9), 1147. [6] Zemouche, A., Zhang, F. , Mazenc, F. , & Rajamani, R. (2019). High-gain nonlinear observer with lower tuning parameter. IEEE Transactions on Automatic Control, 64(8), 3194-3209. [7] Taveira, L. F. R., Kurc, T. , Melo, A. C. M. A. , Kong, J. , Bremer, E. , & Saltz, J. H. , et al. (2019). Multi-objective parameter auto-tuning for tissue image segmentation workflows. Journal of Digital Imaging, 32(3), 521-533. [8] Fuyin, N. I., & Jian, H. (2024). Research on upqc harmonic control strategy based on optimized qpir controller of beetle antennae search algorithm in microgrid. Electrical Engineering, 106(3), 2357-2369.