# Unmanned Vehicles' Placement Optimisation for Internet of Things and Internet of Unmanned Vehicles
## 6 Proposed Algorithm: Communication Optimisation Integration
### Position Optimisation Algorithm  
The goal of the proposed placement optimisation algorithm consists of minimising the cost function \(f_{0}(\Delta,\chi)\) (Equation (28)). \[ \begin{split}\underset{\Delta_{j},\chi_{j}}{\text{minimise}}& f_{0}(\Delta,\chi)=\sum_{n=1}^{\text{v}n}a_{j}\Delta_{j}+b_{j}\chi_{j},\\ \text{subject to }w_{j,j+1}<1+\zeta\end{split}  \tag{28}\]  
where \(j\in\{1,\dots,N_{vn}\}\), \(\Delta=[\Delta_{j}]\) is the distance travelled by \(rn_{j}\) and \(\chi=[\chi_{j}]=\mid[h_{f}]-[h_{i}]\mid\) is the height offset, with \(h_{f}\) and \(h_{i}\) being the final and the initial height of \(rn_{j}\), respectively (only the UAV modifies its height). \(a_{j}\) and \(b_{j}\) are the distance weight and height weight, respectively. The optimisation problem implies a linear optimisation function with nonlinear constraints, representing a non-linear programming problem (NLP). Based on the characteristics of the propagation channels, the heights of the antennae and propagation loss, Algorithm 2 computes the latitude, longitude and elevation of the optimum positions. Therefore, the communication link is assured with minimum cost in UVs horizontal and/or vertical displacement. The algorithm uses an adaptive distance step, \(\Delta d\), to increase its performance and decrease its execution time when \(PL>LB\) and a fixed small step for (\(PL<LB-\Delta_{LB}\)) to avoid the significant changes of PL, which would especially afflict the communication \begin{table}
\begin{tabular}{c c c} \hline \(n_{UAV}+n_{USV}\) & \(d\) (km) & \(t\) (s) \\ \hline \multirow{2}{*}{3} & 1.0 & 0.0348 \\  & 1.5 & 0.0325 \\  & 2.0 & 0.0343 \\  & 1.5 & 0.0323 \\  & 2.0 & 0.0404 \\
10 & 5.0 & 0.0295 \\  & 8.0 & 0.0325 \\  & 2.0 & 0.0377 \\
20 & 5.0 & 0.0295 \\  & 8.0 & 0.0322 \\
52 & 2.0 & 0.0493 \\  & 5.0 & 0.0427 \\
100 & 2.0 & 0.1152 \\  & 5.0 & 0.1165 \\ \hline \end{tabular}
\end{table} 
Table 9: Path division algorithm results: execution time with respect to distance between GW and WSN and number of UVs. between USV and UAV or between USVs. The adaptive step is computed based on Equation (29). \[\Delta d=\rho d_{0i,j} \tag{29}\]  
where \(\rho\) represents the coefficient for adaptive distance and \(d_{0i,j}\) is the distance between node \(i\) and node \(j\) at the previous iteration. ```
0:\(n_{ULAV}\), \(n_{USV}\), \(N_{cm}\), \(N_{m}\) GPS coordinates; served WSN; \(h_{th}\) {Maximum allowed UAVs altitude}; \(h_{FSPL}\) {Minimum UAVs altitude to apply FSPL model};\(\beta h\) {Height step} \(LB\) {Link Budget}, \(\delta d\) {Distance step for \(PL<LB-\Delta_{LB}\)}, \(\Delta d\) {Adaptive distance step for \(PL>LB\)}, \(\rho\) {Coefficient for adaptive distance step \(\Delta d\)}. 0: Optimum latitude \(\phi_{opt,n_{i}}\), longitude \(\lambda_{opt,n_{i}}\), elevation \(\epsilon_{opt,n_{i}}\) for each UV
1: Initialize \(d_{th}\) {Maximum allowed distance offset}
2: Compute initial 2D and 3D distances between each node, \(d_{i,j}^{2D}\), \(d_{i,j}^{3D}\)
3: Assign path loss model based on the IDs and position parameters of each two nodes (A-G, A-W, A-A, W-G, W-W, G-G)
4: Compute initial path loss \(PL(n_{i},n_{j})\)
5: Generate path loss graph G(PL)
6:\(cr\gets n_{GW}\)
7:\(k\gets 0\)
8:while\(k\leq N_{vm}\) & \(P=\emptyset\)do
9:\(ek\gets 0\) {Height exponent}
10:\(t\gets 0\)
11:\(next\gets CN[k]\)
12:if\(next>n_{UAV}\)then
13:\(changed\gets 0\) {USVs cannot change antenna height}
14:else
15:\(changed\gets 1\)
16:endif
17:\(im\gets 1\)
```  
**Algorithm 2** Path loss-based placement optimisation algorithm  
**Input:**\(n_{ULAV}\), \(n_{USV}\), \(N_{cm}\), \(N_{m}\) GPS coordinates; served WSN; \(h_{th}\) {Maximum allowed UAVs altitude}; \(h_{FSPL}\) {Minimum UAVs altitude to apply FSPL model};\(\beta h\) {Height step} \(LB\) {Link Budget}, \(\delta d\) {Distance step for \(PL<LB-\Delta_{LB}\)}, \(\Delta d\) {Adaptive distance step for \(PL>LB\)}, \(\rho\) {Coefficient for adaptive distance step \(\Delta d\)}.