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