Description Usage Arguments Note Author(s) References See Also Examples
View source: R/GA4StratificationSelection.R
This is the selection operation in the Genetic Algorithm approach for the determination of the stratum boundaries and sample sizes in each stratum in stratified sampling with an Equal Sample Allocation Scheme.
1 | GA4StratificationSelection(selectionGeneration, selectionGenerationFitness)
|
selectionGeneration |
The generation that selection operator will be applied. |
selectionGenerationFitness |
The fitness value of the generation that selection operator will be applied. |
This study is part of a project supported by the Scientific and Technological Research Council of Turkey (TUBITAK).
Sebnem Er, Timur Keskinturk, Charlie Daly
Maintainer: Sebnem Er <er.sebnem@gmail.com>
http://ideas.repec.org/a/eee/csdana/v52y2007i1p53-67.html
http://www.sciencedirect.com/science/article/B6V8V-4NHM520-1/2/a21e0295aa1616ff56da1ddf2c0ba1ac
GA4StratificationP1
GA4StratificationP1fit
GA4StratificationP1fitt
GA4StratificationP1m
GA4StratificationP1x
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ## The function is currently defined as
function(selectionGeneration,selectionGenerationFitness)
{
rowSelectionGeneration=nrow(selectionGeneration)
colSelectionGeneration=ncol(selectionGeneration)
selectionStrata=array(0,dim=c(rowSelectionGeneration,(colSelectionGeneration+1)))
newSelectionGeneration=cbind(selectionGeneration, -selectionGenerationFitness)
sortedSelectionGeneration=newSelectionGeneration[order(newSelectionGeneration[,colSelectionGeneration+1]),]
sortedSelectionGenerationFitness=selectionGenerationFitness[order(-selectionGenerationFitness),]
wheelOld = sortedSelectionGenerationFitness / sum(selectionGenerationFitness)
wheel=1:rowSelectionGeneration
for(i in rowSelectionGeneration:1)
{
wheel[rowSelectionGeneration+1-i]=wheelOld[i]
}
wheel=cumsum(wheel)
for ( i in 1:rowSelectionGeneration )
{
r = runif(1,0,1)
for ( j in 1:rowSelectionGeneration )
{
if(r < wheel[j])
{
selectionStrata[i,] = sortedSelectionGeneration[j,]
break;
}
}
}
randomGeneration=selectionStrata[,1:colSelectionGeneration]
fitnessValueGeneration=selectionStrata[,(colSelectionGeneration+1)]
return(randomGeneration)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.