Learn R Programming

nlmixr2auto (version 1.0.0)

ga.sel.tournament: Tournament selection

Description

Select individuals for the next generation using tournament selection.

Usage

ga.sel.tournament(data.pop, npop, nbits)

Value

A matrix of dimension npop x nbits containing the selected chromosomes for the next generation.

Arguments

data.pop

A data.frame containing the current population. The first nbits columns must be the chromosome (typically coded as 0/1). The data frame must also contain a column named rank, where smaller values indicate better individuals (e.g., rank 1 is best).

npop

Integer. Number of individuals to select for the next generation.

nbits

Integer. Number of bits (genes) per chromosome; i.e., the number of columns taken from data.pop to form the chromosome matrix.

Author

Zhonghui Huang

Examples

Run this code
data.pop <- data.frame(fitness = stats::runif(10), rank = rank(stats::runif(10)))
population <- matrix(sample(0:1, 100, replace = TRUE), nrow = 10)
ga.sel.tournament(data.pop=cbind(as.data.frame(population), data.pop), npop=10, nbits=10)

Run the code above in your browser using DataLab