# D2D-Assisted Adaptive Federated Learning in Energy-Constrained Edge Computing
## 3 System Model and Problem Formulation  
As shown in Figure 1, we consider D2D-assisted federated learning in an edge computing network for IoT applications. There are \(N+1\) edge servers that jointly execute FL to obtain an IoT application model, such as traffic flow prediction and environmental monitoring. Servers with indexes 1 to \(N\) act as FL clients, and the server indexed with 0 acts as an aggregator. These clients are heterogeneous in terms of energy budget, local dataset generation, data processing capabilities, and geographical location. A deep neural network (DNN) model is deployed in these clients for training the IoT model [30]. Without loss of generality, the number of rounds for the entire FL system to run is defined as \(K\). In each round, the client servers train their own local model parameters based on the datasets collected from IoT devices and upload them to the aggregation server. In the \(k\)-th round, the number of local training iterations taken by client server \(n\) before uploading its model parameters is given as \(\tau_{n,k}\). Then, based on these collected model parameters, the aggregation server generates a global model and distributes it back to the client servers. Let \(\mathcal{D}_{n,k}\) denote the local dataset of server \(n\) generated in round \(k\), and let \((x_{n,k},y_{n,k})\) be one data point in \(\mathcal{D}_{n,k}\), where \(x_{n,k}\in\mathbb{R}^{d}\) is the input features, \(y_{n,k}\) is the label of the data point, and \(n\in\mathcal{N}=\{1,2,...,N\}\). The learning target of the FL running on server \(n\) is to train a DNN to minimize the error between the neural network output and label \(y_{n,k}\) given input \(x_{n,k}\). The loss function training based on dataset \(\mathcal{D}_{n,k}\) can be defined as  
\[L(\omega_{n,k}|\mathcal{D}_{n,k},\tau_{n,k})=\frac{\sum\limits_{\{x_{n,k},y_{ n,k}\}\in\mathcal{D}_{n,k}}l(\omega_{n,k},x_{n,k},y_{n,k},\tau_{n,k})}{| \mathcal{D}_{n,k}|}, \tag{1}\]  
Figure 1: D2D-assisted federated learning in an edge computing network. where \(\omega_{n,k}\) is a \(d\)-dimensional vector parameter of the trained DNN model, function \(l\) is a mean squared error or cross-entropy, and function \(L(\omega_{n,k}|\mathcal{D}_{n,k}\), \(\tau_{n,k})\) is a monotonically increasing function of dataset size \(|\mathcal{D}_{n,k}|\) and local training iteration time \(\tau_{n,k}\)[31]. Due to the constrained energy budget of the servers, energy conservation becomes a critical issue and can be addressed in two ways. The first is to reduce computing power costs--that is, each client server can selectively participate in the local model training process in each round. We adjust the energy consumption of server \(n\) participating in model training through variable \(\tau_{n,k}\). Another way to save energy is to reduce communication energy consumption. In each FL training round, a client can either not upload any locally trained model parameters or can directly transfer the parameters to the aggregation server or even use a relay node to submit parameters to the aggregation server in a D2D manner. The relay node is selected from the servers that act as clients in the FL training. We take \(\rho_{n,m,k}^{\text{del}}=1\) to indicate that server \(n\) delivers parameters to relay \(m\) and vice versa, where \(n\in\mathcal{N}\), \(m\in\{0\}\cup\mathcal{N}\), and \(m\
eq n\). Given the time \(t_{n}\) of client \(n\) to process a unit size of dataset, the training time for that client in round \(k\) is  
\[T_{n,k}^{\text{tra}}=\tau_{n,k}t_{n}\cdot|\mathcal{D}_{n,k}|. \tag{2}\]  
The spectrum taken to transmit model parameters between the servers participating in the FL training is divided into \(Z\) orthogonal channels with bandwidth \(B\), of which \(Z_{1}\) channels are used for the direct delivery of parameters from client or relay servers to the aggregation server, and the remaining \(Z_{2}\) channels are leveraged for client servers' D2D communications. We assume that a channel can only be allocated to at most one server at the same time.