Skip to content

Designing a simple and intuitive particle swarm optimization algorithm from scratch, without the use of external ML libraries.

License

Notifications You must be signed in to change notification settings

syntax-surgeon/particle-swarm-from-scratch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

particle-swarm-from-scratch

Designing a simple and intuitive particle swarm optimization algorithm from scratch, without the use of external ML libraries.
(current version: 1.0)

Author: Siddharth Yadav (syntax-surgeon)

main.py

  • Contains version-1.0 of the main program which tries to implement a particle swarm optimization algorithm to optimize several classic functions
  • The available funtions include: Booth, Bukin No.6, Himmelblau and Goldstein-Price
  • The core of the optimization algorithm depends on scaled vector addition influenced by personal and global best solutions
  • The code follows a strong object-oriented style in which both the particle and the swarm are implemented created via their respective classes
  • Advanced plotting is included to visualize the results of the optimization
  • An option to save the results of a particular run is provided (see 'dump_swarm' parameter of 'Swarm' class objects)

plot.py

  • Contains the plotting functionality for the results obtained from run the PSO algorithm from main.py
  • Two styles of graphs are available: a collated graph which includes all the positions sampled by the swarm particles (figure 1) and an animation which shows the movement of particles through the run (figure 2)
  • Generally imported as a module from main.py to utilize the 'plot_pso' function
  • Several options are available to customize the animation such as speed, skip, dimension limits etc (see the documentation of the 'plot_pso' function)

Collated graph showing all particle positions (figure 1)

alt text

Particle movement animation (figure 2)

alt text

About

Designing a simple and intuitive particle swarm optimization algorithm from scratch, without the use of external ML libraries.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages