## 5 Contract-Based Energy-Efficient Resource Allocation for UAV-Assisted FL
### Problem Formulation  
Due to the use of landmark recognition as the VUs' local task, the classic MNIST dataset is used to fit the local training accuracy. According to the fitting of a large number of experimental results using the MNIST dataset, we can obtain the relationship between the accuracy of the VU's local model and the data size, as shown in Figure 3.  
Figure 3: Fitting of local data size and local model accuracy.  
In Figure 3, the x axis represents the data size of a VU, and the y axis represents the model accuracy of its local training. We define the local model accuracy as \(\eta_{j}^{loc},\eta_{j}^{loc}=0.32\ln(q_{j})-1.91\). According to [26], we represent \(I_{j}^{loc}=\alpha\log(\frac{1}{\eta_{j}^{loc}})\), where \(\alpha\) is the difficulty coefficient.  
According to the results of the contract during the incentive stage, the optimal data quantity for each VU is \(q_{j}\). By substituting \(q_{j}\) into the fitted formula, the local iterations for each VU can be obtained. Our optimization problem is the minimization of the total energy consumption of VUs, which is the sum of local training and model transmission energy consumption. The variables to be optimized are the CPU frequency \(f_{j}\) and transmission power \(p_{j}\). Based on the energy consumption defined in Equation (42), an optimization problem can be formulated as _P_**1**:  
\[\textbf{P1}: \min_{f_{j},p_{j}} \sum_{j=1}^{J}E_{j} \tag{45}\] \[s.t.\] \[I_{0}(\frac{s}{r_{j}}+I_{j}^{loc}\frac{\xi_{j}q_{j}}{f_{j}}) \leq\varepsilon_{j}^{{}^{\prime}}T_{sojurn}^{i,j},\forall j\in\mathcal{J}\] (45a) \[f_{j}^{min} <f_{j}\leq f_{j}^{max},\forall j\in\mathcal{J}\] (45b) \[p_{j}^{min} <p_{j}\leq p_{j}^{max},\forall j\in\mathcal{J} \tag{45c}\]  
Constraint (45a) restricts the training time of a VU within its sojourn time under the current UAV, where \(s\) means the model size needed to be transmitted. \(\varepsilon_{j}^{{}^{\prime}}\) corresponds to the degree of willingness in the contract. The higher the willingness of the VU to participate in training, the larger the value of \(\varepsilon_{j}^{{}^{\prime}}\). Here, we design a VU with a greater willingness to have a longer sojourn time for training. Constraints (45b) and (45c) set the ranges of the computation frequency and transmission power of each VU.  
In the contract, the greater the willingness to participate, the higher the data quantity allocated to the vehicle. Due to the constraint of sojourn time in constraint (45a), VUs with higher data quantities are more likely to use more computing and transmission resources to ensure that training can be completed within the time limit. Therefore, in the contract-based resource allocation problem designed, each optimization variable is mutually restrictive.  
Since several products in the objective function and constraint (45a) are not convex, _P_**1** is non-convex and thus can be difficult to solve. Consequently, we decompose this problem to make it solvable.  
We characterize _P_**1**'s solution by decomposing it into simpler sub-problems about variables \(f_{j}\) and \(p_{j}\), called _P_**2** and _P_**3**, respectively. If we fix a set of \(p\) first, the sub-problem _P_**2** is only about variable \(f_{j}\).  
\[\textbf{P2}: \min_{f_{j}}I_{0}\sum_{j=1}^{J}(I_{j}^{loc}\xi_{j}q_{j}f_{j}^{2}) \tag{46}\] \[s.t.I_{0}(\frac{s}{r_{j}}+I_{j}^{loc}\frac{\xi_{j}q_{j}}{f_{j}}) \leq\varepsilon_{j}^{{}^{\prime}}T_{sojurn}^{i,j},\forall j\in\mathcal{J}\] (46a) \[f_{j}^{min} <f_{j}\leq f_{j}^{max},\forall j\in\mathcal{J} \tag{46b}\]  
When \(f_{j}\) is solved and substituted into _P_**1**, the sub-problem _P_**3** becomes an optimization problem only related to variable \(p_{j}\).  
\[\mathbf{P3:} \min_{p_{j}}\,l_{0}\sum_{j=1}^{I}p_{j}\frac{s}{B\log_{2}(1+\frac{p_{ j}\delta j}{\mathrm{N}_{0}})}\] (47) s.t. \[l_{0}[\frac{s}{B\log_{2}(1+\frac{p_{j}\delta j}{\mathrm{N}_{0}})} +T_{j}^{train}]\leq\varepsilon_{j}T_{sojourn}^{i,j}\forall j\in\mathcal{J} \tag{47a}\] \[p_{j}^{min}<p_{j}\leq p_{j}^{max},\forall j\in\mathcal{J} \tag{47b}\]