bs2rv: Binary string to real vector

Description Usage Arguments Value Author(s) See Also Examples

View source: R/bs2rv.R

Description

This function decodes binary chromosomes into vectors of reals. The chromosomes are seen as the concatenation of binary strings of given length, and decoded into real numbers in a specified interval using either standard binary or Gray decoding.

Usage

1
2
bs2rv(Chrom,FieldD=list(prec=numeric(),lb=numeric(),ub=numeric(),code=c("binary","gray"),
  scale=c("arith","log"),lbin=T,ubin=T))

Arguments

Chrom

matrix containing the chromosomes of the current population. Each line corresponds to one individual's concatenated binary string representation. Leftmost bits are MSb and rightmost are LSb.

FieldD

a list of additional options describing how to decode each substring in the chromosome. It has 7 elements, prec: a scalar describing the precision when converting chromosome to reals; lb, ub: Lower and upper bounds for each variable; code: binary row vector indicating how each substring is to be decoded; scale: binary row vector indicating where to use arithmetic and/or logarithmic scaling; lbin, ubin: binary row vectors indicating whether or not to include each bound in the representation range

Value

real matrix containing the population phenotypes.

Author(s)

The original matlab implementation of bs2rv was written by Carlos Fonseca and updated by Andrew Chipperfield. The R implementation was written by David Zhao.

See Also

crtbp

Examples

1
2
3
4
5
6
7
## Create a chromsome 
Chrom = crtbp(Nind = 40, Lind = 400)$Chrom

## Converting to reals range from [-512, 512] with a precision of 20 
##(20 bits mean a real number) in  arithmetic scale by binary decoding.
Phen = bs2rv(Chrom = Chrom,
             FieldD = list(prec=20,lb=-512,ub=512,code="binary",scale="arith",lbin=TRUE,ubin=TRUE))

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