breed: Breeding to create a new combination of predictors to use in...

Description Usage Arguments Value Examples

View source: R/breed.R

Description

Breeding to create a new combination of predictors to use in the regression, via genetic crossover and mutation by default.

Usage

1
breed(parents, C, n = 1, op = NULL, cluster = NA...)

Arguments

parents

A tuple (2-list) of ordered numeric vectors, representing the parents which will breed. Each parent is represented by the indices of the genes which are active in its chromosome, e.g. c(1, 4, 7) corresponds to using the first, fourth, and seventh predictors in the regression.

C

The length of chromosomes, i.e. the maximum number of possible predictors.

n

Number of crossover points, up to a maximum of C - 1.

op

An optional, user-specified genetic operator function to carry out the breeding.

...

Additional parameters to pass to the user-specific op function.

Value

A tuple (2-list) of ordered numeric vector representing the two offspring produced by the breeding as indices of the genes (predictors) which are active in the chromosome (regression).

Examples

1
2
3
4
5
6
7
C <- 5 ## 5 genes / max number of predictors
## parent generation of size 3
parent_gen <- list(list(c(1, 3), c(4)),
                   list(c(2, 3), c(1,4)),
                   list(c(3), c(1, 3, 4)))
## list of numeric vectors representing the next generation
next_gen <- unlist(lapply(parent_gen, breed, C), FALSE, FALSE)

kunaljaydesai/GA documentation built on May 28, 2019, 7:38 a.m.