Skip to content

Latest commit

 

History

History
54 lines (36 loc) · 3.02 KB

pso_multiswarm.rst

File metadata and controls

54 lines (36 loc) · 3.02 KB

Moving Peaks Benchmark with Multiswarm PSO

In this example we show how to use the ~deap.benchmarks.movingpeaks.MovingPeaks benchmark. A popular algorithm on this benchmark is the Multiswarm PSO (MPSO) [Blackwell2004] which achieve a great offline error and is able to follow multiple peaks at the same time.

Choosing the Scenario

The moving peak benchmark allows to choose from the 3 original scenarios proposed in the original studies. This is done by retreiving one of the constants defined in the ~deap.benchmarks.movingpeaks module. Here we will use Scenario 2.

/../examples/pso/multiswarm.py

Once the scenario is retrieved, we need to set a few more constants and instantiate the benchmark, here the number of dimensions and the bounds of the problem.

/./examples/pso/multiswarm.py

For a list of all the variables defined in the SENARIO_X dictionaries see ~deap.benchmarks.movingpeaks.MovingPeaks class documentation.

Initialization

As in every DEAP example we are required to create the objects. The moving peak benchmark is a max problem, thus we need a maximizing fitness. And, we associate that fitness to a particle as in the pso_basic example.

/../examples/pso/multiswarm.py

Then, the particle generator is defined. It takes the particle class object pclass into which to put the data. Remeber that creator.Particle, which is gonna be give to this argument in the toolbox, inherits from list and can be initialized with an iterable. The position (elements of the list) and the speed (attribute) of the particle is set to randomly generated numbers between the given bounds.

/../examples/pso/multiswarm.py

The next function update the particle position and speed.

/../examples/pso/multiswarm.py

Thereafter, a function "converting" a particle to a quantum particle with different possible distributions is defined.

/../examples/pso/multiswarm.py

Finally, all the functions are registered in the toolbox for further use in the algorithm.

/../examples/pso/multiswarm.py

Moving Peaks

The registered evaluation function in the toolbox refers directly to the instance of the ~deap.benchmarks.movingpeaks.MovingPeaks benchmark object mpb. The call to mpb evaluates the given individuals as any other evaluation function.

Algorithm

The algorithm is fully detailed in the file pso/multiswarm, it reflects what is described in [Blackwell2004].

Blackwell2004

Blackwell, T., & Branke, J. (2004). Multi-swarm optimization in dynamic environments. In Applications of Evolutionary Computing (pp. 489-500). Springer Berlin Heidelberg.