org.encog.ml.genetic.species
Class BasicSpecies

java.lang.Object
  extended by org.encog.ml.genetic.species.BasicSpecies
All Implemented Interfaces:
Serializable, Species

public class BasicSpecies
extends Object
implements Species, Serializable

Provides basic functionality for a species.

See Also:
Serialized Form

Constructor Summary
BasicSpecies()
          Default constructor, used mainly for persistence.
BasicSpecies(Population thePopulation, Genome theFirst, long theSpeciesID)
          Construct a species.
 
Method Summary
 void calculateSpawnAmount()
          Calculate the amount to spawn.
 Genome chooseParent()
          Choose a parent to mate.
 int getAge()
           
 double getBestScore()
           
 int getGensNoImprovement()
           
 Genome getLeader()
           
 List<Genome> getMembers()
           
 double getNumToSpawn()
           
 Population getPopulation()
           
 double getSpawnsRequired()
           
 long getSpeciesID()
           
 long getTempLeaderID()
           
 void purge()
          Purge all members, increase age by one and count the number of generations with no improvement.
 void setAge(int theAge)
          Set the age of this species.
 void setBestScore(double theBestScore)
          Set the best score.
 void setGensNoImprovement(int theGensNoImprovement)
          Set the number of generations with no improvement.
 void setLeader(Genome theLeader)
          Set the leader.
 void setPopulation(Population thePopulation)
           
 void setSpawnsRequired(double theSpawnsRequired)
          Set the number of spawns required.
 void setSpeciesID(int i)
          Set the species id.
 void setTempLeaderID(long theLeaderID)
          Set the leader id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicSpecies

public BasicSpecies()
Default constructor, used mainly for persistence.


BasicSpecies

public BasicSpecies(Population thePopulation,
                    Genome theFirst,
                    long theSpeciesID)
Construct a species.

Parameters:
thePopulation - The population the species belongs to.
theFirst - The first genome in the species.
theSpeciesID - The species id.
Method Detail

calculateSpawnAmount

public final void calculateSpawnAmount()
Calculate the amount to spawn.

Specified by:
calculateSpawnAmount in interface Species

chooseParent

public final Genome chooseParent()
Choose a parent to mate. Choose from the population, determined by the survival rate. From this pool, a random parent is chosen.

Specified by:
chooseParent in interface Species
Returns:
The parent.

getAge

public final int getAge()
Specified by:
getAge in interface Species
Returns:
The age of this species.

getBestScore

public final double getBestScore()
Specified by:
getBestScore in interface Species
Returns:
The best score for this species.

getGensNoImprovement

public final int getGensNoImprovement()
Specified by:
getGensNoImprovement in interface Species
Returns:
The number of generations with no improvement.

getLeader

public final Genome getLeader()
Specified by:
getLeader in interface Species
Returns:
THe leader of this species.

getMembers

public final List<Genome> getMembers()
Specified by:
getMembers in interface Species
Returns:
The members of this species.

getNumToSpawn

public final double getNumToSpawn()
Specified by:
getNumToSpawn in interface Species
Returns:
The number to spawn.

getPopulation

public final Population getPopulation()
Returns:
The population that this species belongs to.

getSpawnsRequired

public final double getSpawnsRequired()
Specified by:
getSpawnsRequired in interface Species
Returns:
The spawns required.

getSpeciesID

public final long getSpeciesID()
Specified by:
getSpeciesID in interface Species
Returns:
The species ID.

getTempLeaderID

public final long getTempLeaderID()
Returns:
the leaderID

purge

public final void purge()
Purge all members, increase age by one and count the number of generations with no improvement.

Specified by:
purge in interface Species

setAge

public final void setAge(int theAge)
Set the age of this species.

Specified by:
setAge in interface Species
Parameters:
theAge - The age of this species.

setBestScore

public final void setBestScore(double theBestScore)
Set the best score.

Specified by:
setBestScore in interface Species
Parameters:
theBestScore - The best score.

setGensNoImprovement

public final void setGensNoImprovement(int theGensNoImprovement)
Set the number of generations with no improvement.

Specified by:
setGensNoImprovement in interface Species
Parameters:
theGensNoImprovement - The number of generations.

setLeader

public final void setLeader(Genome theLeader)
Set the leader.

Specified by:
setLeader in interface Species
Parameters:
theLeader - The new leader.

setPopulation

public final void setPopulation(Population thePopulation)
Parameters:
thePopulation - the population to set

setSpawnsRequired

public final void setSpawnsRequired(double theSpawnsRequired)
Set the number of spawns required.

Specified by:
setSpawnsRequired in interface Species
Parameters:
theSpawnsRequired - The number of spawns required.

setSpeciesID

public final void setSpeciesID(int i)
Set the species id.

Parameters:
i - The new species id.

setTempLeaderID

public final void setTempLeaderID(long theLeaderID)
Set the leader id. This value is not persisted, it is used only for loading.

Parameters:
theLeaderID - the leaderID to set


Copyright © 2011. All Rights Reserved.