# Data Transmission in Wireless Sensor Networks Based on Ant Colony Optimization Technique
## 2 Materials and Methods
### Increase the Coverage of WSNs
Bubble web predation \begin{table}
\begin{tabular}{l l} \hline \hline
**Number of Hidden Layer Nodes** & **Mean Squared Error of Training Set** \\ \hline
4 & 0.030469 \\ \hline
5 & 0.027156 \\ \hline
6 & 0.02298 \\ \hline
7 & 0.034099 \\ \hline
8 & 0.018178 \\ \hline
9 & 0.027816 \\ \hline
10 & 0.018269 \\ \hline
11 & 0.022957 \\ \hline
12 & 0.020507 \\ \hline
13 & 0.020523 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Node mean square error of wireless sensor networks. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Dataset** & **Tradition K-Means** & **Improve K-Means** \\ \hline Iris & 88.1\% & 91.2\% \\ \hline Wine & 69.7\% & 71.1\% \\ \hline Seeds & 90.6\% & 92.9 \\ \hline Glass & 75.4\% & 78.9\% \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Comparison of clustering accuracy. \[X(t+1)=D^{\prime}\times e^{bl}\times\cos(2\pi l)+X^{*}(t)\] (14) \[D^{\prime}=|X^{*}(t)-X(t)|\] (15) (c) Search for prey \[D^{\prime\prime}=|C\cdot X_{rand}(t)-X(t)|\] (16) \[X(t+1)=X_{rand}(t)-A\cdot D\] (17) ii Improving the Whale Algorithm To further improve the convergence speed and optimization accuracy of the standard whale algorithm, this paper adjusts the convergence factor \(a\) and contraction probability \(p\) in the whale algorithm to improve the convergence speed and optimization accuracy. (1) Improvement in convergence factor: In the standard whale algorithm, the value of the convergence factor \(a\) decreases with the number of iterations, so the algorithm has a larger search range and stronger search ability in the early stage, and gradually tends toward the optimal solution in the later stage. Due to the linear decrease in the value of \(a\), the algorithm may experience a slow convergence speed in the early stage, a small search range in the later stage, and falling into local optima, resulting in insufficient optimization accuracy. The improvement method adjusts the convergence factor \(a\) to a nonlinear reduction formula:  
\[\alpha=\alpha_{0}-\frac{t}{t_{max}}e^{(a_{1}-\alpha_{0})^{l}} \tag{18}\]  
In the formula, \(\alpha_{0}\) is the starting value of \(a\), \(a_{1}\) is the final value of \(a\), \(l\) is a constant, and \(t\) is the current number of iterations. \(t_{max}\) is the maximum number of iterations. (2) Improvement in contraction probability: in the standard whale algorithm, the \(p\) value is set to 0.5, which means surrounding prey and using gas. The probability of bubble net predation is equal throughout the entire process. Due to the constant equality of the two probabilities, the algorithm may experience a slow convergence speed. As the number of iterations gradually increases, the individual gradually approaches the optimal solution, and the probability of surrounding the prey should gradually be greater than the probability of net predation by using bubbles. The improvement method in this article adjusts the contraction probability \(p\) to a linear reduction formula:  
\[p_{surround}=0.5+t*u \tag{19}\] \[p_{BubbleNet}=1-p_{surround} \tag{20}\]  
In the formula, \(u\) is the adjustment parameter, and \(t\) is the current iteration number. In summary, the specific implementation steps of the improved whale algorithm are as follows:  
1. Initialize the population and location information of whales, and set the maximum number of iterations \(t_{max}\);
2. Calculate the fitness of each whale;
3. Record the optimal whale position;
4. If the termination condition is met, proceed to step 8; otherwise, proceed to step 5;
5. Update parameters \(A\),\(C\),\(a\),\(t\);
6. To determine if \(p\) is less than \(0.5+t*u\), proceed to step 7. Otherwise, use bubble nets for predation. Use the mathematical models in (12) and (13) to update the position and proceed to step 2;* Determine if A is less than 1. If so, surround the prey and use the mathematical model to update the position. Go to step (2). Otherwise, search for prey and use the mathematical models in (16) and (17) to update the position. Go to step (2);
* Output the optimal solution.