# Dynamic Repositioning of Aerial Base Stations for Enhanced User Experience in 5G and Beyond
## 5 Solution Modeling  
The optimization problems posed in Sections 4.1 and 4.2 are 0-1 integer programming problems and computationally fall in the class of NP-complete problems. We used MATLAB's bintprog to solve these problems. The function [X Val] = bintprog (F, A, B, Aeq, Beq) produces a vector X whose entries are binary values and a variable \(\text{Val}=\text{F}^{\text{T}}\text{X}\), which is the value that is minimized; \(\text{F}^{\text{T}}\) represents the transpose of F. The arguments \(\text{A}_{\text{eq}}\) and \(\text{B}_{\text{eq}}\) are used for equality constraints such that \(\text{A}_{\text{eq}}\text{X}=\text{B}_{\text{eq}}\), whereas A and B are used for inequality constraints such that \(\text{A}\text{X}\leq\text{B}\). Aeq is a matrix whose number of rows should equal the number of equality constraints and whose columns should equal to the number of 0-1 variables. Based on the positions of users and candidate locations, applicable channel model, transmission power, etc., for each user, the RSSI from each candidate position is calculated and stored in an \(N_{s}\)-by-\(N_{l}\) matrix P, where \(P_{\text{ij}}\) represents the power received by user \(i\) from candidate location \(j\). For our problem of received power maximization defined in Section 4.1, \(\text{A}_{\text{eq}}\) is an \((N_{s}+1)\)-by-\((N_{s}+1)N_{l}\) matrix, whereas \(\text{B}_{\text{eq}}\) is an \((N_{s}+1)\)-by-1 vector. This means that there are \(N_{s}+1\) equality constraints. The first equality constraint ensures that exactly \(N_{u}\) UAVs (small cells are deployed and the remaining \(N_{s}\) constraints ensure that each user is assigned to exactly one candidate location. (Note that we ensure through inequality constraints that each user is assigned to a candidate location with a deployed small cell; we will discuss this shortly). F is an \((N_{s}+1)N_{l}\)-by-1 vector and is constructed such that the first \(N_{l}\) entries are set to zero and entries \(iN_{l}+1\) through \((i+1)N_{l}\) are set to the received powers of user \(i\) from all candidate locations: 1 through \(N_{l}\). Aeq is constructed as given in Algorithm 1. ```
Input: Number of users, \(N_{s}\) and Number of candidate positions, \(N_{l}\) Output: Matrix Aeq
```  
**for\(i=1\) upto\(N_{s}+1\) \(\text{A}_{\text{eq}}[i][(i-1)N_{l}+1:(i-1)N_{l}+N_{l}]=1\) end ```
**Algorithm 1**Construction of matrix Aeq for received power maximization  
The vector \(\text{B}_{\text{eq}}\) is constructed as \(\text{B}_{\text{eq}}=[N_{u}\text{O}]^{\text{T}}\), where \(N_{u}\) is the number of ABSs and O is row vector of size \(\text{N}_{s}\) and each of its entries is 1. Moreover, A is an \(N_{s}N_{l}\) by \((N_{s}+1)N_{l}\) matrix, whereas b is an \(N_{s}N_{l}\)-by-1 vector. Then, for the inequality constraint, the matrix is constructed as given in Algorithm 2. ``` Input: Number of users, \(N_{s}\) and Number of candidate positions, \(N_{l}\) Output: Matrix A ```
**Algorithm 2**Construction of matrix A for received power maximization  
B is an \(N_{s}N_{l}\)-by-1 column vector and is initialized to all zero entries; that is, \(\text{B}[1:N_{s}N_{l}]=0\). The matrix F is constructed as shown in Algorithm 3. ```
Input: Number of users, \(N_{s}\), Number of candidate positions, \(N_{l}\) and Matrix of received powers, P Output: Vector F
```
F[1:\(N_{l}\)] = 0 for\(i=1\) upto\(N_{s}\) F[\(N_{s}+1\): \((i+1)N_{s}\)] = P[\(i\)][:] end  F = F\({}^{\text{T}}\)
```
**Algorithm 3**Construction of vector F for received power maximization

For the problem of SIR optimization defined in Section 4.2, matrix \(\text{A}_{\text{eq}}\) is constructed as given in Algorithm 4. ```
Input: Number of users, \(N_{s}\) and Number of candidate positions, \(N_{l}\) Output: Matrix \(\text{A}_{\text{eq}}\)
```
**Algorithm 4**Construction of matrix \(\text{A}_{\text{eq}}\) for SIR maximization

Then, \(\text{B}_{\text{eq}}\) is constructed as \(\text{B}_{\text{eq}}=[N_{u}\text{ O }N_{u}\) (\(N_{u}-1\))O\(]^{\text{T}}\), where O is a row vector of size \(N_{s}\) containing all ones.