View source: R/xegaGaReplicate.R
| xegaGaReplicateGenePipelineG | R Documentation |
xegaGaReplicateGenePipelineG() returns
a gene with an embedded gene reproduction pipeline
which is represented as a function with crossover and
mutation and an acceptance rule.
The necessary genes are also embedded into the gene.
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.
xegaGaReplicateGenePipelineG(pop, fit, lF)
pop |
Population of binary genes. |
fit |
Fitness vector. |
lF |
Local configuration of the genetic algorithm. |
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:
The genes g, g1 are selected
and the boolean variables mut
and cross are set to runif(1)<rate.
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:
(cross==FALSE) & (mut==FALSE):
Pipeline constructor newPipeline(g, lF).
(cross==TRUE) & (mut==TRUE):
Pipeline constructor newCrossMutPipeline(g, g1, lF).
(cross==TRUE) & (mut==FALSE):
Pipeline constructor newCrossPipeline(g, g1, lF).
(cross==FALSE) & (mut==TRUE):
Pipeline constructor newMutPipeline(g, lF).
A list of a function closure with the operator pipeline.
Other Replication:
xegaGaReplicate2Gene(),
xegaGaReplicate2GenePipeline(),
xegaGaReplicate2GenePipelineG(),
xegaGaReplicateGene(),
xegaGaReplicateGenePipeline()
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<-xegaGaReplicateGenePipelineG(pop10, fit10, lFxegaGaGene)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.