Learn R Programming

galgo (version 1.4)

mutate.Chromosome: Mutates a chromosome in specific positions

Description

Mutates a chromosome in specific positions.

Usage

# S3 method for Chromosome
mutate(ch, positions=sample(length(ch), 1), ...)

Arguments

positions

Vector of gene positions to be mutated. If positions is a vector of length 1 and the value is less than 1, it is considered as a probability; thus a positions vector is computed using the probability and the chromsome length.

Value

Returns the positions mutated.

Details

This method updates the gene values in the chromsome calling the method mutate for all genes indexed by positions vector.

References

Goldberg, David E. 1989 Genetic Algorithms in Search, Optimization and Machine Learning. Addison-Wesley Pub. Co. ISBN: 0201157675

See Also

For more information see Chromosome. *mutate().

Examples

Run this code
# NOT RUN {
   cr <- Chromosome(genes=newCollection(Gene(shape1=1, shape2=100),5))
   cr
   mutate(cr) # mutate 1 gene randomly
   cr
   mutate(cr,1:3) # mutate genes 1, 2, and 3
   cr
 
# }

Run the code above in your browser using DataLab