crossover: Genetic Algorithms Crossover Operation

Description Usage Arguments Value Examples

View source: R/utils.R

Description

Performs a crossover operation for the specified type and parents.

Usage

1
crossover(parent1, parent2, type = "single", num_splits = NA)

Arguments

parent1

The first candidate solution (a vector of 0's and 1's).

parent2

The second candidate solution (a vector of 0's and 1's).

type

The type of crossover, either 'single' or 'multiple'.

num_splits

The number of splits for type multiple. If invalid num_splits specified, then will default to 2.

Value

A list of vectors of the children to return.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Y <- mtcars$mpg
X <- mtcars[2:11]
P = 2 * ncol(X)
regType = 'lm'
family = 'gaussian'
seed = 1

initPop <- initialize(Y, X, P, regType, family, seed)
crossover(initPop[[1]]$variables, initPop[[2]]$variables, "single")
crossover(initPop[[1]]$variables, initPop[[2]]$variables, "multiple", 3)

erickim/GA documentation built on May 28, 2019, 7:15 a.m.