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 Prag Prog topics Top

abtin
page 20: … protoc command… I had to additionally run the following go get commands in order to be able to compile protobuf code using go...
New
belgoros
Following the steps described in Chapter 6 of the book, I’m stuck with running the migration as described on page 84: bundle exec sequel...
New
sdmoralesma
Title: Web Development with Clojure, Third Edition - migrations/create not working: p159 When I execute the command: user=> (create-...
New
Mmm
Hi, build fails on: bracket-lib = “~0.8.1” when running on Mac Mini M1 Rust version 1.5.0: Compiling winit v0.22.2 error[E0308]: mi...
New
AleksandrKudashkin
On the page xv there is an instruction to run bin/setup from the main folder. I downloaded the source code today (12/03/21) and can’t see...
New
jeremyhuiskamp
Title: Web Development with Clojure, Third Edition, vB17.0 (p9) The create table guestbook syntax suggested doesn’t seem to be accepted ...
New
brian-m-ops
#book-python-testing-with-pytest-second-edition Hi. Thanks for writing the book. I am just learning so this might just of been an issue ...
New
brunogirin
When running tox for the first time, I got the following error: ERROR: InterpreterNotFound: python3.10 I realised that I was running ...
New
ggerico
I got this error when executing the plot files on macOS Ventura 13.0.1 with Python 3.10.8 and matplotlib 3.6.1: programming_ML/code/03_...
New
dachristenson
I just bought this book to learn about Android development, and I’m already running into a major issue in Ch. 1, p. 20: “Update activity...
New

Other popular topics Top

Devtalk
Reading something? Working on something? Planning something? Changing jobs even!? If you’re up for sharing, please let us know what you’...
1016 16836 371
New
malloryerik
Any thoughts on Svelte? Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New
wolf4earth
@AstonJ prompted me to open this topic after I mentioned in the lockdown thread how I started to do a lot more for my fitness. https://f...
New
AstonJ
I’ve been hearing quite a lot of comments relating to the sound of a keyboard, with one of the most desirable of these called ‘thock’, he...
New
PragmaticBookshelf
“A Mystical Experience” Hero’s Journey with Paolo Perrotta @nusco Ever wonder how authoring books compares to writing articles?...
New
PragmaticBookshelf
A Hero’s Journey with Chris Pine @chrispine Chris Pine, author of Learn to Program, Third Edition, discusses his journey to beco...
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
New
foxtrottwist
A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
New
AstonJ
If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol: bre...
New
First poster: bot
The overengineered Solution to my Pigeon Problem. TL;DR: I built a wifi-equipped water gun to shoot the pigeons on my balcony, controlle...
New

Latest in PragProg

View all threads ❯