View source: R/xegaGaReplicate.R
xegaGaReplicate2GenePipeline | R Documentation |
xegaGaReplicate2GenePipeline()
replicates a gene
by 3 random experiments which determine if a mutation
operator (boolean variable mut1
and mut2
)
and/or
a crossover operator (boolean variable cross
should be applied. For each of the 8 cases, the
appropriate pipeline constructor is executed
and the genetic operator pipeline(s) is (are) returned.
xegaGaReplicate2GenePipeline(pop, fit, lF)
pop |
A population of binary genes. |
fit |
Fitness vector. |
lF |
The local configuration of the genetic algorithm. |
xegaGaReplicate2GenePipeline()
implements the control flow
by case distinction which depends
on the random choices for mutation and crossover.
The pipeline constructor chosen returns the function closure
with the appropriate genetic operator pipeline.
A gene g
is selected and the boolean variables mut1
,
mut2
,
and cross
are set to runif(1)<rate
.
rate
is given by
lF$MutationRate()
or lF$CrossRate()
.
The truth values of cross
, mut1
, and mut2
determine
the genetic operator pipeline constructor that is executed:
(cross==FALSE) & (mut1==FALSE)
is implicit:
Executes the pipeline constructor newPipeline
.
(cross==TRUE) & (mut1==TRUE) & (mut2==TRUE)
:
Crossover, mutation on both kids.
Executes the genetic operator
pipeline constructor newCrossMut2Pipeline
.
(cross==TRUE) & (mut1==TRUE) & (mut2==FALSE)
:
Crossover, mutation on first kid.
Executes the genetic operator
pipeline constructor newCross2Mut1Pipeline
.
(cross==TRUE) & (mut1==FALSE) & (mut2==TRUE)
:
Crossover, mutation on second kid.
Executes the genetic operator
pipeline constructor newCross2Mut2Pipeline
.
(cross==TRUE) & (mut1==FALSE) & (mut2==FALSE)
:
Crossover (2 kids).
Executes the genetic operator
pipeline constructor newCross2Pipeline
.
(cross==FALSE) & (mut1==TRUE)
:
Mutation.
Executes the genetic operator
pipeline constructor newMutPipeline
.
A list of either 1 or 2 function closures with the operator pipeline.
Other Replication:
xegaGaReplicate2Gene()
,
xegaGaReplicateGene()
,
xegaGaReplicateGenePipeline()
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<-xegaGaReplicate2GenePipeline(pop10, fit10, lFxegaGaGene)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.