JavaGenes, NASA Ames. Written largely by Al Globus

gov.nasa.javaGenes.forceFields
Class Chromosome

java.lang.Object
  extended bygov.nasa.javaGenes.core.Evolvable
      extended bygov.nasa.javaGenes.forceFields.Chromosome
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable

public class Chromosome
extends Evolvable

Implement the representation of a two-dimensional array of double.

See Also:
Serialized Form

Field Summary
protected  double[][] chromosome
           
 
Fields inherited from class gov.nasa.javaGenes.core.Evolvable
childMakersUsed
 
Constructor Summary
Chromosome(AlleleTemplate alleles)
          Sets the array sizes to that of alleles.
Chromosome(Chromosome c)
          Creates a raise with the same structure as c, but does not copy the values
Chromosome(TokenizeInput tokenizer)
          Creates a new chromosome from within a checkpoint file
 
Method Summary
 void addArray(int size)
           
 java.lang.Object clone()
          deep copy
 Chromosome createDifferenceChromosome(Chromosome other)
           
 Chromosome deepCopyChromosome()
           
 double distanceFrom(Evolvable e)
          Subclasses will almost always override this.
 double[] getArray(int i)
           
 int getSize()
           
 int getSize(int index)
           
 double getValue(int i, int j)
          return the value at the indicated indices
 int numberOfArrays()
           
 void setValue(double value, int i, int j)
          set the value at the indicated indices
 void stateSave(TokenizeOutput tokenizer)
          Save the state of a chromosome to a checkpoint file
 java.lang.String toString()
           
 
Methods inherited from class gov.nasa.javaGenes.core.Evolvable
addChildMakers, copyForEvolution, getChildMakersUsed, getSmallest, prepareForEvaluator
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

chromosome

protected double[][] chromosome
Constructor Detail

Chromosome

public Chromosome(AlleleTemplate alleles)
Sets the array sizes to that of alleles. Sets the values to random doubles within the intervals defined by alleles.


Chromosome

public Chromosome(Chromosome c)
Creates a raise with the same structure as c, but does not copy the values


Chromosome

public Chromosome(TokenizeInput tokenizer)
Creates a new chromosome from within a checkpoint file

Method Detail

addArray

public void addArray(int size)

stateSave

public void stateSave(TokenizeOutput tokenizer)
Save the state of a chromosome to a checkpoint file

Overrides:
stateSave in class Evolvable

numberOfArrays

public int numberOfArrays()
Returns:
chromosome.length

getSize

public int getSize(int index)
Returns:
the length of the array indicated by index

deepCopyChromosome

public Chromosome deepCopyChromosome()

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
deep copy

Throws:
java.lang.CloneNotSupportedException

getValue

public double getValue(int i,
                       int j)
return the value at the indicated indices


getArray

public double[] getArray(int i)

setValue

public void setValue(double value,
                     int i,
                     int j)
set the value at the indicated indices


getSize

public int getSize()
Overrides:
getSize in class Evolvable
Returns:
the number of doubles in this chromosome

distanceFrom

public double distanceFrom(Evolvable e)
Description copied from class: Evolvable
Subclasses will almost always override this.

Overrides:
distanceFrom in class Evolvable
Parameters:
e - must be a Chromosome with the same array structure as this
Returns:
the root mean squared distance from the argument.

createDifferenceChromosome

public Chromosome createDifferenceChromosome(Chromosome other)
Returns:
a new chromosome with values = other - this

toString

public java.lang.String toString()

JavaGenes, NASA Ames. Written largely by Al Globus