matchParents: Match Parents for Tournament selection

Description Usage Arguments Details Value Examples

Description

Takes parent vector generated by tournament and pairs the parents for use in Crossover

Usage

1
matchParents(parents=parents, nPop=nPop)

Arguments

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

Details

The function separates the tournament winners randomly into parent pairs for use in Crossover. A parent will never be matched to itself.

Value

a list the first element of which is a vector containing one set of parents and the second elementn of which contains their mates.

Examples

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)

GilChrist19/GA documentation built on May 13, 2019, 5:32 p.m.