## 4 Survey of Existing Works
### PSO in WSNs  
Particle Swarm Optimization (PSO) was invented by [PERSON] and [PERSON] in 1995 [25]. They were trying to simulate the amazing controlled motion of a swarm of birds flying in one direction. In PSO, particles regulate their information (flying directions) with its own flying experience as well as their neighbors' flying experience. In a word it combines self-experience with social experience [33], so the basic PSO was a social behavior simulator. It consists of a swarm of  
Figure 3: A pyramid view of how optimizations of Energy Efficiency, QoS and Security in a wireless sensor network are related to each other.  
candidate solutions called particles. Several revised versions of PSO have emerged with a range of concepts and applications including WSNs. A number of parameters such as inertia weight (_w_) and confidence factors (_c1_, _c2_) were added later on [34, 35] to improve the efficiency of the method. After several improvement processes it was understood that the technique can be used as a population-based optimizer and it can solve stochastic nonlinear optimization problems in a cheaper way. A more recent study on variations and taxonomy of PSO is presented in [36].  
Generating particles' position and velocities, velocity update, and position update- these three main steps defines the PSO algorithm. Here particle refers to a point in a D-dimensional search space that updates its position from one point to another based on related velocity updates. The _i_-th individual (particle) of the population, which is called swarm, can be represented in a D-dimensional vector as, \(X_{i}=\left(x_{i1},x_{i2},...,x_{iD}\right)\). The velocity or the position change for particle \(i\) is represented as \(V_{i}=\left(v_{i1},v_{i2},...,v_{iD}\right)\) and the best previously visited position of this particle is denoted as \(P_{i}=\left(p_{i1},p_{i2},...,p_{iD}\right)\). Symbol \(g\) represents the best particle in the swarm and \(w\) is the inertia weight. The particles are then manipulated according to the following two equations [37]:  
\[V_{id}^{n+1}=wV_{id}^{n}+c_{1}r_{1}^{n}\left(P_{id}^{n}-X_{id}^{n}\right)+c_{2 }r_{2}^{n}\left(P_{gd}^{n}-X_{id}^{n}\right) \tag{4}\]  
\[X_{id}^{n+1}=X_{id}^{n}+V_{id}^{n+1} \tag{5}\]  
where \(d\) = 1, 2,..., D, \(i\) = 1, 2,..., N and N is the size of the swarm and \(n\) = 1, 2,... denotes the iteration number. Two random numbers r1, r2 which are uniformly distributed in [0, 1] ensure good coverage. They also ensure the avoidance of falling into local optima which was a problem of the classical approaches. The inertia weight \(w\) manipulates the trade-off between exploration and exploitation abilities of the flying points. Another two important parameters are _c1_ (self-confidence factor) and _c2_ (swarm confidence factor). The stopping criterion of the algorithm depends solely on which type of problem it's going to deal with. One of the problems of PSO is the tendency towards a fast and premature convergence in mid-optimum points. A lot of effort has been made so far to solve this problem. A general pseudo code of PSO is shown in Figure 4.  
Figure 4: Pseudo code of PSO.  
Because of its inexpensive resource requirements, less occupation of memory and ability to solve stochastic optimization problems in a faster way, PSO is widely used in many types of WSN optimizations like energy aware clustering, optimal WSN deployment, node localization, data aggregation, _etc._