## 3 UAV Path Planning Method Based Modified Fruit Fly Optimization Algorithm
### MSFOA-Based Path Planning
#### 3.2.2 Application of MSFOA to Multi-UAVs Path Planning
**Step 3:** Set up the parameters of MSFOA, including maximum iteration number \(NC\), the number of new swarms \(G\), the fruit fly population size \(M_{pop}\), the _threshold_, the searching step dwindled parameter \(R\), and cross genetic coefficient \(coe_{1}\) and \(coe_{2}\). **Step 4:** Let \(num=1\). **Step 5:** Let \(nc=1\) and randomly generate the location for each swarm, (\(x^{(1),1}_{\text{best}}\), \(y^{(1),1}_{\text{best}}\))... (\(x^{(1),\ D}_{\text{best}}\), \(y^{(1),\ D}_{\text{best}}\))... (\(x^{(G),1}_{\text{best}}\), \(y^{(G),1}_{\text{best}}\))... (\(x^{(G),\ D}_{\text{best}}\), \(y^{(G),\ D}_{\text{best}}\)). **Step 6:** Let \(g=1\), \(i=1\), \(d=1\). **Step 7:** Generate the random locations for the food source using the olfactory according to Equation (34) if \(smell^{(g)}_{\text{best}}\) is larger; otherwise, generate the new locations according to Equation (35), as follows  
\[X^{(g),\ d}_{i}=x^{(g),\ d}_{\text{best}}+\sin((\pi/2)*\text{random}(-1,1))Y^{ (g),\ d}_{i}=y^{(g),\ d}_{\text{best}}+\sin((\pi/2)*\text{random}(-1,1)) \tag{34}\]  
\[X^{(g),\ d}_{i}=x^{(g),\ d}_{\text{best}}+R*\text{random}(-1,1)Y^{(g),\ d}_{i}=y ^{(g),\ d}_{\text{best}}+R*\text{random}(-1,1) \tag{35}\]  
**Step 8:** Update the smell concentration judgement according to the formula below:  
\[S^{(g),\ d}_{\text{old},\ i}=\sqrt{\left(X^{(g),\ d}_{i}\right)^{2}+\left(Y^{ (g),\ d}_{i}\right)^{2}} \tag{36}\]  
if \(S^{(g),\ d}_{\text{old},\ i}\) is bigger than 1, jump to step 7, otherwise jump to step 9. **Step 9:** if \(d<D\), let \(d=d+1\), jump to step 7, otherwise jump to step 10. **Step 10:** Generate the path of this fruit fly \(path_{i}\) using Equations (31)-(33). Update smell concentration by the formula below  
\[smell^{(g)}_{\text{old},\ i}=J(pathi) \tag{37}\]  
where \(J\) is described in Equation (20). If \(i<M_{pop}/G\), then let \(i=i+1\), \(d=1\) and jump to step 7, otherwise jump to step 11. **Step 11:** Find out the old best in the \(g\)-th swarm (\(x^{(g),1}_{\text{oldbest}}\), \(y^{(g),1}_{\text{oldbest}}\)),..., (\(x^{(g),\ D}_{\text{oldbest}}\), \(y^{(g),\ D}_{\text{oldbest}}\)) using Equations (12) and (13). If \(g<G\), then let \(g=g+1\), \(d=1\), \(i=1\) and jump to step 7, otherwise jump to step 12. **Step 12:** Let \(g=1\), \(i=1\), \(d=1\). **Step 13:** Generate fruit fly in new swarms according to the equation below:  
\[ \begin{array}{l}X^{(g),\ d}_{\text{new},\ i}=core_{1}*x^{\text{random}(1,G), \ d}_{\text{oldbest}}+core_{2}*X^{(g),\ d}_{\text{$X^{(g),\ d}_{\text{new},\ i}$}}\\ Y^{(g),\ d}_{\text{new},\ i}=core_{1}*y^{\text{random}(1,G),\ d}_{\text{oldbest}}+core_{2}*Y^{(g),\ d}_{\text{$i$}}\end{array}  \tag{38}\]  
**Step 14:** Update the smell concentration judgement according to the equation below:  
\[S^{(g),\ d}_{\text{new},\ i}=\sqrt{\left(X^{(g),\ d}_{\text{new},\ i}\right)^{2 }+\left(Y^{(g),\ d}_{\text{new},\ i}\right)^{2}} \tag{39}\]  
if \(S^{(g),\ d}_{\text{new},\ i}\) is bigger than 1, jump to step 6, otherwise jump to step 8. **Step 15:** if \(d<D\), let \(d=d+1\), jump to step 13, otherwise jump to step 16. **Step 16:** Generate the path of this fruit fly \(path_{i}\) by using Equations (31)-(33). Update smell concentration by the equation below:  
\[s\mathit{mell}_{\text{new},\ i}^{(g)}=J(path_{i}) \tag{40}\]  
If \(i<M_{pop}/G\), then let \(i=i+1\), \(d=1\) and jump to step 13, otherwise jump to step 17. **Step 17:** Find out the index of new best in the \(g\)-th new swarm \(\mathit{Index}_{\text{new}}^{(g)}\) by Equation (17). **Step 18:** All the fruit flies in the \(g\)-th swarm fly to the location with the minimum smell concentration according to Equations (18) and (19). If \(g<G\), then let \(g=g+1\), \(d=1\), \(i=1\) and jump to step 13, otherwise jump to step 19. **Step 19:** If \(nc<NC\), let \(nc=nc+1\) and jump to step 5, otherwise jump to step 20. **Step 20:** If \(num<Num\), generate and output the path of the \(num\)-th UAV then let \(num=num+1\) and jump to step 5; otherwise, end and output the UAV paths.