# Somersault Foraging and Elite Opposition-Based Learning Dung Beetle Optimization Algorithm
## 5 Application of SFEDBO Algorithm
### Three-Dimensional Unmanned Aerial Vehicle Path Planning
#### 5.3.1 Construction of the Objective Function  
In the problem of three-dimensional unmanned aerial vehicle (UAV) path planning, it is necessary to comprehensively consider three factors: flight path length, changes in flight altitude, and deflection angle. These three factors have different weights of influence on trajectory planning.  
Flight path length is an important indicator for the UAV's flight trajectory. Specifically, it refers to the distance from the starting point to the endpoint, assuming that the UAV does not consider changes in speed. A shorter distance means lower flight costs and indicates higher quality of the planned path. The specific expression function for flight path length is as follows:  
\[f_{L}=\sum_{i=1}^{n}\sqrt{\left(x_{i+1}-x_{i}\right)^{2}+\left(y_{i+1}-y_{i} \right)^{2}+\left(z_{i+1}-z_{i}\right)^{2}} \tag{18}\]  
\begin{table}
\begin{tabular}{c c c c c c} \hline \hline
**Algorithm** & \(\mathbf{s_{1}}\) & \(\mathbf{s_{2}}\) & \(\mathbf{s_{3}}\) & **Weight** & **Rank** \\ \hline SFEDBO & 0.051652 & 0.355816 & 11.3422 & 0.012665 & 1 \\ DBO & 0.05 & 0.317425 & 14.02777 & 0.012719 & 4 \\ GWO & 0.050528 & 0.329171 & 13.11875 & 0.012706 & 3 \\ MSADBO & 0.05193 & 0.362538 & 10.98252 & 0.012693 & 2 \\ SGMDBO & 0.05 & 0.317425 & 14.02777 & 0.012719 & 4 \\ \hline \hline \end{tabular}
\end{table}
Table 6: The result of tension/compression spring design problems.  
where \(f_{L}\) represents the flight path length; \(n\) is the total number of trajectory points; \((x_{i},y_{i},z_{i})\) are the three-dimensional coordinates of the \(i\)-th trajectory point.  
A stable flight height can make the path smoother and reduce the burden on the UAV. To ensure the safety of the UAV during flight, a flight height variation function is set, which represents the standard deviation of height changes during the flight process. The specific definition of the flight height variation function is as follows:  
\[f_{H}=\sqrt{\sum\limits_{i=2}^{n-1}{(z_{2,\ldots,n-1}-mean(z_{2,\ldots,n-1})) ^{2}}/(n-2)} \tag{19}\]  
where \(f_{H}\) represents the flight height variation function; \(z_{i}\) is the height of the \(i\)-th trajectory point; and \(n\) is the number of trajectory points.  
The change in the flight angle of the UAV determines its flexibility. During flight, the deflection angle of the UAV should be less than or equal to its preset maximum deflection angle. The expression for the change in deflection angle is as follows:  
\[\begin{array}{l}f_{S}=\sum\limits_{i=1}^{n}{|\theta_{i+1}-\theta_{i}|}\\ \theta_{i}=\arccos\left({\frac{\overrightarrow{v_{1}}\cdot \overrightarrow{v_{2}}}{\left|\overrightarrow{v_{1}}\right|\cdot \left|\overrightarrow{v_{2}}\right|}}\right)\\ \overrightarrow{v_{1}}=Q_{i}-Q_{i-1},\overrightarrow{v_{2}}=Q_{i+1}-Q_{i}\\ 2\leq i\leq n-1\end{array} \tag{20}\]  
where \(f_{S}\) is the deflection angle function; \(Q_{i}\) is the position of the \(i\)-th trajectory point; \(\overrightarrow{v_{i}}\) refers to the vector between two adjacent trajectory points; \(\theta_{i}\) is the deflection angle; and n is the number of trajectory points.  
The objective function designed by combining these three influencing factors is as follows:  
\[f_{\text{min}}=w_{L}\times f_{L}+w_{H}\times f_{H}+w_{S}\times f_{S} \tag{21}\]  
where \(w_{L}\) is the deflection angle variation function; \(w_{H}\) refers to the weight coefficient for the flight altitude variation; and \(w_{S}\) is the weight coefficient for deflection angle.