net.sf.amiba.evolve.gene
Class Individual<T>

Object
  extended by Individual<T>
All Implemented Interfaces:
Cloneable, Comparable<Individual<T>>

public class Individual<T>
extends Object
implements Cloneable, Comparable<Individual<T>>

An Individual is a sequence of genes. As an Individual could be exported out of a population and could have an independent existence, it contains all the information required for its interpretation.

Author:
juber patel

Constructor Summary
Individual(Gene[] genes, GeneGrammar<T> grammar)
           
 
Method Summary
 void calibrateFitness(Double d)
          bring the fitness on a scale starting from 0
 Individual<T> clone()
          get a deep copy of this individual
 int compareTo(Individual<T> another)
           
 String decode()
          explain this individual in a human readable form.
 double evaluateFitness(List<FitnessCase<T>> fitnessCases)
          This method evaluates afresh the fitness of this individual by building and evaluating the Abstarct Syntax Tree.
 double getCalibratedFitness()
           
 int getChromosomeLength()
          get the sum of lengths of all genes
 double getFitness()
           
 int getGeneLength()
           
 Gene[] getGenes()
           
 GeneGrammar<T> getGrammar()
           
 int getHeadLength()
           
 int getNumberOfGenes()
           
 String toString()
           
 List<T> useOn(List<FitnessCase<T>> fitnessCases)
          use this Individual to calculate the the values for given fitness cases.
 
Methods inherited from class Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Individual

public Individual(Gene[] genes,
                  GeneGrammar<T> grammar)
Method Detail

evaluateFitness

public double evaluateFitness(List<FitnessCase<T>> fitnessCases)
                       throws AmibaException
This method evaluates afresh the fitness of this individual by building and evaluating the Abstarct Syntax Tree. This method is costly and generally should be used only once in the lifetime of the Individual. Use getFitness method to get the pre-evaluated fitness score.

Returns:
a number <= 100 that represents the fitness of this Individual. The higher the number, the better the fitness
Throws:
AmibaException

getFitness

public double getFitness()
Returns:
a number <= 100 that represents the fitness of this Individual, NaN if evaluateFitness has not been called on this Individual yet. The higher the number, the better the fitness

getNumberOfGenes

public int getNumberOfGenes()

getChromosomeLength

public int getChromosomeLength()
get the sum of lengths of all genes

Returns:

getHeadLength

public int getHeadLength()

getGeneLength

public int getGeneLength()

clone

public Individual<T> clone()
get a deep copy of this individual

Overrides:
clone in class Object

decode

public String decode()
explain this individual in a human readable form. This method uses GeneGrammar.decode(Gene) and is completely dependent on it.

Returns:

toString

public String toString()
Overrides:
toString in class Object

getGenes

public Gene[] getGenes()

getGrammar

public GeneGrammar<T> getGrammar()

compareTo

public int compareTo(Individual<T> another)
Specified by:
compareTo in interface Comparable<Individual<T>>

calibrateFitness

public void calibrateFitness(Double d)
bring the fitness on a scale starting from 0


getCalibratedFitness

public double getCalibratedFitness()

useOn

public List<T> useOn(List<FitnessCase<T>> fitnessCases)
              throws AmibaException
use this Individual to calculate the the values for given fitness cases. the getValue() method of the fitness cases is not used. only terminal values are accessed and the result values are calculated according to this Individual

Returns:
Throws:
AmibaException