# A Game Model and Fault Recovery Algorithm for SDN Multi-Domain
## 4 SDN-MARA Algorithm
### Design of the SDN-MARA Algorithm
#### 4.3.3 Game-Enhanced Dynamic Mapping Algorithm for Switches and Target Controllers  
Based on the SDN multi-domain controller game enhancement model proposed above, this paper designs a mapping algorithm to solve the control problem of out-of-control switches and promote their routing function. The algorithm is divided into four stages: (1) The out-of-control switch initiates a migration request to the target controller in the game domain; (2) The target controller comprehensively evaluates its remaining capacity and expected request processing capability, similar to routing decisions in traditional networks; (3) Perform the mapping selection process between switches and controllers to ensure the optimal routing path; (4) Establish the relationship between the switch and the target controller. Inspired by the swarm intelligent optimization algorithm, this paper adopts the multi-population particle swarm optimization algorithm with repulsive interaction in game activities [7] to select the mapping between switches and controllers. The target controllers are abstracted as particles, and the set of target controllers in the game domain is further divided into several decision subdomains based on capacity and hop relationships. The mapping selection process between switches and controllers is divided into four stages, with different interaction factors applied between decision subdomains at different stages to achieve better results. The steps of the mapping selection algorithm are as follows:  
1. Initialize the number of decision subdomains, the size of the particle swarm, and the particle positions x and velocities v. Each decision subdomain conducts independent searches, with particles within the subdomains calculating their fitness values based on Equation (10). The particles adjust their search velocities according to their individual best values and the global best value. During this stage, the search processes within each decision subdomain are completely isolated, thus exhibiting strong global optimization capabilities. Each decision subdomain obtains initial search results during this phase. 2. After obtaining the search results for each decision subdomain, intermittent repulsive forces are applied to different decision subdomains based on Definition 7 and Equations (14) and (15). These repulsive forces interfere with the interaction behaviors between subdomains, enhancing the global optimization capability. 3. In this stage, repulsive forces continue to be applied to the particles within the decision subdomains. Different from step 2, the repulsive forces between subdomains areapplied in every iteration, causing the exploration behaviors of different subdomains to influence each other. 4. Following intense interactions and iterations among the decision subdomains, they begin to converge. The subdomains initially divided during the early stages of the algorithm are re-merged at this stage. The merged particle swarm integrates the previously searched results, and ultimately, the algorithm converges to obtain the optimal result. The global best value represents the optimal matching result between the migrating switch and the target controller. The pseudocode for determining the mapping relationship between out-of-control switches and target controllers is shown in Algorithm 3. ```
Input: Target controller set C\({}_{\text{t}}\), out-of-control switch set V\({}_{\text{o}}\) Output: Mapping relationship E\({}_{1}\) between out-of-control switches and target controllers
```
1. Initialize decision subdomain count N\({}_{\text{d}}\), particle position _pos_, and speed _sp_
2. Get the k = 1-th migrating switch and A\({}_{\text{i}}\) decision subdomain
3. Abstract target controllers as particles for evolution
4.