|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Object
|
+--com.softtechdesign.ga.GA
|
+--com.softtechdesign.ga.GAString
GAString models chromosomes as strings of characters
| Field Summary | |
protected int |
chromDecPts
you can store floating point numbers in strings. |
protected java.lang.String |
possGeneValues
legal gene (char) values. |
| Fields inherited from class com.softtechdesign.ga.GA |
bestFitnessChromIndex, chromNextGen, chromosomeDim, chromosomes, computeStatistics, crossoverProb, crossoverType, genAvgDeviation, genAvgFitness, maxGenerations, maxPrelimGenerations, mutationProb, numPrelimRuns, populationDim, prelimChrom, randomSelectionChance, worstFitnessChromIndex |
| Constructor Summary | |
GAString(int chromosomeDim,
int populationDim,
double crossoverProb,
int randomSelectionChance,
int maxGenerations,
int numPrelimRuns,
int maxPrelimGenerations,
double mutationProb,
int chromDecPts,
java.lang.String possGeneValues,
int crossoverType,
boolean computeStatistics)
Initialize the GAString |
|
| Method Summary | |
protected double |
chromStrToFloat(java.lang.String sChromosome,
int iNumDecPts)
Convert a chromosome string to it's double equivalent for example, if sChromosome = "01234" and iNumDecPts = 4, then return 0.1234 |
protected void |
doOnePtCrossover(Chromosome Chrom1,
Chromosome Chrom2)
Genetically recombine the given chromosomes using a one point crossover technique. |
protected void |
doRandomMutation(int iChromIndex)
randomly swap two genes in the chromosome identified by the given index (iChromIndex) |
protected void |
doTwoPtCrossover(Chromosome Chrom1,
Chromosome Chrom2)
Genetically recombine the given chromosomes using a two point crossover technique which combines two chromosomes at two random genes (loci), creating two new chromosomes. |
protected void |
doUniformCrossover(Chromosome Chrom1,
Chromosome Chrom2)
Genetically recombine the given chromosomes using a uniform crossover technique. |
protected ChromChars |
getChromosome(int index)
returns the given chromosome casted as a ChromChars |
protected double |
getChromValAsDouble(java.lang.String sChromosome)
convert a chromosome string to a double |
protected char |
getRandomGeneFromPossGenes()
Randomly pick and return a possible gene value |
protected void |
initPopulation()
create random chromosomes from the given gene space. |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
protected int chromDecPts
protected java.lang.String possGeneValues
| Constructor Detail |
public GAString(int chromosomeDim,
int populationDim,
double crossoverProb,
int randomSelectionChance,
int maxGenerations,
int numPrelimRuns,
int maxPrelimGenerations,
double mutationProb,
int chromDecPts,
java.lang.String possGeneValues,
int crossoverType,
boolean computeStatistics)
throws GAException
chromosomeDim - populationDim - crossoverProb - randomSelectionChance - maxGenerations - numPrelimRuns - maxPrelimGenerations - mutationProb - chromDecPts - possGeneValues - crossoverType - computeStatistics - GAException - | Method Detail |
protected ChromChars getChromosome(int index)
index -
protected double chromStrToFloat(java.lang.String sChromosome,
int iNumDecPts)
sChromosome - iNumDecPts - protected double getChromValAsDouble(java.lang.String sChromosome)
sChromosome - protected char getRandomGeneFromPossGenes()
protected void doRandomMutation(int iChromIndex)
doRandomMutation in class GAiChromIndex - protected void initPopulation()
initPopulation in class GA
protected void doOnePtCrossover(Chromosome Chrom1,
Chromosome Chrom2)
For example, if we have: chromosome A = "ABCD" chromosome B = "EFGH" and we randomly choose the crossover point of 1, the new genes will be: new chromosome A = "A" + "FGH" = "AFGH" new chromosome B = "E" + "BCD" = "EBCD"
doOnePtCrossover in class GAChrom1 - Chrom2 -
protected void doTwoPtCrossover(Chromosome Chrom1,
Chromosome Chrom2)
For example, if we have: chromosome A = "ABCDE" chromosome B = "FGHIJ" and we randomly choose the crossover points of 1 and 3, the new genes will be: new chromosome A = "A" + "GH" + "DE" = "AGHDE" new chromosome B = "F" + "BC" + "IJ" = "FBCIJ"
doTwoPtCrossover in class GAChrom1 - Chrom2 -
protected void doUniformCrossover(Chromosome Chrom1,
Chromosome Chrom2)
For example, if we have: chromosome A = "ABCD" chromosome B = "EFGH" our uniform (random) crossover might result in something like: new chromosome A = "EBCD" new chromosome B = "AFGH" if only the first gene in the chromosome was swapped.
doUniformCrossover in class GAChrom1 - Chrom2 -
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||