## 5 Ant Colony Optimization
The termination criteria can be a predetermined number of iterations, reaching a specific threshold for the solutions or a specific time limit. Once the termination criteria are met, the algorithm concludes. Figure 2: Representation of how ants are attracted to the shorter route since there is a stronger pheromone scent represented by the thicker line. The binary ant colony algorithm (BACA) is a variant of ant colony optimization. BACA denotes the parameters directly with binary coding; thus, it can take up less storage space and reduce the complexity of the algorithm. Compared with the traditional ant colony algorithm, the biggest difference is the ant's path selection. The states of the BACA are either 1 or 0, indicating the activation or sleep of a sensor node, respectively. This reduces the complexity of the algorithm and allows for more efficiency. Similarly, in the traditional algorithm, artificial ants are used to explore the search space of a given optimization problem. The BACA consists of five phases:  
In the first phase, we initialize parameters such as the number of ants, the number of iterations, and the pheromone trails on the binary string positions. In the second phase, the ants construct a solution by making binary decisions based on the pheromone trails and the heuristic information. Each virtual ant constructs a solution by flipping the bits in a binary string representation, where each bit corresponds to an activation status of a sensor node. The ants determine the movement direction according to the information quantity of each path and the movable probability. We can rewrite Equation (2) to look like the following [6]:  
\[P_{i,j}^{m}(t)=\begin{cases}\frac{\tau_{i,j}^{a}\ast\eta_{i,j}^{b}}{\sum_{mall \_{i,j}}\tau_{i,m}^{a}\eta_{i,m}^{a}}\ if\ j\ e\ allowed\\ \\ 0\ \  
ant enters the field on the left side and stops on the other end, it creates a binary string as it passes through the nodes. Notably, each ant, as it traverses through the field, generates a unique binary string, encapsulating a potential solution to the problem. In Figure 5, we observe a random distribution of sensor nodes in a field depicted by the figure on the left. As the ants traverse through these nodes, their decision-making process adheres to the probabilistic principles dictated by pheromone levels and heuristic information. This interplay of factors guides the ants to form a potential solution, illustrated by the figure on the right. Nodes with the red outline indicate that the ants chose those nodes to be in sleep mode. In the third phase, we evaluate the quality of fitness of each solution based on a fitness function. The fitness function is crucial for evaluating the quality or performance of potential solutions that are generated by the algorithm. The fitness function generally considers the coverage quality, energy consumption, sensing overlap, network lifetime, and deployment cost. \[ \begin{split} Fitness(S)=w_{1}*Coverage(S)-w_{2}*Energy(S)\\ -w_{3}*Overlap(S)+w_{4}*Lifetime(S)-w_{5}*Cost(S)\end{split}  \tag{5}\]  
Weights \(w_{1},w_{2},w_{3},w_{4}\), and \(w_{5}\) represent the relative importance of each parameter in the fitness evaluation. These weights can be adjusted to prioritize certain objectives over others, depending on the specific requirements of the WSN. Using the fitness function, the solutions are ranked in the order of the fittest solutions, or best solutions. The best solution is represented by that with the highest fitness value. After each iteration, the pheromone trails need to be updated based on the fitness of the ant's solution. The pheromone update process consists of two steps. The first step is called the evaporation phase, in which the pheromone trails evaporate according to the following rule based on the works by [PERSON] in [12; 13]:  
\[\tau_{i,j}(t+1)\leftarrow(\rho)\;\tau_{i,j}(t) \tag{6}\]  
where \(\rho\in[0,1]\) is the evaporation parameter. \(t\) represents the iteration count, and \(t+1\) represents the next iteration.