Let’s Fire Some Cannons

The GA starts with a generation of random_tries. The GA selects parents from each generation to breed new solutions by crossover. It then has a new generation and will perform mutation on a few of the pairs to keep some variety. Crossover picks angles and velocities from the parents, so mixes things up a bit, but mutation ensures more variety, by changing the numbers. Crossover could splice together two seating plans but would need to deal with two guests ending up in the same seat. Mutation could swap two guests. These two operations depend on the problem at hand.

You can try crossover or mutation by themselves, but the combination allows the GA to explore more and makes it more likely to find a good solution more ...

Get Genetic Algorithms and Machine Learning for Programmers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.