# D2D-Assisted Adaptive Federated Learning in Energy-Constrained Edge Computing
## 4 Partite Graph-Based FL Scheme with Adaptive D2D Pairing and Aperiodic Local Iterations
Due to the difference in training time of these edge servers, the communication times between the edge servers and the relay server have no overlap, thereby reducing co-channel communication interference and improving transmission efficiency. The client servers in these \(J\) subsets are selected, based on priority, to train local models and aggregate parameters to relay servers. The priority of server \(n\) in FL round \(k\) is determined jointly by the server's remaining energy and its model training efficiency, which can be calculated as  
\[L(\omega_{n,k}^{\prime}|\mathcal{D}_{n,k},\tau_{n,k})\leq L(\omega_{n,k}| \mathcal{D}_{n,k},\tau_{n,k})+\bigtriangledown L(\omega_{n,k}|\mathcal{D}_{n, k},\tau_{n,k})(\omega_{n,k}^{\prime}-\omega_{n,k})+\frac{\zeta}{2}||\omega_{n,k}^{ \prime}-\omega_{n,k}||^{2}\enspace. \tag{13}\]1  
where \(\theta_{1}\) and \(\theta_{2}\) are positive coefficients. In order to normalize the priority, we put \(\{S_{1,k},S_{2,k},...,S_{N,k}\}\) into a softmax function to obtain the probability of each server being selected, which is depicted as  
\[L(\omega_{n,k}^{\prime}|\mathcal{D}_{n,k},\tau_{n,k})\leq L(\omega_{n,k}| \mathcal{D}_{n,k},\tau_{n,k})+\bigtriangledown L(\omega_{n,k}|\mathcal{D}_{n, k},\tau_{n,k})(\omega_{n,k}^{\prime}-\omega_{n,k})+\frac{\zeta}{2}||\omega_{n,k}^{ \prime}-\omega_{n,k}||^{2}\enspace. \tag{13}\]2  
The server with the highest probability will be selected first, which is denoted as \(n_{k}^{*}=\arg\max_{n}\{o_{1,k},o_{2,k},...,o_{N,k}\}\). Let \(\aleph_{n}\) represent the neighbor servers of server \(n\) in graph \(G_{f}\). The next server to be selected is the one with the highest probability belonging to \(\aleph_{n}\). This server selection process continues until the currently selected server has no available new neighbors. Then, these selected servers \(\{n_{k}^{*}\}\) train their local models, respectively, according to their specified number of iterations \(\{\tau_{n^{*},k}\}\), aggregate their local models on relay server \(m^{*}\), and, finally, all the relay severs distributed in \(Z_{1}\) clusters pass their model parameters to the aggregation server for one global aggregation, thereby completing the \(k\)th round of FL. As the remaining energy of the servers changes and the running time elapses, the total number of FL rounds \(K\) also changes. After the \(k\)th FL round is completed, the remaining FL round number is updated as  
\[L(\omega_{n,k}^{\prime}|\mathcal{D}_{n,k},\tau_{n,k})\leq L(\omega_{n,k}| \mathcal{D}_{n,k},\tau_{n,k})+\bigtriangledown L(\omega_{n,k}|\mathcal{D}_{n, k},\tau_{n,k})(\omega_{n,k}^{\prime}-\omega_{n,k})+\frac{\zeta}{2}||\omega_{n,k}^{ \prime}-\omega_{n,k}||^{2}\enspace. \tag{13}\]3  
In the \((k+1)\)th round, the number of iterative training of each server is redetermined, the relay servers and client servers are selected through the constructed partite graph, and the model parameters are aggregated again. The process iterates until the updated FL round reaches 0. The main steps of the proposed partite graph-based FL scheme are summarized as Algorithm 1.