Particle swarm optimization implementation

To locate a minimum of Himmelblau's function using particle swarm optimization, we've created a Python program called, which is located at

The following steps describe the main parts of this program:

  1. We start by setting various constants that will be used throughout the program. First is the dimensionality of the problem at hand two, in our case which, in turn, determines the dimensionality of the location and velocity of each particle. Next comes the population size the total number of particles in the swarm, and the number of generations, or iterations, ...

Get Hands-On Genetic Algorithms with Python now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.