Skip to content

willfurnass/pyshoal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyshoal

An implementation of Particle Swarm Optimisation in Python

Typical usage:

import numpy as np
from pyshoal import PSO

def rastrigin(a, b):
    """Objective function."""
    return 10 * 2 + \
           (a**2 - (10 * np.cos(2 * np.pi * a))) + \
           (b**2 - (10 * np.cos(2 * np.pi * b)))

my_pso = PSO(obj_func=rastrigin,
             box_bounds=((-500, 500), (-500, 500)),
             n_parts=144,
             topo='gbest',
             weights=[0.9, 0.4, 2.1, 2.1],
             extra_args=None,
             minimise=True)

results = my_pso.opt(max_itr=100,
                     tol_thres=(0.01, 0.01),
                     tol_win=5,
                     plot=True,
                     save_plots=False)

(swarm_best, swarm_best_perf, n_itrs) = results

Please see the docstrings in pso.py for more info on pyshoal usage.

Note that pyshoal originally allowed for parallel execution of the objective function at each PSO step. This is not presently supported.

About

Particle Swarm Optimisation implementation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages