chriseyre2000

chriseyre2000

Genetic Algorithms in Elixir: Chapter 2

Now working through chapter 2.

An underscore makes a better placeholder than …

Intialize is added above the two rum functions. We only have one so far…

The first evolve does not need opts.

Most of the new functions should start as defp

run does not need the population variable.

By Hyperparameters initialize already takes genotype so opts is an additional Param.

Most Liked

seanmor5

seanmor5

Author of Genetic Algorithms in Elixir

I’ll adjust the placeholder. As far as the reference to two run functions, I initially named run and evolve the same thing, I must have missed that reference. Most of the stuff in regards to passing hyperparameters via opts is necessary for playing with some configurations later on. For example, opts is used to specify :population_size in initialize. I believe there’s a mistake in the transcription of the signature of initialize where it says:

def initialize(opts \\ []) do
   # ...omitted...
end

It should say:

def initialize(genotype, opts \\ []) do
   # ...omitted...
end

Thank you for the feedback :slight_smile: !

srowley

srowley

I am really enjoying the book (B2) so far.

The version of evolve/4 on page 27 takes genotype as an argument, but it doesn’t seem to need it for anything other than to pass it to itself again recursively. The version on page 28 looks like it was corrected in this regard.

If that isn’t needed, it seems like a slightly prettier way to write run/3 would be:

def run(genotype, fitness_function, max_fitness) do
  genotype
  |> initialize() # maybe call this `initialize_population`
  |> evolve(fitness_function, max_fitness)
end

An even more pedantic suggestion - use verbs for all the function names in the pipeline, i.e., mutate instead of mutation and maybe cross instead of crossover.

Popular Pragmatic Bookshelf topics Top

jesse050717
Title: Web Development with Clojure, Third Edition, pg 116 Hi - I just started chapter 5 and I am stuck on page 116 while trying to star...
New
yulkin
your book suggests to use Image.toByteData() to convert image to bytes, however I get the following error: "the getter ‘toByteData’ isn’t...
New
jdufour
Hello! On page xix of the preface, it says there is a community forum "… for help if your’re stuck on one of the exercises in this book… ...
New
digitalbias
Title: Build a Weather Station with Elixir and Nerves: Problem connecting to Postgres with Grafana on (page 64) If you follow the defau...
New
New
taguniversalmachine
It seems the second code snippet is missing the code to set the current_user: current_user: Accounts.get_user_by_session_token(session["...
New
jonmac
The allprojects block listed on page 245 produces the following error when syncing gradle: “org.gradle.api.GradleScriptException: A prob...
New
kolossal
Hi, I need some help, I’m new to rust and was learning through your book. but I got stuck at the last stage of distribution. Whenever I t...
New
jwandekoken
Book: Programming Phoenix LiveView, page 142 (157/378), file lib/pento_web/live/product_live/form_component.ex, in the function below: d...
New
davetron5000
Hello faithful readers! If you have tried to follow along in the book, you are asked to start up the dev environment via dx/build and ar...
New

Other popular topics Top

New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New
AstonJ
There’s a whole world of custom keycaps out there that I didn’t know existed! Check out all of our Keycaps threads here: https://forum....
New
Exadra37
On modern versions of macOS, you simply can’t power on your computer, launch a text editor or eBook reader, and write or read, without a ...
New
Rainer
Not sure if following fits exactly this thread, or if we should have a hobby thread… For many years I’m designing and building model air...
New
AstonJ
Continuing the discussion from Thinking about learning Crystal, let’s discuss - I was wondering which languages don’t GC - maybe we can c...
New
mafinar
This is going to be a long an frequently posted thread. While talking to a friend of mine who has taken data structure and algorithm cou...
New
AstonJ
If you want a quick and easy way to block any website on your Mac using Little Snitch simply… File > New Rule: And select Deny, O...
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New
AstonJ
This is cool! DEEPSEEK-V3 ON M4 MAC: BLAZING FAST INFERENCE ON APPLE SILICON We just witnessed something incredible: the largest open-s...
New

Sub Categories: