selection: Select Parents to Breed Based on Given Selection Mechanism

Description Usage Arguments Details Value

Description

Selects parents based on specified selection mechanism. The possibile selection mechanism includes (1)selecting both parents with probability proportional to ranking, (2)selecting one parent with probability proportional to ranking and one parent randomly, and (3)selecting with method of tournament selection.

Usage

1
selection(pop, fitScores, offspringNum, method = 1, K)

Arguments

pop

boleans matrix determined by GA::initialization().

fitnessFunction

fitness function that takes in an lm or glm model and returns a numerical fitness of that model. Users can choose AIC or BIC or even define by themselves.

model

the linear model that user wants to use to fit in the data, can be either lm or glm.

fitScores

fitness scores calculated by GA::fitness(). It must be the case that a lower fitness score means a better model.

offspringNum

number of offspring generated to update the generation.

method

the selection mechanism that user wants to apply to select parents, can be choosen from 1 to 3; 1 indicates selecting both parents with probability proportional to ranking; 2 indicates selecting one parent with probability proportional to ranking and one parent randomly, and 3 indicates selecting with method of tournament selection.

dat

data frame containing the predictors in the model. First column should be the response variable.

K

number of groups to partition the population into for tournament selection

Details

This function selects parents to breed based on the passed in selection mechanism. Select (offspringNum / 2) pairs of parents from the passed in population pop, by specific selection mechanism and the fitness scores fitScores obtained from GA::fitness().

Value

Returns a list containing the index for each of parent 1, the index for each of parent 2, the fittest individual, and the fitness scores for the whole population.


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