## 4 Methods
### Cluster-Head Election Phase
#### 4.2.1 Elect the Primary Cluster-Heads in DCK-LEACH  
It is necessary to elect the optimal node as cluster-heads to extend the network lifetime. Because cluster-heads spend more energy compared with that of other nodes in the cluster when they receive, fuse, and forward data within the cluster or among clusters.  
In selecting the primary cluster-heads, the fitness function (\(p\)) is defined by two factors: the residual energy of the node, and the distance from the node to the clustering center. In addition, the weight probabilities of factors are dynamically adjusted according to the characteristics of the network in real-time. Finally, the node with a larger fitness function (\(p\)) value is selected as the primary cluster-head in a cluster.  
The residual energy of nodes is an important factor in cluster-head election [33; 34], and we thus increase the possibility of nodes with high residual energy being elected as the primary cluster-head in DCK-LEACH.  
The first objective function (\(f_{1}(i)\)) [35] for selecting the cluster-head, which is the ratio of the residual energy of a node \(i\) to the average residual energy of all nodes in the same cluster to which it belongs, is as follows:  
\[f_{1}(i)=\frac{E_{res}(i)}{\frac{1}{n}\sum\limits_{j=1}^{n}E_{res}(j)}\  
where \(E_{0}\) is the initial energy of each node, and \(E_{res}(i)\) is the current residual energy of node \(i\). The greater the residual energy of node \(i\), the larger the value of \(\alpha(i)\), and the larger weight value of the objective function \(f_{1}(i)\). In short, the node with large residual energy has a higher probability of being selected as the primary cluster-head in this situation.  
Algorithm 1 in DCK-LEACH for the primary cluster-heads election is as follows:  
```
Input: all member nodes in K clusters Output: the primary cluster-heads in the set C1
```  
(1) For each cluster  
(2) For member nodes within the same cluster  
(3) Calculate the residual energy objective function \(f_{1}(i)\), and the distance function \(f_{2}(i)\) for each node i  
(4) If the sum of energy of all nodes is greater than half of the initial energy of the network (0.5 * n\(E_{0}\))  
(5) Calculate the value of the node adaptation function according to \(P(i)=1/2*f_{1}(i)+\frac{1}{2}*f_{2}(i)\)  
(6) Else  
(7) Calculate the value of the node adaptation function according to \(P(i)=\frac{E_{res}(i)}{E_{0}}*f_{1}(i)\) + (1 - \(\frac{E_{res}(i)}{E_{0}}\)) * \(f_{2}(i)\)  
(8) Find the node with the largest fitness function value and save this node information in the set C1  
(9) End ```
**Algorithm 1**The primary cluster-heads election  
For each node \(i\) in the cluster (\(i=1\dots\ n\)), respectively, calculate the objective functions \(f_{1}(i)\) and \(f_{2}(i)\), and then select the primary cluster-head based on the maximum fitness function \(p\)-value among nodes according to the weight of the two objective functions.  
Here, to compare the value of \(P(i)\), \(f_{1}(i)\), and \(f_{2}(i)\) of the member nodes within a cluster, we list the data in one round in scenario 1, which is as follows:  
Table 1 shows that the node (ID = 6) has the largest value of the adaptive function \(p\). Therefore, the node (ID = 6) becomes the primary cluster-head of this cluster. For the other clusters in the network, the objective function (\(f_{1}\),\(f_{2}\)) and the fitness function value (\(p\)) are calculated for each node, respectively, and finally the primary cluster-head in each cluster is selected according to the value of the fitness function (\(p\)).