# D2D-Assisted Adaptive Federated Learning in Energy-Constrained Edge Computing
## 4 Partite Graph-Based FL Scheme with Adaptive D2D Pairing and Aperiodic Local Iterations  
As (11) is an integer programing problem, it is proved to be NP-complete. To address problem (11), in this section, we leverage the graph theoretic approach, and we propose a partite graph-based FL scheme, which minimizes the learning loss function through adjusting D2D pairing and agent local iterations. Since the energy budget of edge servers is limited, how to improve learning efficiency under energy constraints has become a key issue in FL scheme design. In a traditional FL mechanism, the edge servers as learning clients always perform fixed numbers of local iterations before each aggregation to a central server. However, in practical edge computing applied to the IoT, the dataset gathered by each edge server may follow non-IID (Identical and Independently Distributed), which always cause differences in the local models trained by the edge servers. The differences vary with time and become worse as the number of iterations increases. If model aggregation is implemented in the early iteration of the edge server, excessive differences between local models may cause serious deviations in the aggregation model, thereby reducing learning accuracy. In addition, the transmission of model parameters in the aggregation process also brings unnecessary communication energy costs. Thus, the aggregation time needs to be optimally selected. Given the maximum FL rounds \(K\), for server \(n\), subject to its energy limitation, the number of iterations in each round, denoted as \(\tau_{n,k}\), satisfies the following relationship:  
\[\sum_{k=1}^{K}\tau_{n,k}=\frac{E_{n}^{\max}}{|\mathcal{D}_{n,k}|\epsilon_{n}}. \tag{12}\]  
We consider the loss function \(L(\omega_{n,k}|\mathcal{D}_{n,k},\tau_{n,k})\) to be \(\zeta\)-smooth, i.e., for any \(\omega_{n,k}\) and \(\omega_{n,k}^{\prime}\),  
\[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}\]  
This loss function is also \(\mu\)-quasi-convexity; that is, for \(\omega_{n,k}^{*}\in\arg\min L(\omega_{n,k}|\mathcal{D}_{n,k},\tau_{n,k})\) and any \(\omega_{n,k}\), we have  
\[L(\omega_{n,k}^{*}|\mathcal{D}_{n,k},\tau_{n,k})\geq 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}^{*}-\omega_{n,k})+\frac{\mu}{2}||\omega_{n,k}^{*}- \omega_{n,k}||^{2}\enspace. \tag{14}\]  
Moreover, the gradient of \(L(\omega_{n,k}|\mathcal{D}_{n,k},\tau_{n,k})\) has an upper bound, which can be described as the existence of \(\phi_{n}>0\) and \(G>0\), such that  
\[E||\bigtriangledown L(\omega_{n,k}|\mathcal{D}^{\prime}_{n,k},\tau_{n,k})- \bigtriangledown L(\omega_{n,k}|\mathcal{D}_{n,k},\tau_{n,k})||^{2}\leq\phi_{ n}^{2}, \tag{15}\]  
and  
\[E||\bigtriangledown L(\omega_{n,k}|\mathcal{D}^{\prime}_{n,k},\tau_{n,k})||^ {2}\leq G^{2}, \tag{16}\]  
where \(\mathcal{D}^{\prime}_{n,k}\) is a mini-batch dataset sampled from \(\mathcal{D}_{n,k}\) randomly. For client server \(n\in\mathcal{N}\), when its loss function \(L(\omega_{n,k}|\mathcal{D}_{n,k},\tau_{n,k})\) meets the above conditions, the server's local iteration number in \(K\) FL rounds is an arithmetic sequence with a tolerance of \(\Delta_{n}\); that is, \(\Delta_{n}=\tau_{n,k+1}-\tau_{n,k}\)[32]. Therefore, we can obtain the entire iteration sequence of each client server by calculating its first iteration number and \(\Delta_{n}\). We have  
\[\frac{\sum_{k=1}^{K}\tau_{n,k}}{K}<\tau_{n,1}<\frac{(2K-2+2H)}{(K-1+2H)\sum_{k=1} ^{K}\tau_{n,k}/K}, \tag{17}\]  
where \(H\) is a positive constant that satisfies \(H\Delta<\tau_{n,K}\) and  
\[\Delta=\frac{2(E_{n}^{\max}/|\mathcal{D}_{n,k}|e_{n}-K\tau_{n,1})}{K(K-1)} \tag{18}\]  
according to (12).