Looking Deeper into Genetic Algorithms
Genetic Algorithms in Elixir — by Sean Moriarity (21 / 101)
👈 Reviewing Genetic Algorithms | TOC | Using Mix to Write Genetic Algorithms 👉
Based on what you’ve learned so far, you should understand that every genetic algorithm follows the same basic steps. While different algorithms for different problems may use different techniques, probabilities, or strategies, they all share the same structure. As a programmer, you want to take advantage of this.
One of the golden rules of programming is Don’t Repeat Yourself (DRY), which essentially boils down to not rewriting unnecessary code. You can exploit the shared structure of genetic algorithms to avoid rewriting code that remains the same from algorithm to algorithm. Unfortunately, you have to start from scratch.
So how do you go about designing a versatile framework from the ground up? Start with the basics. All genetic algorithms follow the same structure. They all use chromosomes and populations, and they all require similar inputs. You can use this to your advantage and begin designing from the ground up.
Chromosomes and Populations
Chromosomes represent solutions to problems. In the One-Max problem, your solutions consisted of a series of 1s and 0s; however, that won’t be the case for every problem. Some problems are encoded using real values, some as permutations, and some using characters. Also, some…