com.softtechdesign.ga
Class ChromChars

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

public class ChromChars
extends Chromosome

Chromosome class where genes are stored as an array of chars

Author:
Jeff Smith jeff@SoftTechDesign.com

Field Summary
protected  char[] genes
          array of genes that comprise this Chromosome
 
Fields inherited from class com.softtechdesign.ga.Chromosome
fitness, fitnessRank
 
Constructor Summary
ChromChars(int iGenesDim)
          Constructor creates new array of genes given the iGenesDim
 
Method Summary
 void copyChromGenes(Chromosome chromosome)
          Copy the genes from the given chromosome over the existing genes
 char getGene(int iGene)
          return the gene indexed by iGene as a char
 char[] getGenes()
          Getter for the genes array
 java.lang.String getGenesAsStr()
          return the array of genes as a string
 int getNumGenesInCommon(Chromosome chromosome)
          Determines how many genes are in common betwen this Chromosome and the given Chromosome
 void setGenesFromStr(java.lang.String sChromosome)
          Set this chromosomes genes (array) to the given chromosome string
 java.lang.String toString()
          Returns the genes in this chromosome 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 char[] genes
array of genes that comprise this Chromosome
Constructor Detail

ChromChars

public ChromChars(int iGenesDim)
Constructor creates new array of genes given the iGenesDim
Parameters:
iGenesDim -  
Method Detail

toString

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

getNumGenesInCommon

public int getNumGenesInCommon(Chromosome chromosome)
Determines how many genes are in common betwen this Chromosome and the given Chromosome
Overrides:
getNumGenesInCommon in class Chromosome
Parameters:
chromosome -  
Returns:
int

getGenes

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

getGenesAsStr

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

getGene

public char getGene(int iGene)
return the gene indexed by iGene as a char
Returns:
char gene

setGenesFromStr

public void setGenesFromStr(java.lang.String sChromosome)
Set this chromosomes genes (array) to the given chromosome string
Parameters:
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 -