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
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
!
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
Modern Front-End Development for Rails - application does not start after run bin/setup (page xviii)
Other popular topics
Categories:
Sub Categories:
Popular Portals
- /elixir
- /rust
- /ruby
- /wasm
- /erlang
- /phoenix
- /keyboards
- /python
- /js
- /rails
- /security
- /go
- /swift
- /vim
- /clojure
- /emacs
- /haskell
- /java
- /svelte
- /onivim
- /typescript
- /kotlin
- /crystal
- /c-plus-plus
- /tailwind
- /react
- /gleam
- /ocaml
- /flutter
- /elm
- /vscode
- /ash
- /html
- /opensuse
- /centos
- /php
- /zig
- /deepseek
- /scala
- /lisp
- /textmate
- /sublime-text
- /react-native
- /nixos
- /debian
- /agda
- /kubuntu
- /arch-linux
- /deno
- /django
- /revery
- /ubuntu
- /manjaro
- /nodejs
- /spring
- /diversity
- /lua
- /julia
- /c
- /slackware







