xegaGaReplicate2Gene: Replicates a gene.

View source: R/xegaGaReplicate.R

xegaGaReplicate2GeneR Documentation

Replicates a gene.

Description

xegaGaReplicate2Gene() replicates a gene by 2 random experiments which determine if a mutation operator (boolean variable mut) and/or a crossover operator (boolean variable cross should be applied. For each of the 4 cases, the appropriate code is executed.

Usage

xegaGaReplicate2Gene(pop, fit, lF)

Arguments

pop

A population of binary genes.

fit

Fitness vector.

lF

The local configuration of the genetic algorithm.

Details

xegaGaReplicate2Gene() implements the control flow by case distinction which depends on the random choices for mutation and crossover:

  1. A gene g is selected and the boolean variables mut and cross are set to runif(1)<rate. rate is given by lF$MutationRate() or lF$CrossRate().

  2. The truth values of cross and mut determine the code that is executed:

    1. (cross==TRUE) & (mut==TRUE): Mate selection, crossover, mutation.

    2. (cross==TRUE) & (mut==FALSE): Mate selection, crossover.

    3. (cross==FALSE) & (mut==TRUE): Mutation.

    4. (cross==FALSE) & (mut==FALSE) is implicit: Returns a gene list.

Value

A list of either 1 or 2 binary genes.

See Also

Other Replication: xegaGaReplicateGene()

Examples

lFxegaGaGene$CrossGene<-xegaGaCross2Gene
lFxegaGaGene$MutationRate<-function(fit, lF) {0.001}
names(lFxegaGaGene)
pop10<-lapply(rep(0,10), function(x) xegaGaInitGene(lFxegaGaGene))
epop10<-lapply(pop10, lFxegaGaGene$EvalGene, lF=lFxegaGaGene)
fit10<-unlist(lapply(epop10, function(x) {x$fit}))
newgenes<-xegaGaReplicate2Gene(pop10, fit10, lFxegaGaGene)


xegaGaGene documentation built on April 16, 2025, 5:11 p.m.