# System Design and Reliability Improvement of Wireless Sensor Network in Plant Factory Scenario
## 2 Materials and Methods
### Network Coverage Optimization Model Development  
#### 2.4.1 PSO Algorithm  
Coverage optimization in WSN is a critical issue that directly influences network performance. Among various optimization approaches, heuristic algorithms have attracted significant attention due to their effectiveness in addressing complex, high-dimensional, and nonlinear problems. In this study, the particle swarm optimization (PSO) algorithm was chosen, as it exploits the collaborative and competitive behaviors observed in biological swarms to identify optimal solutions through iterative evolution, thereby achieving global optimization objectives [32]. Compared with heuristic optimization algorithms such as ant colony optimization (ACO), the genetic algorithm (GA), and differential evolution (DE), the particle swarm optimization (PSO) algorithm incorporates fewer stochastic components during the iterative evolution process. Consequently, it exhibits superior memory performance, faster convergence to optimal solutions, and advantages such as a simpler structure and higher convergence speed. When \(N\) particles solve the D dimensional problem, the swarm can be described as  
\[\left\{ \begin{array}{l}x_{i}=\bigl{(}x_{i}^{1},x_{i}^{2},\cdots,x_{i}^{D} \bigr{)},i=1,2,\cdots,N\\ v_{i}=\bigl{(}v_{i}^{1},v_{i}^{2},\cdots,v_{i}^{D}\bigr{)},i=1,2,\cdots,N\\ P_{best}=\Bigl{(}P_{best}^{1},P_{best}^{2},\cdots,P_{best}^{D}\Bigr{)}\\ G_{best}=\Bigl{(}G_{best}^{1},G_{best}^{2},\cdots,G_{best}^{D}\Bigr{)}\end{array} \right. \tag{4}\]  
where \(i\) denotes the number of the particle, D is the dimension of the solution problem, v\({}_{i}\) = [v\({}_{i}\)\({}^{1}\), v\({}_{i}\)\({}^{2}\), \(\ldots\), v\({}_{i}\)\({}^{D}\)] denotes the velocity vector of each particle, and x\({}_{i}\) = [x\({}_{i}\)\({}^{1}\), x\({}_{i}\)\({}^{2}\), \(\ldots\), x\({}_{i}\)\({}^{D}\)] denotes the position vector of each particle. The algorithm also requires that each particle maintains a historical optimal position solution for the population to which it belongs, denoted by \(P_{best}\). In addition, all populations jointly maintain a globally optimal solution, denoted by \(G_{best}\). The steps of the PSO algorithm are described as follows:  
Step 1: It initializes the velocities and positions of all particles and sets the individual's historical optimal solution \(P_{best}\) as the current position and the individual of the population optimal solution as the current \(G_{best}\). Step 2: In each generation of evolution, it calculates the fitness function value for each particle. Step 3: If the current fitness function value of the particle is better than its historical optimal solution, then the historical optimal solution is replaced by the current position. Step 4: If the historical optimal solution of the particle is better than the global optimal solution, then the global optimal solution is replaced by the historical optimal solution of the particle. Step 5: The velocity and position in the Dth dimension of each particle i is updated as  
\[ \begin{cases}{x_{i}}^{D}(k+1)=&{x_{i}}^{D}(k)+{v_{i}}^{D}(k+1)\\ {v_{i}}^{D}(k+1)=&\omega\times{v_{i}}^{D}(k+1)+{c_{1}}\times{r_{1}}\times({P_{ best}}^{D}(k)-{x_{i}}^{D}(k))\\ &+{c_{2}}\times{r_{2}}\times({G_{best}}^{D}(k)-{x_{i}}^{D}(k))\end{cases}  \tag{5}\]  
where \(\omega\) is the inertia weight; k is the number of iterations; c\({}_{1}\) and c\({}_{2}\) represent the acceleration coefficients for the individual and the population, respectively; r\({}_{1}\) and r\({}_{2}\) are two random numbers on the interval [0,1]; and x\({}_{i}\)D(k) and v\({}_{i}\)D(k) represent the position and velocity of the particle i in the D dimension in the kth iteration, respectively. In addition, PSO requires the use of a constant V\({}_{\text{max}}\) to limit the velocity range of particles so that \(v_{i}^{D}\in[V_{\text{max}},V_{\text{max}}]\). Step 6: If the termination condition is satisfied, it outputs G\({}_{\text{best}}\) and ends the process. Otherwise, it repeats steps 2-5.