nextGeneration: Breed the Selected Parents Generated From 'GA::selection()'

Description Usage Arguments Details Value Examples

Description

Breed the Selected Parents Generated From GA::selection()

Usage

1
nextGeneration(pop, selResult, G)

Arguments

pop

boleans matrix determined by GA::initialization()

selResult

list returnd by GA::selection() At the minimum, it needs to contain indices for the selected parents 1 and 2.

offspringNum

number of offspring generated to update the generation.

Details

Breeding uses GA::crossover() for each pair of parents. The Generation Gap G is the proportion of the generation to be replaced by generated offspring. If the number of the selected population produced by generation gap is not an even number, choose the nearest bigger even number. Uses the offspringNum number of offspring to replace the least fit individuals in parent generation

Value

Returns a C by P maatrix containing the population for the next generation.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
dat <- mtcars
C <- ncol(dat) - 1
P <- as.integer(1.5 * C)
pop <- initialization(C, P)
fitnessFunction <- AIC
model <- lm
y <- as.matrix(dat[1])
X <- as.matrix(dat[-1])
fitScores <- fitness(pop, y, X, fitnessFunction, model, dat)
offspringNum <- 4
selResult <- selection(pop, fitnessFunction, model, fitScores, offspringNum, method = 1, dat, K = 2)
nextGeneration(pop, selResult, offspringNum)

mindyyang/GA-R-package- documentation built on May 12, 2019, 12:31 a.m.