# 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
The time of each global round can be approximately obtained on the basis of \(T\). Since it only verifies the diversity of the data contained in both, the typical FedAvg algorithm in FL is used for training. As shown in Figure 3c, since the algorithm in [23] covers all users, so the convergence speed is faster than our proposed algorithm, but from the final convergence results, the final convergence accuracy of the two algorithms is only slightly different. However, our proposed algorithm can greatly reduce the total energy consumption of users under the condition of a lower required FL completion time. Therefore, the user data covered by our proposed algorithm basically contain all the data features of the overall dataset, if the user number is increased, the final learning performance will be little affected, but the total energy consumption of users will be increased. Through the above analysis, our proposed algorithm can not only guarantee the training performance but also reduce the total energy consumption of users under the condition of total completion time variation. Figure 4 a,b show the system cost and the overall energy consumption of users when the global model accuracy \(\varepsilon_{0}\) increases from 0.001 to 0.1, respectively, where the model size \(s\) is 50 kbit and total completion time \(T\) is 120. From Figure 4a,b, when the required global model accuracy decreases, the global rounds of users become less. Indirectly, the four algorithms' total cost function and the total energy consumption of users are decreased. When the global model accuracy changes to 0.05, the gap between the algorithm in [23] and our proposed algorithm is very small. This is because when the required global model accuracy is very small, users only need to train several rounds to reach the required accuracy, which reduces the users' total energy consumption. As a result, the UAV altitude optimized by our proposed algorithm is close to that of the algorithm in [23]. The total system cost and total energy consumption of algorithm FLA and FTT are also higher than our proposed algorithm. Based on previous analysis, because our proposed algorithm will have more users as the global model accuracy increases, so it only needs to compare the learning performance of our proposed algorithm and in [23], when the global model accuracy is 0.001. As shown in Figure 4c, our proposed algorithm covers enough diversity of user data, so the final test accuracy of the two is only slightly different. However, our proposed algorithm reduces the total energy consumption of users when the global accuracy is highly required. In addition, Figure 4c compared with Figure 3c, since \(T\) in Figure 4c is 120, our proposed algorithm covers more users than that in Figure 3c. Therefore, in the early stage of training, the convergence gap between our proposed algorithm and that in [23] is smaller than that in Figure 3c. Moreover, the convergence rate of our proposed algorithm is very close to the algorithm in [23]. This also verifies the conclusion that the more users, the faster the convergence speed, but this has little influence on the final convergence accuracy within the time expectation. In conclusion, our proposed algorithm can guarantee the training performance while reducing the total energy consumption of users under the condition of the global accuracy changes. Figure 5a,b show the system cost and the total energy consumption of users when the model size \(s\) increases from 30 kbit to 80 kbit, respectively, where the global model accuracy \(\varepsilon_{0}\) is 0.001 and total completion time \(T\) is 120. From the Figure 5a,b, as the model size increases, the users need more resources to transmit data, so the four algorithms' system cost and the total energy consumption of users are increased. Because the UAV altitude is not optimized in [23], as the model size increases, wireless resources' competition among users becomes more intense, resulting in a sharp rise in system cost and the total energy consumption of users.