# Joint Deployment of Sensors and Chargers in Wireless
## 4 Solutions
### Approximate Algorithm for Deploying Chargers
We define the particle \(\mathbb{Z}_{i}=(\mathcal{X}_{1},\mathcal{Y}_{1},...,\mathcal{X}_{i},\mathcal{ Y}_{i})\) in \(\Phi\), and the iteration velocity \(v_{i}\) and iteration location \(\mathbb{X}_{i}\) of the particles are respectively:  
\[v_{i}(t+1)=\omega\cdot v_{i}(t)+\varphi_{k}\cdot r_{k}\cdot(\rho_{i}-\mathbb{ X}_{i}(t))+\varphi_{l}\cdot r_{l}\cdot(\rho_{l}-\mathbb{X}_{i}(t))\mathbb{X}_{i}(t+1 )=\mathbb{X}_{i}(t)+v_{i}(t+1) \tag{15}\]  
\(v_{i}(t)\) and \(\mathbb{X}_{i}(t)\) are the current velocity and location of the particle \(\mathbb{Z}_{i}\), \(\rho_{i}\) is the current best location of \(\mathbb{Z}_{i}\), \(\rho_{i}\) is the current best location of all particles, \(r_{k}\) and \(r_{l}\) are two random vectors at \((0,1)\), \(\omega\), \(\varphi_{k}\), \(\varphi_{l}\) are the parameters of the particle swarm solution. The details of the PSO solution deployment charger are shown in Algorithm 3. The principles for iteratively selecting the optimal deployment locations for new chargers are: (1) preferentially deploy chargers for a sensor that has not yet been fully charged and has the most neighbor sensors that have not yet been fully charged; (2) based on the principle one, choose the particles to deploy new chargers, where the maximum number of sensors that have not yet been fully charged can be charged. Specifically, the number of neighbor sensors is defined as the number of other sensors in a circle centered at the sensor with a radius of \(2*d_{th}\). The process of Algorithm 3 is as follows: In Line 1, the minimum charging power \(P_{min}^{s_{j}}\) of each sensor \(s_{j}\) in \(S\) is calculated. In Line 2, the sensors \(S\) are sorted in descending order based on the number of neighbor sensors. Lines 3-10 are the iterative deployment phase. Similarly, \(k\) is the maximum number of chargers to be deployed to charge one sensor, and \(Loop\_1\) is a temporary intermediate variable. In Line 5, the charging power \(P_{h}^{s_{j},C\cup Loop\_1}\) is used to based on the currently deployed charger \(C\) is calculated. If the \(s_{j}\) is still not fully charged (\(P_{h}^{s_{j},C}<P_{min}^{s_{j}}\)) and \(Loop\_1<k\), Line 6 is executed to deploy new chargers for \(s_{j}\). In Line 6, \(g\) iterations are executed to update the positions of the particles and calculate the maximum fitness value \(P_{h}^{s_{j},C\cup Loop\_1}\). In Line 7, the particle with the maximum \(P_{h}^{s_{j},C\cup Loop\_1}\) is used to deploy new chargers. Finally, In Line 10, all deployed chargers C is outputted. ```
0: A set \(s_{j}\) of \(S\), the parameters of the chargers, the scheduling scheme of all sensors \(S_{T}\)
0: The deployment of chargers \(C\)
1: Calculate the \(P_{min}^{s_{j}}\) of the sensor \(s_{j}\);
2: Sort the \(S\) in descending order;
3:For each \(s_{j}\in S\)do
4:\(Loop\_1=0\);
5:\(\textbf{While}P_{h}^{s_{j},C}<P_{min}^{s_{j}}\) && \(Loop\_1\leq k\)do
6: Iterate \(g\) times, and calculate the maximum fitness value \(P_{h}^{s_{j},C\cup Loop\_1}\) of each particle;
7: Select the particle with the maximum \(P_{h}^{s_{j},C\cup Loop\_1}\), update \(C\);
8:End While
9:End for
10:Return \(C\)
```  
**Algorithm 3**Details of PSO for charger deployment  
For Algorithm 3, the number of sensors is \(M\), the particles in the PSO solution are \(w\), and the iteration of each search is \(g\). The time complexity of calculating the minimum charging power for a sensor is \(O(M)\). The time complexity of calculating the number of sensors in the number of neighbors of the sensor and sorting them in descending order is \(O\big{(}M^{2}\big{)}\). Iterate \(g\) times, the time complexity of calculating the maximum \(P_{h}^{s_{j},C\cup Loop\_1}\) with at most \(k\) particles is \(O\big{(}kwgM^{2}\big{)}\). The time complexity of updating the set of chargers is \(O(kM)\). The final time complexity is:  
\[O(M)+O\Big{(}M^{2}\Big{)}+O\Big{(}kwgM^{2}\Big{)}+O(kM)=O\Big{(}M^{2}\Big{)} \tag{16}\]