Skip to content

Commit

Permalink
fix #55
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobbossek committed Feb 17, 2015
1 parent 263f552 commit 874a506
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion R/generateOffspring.R
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ simpleUniformSelection = function(matingPool) {
population = matingPool$individuals
fitness = matingPool$fitness
n = nrow(population)
idx = sample(n, size = 2, replace = FALSE)
# if we have only one individual, return it twice
if (n == 1) {
return(makePopulation(population[c(1, 1), , drop = FALSE], fitness[c(1, 1)]))
}
idx = sample(n, size = 2, replace = FALSE)
makePopulation(population[idx, , drop = FALSE], fitness[idx])
}

0 comments on commit 874a506

Please sign in to comment.