# D2D-Assisted Adaptive Federated Learning in Energy-Constrained Edge Computing
## 4 Partite Graph-Based FL Scheme with Adaptive D2D Pairing and Aperiodic Local Iterations
Since the number of FL aggregation rounds affects the values of \(\tau_{n,1}\) and \(\Delta\), we use an iterative optimization approach to update it. The initial value of the aggregation round \(K\) is calculated as  
\[K=\frac{T^{max}-\max\{E_{n}^{max}/e_{n}t_{n}|D_{n,k}|^{2}\}}{C_{n}/r_{n,0}}. \tag{19}\]  
Considering that these client servers may have different iteration times and computing energy consumption in each round of FL aggregation, we select the servers with sufficient energy surplus as the relay nodes in the D2D pairs. Moreover, in order to aggregate as many local models trained by client servers as possible under the condition of limited communication channels, it is also necessary to optimize the organization of D2D pairs and schedule the delivery time of non-relay nodes to relay nodes to support the concurrent communication of multiple D2D pairs while improving spectrum efficiency. Thus, based on the obtained iteration numbers of these client servers, we propose a partite graph-based D2D pairing scheme, as follows. First, the client servers are divided into \(Z_{1}\) clusters through a voting approach. Here, \(z_{1}\) is the maximum number of channels used by the client servers to directly deliver local model parameters to the aggregation server, and \(Z_{1}\) limits the number of relay nodes working in parallel. For a given server \(n\) in FL round \(k\), we calculate the energy cost of delivering its local model parameters to the aggregation server with the relay help of another server \(m\), where \(n,m\in\mathcal{N}\) and \(n\
eq m\). The relay node with the smallest energy consumption is recorded as \(m^{*}\). If  
\[E_{n,m^{*},k}^{\text{del}}+E_{m^{*},0,k}^{\text{del}}<E_{n,0,k}^{\text{del}}, \tag{20}\]  
then cast one vote for relay node \(m^{*}\); otherwise, no vote will be taken. After traversing all server nodes and completing the voting, we select the \(z_{1}\) nodes with the highest votes as relay servers and divide the client servers that voted for the same relay server into a cluster. For the other servers that did not vote or had lower votes we choose the relay server with the lowest energy consumption to join the corresponding cluster. Next, we build a complete \(J\)-partite graph within each cluster. Let \(G_{f}(V_{f},E_{f})\) denote this graph, where \(V_{f}\) represents the set of vertices consisting of the servers in the cluster and \(E_{f}\) is the set of edges connecting these nodes. Take any two vertices \(n\) and \(n^{\prime}\) from \(V_{f}\), and if  
\[\min\left\{T_{n,k}^{\text{tra}}+\frac{C_{n}}{r_{n,m^{*}}}-T_{n^{\prime},k^{ \prime}}^{\text{tra}},T_{n^{\prime},k}^{\text{tra}}+\frac{C_{n^{\prime}}}{r_{n^ {\prime},m^{*}}}-T_{n,k}^{\text{tra}}\right\}\leq 0, \tag{21}\]  
then connect \(n\) and \(n^{\prime}\) to form an edge. Then, divide the vertices in \(G_{f}(V_{f},E_{f})\) into \(J\) disjoint subsets to form a complete \(J\)-partite graph. In this graph, no two graph vertices within the same set are adjacent but there are edges between vertices that belong to different subsets. The divided subsets satisfy a sequential relationship, in terms of time cost; that is, the sum of the maximum training time of the servers in subset \(J_{i}\) and the time of transmission to the aggregation server should be no more than the minimum training time of the servers in subset \(J_{j}\), where \(i,j\in\mathcal{J}\) and \(i<j\). This relationship can be represented 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}\]0  
By dividing such \(J\) subsets, client servers with similar model training times belong to the same subset, while server training times in different sets have a sequential relationship. In each round of FL, an edge server can be selected from each subset to aggregate to the relay server in graph \(G_{f}(V_{f},E_{f})\).