View source: R/xegaGaReplicate.R
| xegaGaReplicate2Gene | R Documentation |
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 and the genes are generated.
xegaGaReplicate2Gene(pop, fit, lF)
pop |
A population of binary genes. |
fit |
Fitness vector. |
lF |
The local configuration of the genetic algorithm. |
xegaGaReplicate2Gene() implements the control flow
by case distinction which depends
on the random choices for mutation and crossover:
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().
The truth values of cross and mut determine
the code that is executed:
(cross==TRUE) & (mut==TRUE):
Mate selection, crossover, mutation.
(cross==TRUE) & (mut==FALSE):
Mate selection, crossover.
(cross==FALSE) & (mut==TRUE):
Mutation.
(cross==FALSE) & (mut==FALSE) is implicit:
Returns a gene list.
A list of either 1 or 2 binary genes.
Other Replication:
xegaGaReplicate2GenePipeline(),
xegaGaReplicate2GenePipelineG(),
xegaGaReplicateGene(),
xegaGaReplicateGenePipeline(),
xegaGaReplicateGenePipelineG()
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.