Understanding the Flow of Genetic Algorithms
Explore the recursive structure of genetic algorithms in Elixir, including termination criteria and key evolutionary steps like evaluation, selection, and crossover. Understand how populations evolve through transformations over generations to approach optimized solutions.
Recursive nature of genetic algorithms
We’re now ready to start writing our algorithm. But, before we begin, let us take a look at the following question:
What do you notice about the structure of the genetic algorithm described in the previous lesson? Specifically, what happens after children are mutated?
Having that knowledge in mind, we would add the following code snippet in our genetic algorithm below the initial population that we defined in the previous lesson:
The algorithm is an anonymous function that takes two parameters: population, which represents the current generation’s population, and the algorithm parameter, which is a reference to itself. This is a trick used to implement an anonymous recursive function. It’s not essential to understand why this works or why this is necessary. The most important information to know is that the algorithm is a reference to the algorithm function.
In other languages, ...