## 3 Introduction to Particle Swarm Optimization  
Particle Swarm Optimization [24; 25; 26; 27] (from now on PSO) is a metaheuristic inspired on the social behavior of flocks of birds when flying, as well as on the movement of shoals of fish. A population of entities moves in the search space during the execution of the algorithm. These entities are very simple and perform local interactions. The result of combining simple behaviors is the emergence of complex behaviors and the ability to get good results as a team. It is assumed that the flock searches for _food_ in an area and that there are some food at each point in the area. It is also assumed that birds in the flock do not know where the maximum amount of food is, but they can see where other birds are, so a good strategy to find a big food source is to follow the bird that found the biggest food source so far. PSO emulates this behavior to solve optimization problems. Each solution or particle is a bird in the search space that is always moving and never dies. In some versions of PSO, birds can actually die. In fact, we can consider that the swarm is a multi-agent system where particles are simple agents that move through the search space and store (and possibly communicate) the best solution found so far. Each element of the swarm has a fitness value, a position and a velocity vector that directs its flight. The movement of particles is partially guided by the best solution found by all particles. Concretely, a particle \(sw_{i}\) is composed of four vectors: (a) Vector \(x_{i}\), which stores the current position (location) of the particle in the search space; (b) vector \(v_{i}\), which stores the velocity vector according to which the particle moves; (c) vector \(p_{i}\), which stores the location of the best solution found by the particle so far; and (d) vector \(g\), which stores the location of the best solution found by the swarm and is common to all entities. It also has three fitness values: (i) \(x_{i}^{fitness}\), which stores the fitness of the current solution (\(x_{i}\) vector); (ii) \(p_{i}^{fitness}\), which stores the fitness of the best local solution (\(p_{i}\) vector); and (iii) \(g^{fitness}\), which stores the fitness of the best global solution (\(g\) vector). The movement of each particle \(sw_{i}\) depends on the best solution it has found since the algorithm started, \(p_{i}\), and the best solution found by all particles in the entire cloud of particles, \(g\). This kind of particle neighborhood, where all particles in the swarm are attracted to the best solution, is called _gbest_ neighborhood [34]. There exist other kinds of social structures, such as the _lbest_ neighborhood, where each element is guided by the best solution found by its \(k\) nearest neighbors. The behavior of other neighborhood topologies has been studied [35]. In particular, it is shown that using an adequate topology is important to obtain good performance, although the best choice depends on the problem being solved. Generally, the gbest topology provides a quick algorithm convergence. According to this topology, the velocity \(v_{i}\) of \(sw_{i}\) is changed at each iteration of the algorithm to bring it closer to positions \(p_{i}\) and \(g\). Given a swarm \(sw\) where \(S\) is the number of particles in \(sw\), the goal is to minimize or maximize a function \(f:\mathbb{R}^{n}\rightarrow\mathbb{R}\) (hereafter we will assume that the goal is minimizing it). A basic PSO algorithm follows:  
(Initialization) For \(i=1,\ldots,S\) Do  initPosition(\(i\))  initBestLocal(\(i\))  If \(i=1\) Then initBestGlobal()  If improvedGlobal(\(i\)) Then updateBestGlobal(\(i\))  initVelocity(\(i\))  End For  
(While loop)  While not endingCondition()  For \(i=1,\ldots,S\) Do  createRnd(rp,rg)  updateVelocity(\(i\),rp,rg)  updatePosition(\(i\))  If improvedLocal(\(i\)) Then updateBestLocal(\(i\))  If improvedGlobal(\(i\)) Then updateBestGlobal(\(i\))  End For  End While  
We comment on the algorithm steps.