# Artificial-Intelligence-Based Charger Deployment in Wireless Reshargeable Sensor Networks
## 4 Proposed Scheme
### SA-Based Charging Algorithm  
The concept of SA is that some worse solutions have the chance to be accepted [35]. In other words, this method can reduce the chance of falling into a local optimum. Thus, we used the SA concept to design a deployment method that is called the SA-based charging algorithm (SABC). With SABC, candidate chargers will be randomly chosen in the beginning. The status of candidate chargers will be changed at every iteration. This means that this method will compare various possibilities for making a decision as to whether or not to deploy the charger according to _f(x)_. The SA predetermined temperature will continue to decrease. When the temperature is still high, it has a high probability of accepting poor solutions. The temperature needs to be lowered because convergence that is too fast will lead to the solution quickly falling into the local optimum. The probability that a poor solution can be accepted declines when the temperature decreases. The reason is simple: the final solution may become a set of low-quality solutions if poor solutions are always accepted in each iteration.  
The first step is that SABC creates a number of \(N_{c}\) bits; the values of the bits are represented by 1s or 0s randomly. A value of 1 means that the candidate charger can be deployed in this position, whereas 0 means that the charger is not deployed. We set the experimental group and control group fairly. However, in copying the \(L\) neighbor solution, \(L\) is a value which can be freely adjusted by the user. The next step is to randomly change the status of bits and calculate _f(x)_. If the solution meets the threshold of acceptance, the experimental group will be replaced; this process is repeated until the termination criterion is met.  
In this section, we show the pseudocode of the algorithm. In the first step, we set an initial temperature by the annealing schedule and randomly created an initial solution \(N_{c}\), as shown in lines 1-2 of Algorithm 1. To compare the quality of solutions, _f(x)_ will be calculated for any just found solution, as shown in line 3. The next step is randomly choosing \(C_{i}\) from each solution and changing the status shown in line 5. Line 6 shows that the original solution and new solution will calculate their _f(x)_. We can replace the original solution if the new solution is better, and the temperature, as shown in lines 7-9, is also adopted. The last step is to update the temperature according to the SA rule. This process is repeated until the termination criterion is met.  
```
\(\text{SA-Based Charging Algorithm (SABC)}\) \(\text{Input: }V_{c},V_{s}\) Outputs: \(V_{E}\)
1. Set the initial temperature according to the annealing schedule
2. Create the initial solution \(N_{c}\) randomly
3. Calculate the _f(x)_
4. While the termination criterion is met choice \(C_{i}\) randomly
5. Fitness Function (\(N_{c}\), \(C_{i}\))
6. If quality is better and temperature is adapted
7. Replace the solution
8. Update temperature
9. End
```  
**Algorithm 1** SA-based charging algorithm (SABC)