I’m working on particle swarm optimization as my project to Soft computing lectures. If you are interested you can find source code at my github. Here are some gifs I made playing with that:

Sphere

Sphere function as simple optimization problem.

 I used gbest topology here with population of 10 to see it clearly at plot.

sphere

 Rosenbrock function

Rosenbrock or also banana function or valley function. More informations can be found here.

Here I used lbest topology with 4 neighbours for every particle.

rosenbrock

 Rastrigin function

This seems hard. Many local minima can fool the particles, so it takes longer than previous one.

I picked dynamic topology that change every 5 iterations. Each particle has 5 neighbours.

rastrigin