## 4 Our Proposed EC-PSO Algorithm
### Energy Center Based CHs Selection using PSO  
In order to better illustrate our proposed EC-PSO, we firstly introduce some parameters which will be used in Table 1. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Parameter** & **Definition** & **Value** \\ \hline \(S\) & The particles which represent the solution & Random generation \\ \hline \(M\) & The number of particles & 50 \\ \hline \(N\) & The number of CHs & 16 \\ \hline \(P_{i,j}\) & The ordinate of energy center & \\ \hline \hline \end{tabular}
\end{table} 
Table 1: PSO Parameters. Figure 5: Network topology. Figure 6: Energy distribution. Many literatures use the location weight as the center, however the location of sensors is almost stationary and the location centers cannot react the distribution of energy. In this section, PSO algorithm is utilized to search the energy centers for CHs selection. Each particle denotes a whole solution for the energy centers and the dimension of the particle is double the number of CHs. Our algorithm uses a swarm of \(M\) particles and it is shown as Formula (9). \[S=\left[ \begin{array}{c}P_{1}\\ P_{2}\\ \vdots\\ P_{M}\end{array} \right]=\left[ \begin{array}{cccc}P_{1,1}&P_{1,2}&\cdots&P_{ 1,N}\\ P_{2,1}&P_{2,2}&\cdots&P_{2,N}\\ \vdots&\vdots&&\vdots\\ P_{M,1}&P_{M,2}&\cdots&P_{M,N}\end{array} \right] \tag{9}\]  
where \(M\) is the number of particles and \(N\) is the number of CHs, and \(P_{i,j}\) represents a 2-tuple that contains the ordinate of each energy center and is given as Formula (10). \[P_{i,j}=(X_{center\_i},Y_{center\_j}) \tag{10}\]  
The object of the PSO algorithm is to find the energy centers and we expect the global energy of the energy center is as high as possible, so we define the fitness function as follows. \[F=\sum_{1}^{M}\sum_{s\in C_{j}}E_{residual}\frac{1}{N_{C_{j}}} \tag{11}\]  
where \(C_{j}\) is a collection which contains nodes about two hops away from \(P_{i,j}\). We use the following steps to conduct the PSO algorithm. **Step 1**: In order to achieve evenly distributed CHs, we set the initial location of the particles in regular positions and the velocity of each particle is chosen in a random way. Every round, each node reports its status which contains the information of its ID, residual etc. **Step 2**: After the sink receives the message, the value of fitness function is calculated using the Formula (11). Particle \(P_{i}\) compares the value with its individual optimal solution and choose the better one as its \(P_{ibest}\). In the same way, it compares the value with the global optimal solution to choose the best particle as the \(G_{best}\). **Step 3**: The velocity of the particles can be updated using Formula (12) and their positions can be updated using Formula (13). \[V_{i}(t+1)=\omega V_{i}(t)+c_{1}\times rand()\times(P_{ibest}-P_{i}(t))+c_{2} \times rand()\times(G_{best}-P_{i}(t)) \tag{12}\]  
\[P_{i}(t+1)=P_{i}(t)+V_{i}(t+1) \tag{13}\]  
where \(\omega\) represents the self-adapting parameter and \(c_{1}\), \(c_{2}\) are two positive constants. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Parameter** & **Definition** & **Value** \\ \hline \(C_{j}\) & Neighbors of energy center \(P\) & \\ \hline \(V\) & The velocity of particles. & Random generation \\ \hline \(P_{ibest}\) & The optimal local solution & \\ \hline \(G_{best}\) & The optimal global solution & \\ \hline \(\omega\) & The inertia factor & 0.5 \\ \hline \(c_{1}\) & The weight factor of \(P_{ibest}\) & 0.4 \\ \hline \(c_{2}\) & The weight factor of \(G_{best}\) & 0.6 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: _Cont._  
**Step 4**: When each particle gets a new value, it will check the distance of its 2-tuples \(P_{i,j}\) and \(P_{i,k}\). If the distance between the 2-tuples is less than a threshold value, we initialize one of the 2-tuples in order to get the evenly distributed energy centers as much as possible. **Step 5**: Then, it goes to step 2 and terminate until it reaches the maximal iteration number.