# Key Management Scheme Based on Route Planning of Mobile Sink in Wireless Sensor Networks
## 3 The Scheme Design  
### Clustering Deployment  
In order to address the problem of energy holes, ensuring a balanced energy consumption, while improving the network coverage rate, on the basis of the method by [PERSON] _et al._[19], we added a new optimal object: coverage factor to the fitness function, which can improve the network coverage on the premise of energy equilibrium. The clustering is performed by a base station, and the fitness function is defined as follows:  
\[F=a_{1}\times f_{1}+a_{2}\times f_{2}+(1-a_{1}-a_{2})\times f_{3} \tag{1}\]  
\[f_{1}=\max_{k=1,2\cdots K}\left\{\sum_{\forall n_{i}\in C_{k}}d(n_{i},C_{k})/ Num_{C_{k}}\right\} \tag{2}\]  
\[f_{2}=\sum_{i=1}^{N}E(n_{i})/\sum_{k=1}^{K}E(C_{k}) \tag{3}\]  
\[f_{3}=\sum_{k=1}^{K}N_{k} \tag{4}\]  
where \(f_{1}\) is the maximum average Euclidean distance between nodes and their associated cluster head, \(d(n_{i},C_{k})\) is the distance between node \(n_{i}\) and its cluster head \(C_{k}\), \(Num_{Ck}\) is the number of nodes which belong to cluster \(C_{k},f_{2}\) is the ratio of total initial energy of all the nodes \(n_{i}\)(1,2,3,...,N) in the network to the total current energy of all cluster heads in the current round,\(f_{3}\) is the number of the nodes whose distances to their associated cluster head are larger than the maximum communication range. \(a_{1}\), \(a_{2}\) are user-defined evaluation weight coefficients used to weigh the contribution of each sub-objective to the fitness function. By constructing the fitness function, we can effectively minimize the sum of the distances between the member nodes and their cluster heads, and also optimize the energy efficiency of the network. In this clustering algorithm, the \(K\) candidate cluster heads could be abstracted into a particle, which constantly updates its position and velocity information and calculate their fitness values at different positions. That is to say, the operation is iterative and updates the positions of cluster heads, and finds the optimal position of cluster heads which can balance the energy consumption and improve the coverage rate of the network. By this method, we can convert the sensor network clustering problem into a mathematical iterative optimization problem. The specific process of the clustering algorithm can be summed up as follows:  
1. Initialize velocity and position of each particle \(P_{i}\) (\(i\) = 1, 2, 3,..., S), and each particle contains \(K\) candidate cluster heads. 2. Assign node \(n_{i}\) to the nearest cluster head, and then calculate the fitness value of each particle \(P_{i}\) (\(i\) = 1, 2, 3,..., S) by Equations (1)-(4). 3. Ensure the individual optimal solution \(P_{i}\) (\(t\)) and the global optimal solution \(G\) (\(t\)) for each particle. 4. Update the particle's velocity and position. 5. Map the particle's location to the position of cluster heads. 6. Repeat the above steps 1-5 until the maximum number of iterations is reached or the certain required coverage rate is satisfied. After clustering, the network gets into steady stage. Sensor nodes transmit the collected data to their cluster heads with single hop. The pseudo code of the clustering algorithm is as follows: