## 3 Problem Formulation  
The primary objective of this work is to maximize the number of connected users while minimizing the total energy consumption of the UAV BS to prolong its flight time. In this regard, we aim to find the optimal position of the UAV BS and associate the ground users, which are normally out-of-service due to the congestion in the terrestrial network, to it so that the number of unconnected users are reduced; however, it is important to consider the total energy consumption of the UAV BS to maximize the service duration given they they are battery operated and have limited flight time. We also consider certain constraints, including the NFZs (e.g., the UAV BS cannot fly over those forbidden regions), the altitude regulations for UAVS, etc., thereby determining the optimal positioning of the UAV BS by taken into account both the requirements and constraints becomes a nontrivial objective. The number of connected users, \(n_{\rm c}\), can be controlled by the altitude of the UAV BS, \(h_{\rm d}\). Proof. : Let \(K\) be a rectangular prism with the base area of \(A_{K}=x_{K}y_{K}\), \(x_{K}\) and \(y_{K}\) are the \(x\) and \(y\) dimensions of the base of \(K\) that is placed on \(z=0\) plane. If we place the UAV BS--with a directivity angle of \(\theta\)--at any point inside \(K\), the radius of the footprint of the UAV BS can be calculated as follows [16]:  
\[R_{\rm d}=h_{\rm d}\tan\left(\frac{\theta}{2}\right), \tag{11}\]  
where \(h_{\rm d}\) is determined by  
\[h_{\rm d}=|\bar{\bf N}|, \tag{12}\]  
where \(|\bar{\bf N}|\) is the length of the normal vector, \(\bar{\bf N}\), from UAV BS to the \(z=0\) plane. Then, the footprint of the UAV BS can be found as  
\[A_{\rm d}=\pi R_{\rm d}^{2}. \tag{13}\]  
If a random point is selected on \(z=0\) plane, then the probability of falling inside the footprint of the UAV BS can be given as  
\[p_{\rm f}=\frac{A_{\rm d}}{A_{K}}=\frac{\pi R_{\rm d}^{2}}{x_{K}y_{K}}, \tag{14}\]  
where \(A_{K}\) is the base area of the rectangular prism \(K\). Let \(p_{\rm q}\) is the probability of receiving sufficient signal-to-noise ratio (SNR (It is worth noting that we assumed that the UAV BS is operating at an out-of-band spectrum, and thus it does not cause any interference to the terrestrial networks, or vice versa.)) for a UE, such that  
\[p_{\rm q}=P(S_{\rm r}\geq T_{\rm min}), \tag{15}\]  
where \(S_{\rm r}\) is the received SNR, while \(S_{\rm min}\) is the minimum required SNR value to establish a connection between the UAV BS and the UE. We assume the ground BS uses a different frequency band than the UAV BS, thereby it does not create any interference to the UAV BS. Therefore, SNR is a better choice here. Moreover, note that \(T_{\rm s}\) captures the receiver sensitivity of the user equipment (UE), and \(p_{\rm q}\) encompasses small-scale and large-scale fading effects. Therefore, for a UE, the probability of being served by the UAV BS can be determined as  
\[p_{\rm c}=p_{\rm f}p_{\rm q}p_{\rm r}, \tag{16}\]  
where \(p_{\rm r}\) is the probability of having enough resource for the UE at the UAV BS, such that \(p_{\rm r}=P(B_{\mathcal{L}}\geq B_{\mathcal{R}})\), where \(B_{\mathcal{L}}\) is the remaining radio resources at the UAV BS and \(B_{\mathcal{R}}\) is the required radio resources for the UE. By substituting (11), (13), and (14) into (16), we get:  
\[p_{\rm c}=p_{\rm q}p_{\rm r}\frac{\pi z_{\rm d}^{2}\tan^{2}\left(\frac{\theta} {2}\right)}{x_{\rm K}y_{\rm K}}. \tag{17}\]  
Hence, it is obvious from (17) that the probability of being served by the UAV is a function of the height of the UAV BS and they have a direct proportionality. **Theorem 2**: _The total energy consumption of the UAV BS, \(E_{T}\), can be controlled by the altitude of the UAV BS, \(h_{d}\)._  
Let \(E_{T}\) be the total energy consumption of the UAV BS, \(E_{C}\) be the communication energy, \(E_{M}\) be the energy consumption during the UAV mobility. Suppose UAV moves to the optimal position and attain optimal altitude to serve the ground users.