Breed: Breed

Description Usage Arguments Details Value Examples

Description

Perform recombination on chromosomes

Usage

1
Breed(population, method, scores, nPop, nGenes)

Arguments

population

Matrix of chromosomes currently in the population.

method

One of three methods for choosing which chromosomes pair before crossover.

  • oneScore: One parent is picked proportional to score, the second is random.

  • twoScore: Both parents are picked proportional to score.

  • tournament: Tournament selection method.

scores

List of scores for each model, generated by scoreFunc().

nPop

Integer defining the population size. Equal to the length of population and scores.

nGenes

Integer number of genes provided by the user or calculated prior to running the model.

Details

This function performs crossovers between chromosomes to generate the next generation of population. It performs an elite style recombination, where the best scoring chromosome is always kept and the worst is removed, then applies one of 3 methods to determine the crossovers between the remaining chromosomes. Crossovers are then performed randomly within each pair.

Value

A matrix of chromosomes, with nRow=nPop and nCol=nGenes.

Examples

1
2
3
4
5
6
7
set.seed(42)
test_PopChrom <- matrix(sample(c(0,1),16,replace=T), ncol = 4, nrow = 4)
test_Method <- "tournament"
test_Score <- rnorm(n = 4, mean = 10, sd = 1)
test_nPop <- 4
test_nGenes <- 4
Breed(test_PopChrom, test_Method, test_Scores, test_nPop, test_nGenes)

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