## 3 Iterative Search Algorithms
### Population-Based Algorithms
#### 3.3.5 Particle Swarm Optimization  
Particle swarm optimization (PSO) is another form of PB metaheuristic, developed by [PERSON] and [PERSON] in 1995 [51]. Contrarily to previously presented EAs, PSO was inspired by the social behavior of living organisms, such as birds and fish, when looking for food sources. Following PSO's nomenclature, a population is called _swarm_, and a candidate solution is a _particle_. Figure 7: Procedural steps of differential evolution. In PSO, the position of particle \(p\) at iteration \(i\), formally represented as \(\vec{x}_{p,i}\) is updated at each iteration based on a procedure that takes into account two components: particle's and swarm's best-so-far positions. The former (also known as the _local best_) relates to the cognitive component of the particle (i.e., its _memory_). The latter (also known as the _global best_) relates to the social component of the particle (i.e., its _cooperation_ with surrounding neighbors). Since the introduction of PSO, the scientific community has proposed numerous variations to improve its effectiveness. In our library, we rely on the variant of _gbest_ PSO proposed by [PERSON] and [PERSON] in 1998 [52], where authors have introduced a new parameter, called inertia weight (\(w\)). Formally, the procedure for a particle's position update is defined as \(\vec{x}_{(p,i)}=\vec{x}_{(p,i-1)}+\vec{v}_{(p,i)}\), such that \(\vec{v}_{(p,i)}=w*\vec{v}_{(p,i-1)}+C_{1}\vec{\Phi}_{1}(\vec{best}_{p}-\vec{x }_{(p,i-1)})+C_{2}\vec{\Phi}_{2}(\vec{best}-\vec{x}_{(p,i-1)})\), where \(\vec{best}_{p}\) and \(\vec{best}\) represent the local and global best, respectively, with \(C_{1}\) and \(C_{2}\) being two positive constants used to scale their contributions in the equation (also known as acceleration coefficients). The quantities \(\vec{\Phi_{1}}\) and \(\vec{\Phi_{2}}\) are two random vectors whose values follow \(\sim\)\(U(0,\,1)\) at each dimension. Since a large value of \(w\) can help to find a good area through exploration in the beginning of the search, and a small \(w\) in the end, when typically a good area was found already, a time-decreasing \(w\) can be used instead of a fixed one [53]. Following the aforementioned definition of the update-rule, the swarm's positions are updated, taking in consideration the same version of the global best, which was obtained after evaluating the whole swarm at the previous iteration (\(i-1\)). That is, the global best is first identified and then used by all the particles in the swarm. The strength of this update method, frequently called synchronous-PSO (S-PSO), relies in the exploitation of the information. The main steps of S-PSO are represented in Figure 8. [PERSON] and [PERSON] [54] proposed an asynchronous update (A-PSO), in which global best is identified immediately after updating the position of each particle. Hence, particles are updated using incomplete information, enhancing the algorithm's exploratory features. The main steps of A-PSO is represented in Figure 9.  
After the introduction of A-PSO, one can identify some degree of ambiguity in the scientific community regarding which variant performs better; some pointing to its superiority [55], but others point to the opposite [56]. For this reason, we have decided to include both variants to open the possibility to assessing the impact of synchronization in continuous problem solving. These are implemented as _SPSO_ and _APSO_ classes. The former extends _PopulationBased_, whereas the latter extends _SPSO_; both require an additional parameter, called _v_clamp_ which allows one to bound represents the velocity vector to foster the convergence, as suggested in [53]. The **solve** method for _SPSO_ and _APSO_ reflects the underlying algorithmic logic which guides the search-procedure. Additionally, both classes implement a private method, called _update_, which efficiently encapsulates step number 2 from the procedural steps of S-PSO and A-PSO, and constitutes the main difference between the two classes.