Description Usage Arguments Details Value Examples
Takes parent vector generated by tournament and pairs the parents for use in Crossover
1 | matchParents(parents=parents, nPop=nPop)
|
parents |
a vector indicating parent chromosomes by their row index in the population matrix. They must be generated by tournament selection or the function will return an error. |
nPop |
size of the population of chromosomes |
The function separates the tournament winners randomly into parent pairs for use in Crossover. A parent will never be matched to itself.
a list the first element of which is a vector containing one set of parents and the second elementn of which contains their mates.
1 2 3 4 5 6 7 8 | PopChrom <- matrix(data = sample(x = c(0,1), size = 6*3, replace = TRUE), nrow = 6, ncol = 3)
PopChrom <- safetyFunc(population = PopChrom)
# assumes 1 chrom was left out of of sample and reserved for next gen
parents <- tournamentSelection(population=PopChrom, scores=c(4,50,3,100,4), nPop=6)
matchParents(parents=parents, nPop=6)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.