OFEC logo OFEC

Reference

R. Eberhart and J. Kennedy. (1995). “A new optimizer using particle swarm theory”. Proceedings of the Sixth International Symposium on Micro Machine and Human Science.

Pseudocode

  1. Set algorithm parameters C$_1$, C$_2$, and W
  2. Initialize swarm $\mathbb{S}=\{\mathbf{p}_1,\ldots,\mathbf{p}_N\}$.
    1. For each $\mathbf{p}_i \in \mathbb{S}$:
      1. Initialize $\mathbf{p}_i=\{$x, v, x$_{pbest}$, f(x), f(x$_{pbest}$)$\}$
      2. Evaluate f(x)
      3. $\{$x$_{pbest}$, f(x$_{pbest}$)$\}\gets\{$ x, f(x)$\}$
    2. update_best()
  3. While termination criterion is not fulfilled:
    1. For each $\mathbf{p}_i\in \mathbb{P}$ (with random sequence):
      1. set_neighborhood()
      2. $\{$x$_{lbest}$, f(x$_{lbest}$)$\}\gets$ get_best_neighbor($i$)
      3. v $\gets$ next_velocity(x$_{lbest}$, W, C$_1$, C$_2$)
      4. x $\gets$ move(x, v)
      5. x $\gets$ clamp_velocity(x)
      6. Evaluate f(u)
      7. If better(f(x), f(x$_{pbest}$)):
        1. $\{$x$_{pbest}$, f(x$_{pbest}$) $\}\gets\{$x, f(x)$\}$
        2. update_best($\{$x, f(x)$\}$)
  4. Output results

swarm

Class view

template <typename Particle>
class swarm : public population<Particle> 

Links: population

Data member

Name Type Utility
m_C1 m_C2 real The value of accelerators C$_1$ and C$_2$
m_weight real The value of inertia weight W
m_link vector<vector<bool>> The connections between particles
m_flag_best_impr bool Whether the global best particle improves

Member function

Name Utility
evolve()  
set_neighborhood() The adaptive random topology by default
get_best_neighbor(idx) Return the best neighbor of the idx-th particle

particle

Class view

class particle : public individual<> 

Links: individual

Data member

Name Type Utility
m_pbest solution<> The personal best position
m_vel vector<real> The velocity vector

Member function

Name Utility
initialize_velocity()  
next_velocity(lbest, w, c1, c2)  
move()  
clamp_velocity()  

SPSO-07

Reference

C. Maurice. (2007). “Standard pso 2007 (spso-07)”.

Command line arguments example

AN=SPSO07 PS=100

Class view

class SPSO07 final : public algorithm

Data member

Name Type Utility
m_pop swarm<particle07>  

Member function

Name Utility
initialize()  
run_()  
record()  

Class view

class particle07 final : public particle

Member function

Name Utility
initialize_velocity()  
next_velocity(lbest, w, c1, c2)  

SPSO-11

Reference

C. Maurice. (2011). “Standard PSO 2011 (SPSO-2011)”.

Command line arguments example

AN=SPSO11 PS=100

Class view

class SPSO11 final : public algorithm {

Data member

Name Type Utility
m_pop swarm<particle11>  

Member function

Name Utility
initialize()  
run_()  
record()  

Class view

class particle11 final : public particle

Member function

Name Utility
initialize_velocity()  
next_velocity(lbest, w, c1, c2)  
clamp_velocity()