Chapter 2
Okay, so chapter 1 mostly introduced genetic algorithms and this population > evaluate > selection > crossover > mutation
workflow, but had a lot of the parameters hard-coded, and it was presented as a stand-alone exs
script. By the time I finished it, I knew what was coming in chapter 2.
So, we took everything learnt in chapter 1, and modularized it in chapter 2. Lift the hard-coded values and turn them into (hyper)parameters, inject the genotype and fitness function, and have the solution run while punching everything in.
All in all, a nice supplement to chapter 1, quite a few new concepts to learn (Hyper-parameters!). And learned a new word: Genotype.
No, I looked up genotype and saw the definition read as:
In a broad sense, the term “genotype” refers to the genetic makeup of an organism ; in other words, it describes an organism’s complete set of genes. In a more narrow sense, the term can be used to refer to the alleles, or variant forms of a gene, that are carried by an organism.
I was wondering why the function name wasn’t something like make_chromosome
or something like that, but this term seemed to be a good fit for the purpose!
Error?
On page 27, when run
was defined, we see fitness_function
as the first argument. However, on page 28 when it introduces the opt
parameter, it has genotype
as the first argument (We see the same thing at the bottom of that page too as run
receives code). However, on page 30, when run
is called to form solution, we see soln = Genetic.run(fitness_function, genotype, max_fitness)
, fitness_function
is back at number 1 position. Update: Looks like someone already reported this one here!
Looking at how population
gets the first spot for other functions and fitness_function
being second, I feel it should also be the case for run
. But even if not, the function got different signatures here.
Looking forward to starting next weekend, I’ll get back with update once done with that.