## 3 UAV Path Planning Method Based Modified Fruit Fly Optimization Algorithm
### MSFOA-Based Path Planning  
#### 3.2.1 Problem Modeling  
UAV path planning needs to adapt to current terrain and physical world constraints, such as terrain undulation, gravitational acceleration, etc. In addition, the path of the UAV cannot exceed the limits of the UAV itself, such as turning radius, glide angle, flying speed, minimum flying height,and so on. Within these limits, an optimal flight path is planned for the UAV, which can avoid a specific area and reach the target point with less energy consumption in a shorter time. The collision risk between UAVs needs to be considered in the three-dimensional (3D) cooperative path planning of multi-UAVs. Path representation is a key problem in path planning, and the grid-based map [15] and spline curve [1, 5] are two common methods. [PERSON] proves that by using the B-spline-based path representation strategy, the path can be constructed using a relatively smaller number of parameters than using a complete geometric description of the path [1]. Thus, in charting our course, the algorithm uses very few control points to record the path. When the algorithm needs to use the full path, it will use the control points to generate the whole path. In this paper, the objective function divides the path constraints into the following categories: path length, threat cost, altitude cost, terrain constraint, corner constraint, and descent angle constraint. All the constraints constitute the objective function. The algorithm uses the objective function to express the quality of a path. Before calculating the objective function, it is necessary to generate a complete path with path points before calculating. The objective function is calculated as follows:  
\[J=\sum JH+JL+JT+CH+CT+CG+JP \tag{20}\]  
where the objective function includes the altitude cost \(JH\), the length cost \(JL\), the threat cost \(JT\), the terrain constraint \(CH\), the corner constraint \(CT\), the climb down constraint \(CG\), and the collision risk \(JP\), which are described in detail as follows. The altitude cost is determined by all points along the path, which reflects the flying altitude of the UAV above the ground. When flying at a low altitude, the UAV can benefit from terrain masking to avoid unknown radars [1]. Suppose the whole UAV path is represented by \(k\) points, if the variable \(z_{n}\) is the height of the \(n\)-th point in the path, and \(h_{min}\) is the minimum flying height of the UAV, then the altitude cost \(JH\) adds up the height of all the points along the path on the ground as follows:  
\[JH=\sum\limits_{n=1}^{k}(z_{n}-h_{min}) \tag{21}\]  
The path length cost \(JL\) reflects the flight length of the entire UAV path, which calculates and adds the distance between any two adjacent points to get the total length as follows:  
\[ \begin{split} JL=\sum\limits_{n=1}^{k-1}l_{n}\\ \text{with}\\ l_{n}=\sqrt{(x_{n+1}-x_{n})^{2}+(y_{n+1}-y_{n})^{2}+(z_{n+1}-z_{ n})^{2}}\end{split}  \tag{22}\]  
where the variable \(x_{n}\) is the \(x\) coordinate of the \(n\)-th point in the path, \(y_{n}\) is the \(y\) coordinate of the \(n\)-th point in the path, and \(z_{n}\) is the \(z\) coordinate of the \(n\)-th point in the path. The terrain constraints are determined by the length of the path in the underground section. This symbol is used to punish those paths that are not entirely on the ground. The variable \(p\) is the information of the map, and function H(\(p\)) means the height of the current point in map \(p\). \[ \begin{split}\text{CH}=\sum\limits_{n=1}^{k}T_{n}\\ \text{with}\\ T_{n}=\left\{\begin{array}{ll}H(p)-z_{n}&,&\text{if }z_{n}<H(p)\\ 0&,&\text{if }z_{n}>H(p)\end{array}\right.\end{split}  \tag{23}\]In this paper, the threat around the threat point is only related to the distance, so the threat area is approximated as a cylinder, within a certain range; the closer to the threat point, the greater the degree of threat. The variable \(n_{r}\) is the amount of threaten points. \(T_{\text{de}}(i)\) is the coordinate of the \(i\)-th threaten points.