## 3 Path Generation and Optimization Scheme
### Path Optimization Using PSO  
PSO is an optimization method inspired by the behavior patterns of biological populations. It effectively identifies optimal solutions or approaches the desired goals by mimicking the feeding strategies of birds [38]. PSO is characterized by its rapid convergence and robust global optimization capabilities, making it well-suited for optimizing local pathways.  
To define a population within a two-dimensional space, the positional data and boundary constraints of the \(i\)-th particle during the \(n\)-th iteration are described below:  
\[\left\{\begin{aligned} X_{i}(n)&=[k_{1,i}(n),k_{2,i}(n) ]\\ 0&<k_{1,i}\leq 20\\ 0&<k_{2,i}\leq 50\end{aligned}\right. \tag{10}\]  
The method for updating the speed and position of the particle is illustrated in Figure 6. The speed update formula is as follows:  
\[V_{i}(n+1)=\omega V_{i}(n)+c_{1}r_{1}[p_{best}-X_{i}(n)]+c_{2}r_{2}[g_{best}-X_ {i}(n)] \tag{11}\]  
\[X_{i}(n+1)=X_{i}(n)+V_{i}(n{+}1) \tag{12}\]  
where \(p_{best}\) (personal best position) refers to the best solution a particle has achieved individually during the optimization process, and \(g_{best}\) (global best position) represents the best solution found by the entire particle swarm. These positions guide the particles toward the optimal path by balancing individual exploration and swarm collaboration. \(c_{1}\) is the personal learning factor and fixed at 1.3, \(c_{2}\) is the global learning factor and fixed at 1.7. They are utilized to modulate the step length of particle learning, concerning and \(g_{best}\). \(r_{1}\) and \(r_{2}\) are two stochastic numbers falling in the interval from 0 to 1. The inertia weight denoted as \(\omega\), is essential for balancing the global and local search abilities within the particles. To enhance optimization efficiency, \(\omega\) ought to progressively diminish as the iteration count rises. It is defined in the following way:  
\[\omega=\omega_{start}-(\omega_{start}-\omega_{end})\times(n/g)^{2} \tag{13}\]  
where \(\omega_{start}\) represents the initial inertia weight, assigned a value of 0.9, whereas \(\omega_{end}\) represents the final inertia weight, assigned a value of 0.4. \(n\) refers to the current iteration count, and \(g\) denotes the upper limit on the number of iterations.  
Figure 6: Process of particle updating.  
The fitness function of the particles is presented below:  
\[f=\omega_{1}f_{1}+w_{2}f_{2} \tag{14}\]  
\[f_{1}=\sum\sqrt{\left(x_{i+1}-x_{i}\right)^{2}+\left(y_{i+1}-y_{i}\right)^{2}} \tag{15}\]  
\[f_{2}=\frac{\sum K_{i}}{n} \tag{16}\]  
where \(f\) is the fitness function of the particles, \(f_{1}\) is the length of the generated path, \(f_{2}\) is the mean curvature of the path, \(K_{i}\) is the curvature of points on the path, \(\omega_{1}\) is the weight of the path length, and set to 1, and \(\omega_{2}\) is the weight of the mean curvature of the path and set from 100 to 10,000. By changing the ratio of \(\omega_{1}\) and \(\omega_{2}\), the optimal path with different weight ratios can be obtained. To handle the computational cost, we pre-calculate the optimal paths corresponding to different ratios of \(\omega_{1}\) and \(\omega_{2}\). Subsequently, during the actual application, we efficiently utilize pre-calculated optimal paths through offline processing. By doing so, we can effectively bypass the computational cost that would otherwise be incurred during real-time optimization. This approach ensures that the PSO-based path optimization can be carried out efficiently without sacrificing the real-time performance of the overall system.