crtrp: Create a real-valued initial population

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/crtrp.R

Description

This function creates a population of given size of random real-values.

Usage

1
crtrp(Nind,FieldDR)

Arguments

Nind

a value containing the number of individuals in the new population.

FieldDR

a matrix of 2 rows by number of variables describing the boundaries of each variable.

Details

The first step in a genetic algorithm is to create an initial population consisting of random individuals. crtrp produces a matrix, Chrom, containing uniformly distributed random values in its elements.

Chrom = crtrp(Nind, FieldDR) creates a random real-valued matrix of size Nind * Nvar, where Nind specifies the number of individuals in the population and Nvar the number of variables of each individual. Nvar is derived from FieldDR with Nvar = NCOL(FieldDR).

FieldDR is a matrix of size 2 * Nvar and contains the boundaries of each variable of an individual. The first row contains the lower bounds, the second row the upper bounds.

FieldDR is used in other functions mutate

Value

a matrix containing the random valued individuals of the new population of size Nind by number of variables.

Author(s)

The original matlab implementation of crtrp was written by Hartmut Pohlheim and tested by Alex Shenfield. The R implementation was written by David Zhao.

See Also

mutbga, recdis, recint, reclin

Examples

1
2
3
4
5
6
## To create a random populatin of 6 individuals with 4 variables each:
## Define boundaries on the variables,
FieldDR = matrix(c(-100,-50,-30,-20,
                    100,50,30,20),2,4,byrow=TRUE)
## Create initial population
Chrom = crtrp(6,FieldDR)                     

drizztxx/gatbxr documentation built on Dec. 27, 2021, 2:26 a.m.