## 4 Simulation Results
Compared with Algorithm 1, the benchmark Algorithm 2 indicates the impact of UAV location optimization, while Algorithm 3 reflects the effect of caching optimization. The two benchmark algorithms are outlined in Algorithms 2 and 3. ```
Initialization:
1. Set user positions \(\mathbf{u}\) and connection relationship \(q_{ij}\). Set \(\mathbf{v}\) to the average of connected users' positions. Calculate \(\mathbf{h}_{ij}^{*}\) from \(\mathbf{u}\) and \(\mathbf{v}\). 2. Set the iteration number \(\ell=0\), and initialize start values of \(\mathbf{w}^{[\ell]}\) and \(\mathbf{z}^{[\ell]}\). Repeat:
3. Solve problem (32) to obtain the optimal solutions \(\mathbf{w}^{*}\). 4. Solve problem (31) to obtain the optimal solution \(\mathbf{z}^{*}\). 5. \(\ell=\ell+1\). 6. \(\mathbf{w}^{[\ell]}=\mathbf{w}^{*}\), \(\mathbf{z}^{[\ell]}=\mathbf{z}^{*}\). Until convergence of the objective function in (32). 7. Output \(\mathbf{w}^{[\ell]}\) and \(\mathbf{z}^{[\ell]}\) as the optimal solution. ```  
**Algorithm 2**The beamforming and caching iterative optimization algorithm. ```
Initial:
1. Set user positions \(\mathbf{u}\) and connection relationship \(q_{ij}\). Set every elements of \(\mathbf{z}\) to \(\frac{r_{cc}}{M}\). 2. Set the iteration number \(\ell=0\), and initialize start values of \(\mathbf{w}^{[\ell]}\), \(\mathbf{v}^{[\ell]}\). Calculate \(\boldsymbol{\theta}^{[\ell]}\) from \(\mathbf{v}^{[\ell]}\) and \(\mathbf{u}\). Repeat:
3. Solve problem (30) to obtain the optimal solutions \(\mathbf{w}^{*}\), \(\mathbf{v}^{*}\). Calculate \(\boldsymbol{\theta}^{*}\) from \(\mathbf{v}^{*}\) and \(\mathbf{u}\). 4. \(\ell=\ell+1\). 5. \(\mathbf{w}^{[\ell]}=\mathbf{w}^{*}\), \(\mathbf{v}^{[\ell]}=\mathbf{v}^{*}\). Until convergence of the objective function in (30). 6. Output \(\mathbf{w}^{[\ell]}\) and \(\mathbf{v}^{[\ell]}\) as the optimal solution. ```  
**Algorithm 3**The joint beamforming and location optimization algorithm. Firstly, we observe the impact of the UAV capacity coefficient \(r_{cc}\) on the system latency. We set the Zipf parameter \(\alpha=0.5\). As it is shown in Figure 2, the latency performance of the proposed algorithm is better than those of the two benchmark algorithms. The delay decreases with the increase in UAV coefficient, which means expanding the cache capacity of UAVs would achieve a higher network efficiency. And, note that the average transmission latency of Algorithm 3 gets closer and closer to that of proposed Algorithm 1, while \(r_{cc}\) changes from 0.7 to 1. When \(r_{cc}=1\), the latency of Algorithm 3 is almost the same as that of Algorithm 1 because if \(r_{cc}\geq 1\), which means UAVs obtain enough capacity to cache all the contents, users do not need to request content from MBS. In this case, the content placement in UAVs has little impact on the average transmission latency. Then, in Figure 3, we consider the impact of Zipf parameter \(\alpha\). The UAV capacity coefficient is set as \(r_{cc}=0.8\). We increase \(\alpha\) from 0.3 to 1, and it is observed that the latency of Algorithm 1 is decreased. Predictably, the performance of Algorithm 2 is relatively poor compared with Algorithm 1, and the trend of its curve is consistent with that of Algorithm 1. Note that the performance of Algorithm 3 is much worse and that the trend of its curve is different from those of Algorithms 1 and 2. Via an analysis, the reason behind the difference is whether the caching strategy is optimized. Content placement is fixed in Algorithm 3, and the trend of its curve is related to the sizes of the files. The latency of Algorithm 3 is directly proportional to the expectation of the content size. If the size of content with a high popularity is relatively larger, the expectation of the content size will increase with  
Figure 2: The latency performance versus UAV capacity coefficient. the increase in the Zipf parameter; otherwise, the opposite happens.