## 2 Optimization Model for Network Reconfiguration Problem of Ship Power System
### Simulation Experiments and Analysis  
3.1 Reconfiguration of Power Grid Processes by Swarm Exchange Particle Swarm Optimization Algorithms  
Load coding: Use 0, 1, and 2 to code the loads in the ring grid, where 0 means the loads lose power, 1 means the loads are normally supplied, and 2 means the loads are supplied using alternate paths. Loads that are not supplied by alternate paths are only coded with 0 and 1;  
Input the faulty node for connectivity check;  
Perform particle initialization operations for the main and auxiliary swarms using the chaos model of the Logistic Chaos Mapping System;  
Determine whether the particle complies with the constraints, and if not, artificially assign a very small constant value to its fitness value;  
Update the particles according to the main and auxiliary groups of particle evolution (Equations (23) and (24)). Particle updating is carried out to record the global optimal particle positions in the main and auxiliary particle swarms, respectively;  
According to the objective function in Section 2, Equations (1)-(14) are used to perform the comparison of fitness values, record the optimal value, and sort particles according to the size of the fitness value;  
Swarm exchange: arrange the main and auxiliary swarms in descending order according to the fitness value and exchange \((1-0.618)*N=0.382*N\) particles in the auxiliary search swarm with the same number of particles in the main search swarm according to the golden ratio. Return to step (6) and continue to repeat the iteration;  
Iteration termination: determine whether the set maximum number of iterations is satisfied and complete the iteration. The connectivity check in step (2) is based on the load branch correlation matrix method in Section 2, through which the procedure can determine the power supply paths of some loads before the reconfiguration scheme, which can reduce the amount of data computation and pave the way for the next search process. The flowchart is shown in Figure 7.  
3.2 Simulation Analysis of Reconfiguration of Power Grid by Swarm Exchange Particle Swarm Optimization Algorithm  
The simulation experiment environment of this paper: The programming language is chosen in MATLAB R2019a; the host computer uses a 64-bit Windows 11 operating system. The simulation parameters are set as follows: the number of particles in the main search group \(N_{A}=100\); the number of particles in the auxiliary search group \(N_{B}=100\), the dimensions \(D=20\), \(c_{1}=\)2, \(c_{2}=\)2, \(c_{3}=\)2, the inertia weights decrease from 0.9 to 0.4; and the maximum number of iterations \(T_{max}\). Fault calculus: The model used in this paper is shown in Figure 3. Set node 7 and node 41 to fail, and carry out the simulation experiment of the ship power system reconstruction by the swarm exchange particle swarm optimization algorithm. Inputting the faulty node into the connectivity identification program can result in the following path for restoring power to some switches:  
\[[X\ 0\ 2\ X\ X\ X\ X\ 0\ 2\ X\ 1\ X\ X\ X\ X\ 1]\]  
After the connectivity identification, it can be concluded that because of the failure of node 7, L2 has no alternate power supply path and can only choose to disconnect; L3 can choose to use the alternate power supply path as a power supply; L20 has a damaged alternate power supply path and can only choose the normal power supply path; because of the failure of node 41, L9 has no alternate power supply path and can only disconnect; L10 can choose to use the alternate power supply path as a power supply; and L13 can only choose to use the normal power supply path as a power supply because of the alternate power supply path failing to conduct. L13 can choose to use the normal power supplypath as a power supply because its backup power supply path cannot be energized. The simulation reconstruction scheme for this failure example is shown in Figures 8-11.