|
||||||||
| 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.GAStringsSeq
GAStringsSeq models chromosomes as arrays of strings.
Chromosome strings store chromosomeDim genes. Unlike GAString (where each gene is a
single char), with GAStringsSeq each gene itself is a string. For example, one might look
like:
"dw|l80|nop|dn2" --4 genes, each separated by a pipe char (nop = special no operation gene)
This type of GA could be used for:
determining a sequence for navigating a maze
discovering a useful image processing algorithm (seq) for highlighting an image feature
modeling any system where genes are naturally modeled as Strings
| Field Summary | |
protected int |
numPossGeneValues
the number of possible gene values |
protected java.lang.String[] |
possGeneValues
the building material or pool "allowed" or "possible" gene 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 | |
GAStringsSeq(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 GAStringSeq |
|
| Method Summary | |
protected void |
doOnePtCrossover(Chromosome Chrom1,
Chromosome Chrom2)
Genetically recombine the given chromosomes using a one point crossover technique. |
protected void |
doRandomMutation(int iChromIndex)
Randomly reassign a gene in the chromosome identified by the given index (iChromIndex) to one of the possible gene values |
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 ChromStrings |
getChromosome(int index)
Returns the chromosome given by index casted as a ChromStrings object |
protected java.lang.String |
getRandomGeneFromPossGenes()
Randomly pick and return a gene value |
protected void |
initPopulation()
Create random chromosomes from the given gene space. |
private void |
setGeneValue(int iChromIndex,
int geneIndex,
java.lang.String gene)
Sets the value of a gene for the given chromosome at the given geneIndex |
| Methods inherited from class java.lang.Object |
|
| Field Detail |
protected java.lang.String[] possGeneValues
protected int numPossGeneValues
| Constructor Detail |
public GAStringsSeq(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 ChromStrings getChromosome(int index)
index - protected java.lang.String getRandomGeneFromPossGenes()
protected void doRandomMutation(int iChromIndex)
doRandomMutation in class GAiChromIndex -
private void setGeneValue(int iChromIndex,
int geneIndex,
java.lang.String gene)
iChromIndex - geneIndex - gene - protected void initPopulation()
initPopulation in class GA
protected void doOnePtCrossover(Chromosome Chrom1,
Chromosome Chrom2)
For example, if we have:
chromosome A = { "x1", "x2", "x3", "x4" }
chromosome B = { "y1", "y2", "y3", "y4" }
and we randomly choose the crossover point of 1, the new genes will be:
new chromosome A = { "y1", "x2", "x3", "x4" }
new chromosome B = { "x1", "y2", "y3", "y4" }
doOnePtCrossover in class GAChrom1 - Chrom2 -
protected void doTwoPtCrossover(Chromosome Chrom1,
Chromosome Chrom2)
For example, if we have:
chromosome A = { "x1", "x2", "x3", "x4", "x5" }
chromosome B = { "y1", "y2", "y3", "y4", "y5" }
and we randomly choose the crossover points of 1 and 3, the new genes will be:
new chromosome A = { "y1", "x2", "y3", "x4", "x5" }
new chromosome B = { "x1", "y2", "x3", "y4", "y5" }
doTwoPtCrossover in class GAChrom1 - Chrom2 -
protected void doUniformCrossover(Chromosome Chrom1,
Chromosome Chrom2)
For example, if we have:
chromosome A = { "x1", "x2", "x3", "x4", "x5" }
chromosome B = { "y1", "y2", "y3", "y4", "y5" }
our uniform (random) crossover might result in something like:
chromosome A = { "y1", "x2", "x3", "x4", "x5" }
chromosome B = { "x1", "y2", "y3", "y4", "y5" }
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 | |||||||