# Artificial-Intelligence-Based Charger Deployment in Wireless Reshargeable Sensor Networks
## 4 Proposed Scheme
### ACO-Based Charging Algorithm  
The concept of ACO originated from the behavior of ants seeking food [39]. Ants will follow the pheromone on the road where other ants have walked. The other ants can find the better solution according to the pheromone. We used this concept to design the deployment algorithm that is called the ACO-based charging algorithm (ACOBC). In this method, ants will walk to the position of the candidate charger. If this position is a better solution, the ant pheromone will remain, and vice versa; that is called online updating. At the end of each run, the pheromone will be updated offline regarding the best road in this run. Offline updating is a method by which to follow the best previous experience. The other important factor of ACOBC is overlapping areas. The solution will be better if the overlapping area is small. The directions of ant searches will be decided according to both above-mentioned factors. To make the solution converge, the pheromone will evaporate if ants have not walked there. In the beginning, the direction of ants searching will be decided by the factor of overlapping. As the values of the pheromones are the same, the solution will avoid falling into the local optimum through randomly choosing nodes at the beginning and updating pheromones. Ants will choose the candidate charger according to \(f_{ant}\), which is calculated as follows:  
\[f_{ant}(x)=\frac{P^{\text{a}}\times\frac{1}{S_{overlapping}}^{\beta}}{\sum_{i=1} ^{n}P^{\text{a}}\times\frac{1}{S_{overlapping}}^{\beta}}, \tag{9}\]  
where \(P\) is the pheromone; \(S_{overlapping}\) is the value of overlapping; \(\alpha\) and \(\beta\) are the values of weights and can be adjusted in different environments. Ants will walk to each position of candidate chargers only once and ensure that the solution will not fall into an infinite loop. At the outset, ACOBC does not choose any candidate charger. Ants will choose the direction of the solution according to \(f_{ant}\). When an ant arrives at a new node, ACOBC will evaluate the deployment status and whether or not to deploy by _f(x)_. The position which ants have arrived at will be recorded on the checklist to ensure that the ants has arrived only once at each position. The position of the candidate charger will be deployed and updated on the online pheromone if the value of _f(x)_ is better than that. If the value of _f(x)_ is worse, the checklist is updated but not the online pheromone, as shown in case 2. The pheromone which ants retained as the best solution will be updated offline in the end. We present the ACOBC algorithm by its pseudocode. The first step initiates the values of \(S_{overlapping}\) and \(P\), while setting the solution value as zero and calculating the _f(x)_, as shown in lines 1-3 of Algorithm 4. The number of ants is \(N_{ant}\). Each ant will choose the position by \(f_{ant}(x)\) and update the checklist; the _f(x)_ will be calculated at the same time, as shown in lines 7-8. If ants arrived at new positions and the _f(x)_ will be better, pheromone will be added and the online pheromone updated, as shown in lines 9-11. The covered sensor will be recorded in \(S_{covered}\). If the value of \(S_{covered}\) is equal to the value of \(N_{s}\), the ant is finished finding positions in this run. In other words, all the sensors will be covered by the candidate charger shown in lines 12-13. In the end, the best solution is found to update the online pheromones, as shown in lines 16-17. ```
ACO-based charging algorithm (ACOBC)  Input: \(V_{c},V_{s}\)  Output: \(V_{E}\) 1. Initialize the values of \(S_{overlapping}\) and \(P\) 2. Create the initial solution \(N_{c}\) 3. Calculate the _f(x)_ 4. While the termination criterion is not met 5. For \(i\) = 1 to \(N_{ant}\) 6. For \(j\) = 1 to \(N_{s}\) 7. Choice the position by \(f_{ant}\) (\(x\)) and calculate _f(x)_ 8.