# A Service-Constrained Positioning Strategy for an Autonomous Fleet of Airborne Base Stations
## 4 Positioning and Communication for a Fleet of UAVs
### Derivation of the UAV Trajectories
#### 4.2.1 Gradient of the Cost Function  
Regarding the increase of the cost function, the region with the lowest average rate per user has to be identified and then its rate should be increased, which requires, first, to identify which are the UAVs to be moved and, second, to calculate the optimum movements of these UAVs.  
Regarding the first step, the UAVs that have to be moved are those that affect the lowest \(\overline{R}\). Observing Equation (22), it is clear that there are two different ways of modifying it. Let us assume that the UAV providing the lowest \(\overline{R}\) is \(i_{0}\) (i.e., \(\left.\overline{R}\big{|}_{A_{i_{0}}}\leq\left.\overline{R}\big{|}_{A_{i}} \right.,\quad\forall i\
eq i_{0}\)). Then, the UAVs whose positions affect \(\left.\overline{R}\big{|}_{A_{i_{0}}}\right.\) are the \(i_{0}\)th UAV (that has an impact on the UAV-user distance, the orientation of the antenna, the fading probabilities and the boundary of the region \(A_{i_{0}}\)) and the neighboring UAVs (that only affect the boundary of the region \(A_{i_{0}}\)).  
As to the second step, the movement of the selected UAVs can be computed through a gradient ascent optimization:  
\[\mathbf{v}[n+1]=\mathbf{v}[n]+\mu\cdot\
abla_{\mathbf{v}}\left(\left.\overline{ R}\big{|}_{A_{i_{0}}}\right)[n], \tag{26}\]  
where \(\mu\) is the step size, \(n\) is the iteration index and \(\mathbf{v}\) is a vector with the positions of all the UAVs and the bandwidths of their individual backhaul links:  
\[\mathbf{v}=\begin{bmatrix}x_{1}&y_{1}&h_{1}&B_{1}^{BH}&...&x_{P}&y_{P}&h_{P}&B_ {P}^{BH}\end{bmatrix}^{T}, \tag{27}\]  
where the superscript \(T\) stands for transpose.  
However, as the gradient has non-zero values only in the entries that belong to the positions of the UAV servicing \(A_{i_{0}}\) and its neighbors, the gradients for the other entries of \(\mathbf{v}\) (that is, the positions of the other UAVs and all the backhaul bandwidths) do not need to be computed.  
One of the issues is that a closed form expression of the gradient cannot be found since the boundaries between regions cannot be expressed analytically. Thus, a numerical estimation of the gradient is needed. In this paper, we propose to do it in two stages. First, for each coordinate in vector \(\mathbf{v}\) corresponding to a \((x_{i},y_{i},h_{i})\) triplet for which the movement of the \(i\)th UAV implies a variation of the cost function, we assume a virtual movement of that UAV in a given direction. Thus, the UAV is not physically moved but a subsequent variation of the average rate per user can be computed using Equation (22) and a UAV test displacement \(\triangle\). Then, to estimate the gradient of the \(j\)th component of vector \(\mathbf{v}\), the resulting variation of the average rate per user is divided by \(\triangle\):  
\[v_{j}[n+1]=v_{j}[n]+\mu\cdot\frac{\left(\left.\overline{R}\right|_{A_{i_{0}}} \right)\bigg{|}_{v_{j}[n]+\triangle}-\left.\left(\left.\overline{R}\right|_{A _{i_{0}}}\right)\bigg{|}_{v_{j}[n]}}{\triangle}, \tag{28}\]  
for all \(j\) entries with a non-zero gradient.  
Moreover, to obtain realistic results, the displacements per iteration (that is, \(v_{j}[n+1]-v_{j}[n]\) in Equation (28)) are limited by the maximum velocities that a UAV can achieve. These maximum velocities are characteristics obtained from the specifications of the UAV manufacturer and they are the forward (\(V_{F}^{Max}\)) and the vertical, within positive (\(V_{V}^{Max}\)) and negative (\(V_{V}^{Min}\)), velocities. If we denote by \(T_{it}\) the time interval associated to each iteration, then the maximum velocity is translated into a maximum displacement constraint given by \(V^{Max}\cdot T_{it}\). In other words, if the displacement calculated by the application of the gradient \(v_{j}[n+1]-v_{j}[n]\) exceeds this maximum value, then it is limited to the maximum value.