Skip to content

manishravula/ParticleSwarmOptimization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A 2-Dimensional Particle Swarm Algorithm Implementation

This is an implementation of the Particle Swarm Algorithm for solving two-dimensional optimization problems.

Usage:

The class PSO is the base class to carry out all operations such as updating velocities , positions, global best, local best position values.

class PSO():
    def __init__(self,no_particles,no_dim,self_accel_coeff,global_accel_coeff,dt):

The method PSO.funcdef() holds the required defitinion of the score. It is currently the norm function.

def funcdef(self,locs,no_particles):
    score_curr = np.empty(no_particles);
    for i in range(no_particles):
        score_curr[i] = np.linalg.norm(locs[i])
        print(score_curr[i])
    return score_curr

The animation doesn't occure in realtime. The PSO.valueIO() method writes all states that the particles go through, to a .npy file. The script plotter.py reads the file and animates the states using scatter plots.

Score Function can be changed by changing the methodPSO.funcdef()

Feel free to fork and experiment!

Reference: http://www.softcomputing.net/aciis.pdf

Algorithm implemented from directions given in the above reference article.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages