xegaGaReplicateGenePipeline: Replicates a gene by generating a pipeline with a crossover...

View source: R/xegaGaReplicate.R

xegaGaReplicateGenePipelineR Documentation

Replicates a gene by generating a pipeline with a crossover operator returning a single kid.

Description

xegaGaReplicateGenePipeline() returns a gene reproduction pipeline which is represented as a closure with crossover and mutation and an acceptance rule together with the necessary genes. The control flow starts by selecting a gene from the population followed by the case distinction:

  • Check if the mutation operation should be applied. (mut is TRUE with a probability of lF$MutationRate()).

  • Check if the crossover operation should be applied. (cross is TRUE with a probability of lF$CrossRate()).

The state distinction determines which genetic operator pipeline is returned.

Usage

xegaGaReplicateGenePipeline(pop, fit, lF)

Arguments

pop

Population of binary genes.

fit

Fitness vector.

lF

Local configuration of the genetic algorithm.

Details

xegaGaReplicateGenePipeline() returns an operator pipeline with the steps crossover, mutate, accept, and evaluate. generated by a pipeline constructor depending on the random choices for mutation and crossover:

  1. The genes g, g1 are selected and the boolean variables mut and cross are set to runif(1)<rate.

  2. The local function for the operator pipeline OPpip(g, lF) is generated by the pipeline constructor selected by the truth values of cross and mut:

    1. (cross==FALSE) & (mut==FALSE): Pipeline constructor newPipeline(g, lF).

    2. (cross==TRUE) & (mut==TRUE): Pipeline constructor newCrossMutPipeline(g, g1, lF).

    3. (cross==TRUE) & (mut==FALSE): Pipeline constructor newCrossPipeline(g, g1, lF).

    4. (cross==FALSE) & (mut==TRUE): Pipeline constructor newMutPipeline(g, lF).

Value

A list of a function closure with the operator pipeline.

See Also

Other Replication: xegaGaReplicate2Gene(), xegaGaReplicate2GenePipeline(), xegaGaReplicateGene()

Examples

lFxegaGaGene$CrossGene<-xegaGaCrossGene
lFxegaGaGene$MutationRate<-function(fit, lF) {0.5}
lFxegaGaGene$CrossRate<-function(fit, lF) {0.5}
lFxegaGaGene$Accept<-function(OperatorPipeline, gene, lF) {gene}
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<-xegaGaReplicateGenePipeline(pop10, fit10, lFxegaGaGene)

xegaGaGene documentation built on Aug. 8, 2025, 6:30 p.m.