## 4 Simulations and Experiments
### Validation of Algorithm  
We selected the Sphere (A1), Ackley (A2), and Rastrigin (A3) functions to test the performance of the G-PSO algorithm. The Sphere function can test the local search ability of the algorithm and the Ackley and Rastrigin functions can test the comprehensive search ability of the algorithm [19]. The above three optimization test functions are optimized by DE, ALO, GA, and G-PSO algorithms, respectively. In the DE algorithm, the scaling factor is 0.5 and the crossover rate is 0.3. The coefficient of ants' random walks in the ALO algorithm is 2. In the GA, the crossover rate is 0.75, and the variation rate is 0.01. In the G-PSO algorithm, \(c_{p1}\) and \(c_{g1}\) are both 0.8, \(c_{p2}\) and \(c_{g2}\) are both 1.7, \(\omega_{min}\) is 0.4, and \(\omega_{max}\) is 0.9. The relevant parameters are shown in Table 1.  
Figure 2: Flow chart of the G-PSO algorithm.  
Each algorithm runs 10 times independently for each test function. The average values of the optimal solution obtained are shown in Table 2. The average convergence curves of the algorithm are shown in Figure 3.  
As can be seen from Figure 3 and Table 2, GA converges faster in the Sphere and Rastrigin functions, while the G-PSO algorithm converges faster in the Ackley function. Moreover, the GA algorithm is easy to fall into the local optimum, so the G-PSO algorithm has more advantages in optimization.  
To further verify the effectiveness of the G-PSO algorithm, the models in [7; 18; 21] are optimized by this algorithm and the step response curves are shown in Figure 4. Table 3 shows the system performance parameters. The rise times of the systems in [7; 18; 21] are 0.11 s, 1.8 s, and 1 s, respectively. After G-PSO algorithm optimization, the rise times are shortened to 0.042 s, 0.039 s, and 0.219 s and the settling times are reduced from 0.23 s, 3.7 s, and 2.1 s to 0.067 s, 0.056 s, and 0.371 s. The overshoot of the system in [7; 18] is successfully suppressed. Meanwhile, with the G-PSO algorithm optimization, the number of iterations in [7; 18] is reduced from 49 to 16 and 20 to 5, respectively. Although the number of iterations in this study is similar to that in [21], the response speed of the system is significantly faster.  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Function** & **Dimension** & **Search Range** & **Population Size** & **Max Iterations** \\ \hline Sphere & 10 & [\(-100,100\)] & 50 & 500 \\ Ackley & 10 & [\(-32.768,32.768\)] & 50 & 500 \\ Rastrigin & 5 & [\(-10,10\)] & 50 & 500 \\ \hline \hline \end{tabular}
\end{table}
Table 1: The parameters for optimization test function.  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Function** & **DE** & **ALO** & **GA** & **G-PSO** & **Optimal Value** \\  & & & & **in Theory** \\ \hline Sphere & 0.0048 & \(6.0903\times 10^{-9}\) & 0.0086 & \(3.7506\times 10^{-9}\) & 0 \\ Ackley & 0.0689 & \(3.3138\times 10^{-5}\) & 0.0518 & \(3.1704\times 10^{-5}\) & 0 \\ Rastrigin & 5.2145 & 4.7758 & 1.1424 & 0.6969 & 0 \\ \hline \hline \end{tabular}
\end{table}
Table 2: The average value of the optimal solution of the test functions by different algorithms.  
Figure 3: Average convergence curves:(**a**) Convergence curves of Sphere function, (**b**) Convergence curves of Ackley function, (**c**) Convergence curves of Rastrigin function.  
The comparison results show that the G-PSO algorithm-optimized PID controller in the system has a faster response speed and can suppress the overshoot. The main reason for this is that the G-PSO algorithm has a good global optimization ability, and a fitness function is designed to improve the system response speed and suppress the system overshoot. During optimization, the system response speed and overshoot can be taken into account, so the optimization effect is obviously improved.