com.softtechdesign.ga
Class GAFloat

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

public abstract class GAFloat
extends GA

GAFloat class models chromosomes as floating point numbers.

Author:
Jeff Smith

Field Summary
protected  int decPtsPrecision
          the number of decimal points precision to use.
protected  boolean positiveNumOnly
          constrain chromsosomes to positive numbers only?
 
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
GAFloat(int chromosomeDim, int populationDim, double crossoverProb, int randomSelectionChance, int maxGenerations, int numPrelimRuns, int maxPrelimGenerations, double mutationProb, int crossoverType, int decPtsPrecision, boolean positiveNumOnly, boolean computeStatistics)
          Initializes the GAFloat chromosome
 
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 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  ChromFloat getChromosome(int index)
          Returns the chromosome casted as a ChromFloat
protected  void initPopulation()
          Create random chromosomes from the given gene space (floating pt numbers).
 
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

decPtsPrecision

protected int decPtsPrecision
the number of decimal points precision to use. If the chromosome has a dimension of 10 and the decPtsPrecision = 9, numbers will be stored in the chromosomes like "0.123456789"

positiveNumOnly

protected boolean positiveNumOnly
constrain chromsosomes to positive numbers only?
Constructor Detail

GAFloat

public GAFloat(int chromosomeDim,
               int populationDim,
               double crossoverProb,
               int randomSelectionChance,
               int maxGenerations,
               int numPrelimRuns,
               int maxPrelimGenerations,
               double mutationProb,
               int crossoverType,
               int decPtsPrecision,
               boolean positiveNumOnly,
               boolean computeStatistics)
        throws GAException
Initializes the GAFloat chromosome
Parameters:
chromosomeDim -  
populationDim -  
crossoverProb -  
randomSelectionChance -  
maxGenerations -  
numPrelimRuns -  
maxPrelimGenerations -  
mutationProb -  
crossoverType -  
decPtsPrecision -  
positiveNumOnly -  
computeStatistics -  
Throws:
GAException -  
Method Detail

getChromosome

protected ChromFloat getChromosome(int index)
Returns the chromosome casted as a ChromFloat
Parameters:
index -  
Returns:
ChromFloat

doRandomMutation

protected void doRandomMutation(int iChromIndex)
Randomly swap two genes in the chromosome identified by the given index (iChromIndex)
Overrides:
doRandomMutation in class GA
Parameters:
iChromIndex -  

initPopulation

protected void initPopulation()
Create random chromosomes from the given gene space (floating pt numbers).
Overrides:
initPopulation in class GA

doOnePtCrossover

protected void doOnePtCrossover(Chromosome Chrom1,
                                Chromosome Chrom2)
 Genetically recombine the given chromosomes using a one point crossover technique.
 For example, if we have:
   chromosome A = 1.0, 2.0, 3.0, 4.0
   chromosome B = 5.0, 6.0, 7.0, 8.0
 and we randomly choose the crossover point of 1, the new genes will be:
   new chromosome A = 1.0, 6.0, 3.0, 4.0
   new chromosome B = 5.0, 2.0, 7.0, 8.0
 
Overrides:
doOnePtCrossover in class GA
Parameters:
Chrom1 -  
Chrom2 -  

doTwoPtCrossover

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.
 For example (crossover pts, 1 and 4):
  1 234 567890 --> 1 999 567890
  8 999 888888 --> 8 234 888888

  For example (crossover pts, 9 and 10):
  123456789 0 --> 123456789 0
  888888888 9 --> 888888888 9
 
Overrides:
doTwoPtCrossover in class GA
Parameters:
Chrom1 -  
Chrom2 -  

doUniformCrossover

protected void doUniformCrossover(Chromosome Chrom1,
                                  Chromosome Chrom2)
Genetically recombine the given chromosomes using a uniform crossover technique. This technique randomly swaps genes from one chromosome to another.
 For example, if we have:
   chromosome A = 1.0, 2.0, 3.0, 4.0
   chromosome B = 5.0, 6.0, 7.0, 8.0
 our uniform (random) crossover might result in something like:
   new gene A = 5.0, 2.0, 3.0, 4.0
   new gene B = 1.0, 6.0, 7.0, 8.0
 if only the first gene in the chromosome was swapped.
 
Overrides:
doUniformCrossover in class GA
Parameters:
Chrom1 -  
Chrom2 -