select_parent: Selects parents for the next generation of creatures

View source: R/select_parent.R

select_parentR Documentation

Selects parents for the next generation of creatures

Description

This function's purpose is to take a score vector and to return a vector of the next generation of parents. To do this to do this it the number of parents required per an offspring, and the general population required. The resulting new_parents vector will be of length pop_required * number_of_parents.

Usage

select_parent(
  score_vec,
  number_of_parents,
  method = "roulette",
  susN = 1,
  tourn_size = 4,
  pop_required
)

Arguments

score_vec

a positive, numeric vector with length equal to the total population

number_of_parents

an integer indicating the number of parents per offspring

method

the method of choosing parents, 'roulette', 'rank', 'tournament', and 'sus'

susN

if sus is selected how many parents are chosen scholastically

tourn_size

if tournament is chosen how many candidates are in the tournament

pop_required

number of offspring needed at the start of the next generation

Details

Roulette Method selects parents randomly with a probability proportional to their fitness

Rank Method selects parents randomly with a probability proportional to the rank of their fitness

Tournament uses tourn_size to randomly group that many creatures together. The most fit in that group becomes a parent.

Stochastic Universal Sampling works like roulette but also selects a number (susN) more candidates at a fixed width from the first draw to increase diversity

Value

a numeric vector indexing which parents are reproducing for the next generation

Examples

score_vec <- abs(rnorm(10))
number_of_parents <-2
pop_required <- 10

new_parents <- select_parent(score_vec = score_vec,
 number_of_parents = number_of_parents,pop_required = pop_required)


AndrewM1130/GA documentation built on July 9, 2022, 11:43 a.m.