...

/

Tracking Genealogy in Your Framework

Tracking Genealogy in Your Framework

Learn how to track genealogy in the tiger evolution framework defined so far.

Incorporating genealogy

The genealogy tree should be updated every time we add a new chromosome into the population. That means we should update the genealogy tree after population initialization, after any crossover takes place, and after any mutation takes place.

To do this, start with the population initialization process. After creating the population in initialize/2, we’ll want to immediately add those chromosomes to the genealogy tree, like this:

Press + to interact
def initialize(genotype, opts \\ []) do
population_size = Keyword.get(opts, :population_size, 100)
population = for _ <- 1..population_size, do: genotype.()
Utilities.Genealogy.add_chromosomes(population)
population
end

In this function, rather than immediately returning a new ...

Access this course and 1400+ top-rated courses and projects.