EncodeChromosome: Encode and Decode an Integer Chromosome

Description Usage Arguments Value Author(s) See Also Examples

View source: R/FindOptimalSubset.R

Description

Functions for encoding and decoding a chromosome represented by integer values. Where a chromosome is a set of numbers that defines a proposed solution to the problem that a genetic algorithm is trying to solve.

Usage

1
2
3

Arguments

x

'integer' vector. Integer representation of chromosome.

n

'integer' count. Maximum permissible number in the integer chromosome, used to calculate the bit width of a binary string.

y

'integer' vector. Binary representation of chromosome, a vector of 0s and 1s.

Value

EncodeChromosome returns a 'numeric' vector of 0s and 1s.

DecodeChromosome returns a 'numeric' vector of integers.

Author(s)

J.C. Fisher, U.S. Geological Survey, Idaho Water Science Center

See Also

FindOptimalSubset, binary2decimal

Examples

1
2
3
4
5
x <- c(41, 796, 382)
y <- EncodeChromosome(x, 1000)
print(y)
x <- DecodeChromosome(y, 1000)
print(x)

inlmisc documentation built on Jan. 25, 2022, 1:14 a.m.