Optimization by Particle Swarm (PSO) was proposed by Kennedy and Eberhart. This method is inspired by the social behavior of swarming animals.

Initially, they sought to simulate the ability of birds to fly synchronously and their ability to change direction suddenly while remaining in optimal training.

Particles are individuals and they move in the hyperspace of research based on limited information:

- Each particle has a memory that allows it to memorize the best point by which it has already passed and it tends to return to that point.
- Each particle is informed of the best known point within its neighborhood and it will tend to move towards this point.

Each individual uses not only his own memory but also local information about his closest neighbors to decide on his own move. Simple rules, such as: going at the same speed as others, moving in the same direction or staying close to one’s neighbors are examples of behaviors that are sufficient to maintain the cohesion of the swarm.

The displacement of a particle is influenced by the three types of behavior:

- A physical component: the particle tends to follow its own path;
- A cognitive component: the particle tends to return to the best point by which it has already passed;
- A social component: the particle tends to move towards the best point already reached by its neighbors.

# Algorithm

In R^{n}, the particle i of the swarm is modeled by its vector position x_{i} = (x_{i1}, …, x_{in}) and by its velocity vector v_{i} = (v_{i1}, …, v_{in}).

This particle keeps in memory the best position by which it has already passed, noted p_{i} = (p_{i1}, …, p_{in}). The best position reached by all the particles of the swarm is noted p_{g} = (p_{g1}, …, p_{gn}).

At time t + 1, the velocity vector is calculated from formula A:

with c_{1 }and c_{2} two constants, called acceleration coefficients; r_{1} and r_{2} are two random numbers drawn uniformly in [0,1].

The three added terms of the formula are explained as follows:

- v
_{ij}(t) corresponds to the physical component of the displacement; - the term afterwards corresponds to the cognitive component of displacement with c
_{1}, which weights the tendencies of the particle to want to follow its instinct of conservation and to move towards its best known position; - the last term corresponds to the social component of displacement. It controls the social fitness of the particle by getting closer to the best position of its informants.

The position of the particle i is then defined by the formula B:

# Pseudo code

The stopping criterion may be different depending on the problem and the requirements of the user. If the global optimum is known a priori, we can define an acceptable error as a stopping criterion. Otherwise, one can set maximum number of iterations or a maximum number of evaluations of the objective function.

# Variants

- To impose a positive and negative max speed
- To apply a coefficient of inertia to the first term of the formula A (Shi and Eberhart 1998)
- To apply a constriction factor in formula A instead of constants (Clerc and Kennedy 2002)
- To apply a neighborhood topology to know with which particle a particle i will communicate (Kennedy 1999)