# Joint Resource Allocation and Learning Optimization for UAV-Assisted Federated Learning
## 3 Joint Optimization Algorithm
### Subproblem 3: User Computation and Communication Resources
#### 3.3.1 Subproblem 3-1: **f**, **t**, **p** Optimization Problem  
When **b** is determined, the **f**, **t**, **p** optimization problem can be expressed as  
\[ \begin{array}{ll}\text{P7-1}:&\min\limits_{\textbf{f},\textbf{t},\textbf{p}} \frac{a}{(1-\eta)}\sum\limits_{i\in\mathcal{N}_{m}}^{|\mathcal{N}_{m}|}\Big{(} \upsilon\log\Big{(}\frac{1}{\eta}\Big{)}C_{i}D_{i}f_{i}^{2}+p_{i}t_{i}\Big{)}\\ &\text{s.t.}\ \text{C1}:0\leq f_{i}\leq f_{i}^{\max},\forall i\in\mathcal{N}_{m}\\ &\text{C2}:0\leq p_{i}\leq p_{i}^{\max},\forall i\in\mathcal{N}_{m}\\ &\text{C3}:l_{g}\Big{(}t_{i}+l_{i}\frac{C_{i}D_{i}}{f_{i}}\Big{)}\leq T,\forall i \in\mathcal{N}_{m}\\ &\text{C4}:t_{i}p_{i}\log_{2}\Big{(}1+\frac{p_{i}g_{i}}{f_{i}N_{0}}\Big{)} \geq s,\forall i\in\mathcal{N}_{m}\end{array}  \tag{24}\]  
According to constraint C3, we obtain \(f_{i}\geq\frac{l_{i}C_{i}D_{i}}{\frac{l}{l_{g}}-t_{i}}\), since the higher the frequency \(f\), the greater the training energy consumption, so we set \(f_{i}=\frac{l_{i}C_{i}D_{i}}{\frac{l}{l_{g}}-t_{i}}\). According to constraint C4, we obtain \(p_{i}\geq\frac{N_{0}b_{i}}{g_{i}}\Big{(}2^{\frac{s}{l_{i}}}-1\Big{)}\), so we set \(p_{i}=\frac{N_{0}b_{i}}{g_{i}}\Big{(}2^{\frac{s}{l_{i}}}-1\Big{)}\). We substitute \(f_{i}=\frac{l_{i}C_{i}D_{i}}{\frac{l}{l_{g}}-t_{i}}\) and \(p_{i}=\frac{N_{0}b_{i}}{g_{i}}\Big{(}2^{\frac{s}{l_{i}}}-1\Big{)}\) into (23), and the P7-1 problem is transformed into:  
\[ \begin{array}{ll}\text{P8}:&\min\limits_{\textbf{f},\textbf{t},\textbf{p}} \frac{a}{(1-\eta)}\sum\limits_{i\in\mathcal{N}_{m}}^{|\mathcal{N}_{m}|}\bigg{(} \upsilon\log\Big{(}\frac{1}{\eta}\Big{)}C_{i}D_{i}\bigg{(}\frac{l_{i}C_{i}D_{ i}}{\frac{l}{l_{g}}-t_{i}^{2}}\bigg{)}^{2}+\frac{N_{0}b_{i}}{g_{i}}\Big{(}2^{ \frac{s}{l_{i}}}-1\Big{)}t_{i}^{*}\bigg{)}\\ &\text{s.t.}\ \text{C1}:0\leq\frac{l_{i}C_{i}D_{i}}{\frac{l}{l_{g}}-t_{i}}\leq f_{i}^{ \max},\forall i\in\mathcal{N}_{m}\\ &\text{C2}:0\leq\frac{N_{0}b_{i}}{g_{i}}\Big{(}2^{\frac{s}{l_{i}}}-1\Big{)} \leq p_{i}^{\max},\forall i\in\mathcal{N}_{m}\end{array}  \tag{25}\]  
According to constraints C1 and C2, we can obtain the maximum and minimum values of \(t_{i}\), so the P8 problem is further converted the P9 problem:  
\[ \begin{array}{ll}\text{P9}:&\min\limits_{\textbf{t}}\frac{a}{(1-\eta)}\sum \limits_{i\in\mathcal{N}_{m}}^{|\mathcal{N}_{m}|}\bigg{(}\upsilon\log\Big{(} \frac{1}{\eta}\Big{)}C_{i}D_{i}\bigg{(}\frac{l_{i}C_{i}D_{i}}{\frac{l}{l_{g}}- t_{i}}\bigg{)}^{2}+\frac{N_{0}b_{i}}{g_{i}}\Big{(}2^{\frac{s}{l_{i}}}-1\Big{)}t_{i} \bigg{)}\\ &\text{s.t.}\ \text{C1}:t_{i}^{\min}\leq t_{i}\leq t_{i}^{\max},\forall i\in \mathcal{N}_{m}\end{array}  \tag{26}\]  
For the P9 problem, when \(t_{i}\) satisfies \(\left|\partial E_{n}^{comp}/\partial t_{n}\right|=\left|\partial E_{n}^{comm}/ \partial t_{n}\right|\), we can obtain the optimal solution \(t_{i}\), and further obtain \(f_{i}^{*}\) and \(p_{i}^{*}\). **Proof:** The training energy consumption and communication energy consumption of user \(n\) in each global round separately are:  
\[E_{n}^{comp}=\kappa l_{i}C_{n}D_{n}f_{n}^{2}=\kappa l_{i}C_{n}D_{n}\left(\frac {l_{i}C_{n}D_{n}}{\frac{l}{l_{g}}-t_{n}}\right)^{2} \tag{27}\]  
\[E_{n}^{comm}=p_{n}t_{n}=\frac{N_{0}b_{n}}{g_{n}}\Big{(}2^{\frac{s}{l_{n}b_{n}}} -1\Big{)}t_{n} \tag{28}\]  
Equation (27) differentiates the transmission time \(t_{n}\) to obtain:  
\[\frac{\partial E_{n}^{comp}}{\partial t_{n}}=2l_{i}^{3}\kappa C_{n}{}^{3}D_{n}{} ^{3}\bigg{(}\frac{T}{l_{g}}-t_{n}\bigg{)}^{-3}\geq 0 \tag{29}\]  
so the training energy consumption \(E_{n}^{comp}\) is an increasing function of \(t_{n}\).