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 Breed Solutions

You know the solutions are pairs of numbers, which you need to initialize. You can weed out a few numbers with a little thought since they are bound to fail. Armed with a handful of initial attempts, you need a way to pick better ones to breed even better solutions. Once you have a clear idea of the backbone of the algorithm, you can implement the crossover operator to breed new solutions and mutate these from time to time in Python (either 2.x or 3.x), as described in Let’s Fire Some Cannons. Feel free to write the code as you read, or start thinking about how you want to implement this. Be sure to write some unit tests so that you can use these for Mutation Testing.

Starting Somewhere

The GA needs pairs of velocities ...

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