# Blockchain-Based Decentralized Federated Learning Method in Edge Computing Environment
## 4 Experiments and Results
### Evaluation of BD-FL  
Since the proposed preference-based stable matching algorithm plays an important role in BD-FL to minimize the model cost and reduce the system delay, we first conducted a set of experiments to evaluate the stable matching algorithm. We designed three matching algorithms as the baseline, i.e., the local device first greedy algorithm (DFG), the edge server first greedy algorithm (SFG), and the random matching algorithm (RMA), and applied them to BD-FL for comparison experiments. For DFG, each local device sends a matching request to the edge server according to its preference list. If the candidate list of the edge server does not reach the maximum number of bindings, the device binds with the server directly, otherwise, it continues to send requests to other servers. For SFG, each edge server sends a matching request to the local device according to its preference list. If the local device is unbound, the server binds with the device directly, otherwise, it continues to send requests to other local devices. For RMA, the local device and the edge server randomly send matching requests to each other. If both parties are unbound, they can bind directly, otherwise, they continue to send requests to other unbound devices or servers. Figure 4 shows the total system costs of the four matching algorithms with different numbers of nodes. As RMA is a pure random matching algorithm without considering any factors that affect the matching result, it has the highest system cost. The costs of DFG and SFG are also higher than that of the stable matching algorithm. Because they only consider the one-side cost function of the local device or the edge server as the minimization objective, they cannot achieve the overall optimization of the system cost. In contrast, the preference-based stable matching algorithm designs the corresponding preference functions of local devices and edge servers by considering various influencing factors, therefore, both parties are able to match and bind efficiently. The stable matching algorithm achieves the minimum system cost, which reduces the cost by 34.9%, 43.6%, and 69.9% compared to DFG, SFG, and RMA, respectively, on average. We also counted the number of unstable matches of DFG, SFG, and RMA, which is shown in Figure 5. It can be seen that the number of unstable matches in these algorithms increases with the number of nodes. Due to the randomness of RMA, the number of unstable matches is the largest. DFG and SFG also have multiple unstable matches. The result of unstable matches is consistent with the result of system costs in Figure 4, and the reason is the same. For the stable matching algorithm, the number of unstable matches is always 0, even if the number of nodes in BD-FL increases. Figure 4: System costs of 4 matching algorithms with different numbers of nodes. To evaluate the model training time of BD-FL with the four matching algorithms, we set the number of edge servers to 4 and the number of local devices to 20 to build the simulation environment. In order to eliminate the influence of the consensus algorithm, all BD-FL models adopt traditional PBFT for blockchain consensus. Figure 6 shows the results of model training time. It can be seen that the training time of BD-FL models with DFG, SFG, and RMA is longer than that of the stable matching algorithm. This is because DFG and SFG only consider the single-side matching on local devices or edge servers, and RMA binds devices to servers in a random way, they cannot achieve the optimal stable matching. According to Figure 5, there are unstable matches in DFG, SFG, and RMA, which will increase the communication delay, and thus lead to a longer total time of model training. On the contrary, BD-FL uses the stable matching algorithm on both sides of the device and the server to utilize the computing resources and minimize the system communication cost. Compared with DFG, SFG, and RMA, the stable matching algorithm reduces the training time of BD-FL by 10.0%, 12.5%, and 19.7%, respectively, for 15 rounds of training.