com.softtechdesign.ga
Class GASequenceList

java.lang.Object
  |
  +--com.softtechdesign.ga.GA
        |
        +--com.softtechdesign.ga.GAString
              |
              +--com.softtechdesign.ga.GASequenceList
All Implemented Interfaces:
java.lang.Runnable

public abstract class GASequenceList
extends GAString

 The GASequenceList class models chromosomes as strings and extends GAString 
 while adding one main capability:
 the ability to prevent duplicate genes from appearing in a chromosome.

 For example, if you extend this class to optimize some sort of list (set), you don't
 want chromosomes to evolve that violate the rule that there be no duplicates in
 the list.
 
 If you just extended GAString, you could wind up with duplicate genes. For example,
 with GAString, if your gene space is "ABCDEF", you may wind up with chromosomes like
 "ADDCBE".

 The GASequenceList methods prevent duplicate gene entries in your chromosomes. So a gene
 space like "ABCDEF" can result in chromosomes like "FABCDE" and "EFABCD" but NEVER
 "ADDCBE".

Author:
Jeff Smith jeff@SoftTechDesign.com

Field Summary
protected  double[] sequence
          sequence of genes
 
Fields inherited from class com.softtechdesign.ga.GAString
chromDecPts, possGeneValues
 
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
GASequenceList(int pChromosomeDim, int pPopulationDim, double pCrossoverProb, int pRandomSelectionChance, int pMaxGenerations, int pNumPrelimRuns, int pMaxPrelimGenerations, double pMutationProb, int pChromDecPts, java.lang.String pPossGeneValues, int pCrossoverType, boolean computeStatistics)
          Initialize the GASequenceList
 
Method Summary
protected  void doOnePtCrossover(Chromosome Chrom1, Chromosome Chrom2)
          Perform one point crossover on the two given chromosomes
protected  void doTwoPtCrossover(Chromosome Chrom1, Chromosome Chrom2)
          Perform two point crossover on the two given chromosomes
protected  void doUniformCrossover(Chromosome Chrom1, Chromosome Chrom2)
          Perform uniform crossover on the given two chromosomes
protected  java.lang.String getChromWithoutDuplicates(java.lang.String sChromosome)
          Take the given chromosome which may have duplicated genes and eliminate any duplicated genes by replacing duplicates with genes which were left out of the chromosome (that is they exist in the gene space but not in the given chromosome).
protected  void initPopulation()
          Create random chromosomes from the given gene space.
 
Methods inherited from class com.softtechdesign.ga.GAString
chromStrToFloat, doRandomMutation, getChromosome, getChromValAsDouble, getRandomGeneFromPossGenes
 
Methods inherited from class com.softtechdesign.ga.GA
addChromosomesToLog, binaryStrToInt, computeFitnessRankings, copyNextGenToThisGen, doGeneticMating, evolve, getAvgDeviation, getAvgDeviationAmongChroms, getAvgFitness, getAvgFitness, getChromosomeDim, getComputeStatistics, getCrossoverProb, getCrossoverType, getFitness, getFitnessRank, getFittestChromosome, getFittestChromosomesFitness, getMaxGenerations, getMaxPrelimGenerations, getMutationProb, getNumPrelimRuns, getPopulationDim, getRandom, getRandom, getRandomSelectionChance, run, selectTwoParents
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

sequence

protected double[] sequence
sequence of genes
Constructor Detail

GASequenceList

public GASequenceList(int pChromosomeDim,
                      int pPopulationDim,
                      double pCrossoverProb,
                      int pRandomSelectionChance,
                      int pMaxGenerations,
                      int pNumPrelimRuns,
                      int pMaxPrelimGenerations,
                      double pMutationProb,
                      int pChromDecPts,
                      java.lang.String pPossGeneValues,
                      int pCrossoverType,
                      boolean computeStatistics)
               throws GAException
Initialize the GASequenceList
Parameters:
pChromosomeDim -  
pPopulationDim -  
pCrossoverProb -  
pRandomSelectionChance -  
pMaxGenerations -  
pNumPrelimRuns -  
pMaxPrelimGenerations -  
pMutationProb -  
pChromDecPts -  
pPossGeneValues -  
pCrossoverType -  
computeStatistics -  
Throws:
GAException -  
Method Detail

getChromWithoutDuplicates

protected java.lang.String getChromWithoutDuplicates(java.lang.String sChromosome)
Take the given chromosome which may have duplicated genes and eliminate any duplicated genes by replacing duplicates with genes which were left out of the chromosome (that is they exist in the gene space but not in the given chromosome). For example if gene space = 'ABCDEFGH' and sChrom1 = 'ABCDDEFG', then the gene 'D' is duplicated and 'H' has been left out. Swap the 2nd 'D' with 'H' and the chromosome is fixed.
Parameters:
sChromosome -  
Returns:
Chromosome string without any duplicate genes.

initPopulation

protected void initPopulation()
Create random chromosomes from the given gene space.
Overrides:
initPopulation in class GAString

doOnePtCrossover

protected void doOnePtCrossover(Chromosome Chrom1,
                                Chromosome Chrom2)
Perform one point crossover on the two given chromosomes
Overrides:
doOnePtCrossover in class GAString
Parameters:
Chrom1 -  
Chrom2 -  

doTwoPtCrossover

protected void doTwoPtCrossover(Chromosome Chrom1,
                                Chromosome Chrom2)
Perform two point crossover on the two given chromosomes
Overrides:
doTwoPtCrossover in class GAString
Parameters:
Chrom1 -  
Chrom2 -  

doUniformCrossover

protected void doUniformCrossover(Chromosome Chrom1,
                                  Chromosome Chrom2)
Perform uniform crossover on the given two chromosomes
Overrides:
doUniformCrossover in class GAString
Parameters:
Chrom1 -  
Chrom2 -