Using Behaviours to Model Problems

Genetic Algorithms in Elixir — by Sean Moriarity (29 / 101)

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Using Structs to Represent Chromosomes | TOC | Understanding and Choosing Genotypes 👉

Recall that one technique to solving problems is to transform them into a form you already understand. While every problem seems different, and on the surface may require different techniques to solve, they almost always have patterns and similarities between them. This is especially true with the problems you’ll solve with genetic algorithms.

The framework you built in Chapter 2, Breaking Down Genetic Algorithms, separates a few problem-specific parameters from the common aspects of a genetic algorithm. These parameters are a fitness function, a genotype, and termination criteria. This means that every problem you attempt to solve using a genetic algorithm must implement all three of these functions — the nature of the framework creates a natural abstraction for problems.

An abstraction is a simplification of underlying complexities and implementations. The purpose of abstraction is to force you to think of things at different levels of specificity. It gives you an idea of what to look for before you approach a problem. This is especially useful when approaching new problems with genetic algorithms. When you want to approach a new problem, you already know that you need a fitness function, or a way to measure success; a genotype, or a way to represent solutions; and some termination…

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.