Skip to content

Particle Swarm Optimization

Leo Hanisch edited this page Nov 9, 2020 · 2 revisions

This repository also implements modified particle swarm optimization that was introduced by Yuhui Shi and Russell C. Eberhart in their paper A modified particle swarm optimizer in 1998 (DOI: 10.1109/ICEC.1998.699146). Their approach introduces a so called inertia weight w. To get the original particle swarm optimization algorithm, just set the parameter --weight=1.

Features

Enables particle swarm optimization to one of the provided 2D functions. The algorithm tries to find the global minimum of the selected function. Any of landscapes' 2D or nD functions can be selected.

The plot shows all particles and their velocities.

CLI

To print all available options execute:

swarm particles -h

API

In addition to the cli you can also use the API:

from swarmlib import PSOProblem, FUNCTIONS

problem = PSOProblem(function=FUNCTIONS['michalewicz'], particles=14)
best_particle = problem.solve()
problem.replay()

Example

particle swarm optimization