# Dynamic Layered Dual-Cluster Heads Routing Algorithm Based on Krill Herd Optimization in UWSNs
## 3 Problem and Algorithm Description
### Krill Swarm Optimization Algorithm  
[PERSON] and [PERSON] proposed a KH optimization algorithm in the \"Communications in Nonlinear Science and Numerical Simulation\"; that is, a new bio-inspired optimization algorithm based on the simulation of the herding behavior of krill individuals [13]. In this algorithm, the krill moves to its location oriented with a high likelihood region using Lagrangian model, which mainly considers the distance from the food and from the highest density of the krill swarm. The movement of krill individuals includes three main actions: the movement induced by other krill individuals (\(N_{i}\)), foraging activity (\(F_{i}\)), and random diffusion (\(D_{i}\)). These moving actions interact iteratively and update their location until the global optimal solution is obtained.  
1. The following Lagrangian model is generalized to an n-dimensional decision space: \[\frac{dx_{i}}{dt}=N_{i}+D_{i}+F_{i}\] (7)
2. Movement Induced by Other Krill Individuals  
Krill individuals try to maintain a high density and move due to their mutual effects. For an individual krill, this movement can be defined as follows:  
\[N_{i}^{new}=N^{max}d_{i}+w_{n}N_{i}^{old} \tag{8}\]  
\[d_{i}=d_{i}^{local}+d_{i}^{target} \tag{9}\]  
where \(N^{max}\) is the maximum induced speed which set to 0.01 (ms\({}^{-1}\)), \(d_{i}\) is estimated from the local swarm density (local effect), \(w_{n}\) is the inertia weight of the motion which is distributed in the range [0, 1], \(N_{i}^{old}\) is the last induced motion, \(d_{i}^{local}\) is the local effect provided by the neighbors, and \(d_{i}^{target}\) is the target direction effect provided by the best krill individual.  
The effect of the neighbors can be assumed as attractive and repulsive tendency between the individuals for a local search. In this study, the effect of the neighbors on individual krill movement individual is determined with the following equations:  
\[d_{i}^{local}=\sum_{j=1}^{NN}K_{i,j}X_{i,j} \tag{10}\]  
\[X_{i,j}=\frac{X_{j}-X_{i}}{\|X_{j}-X_{i}\|+\epsilon} \tag{11}\]  
\[K_{i,j}=\frac{K_{j}-K_{i}}{K^{worst}-K^{best}} \tag{12}\]  
To avoid singularities, a small positive number \(\epsilon\) is added to the denominator. \(NN\) is the number of the neighbors, \(K_{i}\) represents the fitness or the objective function value of the \(i\)-th krill individual, \(K_{j}\) is the fitness of \(j\)-th (\(j=1,\,2,\,\ldots,\,N\)), \(K^{best}\) and \(K^{worst}\) are the best fitness and the worst fitness values of the krill individuals respectively, and \(X\) represents the related positions.  
According to the actual behavior of krill, the neighbors can be found by other krill individual once the sensing distance is determined. The expression for this condition is as follows:  
\[d_{s,i}=\frac{1}{5N}\sum_{j=1}^{N}\|X_{j}-X_{i}\| \tag{13}\]where \(d_{s,i}\) is the sensing distance for the \(i\)-th krill individual, and \(N\) is the number of krill individuals. If the distance of two krill individuals is less than the defined sensing distance, then they are neighbors.  
Considering the effect of the individual krill with the best fitness, the following equation can be obtained:  
\[d_{i}^{target}=C^{best}K_{i,best}X_{i,best} \tag{14}\]  
\[C^{best}=2(rand+\frac{I}{I_{max}}) \tag{15}\]  
where \(C^{best}\) is the effective coefficient of the krill individual with the best fitness, rand is the random values between 0 and 1 which is for enhancing exploration, \(I\) is the actual iteration number, and \(I_{max}\) is the maximum number of iterations.