# A Method to Construct an Indoor Air Pollution Monitoring System Based on a Wireless Sensor Network
## 4 Simulation and Results Discussion
### WSN Coverage Optimization  
#### 4.1.1 Application Method  
In the simulated two-dimensional target area, assuming that all the deployed sensors in a big space have a large sensing range \(r=20\) m, and each sensor knows its location by a certain mechanism and sends it to the base station. The coverage optimization based on the PSO algorithm should calculate the coverage rate of each pixel node for each sensor node according to Equation (4), calculate the joint coverage of each pixel node for each sensor node according to Equation (5), and calculate the coverage rate of the RoI using the objective function according to Equation (8), in the particle swarm algorithm also known as fitness. In this work, we assume that there are M particles (the total number of the sensors in RoI, M = 100). The condition for the simulation experiment is described in the Table 1. The PSO algorithm is as follows:  
1. Randomly generate the position and velocity of each particle in the monitoring area;
2. Update the position and velocity of each particle according to Equations (9-11);
3. Calculate the fitness of each particle according to the optimization objective function;
4. Compare the particle fitness and the fitness of its own best position, if better, and then set the new _pbest_
5. Compare the fitness of each particle and the fitness of the best position in the population, if better, set the new _gbest_
6. Until the maximum number of iterations is reached, the algorithm stops, otherwise proceed to step two
7. Output the optimal fitness and the corresponding particle position. During the optimization of coverage by using the PSO algorithm, the coverage optimization went through four stages, first the deployment of 20 sensors, then 30 sensors, followed by 35 sensors, and finally 40 sensors. The simulations results are as follows:  
* The 20-sensor deployment result graph started with 84% coverage, after that the graph started to increase until it reached 87% at iteration 230 then jumped directly to the optimal result 88% and stabilized. * The 30-sensor deployment result graph started with a 92% coverage rate and reached almost 95% after few iterations and remained practically stable until 150 iterations. After that, the algorithm started looking for a better result until iteration 225 where the final optimal coverage rate was 96%. * The 35-sensor deployment result graph started with a 95% coverage rate, and reached almost 97% just after few iterations. After that, the algorithm started looking for a better result until iteration 280, where the final optimal coverage rate was 98%. * The 40-sensor deployment result graph started with 97% coverage and increased to 99% at iteration 120 and maintained that rate until iteration 200. After that, the algorithm started looking for a better result. In this application the monitoring area was totally covered, and the rate reached 100%. According to the results presented above, the curves of the coverage rate, with and without optimization according to the number of the deployed sensors, are shown in Figure 7.  
Figure 5: Coverage of 35 sensors. Figure 6: Coverage of 40 sensors. The analysis of the Figure 7 shows us that the PSO algorithm was more efficient when the number of sensors used was 20 where the percentage of the coverage rate had increased from 70% to 88%. This was revised in principle of the PSO algorithm which attempted to find a better solution in bad conditions. It is also noted that the curve slope between the 20 sensors and 35 sensors was large compared to the curve slope between the 35 sensors and 40 sensors. We can conclude that in a RoI with our characteristics (\(L\times W,r,n,m\)), the optimal number of deployed sensors to have total coverage of the monitoring area varied between 35 and 40 sensors. In reference [23], 20 sensors from total 40 sensors were used to completely cover an area of 20 m\({}^{2}\). Therefore, the number of deployed sensors was optimized by 50%.