# Joint Resource Allocation and Learning Optimization for UAV-Assisted Federated Learning
## 2 System Model and Problem Formulation
### Problem Formulation  
The battery capacity of the users is limited, and the energy consumption of users directly affects the users' experience. Therefore, this paper defines the total energy consumption of users as a part of the cost function. Because the performance of FL is related to the number of users participating, the more users participating, the faster the speed of FL convergence; meanwhile, the more data diversity of users participating in FL, the stronger the generalization ability of the model. Therefore, the reciprocal of the number of users participating in FL is defined as another part of the cost function, representing the performance of federated learning. So as to achieve a balance between the total energy consumption of users and the FL performance, the total cost function is defined as  
\[C=E_{total}+\rho\frac{1}{N_{m}} \tag{12}\]  
where \(N_{m}\) is number of users participating in FL and \(\rho\) is a weight coefficient.  
Therefore, to achieve the balance between the total energy consumption and FL performance, the objective of this paper is to minimize the total cost function by jointly optimizing the UAV \(m\) position (horizontal placement \(\mathbf{q}_{m}=\{x,y\}\), altitude \(h\)), user computation frequency \(\mathbf{f}=[f_{1},\cdots f_{N_{m}}]\), transmission power \(\mathbf{p}=[p_{1},\cdots p_{N_{m}}]\), transmission bandwidth\(\mathbf{b}=[b_{1},\cdots b_{N_{m}}]\), transmission time \(\mathbf{t}=[t_{1}\cdots t_{N_{m}}]\) and local accuracy \(\eta\) within a given total FL completion time budget. The optimization problem can be expressed as  
\[\begin{array}{ll}\text{P1}:&\underset{\mathbf{q}_{m},\ h,\ \mathbf{f},\ \mathbf{t},\ \mathbf{p},\ \mathbf{b},\ \eta}{\text{min}}\left(\sum\limits_{i \in\mathcal{N}_{m}}^{|\mathcal{N}_{m}|}\log\left(\frac{1}{\eta}\right)\varphi C _{i}D_{i}f_{i}^{2}+t_{i}p_{i}\right)+\frac{\rho}{N_{m}}\\ &\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}:I_{g}\left(t_{i}+l_{i}\frac{C_{i}D_{i}}{f_{i}}\right)\leq T,\forall i \in\mathcal{N}_{m}\\ &\text{C4}:t_{i}\geq\frac{s}{b_{i}\log_{2}\left(1+\frac{P_{i}B_{i}}{P_{i}N_{ 0}}\right)},\forall i\in\mathcal{N}_{m}\\ &\text{C5}:\|\mathbf{q}_{m}-\mathbf{q}_{i}\|_{2}^{2}\leq r^{2},\forall i\in \mathcal{N}_{m},\\ &\text{C6}:h^{\min}\leq h\leq h^{\max}\\ &\text{C7}:\sum\limits_{i\in\mathcal{N}_{m}}^{|\mathcal{N}_{m}|}b_{i}\leq B,b _{i}>0,\forall i\in\mathcal{N}_{m}\\ &\text{C8}:0\leq\eta\leq 1\end{array} \tag{13}\]  
where \(a=\frac{2t^{2}}{\gamma^{2}\zeta}\log\frac{1}{\epsilon_{0}}\), \(v=\frac{2}{(2-L)\delta\gamma}\) are constants. Constraints C1 and C2 indicate constraints on the computation frequency and transmission power. Constraint C3 indicates that the total latency of users participating in FL cannot exceed the preset maximum. Constraint C4 is the constraint on transmission delay, that is, the transmission of the model must be completed within the specified transmission time. Constraint C5 represents the position constraint of the UAV. The distance between the user and the UAV should not exceed the coverage range of the UAV. Constraint C6 restricts the flying altitude range of the UAV. If the altitude is too low, there will be too few users to participate; however, if the altitude is too high, the competition for wireless resources will be fierce, leading to an increase in users' energy consumption, and both of them will slow down the convergence rate of FL. Constraint C7 represents that the total bandwidth allocated to all users within the UAV's coverage range cannot exceed the preset total bandwidth \(B\). Constraint C8 specifies the constraint range of local accuracy.