org.jgap
Class Specie

java.lang.Object
  extended byorg.jgap.Specie

public class Specie
extends java.lang.Object

Species are reproductively isolated segments of a population. They are used to ensure diversity in the population. This can protect innovation, and also serve to maintain a broader search space, avoiding being trapped in local optima.

Author:
Philip Tucker

Field Summary
static java.lang.String CHROMOSOME_TAG
          XML chromosome tag
static java.lang.String COUNT_TAG
          XML count tag
static java.lang.String FITNESS_TAG
          XML fitness tag
static java.lang.String ID_TAG
          XML ID tag
static java.lang.String SPECIE_TAG
          XML base tag
 
Constructor Summary
Specie(SpeciationParms aSpeciationParms, Chromosome aRepresentative)
          Create new specie from representative.
 
Method Summary
 boolean add(Chromosome aChromosome)
           
 void cull(java.util.Collection keepers)
          remove all chromosomes from this specie except keepers
 boolean equals(java.lang.Object o)
           
 double getChromosomeFitnessValue(Chromosome aChromosome)
           
 java.util.List getChromosomes()
           
 double getFitnessValue()
           
 Chromosome getFittest()
           
protected  Chromosome getRepresentative()
           
 java.lang.Long getRepresentativeId()
           
 int hashCode()
           
 boolean isEmpty()
           
 boolean match(Chromosome aChromosome)
           
 java.lang.String toString()
           
 java.lang.String toXml()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

SPECIE_TAG

public static final java.lang.String SPECIE_TAG
XML base tag

See Also:
Constant Field Values

ID_TAG

public static final java.lang.String ID_TAG
XML ID tag

See Also:
Constant Field Values

COUNT_TAG

public static final java.lang.String COUNT_TAG
XML count tag

See Also:
Constant Field Values

CHROMOSOME_TAG

public static final java.lang.String CHROMOSOME_TAG
XML chromosome tag

See Also:
Constant Field Values

FITNESS_TAG

public static final java.lang.String FITNESS_TAG
XML fitness tag

See Also:
Constant Field Values
Constructor Detail

Specie

public Specie(SpeciationParms aSpeciationParms,
              Chromosome aRepresentative)
Create new specie from representative. Representative is first member of specie, and all other members of specie are determined by compatibility with representative. Even if representative dies from population, a reference is kept here to determine specie membership.

Parameters:
aSpeciationParms -
aRepresentative -
Method Detail

hashCode

public int hashCode()
See Also:
Object.hashCode()

equals

public boolean equals(java.lang.Object o)
See Also:
Object.equals(java.lang.Object)

getRepresentativeId

public java.lang.Long getRepresentativeId()
Returns:
unique ID; this is chromosome ID of representative

getRepresentative

protected Chromosome getRepresentative()
Returns:
representative chromosome

add

public boolean add(Chromosome aChromosome)
Parameters:
aChromosome -
Returns:
true if chromosome is added, false if chromosome already is a member of this specie

getChromosomes

public java.util.List getChromosomes()
Returns:
all chromosomes in specie

cull

public void cull(java.util.Collection keepers)
remove all chromosomes from this specie except keepers

Parameters:
keepers - Collection contains chromosome objects

isEmpty

public boolean isEmpty()
Returns:
true iff specie contains no active chromosomes in population

getChromosomeFitnessValue

public double getChromosomeFitnessValue(Chromosome aChromosome)
Parameters:
aChromosome -
Returns:
double adjusted fitness for aChromosome relative to this specie
Throws:
java.lang.IllegalArgumentException - if chromosome is not a member if this specie

getFitnessValue

public double getFitnessValue()
Returns:
average raw fitness (i.e., not adjusted for specie size) of all chromosomes in specie

getFittest

public Chromosome getFittest()
Returns:
Chromosome fittest in this specie

match

public boolean match(Chromosome aChromosome)
Parameters:
aChromosome -
Returns:
boolean true iff compatibility difference between aChromosome

toString

public java.lang.String toString()
See Also:
Object.toString()

toXml

public java.lang.String toXml()
Returns:
String XML representation of object according to NEVT .