# Joint Resource Allocation and Learning Optimization for UAV-Assisted Federated Learning
## 3 Joint Optimization Algorithm
### Subproblem 3: User Computation and Communication Resources
#### 3.3.2 Subproblem 3-1: \(\mathbf{b}\) Optimization Problem
In our simulations, we deploy \(N=20\) users uniformly in a square area of size 250 m \(\times\) 250 m. In addition, the data distribution among users is non-IID, we used the MNIST dataset that consists of handwritten numbers \"0\" through \"9\" to train the neural network, and a total of 60,000 labeled training data samples. For data distribution processing between users, we first sorted all data samples by their digit labels, divided them into 200 shards of size 300, and then assigned each user with eight shards. So, each user obtains the data samples with no more than eight types of digits, with a total size of 2400. Other simulation parameters are shown in Table 2.

Next, we compared the algorithm proposed in this paper with three algorithms, including: (1) the algorithm in [23] (UAV altitude fixed). In [23], the UAV altitude is the highest, that is, all users in the UAV-covered area; (2) The baseline algorithm that does not optimize local accuracy \(\eta\) is called the FLA in this paper, where the local accuracy is fixed; (3) The baseline algorithm that does not optimize the transmission time is called FTT in this paper, where the transmission time is fixed. Figure 2(a),b show the system cost and the overall energy consumption of users when the required FL completion time \(T\) increases from 100 to 200, respectively, where the model size \(s\) is 50 kbit and the global accuracy \(\varepsilon_{0}\) is 0.001. As the required FL completion time \(T\) increases, so the four algorithms show a downward trend as users have more time to train \begin{table}
\begin{tabular}{c c} \hline \hline
**Parameter** & **Value** \\ \hline Maximum Bandwidth of UAV \(B\) & 1 MHz \\ Maximum Transmission Power \(p^{\max}\) & 10 mW \\ Maximum Calculated Frequency \(f^{\max}\) & 2 GHz \\ CPU of User \(C_{n}\) & \([1,3]\times 10^{4}\) cycle/sample \\ Noise PowerSpect Density \(N_{0}\) & \(-174\) dBm/Hz \\ User Dataset Size \(D_{n}\) & 2400 \\ Effective Switched Capacitance \(\kappa\) & \(10^{-28}\) \\ Loss Function Parameters & \(\gamma=2\), \(L=2\), \(\delta=1/4\), \(\xi=1/3\) \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Simulation Parameters. and upload, which reduces the resource competition among users. When \(T\) is small, the UAV in [23] is a fixed height, and as the UAV altitude is not optimized, so the total system cost and the total energy consumption of users are very high. Because the algorithm FLA does not optimize the local accuracy and the algorithm FTT does not optimize the transmission time, the system total cost and the total energy consumption of users are higher than our proposed algorithm. In Figure 3b, with the required FL completion time \(T\) increases, the total energy consumption of users decreases, and the learning performance plays a dominant role at this time. Therefore, the altitude of the UAV is increased, and the coverage area is expanded to reduce the cost of learning, thus the number of users participating in learning is increased. Therefore, as the required FL completion time increases, the number of participating users increases and the total energy consumption of users decreases. When the number of participants increases to a certain level, the diversity of the user dataset participating in learning is sufficient. If the number of users is increased on this basis, the effect of learning improvement is not obvious, but will occupy wireless resources and the use energy consumption will rise sharply. From the above analysis, our proposed algorithm has the fewest users participating in learning when \(T\) is 100, it only needs to compare the learning performance of our proposed algorithm and that in [23]. Figure 3: Total Completion Time Influence on Performance: (**a**) total system cost; (**b**) total energy consumption of users; (**c**) learning performance. When \(T\) is 100, we can obtain the global rounds and local update rounds of the two algorithms according to the optimal local accuracy and preset global accuracy.