# A Game Model and Fault Recovery Algorithm for SDN Multi-Domain
## 4 SDN-MARA Algorithm
### Optimal Mapping Between Controllers and Switches  
When seeking the target controller, it is necessary to consider the balance between the migration cost of out-of-control switches and the propagation delay within the game domain. In this paper, the mapping selection between out-of-control switches and target controllers within the controller's game domain is transformed into a linear programming problem for solution. Factors such as the migration cost of out-of-control switches and the load pressure on controllers are comprehensively considered in mapping selection. This paper employs a multi-population particle swarm algorithm with repulsive interaction to solve this linear programming problem, aiming to find an optimal mapping scheme. The designed optimal mapping algorithm between controllers and out-of-control switches not only minimizes the migration cost of switches but also ensures that the network load pressure remains within an acceptable range. Based on the game-enhanced model proposed in this paper, the fitness function is calculated according to Equation (10). In order to achieve a more balanced controller load and shorter task processing delays in the reestablished mapping, it is necessary to design a mapping strategy that takes into account both global and local performance. Since a hybrid mapping strategy can achieve global load balancing and avoid issues such as locally optimal performance, this paper adopts a hybrid mapping strategy. The repulsive forces between different decision subdomains are divided into repulsive forces of positive, negative and equal. Let the current average fitness value be denoted as \(f_{avg}\), and the historical best fitness value as \(f_{gb}\). This paper proposes the following three types of strategies \(X\): (1) During the controller game process, positive repulsive force indicates that the switch has a low fitness with the current game domain, and other game domains should be prioritized. That is, when under positive repulsive force, both \(f_{avg}\) and \(f_{gb}\) of the current decision subdomain are weaker than those of other decision subdomains. The optimization behavior of this subdomain is influenced by other stronger ones and tends to align with their exploration behavior. (2) Negative repulsive force indicates that the switch has a high fitness with the current game domain which should be prioritized. That is, when under negative repulsive force, both \(f_{avg}\) and \(f_{gb}\) of the current decision subdomain are stronger than those of other subdomains. This subdomain has a strong independent optimization capability and can influence the exploration behavior of other others. (3) Equal repulsive force indicates different results for different judgment conditions. That is, when under equal repulsive force, \(f_{avg}\) or \(f_{gb}\) of the current decision subdomain is weaker than those of others, while the other is stronger. In this case, the decision subdomains will maintain their respective search areas, thereby keeping both in relatively independent search regions. The three types of repulsive forces can be evaluated based on two indicator parameters: the current average fitness value \(f_{avg}\) and the historical best fitness value \(f_{gb}\) of particles in the decision subdomain. Therefore, after introducing the repulsive relationship, for decision subdomains A and B, the calculation methods for particle velocity \(sp_{A}\) and position \(pos_{A}\) update are as shown in Equations (14) and (15):  
\[ \begin{array}{c}sp_{A}(t+1)=w\times sp_{A}(t)+\theta_{1}\times r_{1}\times \left(f_{Apb}(t)-pos_{A}(t)\right)\\ \hskip 14.226378 pt+\theta_{2}\times r_{2}\times\left(f_{Agb}(t)-pos_{A}(t)\right) \\ \hskip 14.226378 pt-\frac{\theta_{3}}{\left(f_{gb}(t)-pos_{A}(t)\right)}\times natural \left(\ \right)\end{array}