Genetic Algorithms in Elixir: Some feedback, a question and suggestion

@seanmor5 - This is a great book so far… I’m enjoying reading and coding along with it!

Quick question, though - since “evaluate” goes to the trouble of calling the “fitness_function” and generating an updated list of Chromosomes with the new calculated “fitness” values in the struct, instead of ending the function with this (where it has to call the “fitness_function” a bunch more times):

 |> Enum.sort_by(fitness_function, &>=/2)

why not end it with this (in order to use these pre-calculated values)?

|> Enum.sort_by(& &1.fitness, &>=/2)

Also, I’m kinda sad that you dismissed the tree-type genetic programming like John Koza did in the 60s and 70s (to generate electronic circuits and a whole bunch of other cool stuff), but that is a huge topic in itself. Also, I’m extremely interested in Gene Expression Programming invented by Dr. Candida Ferreira, but that is also tree-type.

Anyway, thanks for the great book, and I look forward to your updates!

– Glenn

1 Like

Good catch! I think that’s the result of me forgetting to update the call to sort_by after I added in the fitness calculation for each chromosome. I’ll make sure that gets fixed.

I thought a lot about whether or not to include some examples of Genetic Programing and other tree-type methods. Ultimately I thought it might have been a lot of overhead just to get a simple example up and running and I was trying to cover a lot of ground without getting too carried away with any one topic. I was also trying to make sure the topics built on top of one another and felt like a dive into tree-based encodings and their applications would have been too much of a detour from the progression of the book.

Now that you mention it I think a dive into tree-based encoding schemes would make for an excellent supplement to the book. I’ll put something together and release it on my blog for anybody who’s interested.

3 Likes

Awesome! Can you please provide a link to your blog? I don’t remember seeing it in the book (yet).

Also, just for kicks, you might enjoy checking out my early attempts of Gene Express Programming (in Go) from a few years back: GitHub - gmlewis/gep: Gene Expression Programming in Go

– Glenn

1 Like

You could add it to your profile as well Sean :+1:

1 Like

Thanks for the suggestion. It’s in my profile. Not much content…yet.

2 Likes

Just noticed another small point: be consistent on using the pipeline operator for the first parameter. This has the added benefit of making the examples read better on narrow screens.

Still enjoying the book…

1 Like