eekenpiet

eekenpiet

Genetic Algorithms in Elixir: Error in chapter 8 page 132 ebook version 1.02

Elitist gives error at Enum.sort_by…
This is because “parents” is still a list of tuples.
It hast to be flattened: parents = Enum.flat_map(parents, fn {a, b} → [a, b] end)
The same should also be done in uniform, although no error is given there with the Enum.take.
I do not know why not?

Why is this not regognized?
Because “reinserton_strategy: &Toolbox.Reinsertion.elitist(&1, &2, &3, 0.1)” and “reinserton_strategy: &Toolbox.Reinsertion.uniform(&1, &2, &3, 0.1)” just take “pure”.
Haha!
And that is because of the typo “reinserton”!
If one correct that typo one should see:
Function<………… in file:scripts/schedule.exs> with arity 3 called with 4 arguments

The correct way to do this is:

#In schedule.exs
reinsertion_strategy: &Toolbox.Reinsertion.elitist/4 
survival_rate: 0.1

#And in reinsertion
survival_rate = Keyword.get(opts, :survival_rate, 0.1)
info = Function.info(strategy_fn)

    case info[:name] do
      :pure -> strategy_fn.(parents, offspring, leftover)
      _ -> strategy_fn.(parents, offspring, leftover, survival_rate)
    end

Where Next?

Popular Pragmatic Bookshelf topics Top

telemachus
Python Testing With Pytest - Chapter 2, warnings for “unregistered custom marks” While running the smoke tests in Chapter 2, I get these...
New
lirux
Hi Jamis, I think there’s an issue with a test on chapter 6. I own the ebook, version P1.0 Feb. 2019. This test doesn’t pass for me: ...
New
mikecargal
Title: Hands-on Rust: question about get_component (page 295) (feel free to respond. “You dug you’re own hole… good luck”) I have somet...
New
patoncrispy
I’m new to Rust and am using this book to learn more as well as to feed my interest in game dev. I’ve just finished the flappy dragon exa...
New
AndyDavis3416
@noelrappin Running the webpack dev server, I receive the following warning: ERROR in tsconfig.json TS18003: No inputs were found in c...
New
brunogirin
When I run the coverage example to report on missing lines, I get: pytest --cov=cards --report=term-missing ch7 ERROR: usage: pytest [op...
New
brunogirin
When installing Cards as an editable package, I get the following error: ERROR: File “setup.py” not found. Directory cannot be installe...
New
oaklandgit
Hi, I completed chapter 6 but am getting the following error when running: thread 'main' panicked at 'Failed to load texture: IoError(O...
New
gorkaio
root_layout: {PentoWeb.LayoutView, :root}, This results in the following following error: no “root” html template defined for PentoWeb...
New
SlowburnAZ
Getting an error when installing the dependencies at the start of this chapter: could not compile dependency :exla, "mix compile" failed...
New

Other popular topics Top

PragmaticBookshelf
Write Elixir tests that you can be proud of. Dive into Elixir’s test philosophy and gain mastery over the terminology and concepts that u...
New
AstonJ
You might be thinking we should just ask who’s not using VSCode :joy: however there are some new additions in the space that might give V...
New
Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New
PragmaticBookshelf
Learn different ways of writing concurrent code in Elixir and increase your application's performance, without sacrificing scalability or...
New
Margaret
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
1147 29994 760
New
PragmaticBookshelf
Rails 7 completely redefines what it means to produce fantastic user experiences and provides a way to achieve all the benefits of single...
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
PragmaticBookshelf
Author Spotlight: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New
New
New

Sub Categories: