Understanding and Choosing Genotypes

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

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Using Behaviours to Model Problems | TOC | Solving One-Max for the Last Time 👉

One of the most important decisions you can make when using a genetic algorithm is the type of encoding you use to represent solutions. Encodings are simply representations of a single solution. A good encoding needs to contain only the information necessary to represent a complete solution to a problem. If a solution is a path through a grid, an encoding of a solution would only need to contain the coordinates of each gridpoint it passes through.

The type of encoding scheme you use is known as a genotype. The genotype of a chromosome tells you what the chromosome should look like. It defines your search space. For example, if you’re trying to create an optimal shipping route through fifteen cities, your genotype is a permutation of all fifteen cities.

While the genotype is the internal representation of solutions, the phenotype is the expressed representation of solutions. The following figure illustrates the relationship between genotype and phenotype:

images/EncodingProblemsAndSolutions/GenotypePhenotype.png

You don’t need to understand the distinction between genotype and phenotype. It’s just some useful terminology.

--

--

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.