Skip to content

zaman13/Particle-Swarm-Optimization-PSO-using-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Particle Swarm Optimization (PSO) using Python

alt text alt text alt text

Vectorized general particle swarm optimization code using python.

The code can work with any arbitrary fitness/cost function with arbitrary number of optimization parameters (dimensions). To increase the processing speed, the code has been completely vectorized. All possible parallel operations are implemented using matrix mathematics. Thus, nested loops are avoided. Only a single for loop going over the iterations/generations is used.

Output animation

Generated using pso_2D_animation_v1.py file.

alt text alt text alt text

Version Notes:

v1_1:

  • Added average fitness and average pbest plots for checking convergence

v1_2:

  • The intial variable assignment has been embedded within the loop
  • Added elapsed time calculator