## 3 Simulation Results and Analysis
### Comparison between Improved PSO and SA  
The simulated annealing algorithm (SA) [5], one of the most widely used optimization algorithms, is applied for comparison to demonstrate the efficiency and robustness of PSO.  
In SA, \(T_{\text{max}}\) represents the maximum temperature, \(T_{\text{min}}\) represents the minimum temperature, \(r\) represents the cooling rate, and \(K\) represents the number of temperature iterations.  
During the process of finding the optimal solution, SA accepts not only the current optimal solution but also the bad solution with a certain probability. This strategy is the key to causing SA to jump out of the local optimal solution. However, due to the many parameters of SA, the improper setting of these parameters will cause SA to fall into local optimal solutions or take more time to obtain a stable optimal solution.  
To facilitate comparison, Equation (3) was used for both the improved PSO and SA as the evaluation function when defocusing the insensitivity of the current wavefront coding system, and threshold T was introduced into SA.  
Tables 4 and 5 show the influence of all parameters on SA. For details of the phase mask design based on SA, please refer to Appendix A.  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Parameter** & **Avg** & **Var** & **Average Time/s** \\ \hline r = 0.90; \(K=100\) & 89.77 & 0.17 & 57.97 \\ r = 0.90; \(K=10\) & 86.31 & 9.41 & 5.53 \\ r = 0.60; \(K=100\) & 88.08 & 4.93 & 11.44 \\ r = 0.30; \(K=100\) & 86.57 & 9.13 & 5.02 \\ r = 0.30; \(K=10\) & 66.75 & 2.44 \(\times\) 10\({}^{2}\) & 0.45 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Influence of the cooling rate and the number of temperature iterations on SA.  
\begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Parameter** & **Avg** & **Var** & **Average Time/s** & **References** \\ \hline \(v_{\text{max}}=0.7;v_{\text{min}}=-0.7\) & 70.71 & 0.27 & 5.96 & [8] \\ \(v_{\text{max}}=0.8;v_{\text{min}}=-0.8\) & 80.70 & 0.23 & 5.94 & [8] \\ \(v_{\text{max}}=0.9;v_{\text{max}}=-0.9\) & 90.58 & 0.53 & 5.98 & [8] \\ \(v_{\text{max}}=1.0;v_{\text{max}}=-1.0\) & 100.77 & 0.19 & 6.08 & [8] \\ T = 0.15 & 90.23 & \(7.40\times 10^{-3}\) & 5.90 & this work \\ \hline \hline \end{tabular}
\end{table}
Table 3: Comparison of improved PSO and traditional PSO.  
In Table 4, with the decrease in cooling rate \(r\) and the number of temperature iterations \(K\), the solution easily falls into the local optimal solution when the maximum temperature \(T_{\text{max}}\) and the minimum temperature \(T_{\text{min}}\) are constants. If the cooling rate \(r\) and the number of temperature iterations \(K\) are increased, the optimization time will be increased.  
In Table 5, \(T_{\text{min}}\) has a greater influence on the optimization result than \(T_{\text{max}}\). SA easily falls into the local optimal solution when \(T_{\text{min}}\) increases. Additionally, the program runtime will increase when \(T_{\text{min}}\) decreases.  
In contrast, the improved PSO is robust and easy to use. For the optimization of the cubic phase mask, the runtime of the improved PSO is only related to the population of particles \(D\) and the number of iterations \(I\). Table 6 shows the influence of the population of particles and the number of iterations on the improved PSO. With the appropriate population of particles and number of iterations, the algorithm can obtain a stable optimal solution within a short time. As shown in the data in row 5 of Table 6, when \(D=30\) and \(I=100\), the average value of the cubic phase mask optimized by the improved PSO is 90.23, the variance is only 7.40 \(\times\) 10\({}^{-3}\), and the average time is only 5.90 s.