# Joint Resource Allocation and Learning Optimization for UAV-Assisted Federated Learning
## 3 Joint Optimization Algorithm
### Subproblem 1: UAV Horizontal Placement  
When \(h\), \(\mathbf{f}\), \(\mathbf{t}\), \(\mathbf{p}\), \(\mathbf{b}\), \(\eta\) are determined, since the optimization of UAV horizontal placement only affects the transmission energy consumption of users, we formulated the P2 problem  
\[ \begin{array}{ll}\text{P2}:&\underset{\mathbf{q}_{m}}{\min}\sum\limits_{i \in\mathcal{N}_{m}}^{|\mathcal{N}_{m}|}p_{i}\frac{s}{K_{i}}\\ &\text{s.t.}\ \text{C1}:t_{i}\geq\frac{s}{K_{i}},\forall i\in\mathcal{N}_{m} \\ &\text{C2}:\|\mathbf{q}_{m}-\mathbf{q}_{i}\|_{2}^{2}\leq r^{2},\forall i\in \mathcal{N}_{m}\end{array}  \tag{14}\]Because P2 is a non-convex problem, it is difficult to solve it directly, so we introduced slack variables \(\beta\), and converted it to the P3 problem. \[ \begin{split}\text{P3}:&\min\limits_{\mathbf{q}_{m},\mathbf{\beta}_{i}\in\mathcal{N}_{m}}^{|\mathcal{N}_{m}|}p_{i}\mathbf{\beta} _{i}\\ &\text{s.t.}\ \text{C1}:\mathbf{\text{$s$}}\beta_{i}\leq t_{i}, \forall i\in\mathcal{N}_{m}\\ &\qquad\qquad\text{C2}:b_{i}\log_{2}\left(1+\frac{p_{i}\mathbf{ \beta}_{0}}{b_{i}N_{0}\left(\|\mathbf{q}_{m}-\mathbf{q}_{i}\|_{2}^{2}+h^{2} \right)}\right)\geq\frac{1}{\beta_{i}},\forall i\in\mathcal{N}_{m}\\ &\qquad\qquad\text{C3}:\|\mathbf{q}_{m}-\mathbf{q}_{i}\|_{2}^{2} \leq r^{2},\forall i\in\mathcal{N}_{m}\end{split}  \tag{15}\]  
Since constraint C2 in P3 is not convex, so we introduced a variable \(S_{m,i}=\|\mathbf{q}_{m}-\mathbf{q}_{i}\|_{2}^{2}\), and made the constraints C2 at the feasible solution \(S_{m,i}^{0}=\left\|\mathbf{q}_{m}^{0}-\mathbf{q}_{i}\right\|_{2}^{2}\) use a first-order Taylor expansion. Figure 2: The interactions and dependency relationships among algorithms. \[b_{i}\log_{2}\left(1+\frac{p_{i}g_{0}}{b_{i}N_{0}\left(5_{m,i}+h^{2} \right)}\right)\geq\lambda\left(S_{m,i}-S_{m,i}^{0}\right)+\kappa \tag{16}\] \[\lambda=-\frac{b_{i}g_{0}p_{i}\log_{2}(e)}{N_{0}b_{i}\left(5_{m,i} ^{0}+h^{2}\right)\left(S_{m,i}^{0}+h^{2}+\frac{g_{0}p_{i}}{N_{0}b_{i}}\right)}\] (17) \[\kappa=b_{i}\log_{2}\left(1+\frac{g_{0}p_{i}}{N_{0}b_{i}\left(S_{ m,i}^{0}+h^{2}\right)}\right) \tag{18}\]  
where \(\lambda\), \(\kappa\) are intermediate variables. Equation (16) is substituted into (15), and then the P3 optimization problem is transformed into the P4 problem  
\[ \begin{array}{rl}\text{P4}:&\min\limits_{\mathbf{q}_{m},\mathbf{\Psi}_{i} \in\mathcal{N}_{m}}^{|\mathcal{N}_{m}|}p_{i}\mathbf{\mathbf{\mathbf{\mathbf{ \mathbf{\mathbf{\mathbf{\mathbf{\mathbf{\mathbf{\mathbf{\mathbf{\mathbf{\mathbf{\mathbf{\mathbf{ \mathbf{\mathbf{\mathbf{\mathbf{\mathbf{\mathbf{    }}}}}}}}}}}}}}\beta_{i}\\ &\text{s.t.~{}\text{C1}:&\mathbf{s}\beta_{i}\leq t_{i},\forall i\in\mathcal{N} _{m}\\ &\text{C2}:&\lambda\left(S_{m,i}-S_{m,i}^{0}\right)+\kappa\geq\frac{1}{\beta_ {i}},\forall i\in\mathcal{N}_{m}\\ &\text{C3}:&\left\|\mathbf{q}_{m}-\mathbf{q}_{i}\right\|_{2}^{2}\leq r^{2}, \forall i\in\mathcal{N}_{m}\end{array}  \tag{19}\]  
In this case, the P4 problem becomes a convex problem and can be settled by the successive convex approximation (SCA) technique. When the UAV arrives at the new placement, the UAV coverage placement will be changed. Due to the C2 constraint, the original users are still within the scope of the UAV, but new users may join. At this time, the values of each variable are reinitialized and the algorithm is reiterated. The details are shown in Algorithm 1.