# A Hierarchical Federated Learning Algorithm Based on Time Aggregation in Edge Computing Environment
## 4 Hierarchical Federated Learning Algorithm Based on Time-Effective Aggregation
\(\tau\) indicates the waiting period that starts after the edge server distributes the global model to individual clients. During the waiting period, the participating clients' local model parameters can be received by the edge server. Once the allotted waiting time has passed, the edge server ceases receiving and starts the edge aggregation. Since the global model is sent down in a very short time, the global model sending time is disregarded in this study. Namely, the waiting time \(\tau\) can be determined by the total time from the start of local training to the completion of uploading local model parameters for the last round of participating clients. The local training time \(T_{(cmp,i)}\) and the model upload time \(T_{(com,i)}\) are shown in Equations (10) and (12), respectively. For participating client \(i\), the time consumed from the start of local training to the end of the local model upload is given by:  
\[T_{i}=T_{(cmp,i)}+T_{(com,i)}. \tag{16}\]  
Assuming the client device's basic background conditions, such as geographical location, user population, and computing power, remain constant, there is no significant difference in the time required for the device to complete the training round using the same global parameter setting each time. Therefore, the time consumed in the current round can be estimated based on the total time spent in the previous round. The edge server \(m\) selects the median of the total time consumed by participating clients in the previous round as the waiting time \(\tau\) for the current round. On the one hand, this ensures that each round has local model parameters that will participate in the global aggregation after passing this round of training. On the other hand, it prevents clients with fast training from waiting too long, which improves the overall training efficiency. This time-effective aggregation method enables fast-training clients to train more frequently within the same amount of time, while also incorporating the local models contributed by slow-training clients into global convergence. (2) Local model receiving. Assuming that the edge server \(m\) receives local model parameters from participating client devices \(\mathcal{S}_{m}=\{s|s=1,\ldots,S\}\) during the waiting time \(\tau\), these clients can be classified into two groups according to the training round: the client devices \(\mathcal{S}^{\prime}_{m}=\{k^{\prime}|k^{\prime}=1,\ldots,S^{\prime}\}\) participating in the current round of training and client devices \(\mathcal{S}^{\prime\prime}_{m}=\{k^{\prime\prime}|k^{\prime\prime}=1,\ldots,S^ {\prime\prime}\}\) participating in previous rounds, and satisfying \(\mathcal{S}^{\prime}_{m}\cup\mathcal{S}^{\prime\prime}_{m}=\mathcal{S}_{m}\). The local model parameters of participating client \(k^{\prime}\) are denoted \(\omega_{k^{\prime}}\), which are obtained through training according to the latest global model parameters issued in this round, and their values must be retained during aggregation. Similarly, the relatively old local model parameters \(\omega_{k^{\prime\prime}}\) also possess value, and they could be more valuable in improving the accuracy of the global model than the models that are trained quickly. Therefore, they should not be ignored. However, if the old model is overemphasized, it may have a negative impact on the convergence of the global model. To summarize, this algorithm needs to weigh the proportion of local model parameters of two subgroups in the global model. For each group of local model parameters, the edge group aggregation model is produced using the dynamic local model weighted aggregation algorithm in Section 3.3.2.