# A Novel Multi-Server Federated Learning Framework in Vehicular Edge Computing
## 4 Proposed MS-FL Framework
### Inter-Server Model Aggregation
At each server, the validation losses are analyzed statistically to identify underperforming models. The proposed method leverages the z-score, a standardized metric that quantifies how far a particular value deviates from the mean, thus effectively capturing each value's outlier strength. To begin, we compute the mean \(\mu_{\rm L}\) and standard deviation \(\sigma_{\rm L}\) of all validation losses:  
\[\mu_{\rm L}=\frac{1}{\rm N}\sum_{\rm s=1}^{\rm N}L_{\rm s}\cdot \tag{6}\]  
\[\sigma_{\rm L}=\sqrt{\frac{1}{\rm N}\sum_{\rm s=1}^{\rm N}\left(L_{\rm s}\ -\mu_{\rm L}\right)^{2}}, \tag{7}\]  
where \(N\) is the number of models being considered. Each model's loss is converted into a \(z\)-score to quantify how much it deviates from the mean loss. Models whose \(|z|\) exceeds a selected threshold (e.g., \(|z|\ >\ 2\)) are deemed outliers and are penalized to reduce their impact on the final aggregated model. The penalty for each model is computed using a sigmoid function as follows:  
\[\Theta_{\rm s}(z_{\rm s})= \frac{1}{1+\exp(z_{\rm s})}, \tag{8}\]  
where \(\Theta_{\rm s}(z_{\rm s})\) is the penalty for the server \(s\) model, which decreases the contribution of models with higher deviations from the mean loss. Once the penalties are applied, the adjusted weights for each model are computed as follows:  
\[\omega_{\rm s\_adjusted}=\rm e^{-L_{\rm s}}\times\Theta_{\rm s}(z_{\rm s}), \tag{9}\]  
The weights are normalized using (10) to ensure that they sum to one. Each server aggregates the models using a weighted sum of their parameters, where models with lower validation loss contribute to the final aggregated model. \[\omega_{\rm s\_adjusted}=\frac{\omega_{\rm s\_adjusted}}{\sum_{\rm s=1}^{\rm N} \omega_{\rm s\_adjusted}}. \tag{10}\]  
This approach ensures that models with significant deviations are penalized, contributing less to the aggregated global model. In the proposed aggregation models, we primarily utilized accuracy and loss as performance metrics. However, other performance indicators can be incorporated to assess models' effectiveness and adjust their contribution based on specific performance objectives and system requirements, ensuring adaptability in various application scenarios. Algorithm 2 details how each FL server in the proposed MS-FL framework--with DWAA and SPAA mechanisms--handles both inter-server collaboration and vehicles' models' aggregation at each communication round \(\rm t\ (t=\{1,\ldots,\ T\})\). Initially, if no pre-trained model exists, the server randomizes its model weights (Line 1). At the beginning of round \(\rm t\), the server collects models from its peer servers (Line 3) and evaluates their performance on its validation dataset (Line 4) using accuracy and loss metrics. Then the server normalizes these performance metrics--applying z-score penalties for SPAA--and computes the contribution weights (Line 5). The server then merges the peer models into its current model via a weighted sum (Line 6). Following the server-level aggregation, the server selects clients using a client selection algorithm, (Line 7), and distributes its current model to the chosen vehicles (Line 8). This process repeats until the training rounds reach a preset limit or the server's model achieves the desired accuracy. ```
Input: servers' models (\(\text{w}^{(\text{s})}(\text{t})(\text{s }\in\ \{1,2,\ldots N\})\)), vehicles' models (\(\text{w}_{\text{i}}(\text{t})(\text{i }\in\ \{1,2,\ldots K\})\)). Output: updated server model \(\text{w}^{(\text{s})}(\text{t}+1)\) #Initialize the model at server s
1. \(\text{w}^{(\text{s})}(\text{t})\leftarrow\) RandomInitialization()
2. fort = 1 to T do:
#Inter-server collaboration:
3. Receive peer servers' models (\(\text{w}^{(\text{s}^{\prime})}(\text{t})\))
4. Evaluate each received model
5. Adjust weights for each server's model
6. \(\text{w}^{(\text{s})}(\text{t})\leftarrow\)update model using an aggregation mechanism
#Intra-server client selection, local training and aggregation:
7. \(\text{v}^{(\text{s})}(\text{t})\leftarrow\)ClientSelection()
8.