com.softtechdesign.ga
Class ChromFloat

java.lang.Object
  |
  +--com.softtechdesign.ga.Chromosome
        |
        +--com.softtechdesign.ga.ChromFloat

public class ChromFloat
extends Chromosome

Chromosome class where genes are stored as floating point numbers

Author:
Jeff Smith jeff@SoftTechDesign.com

Field Summary
protected  double[] genes
          array of genes that comprise the chromosome
 
Fields inherited from class com.softtechdesign.ga.Chromosome
fitness, fitnessRank
 
Constructor Summary
ChromFloat(int iGenesDim)
          Creates an double array which stores the genes
 
Method Summary
 void copyChromGenes(Chromosome chromosome)
          Copy the genes from the given chromosome over the existing genes
 double getGene(int iGene)
          return the gene indexed by iGene as a double
 double[] getGenes()
          Getter for the genes array
 java.lang.String getGenesAsStr()
          return the array of genes as a string
 java.lang.String getGenesAsString()
          Return the array of genes as a string
 int getNumGenesInCommon(Chromosome chromosome)
          Get the number of genes in common
 void setGene(int iGene, double value)
          Set the gene indexed by iGene to the given double value
 java.lang.String toString()
          Return the genes as a string
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

genes

protected double[] genes
array of genes that comprise the chromosome
Constructor Detail

ChromFloat

public ChromFloat(int iGenesDim)
Creates an double array which stores the genes
Parameters:
iGenesDim -  
Method Detail

getGenes

public double[] getGenes()
Getter for the genes array
Returns:
double[]

toString

public java.lang.String toString()
Return the genes as a string
Overrides:
toString in class java.lang.Object
Returns:
String

getNumGenesInCommon

public int getNumGenesInCommon(Chromosome chromosome)
Get the number of genes in common
Overrides:
getNumGenesInCommon in class Chromosome
Parameters:
chromosome -  
Returns:
int

getGenesAsString

public java.lang.String getGenesAsString()
Return the array of genes as a string
Returns:
String

copyChromGenes

public void copyChromGenes(Chromosome chromosome)
Copy the genes from the given chromosome over the existing genes
Overrides:
copyChromGenes in class Chromosome
Parameters:
Chromosome -  

getGene

public double getGene(int iGene)
return the gene indexed by iGene as a double
Parameters:
int - iGene gene to get
Returns:
double gene value

setGene

public void setGene(int iGene,
                    double value)
Set the gene indexed by iGene to the given double value
Parameters:
int - gene to set
double - value to set gene

getGenesAsStr

public java.lang.String getGenesAsStr()
return the array of genes as a string
Overrides:
getGenesAsStr in class Chromosome
Returns:
String