## 4 LEACH Protocol Improvement Based on the Differential Evolution Algorithm
### Optimizing Algorithm and Determining Cluster Heads with the DE  
The DE algorithm executes basically in the same way as other evolution algorithms, including coding, initial swarm formation, variation, crossover and selection operations. In order to make it suitable for the problem domain, the DE algorithm has to be modified, which is described in details as follows. (1) Initial Swarm Formation: Initial swarms are formed with the corresponding groups of integer sequences of ID numbers of neighbor nodes the auxiliary cluster heads collect. Defining the solution vector as:  
\[X_{i,G}=(x_{1},x_{2},\cdots,x_{n})\ \ i=1,2,\cdots,NP \tag{3}\]  
Each solution vector is an evolution individual. Each generation of an evolution swarm is expressed as _G, \(i\)_, is an individual's location in the swarm, \(n\) is the number of neighbor nodes auxiliary cluster heads collect, and \(NP\) is the scale of the swarm. The first-generation swarm is created at random. The rule is to sort the IDs of neighbor nodes' auxiliary cluster heads collected in an ascending order of \(ID_{1}<ID_{2}<\ldots<ID_{n}\), to create a corresponding relationship of \(ID_{i}\leftrightarrow i\), \(i=1,\ldots,\ n\), and to create the initial swarm based on that relationship. Each element in the swarm is given as:  
\[x_{i,3}=1+round[rd\times(n-1)]\,,\ i=1,2,\cdots,NP\ \ j=1,2,\cdots,n\ . \tag{4}\]  
where \(rd\) is a random number between (0,1), \(round\) [] is a closest integer, and \(n\) is the number of neighbor nodes. (2) Variation Operation: Variation Operation is an important step for the DE algorithm to create sub-individuals. The algorithm uses the variation mode of DE/rand/1 [19]. Super-individuals, plus the difference between two or more individuals in the group create the sub-individuals. The basic unit of the variation operation is individual, which is solution vector. For the evolution target vector of each generation \(X_{i,G}\), \(i\) = 1,2,...,\(NP\), its variation operation is given by:  
\[V_{i,G+1}=X_{i,G}+F(X_{i,G}-X_{i,G}) \tag{5}\]  
where \(r_{1}\), \(r_{2}\), \(r_{3}\) are not equal random integers in [1,2,\(NP\)], and not equal to \(i\). \(X_{ri,G}\) is called the father individual or basic individual. \(F\) is the variation factor, and \(F\) \(\in\) (0,1). (3) Crossover Operation: The crossover operation adds varieties to the swarm. It includes two modes, index crossover mode and binomial crossover mode. The algorithm uses the common binomial crossover mode defined as  
\[u_{j,G+1}=\left\{ \begin{array}{ll}v_{j,G+1}&if(randb(j)\leq CR)\ or\ j=randr(i)\\ x_{j,G}&if(randb(j)>CR)\ and\ j\
eq randr(i)\end{array} \right. \tag{6}\]  
where \(randb(j)\) is a random decimal figure between [0,1], \(randr(i)\) is a random integer between [1,\(n\)] and \(CR\) is the crossover factor. (4) Selection Operation: In order to calculate the adaptation value of each experimental vector, it is necessary to establish an objective function first. Each vector is composed of n integers between 1\(\sim\)\(n\), corresponding to the ID numbers of the neighbor nodes, respectively. The purpose of establishing the function is to connect an actual physical relationship with abstract numbers in the algorithm to judge the quality of the vectors. Determining the adaptation value of the experiment vectors not only needs to consider the energy of corresponding nodes, but also reflects the energy distribution of surrounding nodes. The further away from the node the neighbor nodes are, the greater the energy; and _vice versa_. Based on this characteristic, an objective function is defined as:  
\[f(i)=\frac{1}{n}\sum_{j\sim i}^{n}(\alpha e_{j}+\beta\overline{e_{j}}) \tag{7}\]  
where \(\alpha+\beta=1\) and \(\alpha\in\) [0,1], \(\beta\in\) [0,1]; \(e_{j}\) is the energy of the corresponding node of element \(j\) in the experiment vector (node \(j\) in short); \(\overline{e_{j}}\) is the average energy of nodes except node \(j\); \(\alpha\) is the influential energy factor of \(e_{j}\); and \(\beta\) is the influential energy factor of \(\overline{e_{j}}\).