O'Reilly logo

Genetic Algorithms and Machine Learning for Programmers by Frances Buontempo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to Form a Swarm

You built the single particle code already. Drawing several particles is similar. They can even move randomly but don’t improve over time if that is all they do.

First, get the particles following their neighbors by finding these and making a move function to nudge each particle toward these. Unsurprisingly, these tend to gang together and take a long time to escape the paper bag. By making a different move function, the particles swarm out of your paper bag. The individual movement of the swarm particles will combine momentum, picked at random, to begin with. Over time, the movement needs to include movement toward a personal best and the global best to share information through the swarm. The standard PSO calculates a ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required