Skip to content

Instantly share code, notes, and snippets.

@machkouroke
Created April 14, 2023 22:31
Show Gist options
  • Save machkouroke/8abb87a4ecaad91b508c5173d58de43c to your computer and use it in GitHub Desktop.
Save machkouroke/8abb87a4ecaad91b508c5173d58de43c to your computer and use it in GitHub Desktop.
function survival(n_survivors::Int64, population::Vector{Chromosome})::Vector{Chromosome}
evaluations::Vector{Float64} = [fitness(x) for x in population]
indices_tries = sortperm(vec(evaluations), rev=true)
return population[indices_tries[1:n_survivors]]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment