experiments in particle swarm optimisation

an experiment

consider the problem of finding the point closest to the centre of a square, not hard but easy to visualise

below are three swarms with different configurations trying to solve this problem

ticks represent the personal best of a particle. lines represent where the particle is currently in relation to their best

(it's likely that by the time you get to here the third has already converged on the optimal solution, you might want to hit f5 and refresh)

these particles are just moving in straight lines these particles are also moving in straight lines but have an attraction to return to where they have their personal best these particles move in straight lines, with an attraction to their personal best, but also an attraction to the personal best of two fixed other particles

this problem though is not very hard to solve. a very simple hill climbing algorithm would solve this one since there are no local maximums

let's try something a bit harder