# Dynamic Layered Dual-Cluster Heads Routing Algorithm Based on Krill Herd Optimization in UWSNs
## 3 Problem and Algorithm Description
### Krill Swarm Optimization Algorithm
#### 3.1.3 Foraging Motion  
The foraging motion of the krill individuals is formulated in terms of two main effective parameters. The first one is the food location. The second is the previous experience about the food location. These parameters are depicted below.  
\[F_{i}=v_{f}\ \beta_{i}+w_{f}F_{i}^{old} \tag{16}\]  
where \(F_{i}^{old}\) is the old foraging motion.  
\[\beta_{i}=\beta_{i}^{food}+\beta_{i}^{best} \tag{17}\]  
where \(v_{f}\) is the foraging speed which sets to 0.02 (ms\({}^{-1}\)), \(w_{f}\) is the inertia weight of the foraging motion which distributes in the range [0, 1], \(\beta_{i}^{food}\) is the food attractive, and \(\beta_{i}^{best}\) is the effect of the best fitness.  
Food effect is defined in terms of its location. The center of food should first be identified. It is followed by the formulation of food attraction. Food effect cannot be determined but can be estimated. In this study, the virtual center of food concentration is estimated according to the fitness distribution of the krill individuals inspired from the \"center of mass\". The formula for this variable is as follows:  
\[X^{food}=\frac{\sum_{i=1}^{N}\ \frac{1}{K_{i}}\ X_{i}}{\sum_{i=1}^{N}\ \frac{1}{K_{i}}} \tag{18}\]  
Therefore, the food attraction for the \(i\)-th krill individual can be determined using the following equation:  
\[\beta_{i}^{food}=C^{food}K_{i,food}X_{i,food} \tag{19}\]  
\[C^{food}=2\times(1-\frac{I}{I_{max}}) \tag{20}\]  
where \(C^{food}\) is the food coefficient. The effect of food on KH decreases with time.  
The foraging motion of individual krill promotes global optimization, and krill individuals normally herd around the global optima after a number of iterations. Therefore, this proceeding can be considered an efficient global optimization strategy that can improve the globality of the KH algorithm.  
The effect of the best fitness of the \(i\)-th krill individual is identified using the following equation:  
\[\beta_{i}^{best}=K_{i,best}X_{i,best} \tag{21}\]  
where \(K_{i,best}\) is the best previously visited position of the \(i\)-th krill individual.  
Random motion can be expressed in terms of a maximum diffusion speed and a random directional vector. This variable can be formulated as follows:  
\[D_{i}=D^{max}(1-\frac{I}{I_{max}})\delta \tag{22}\]  
where \(D^{max}\) is the maximum diffusion speed, and \(\delta\) is the random directional vector whose arrays are random values varying between \(-1\) and \(1\).  
5. Status Update  
The status update can be formulated as follows:  
\[X_{i}^{(n+1)}=X_{i}^{(n)}+(N_{i}^{new}+F_{i}^{new}+D_{i}^{new})\cdot t \tag{23}\]  
where \(t\) is the time interval and should be carefully set according to actual situations, and \(N_{i}^{new}\) is the newest induced motion speed, \(F_{i}^{new}\) is the newest foraging motion speed, \(D_{i}^{new}\) is the newest diffusion speed.  
The parameters of krill swarm optimization algorithm are based on the actual simulation of krill motion and experimental validation. Among these parameters, only the one-time interval parameters need to be adjusted automatically. This case is one of the characteristics of the intelligent algorithm that makes it better than other groups. In this study, we attempt to improve the krill swarm optimization algorithm to solve the routing problem of UWSNs.