org.encog.solve.genetic.species
Class BasicSpecies

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

public class BasicSpecies
extends Object
implements Species

Provides basic functionality for a species.


Constructor Summary
BasicSpecies()
          Default constructor, used mainly for persistence.
BasicSpecies(Population population, Genome first, long speciesID)
          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()
           
 void purge()
          Purge all members, increase age by one and count the number of generations with no improvement.
 void setAge(int age)
          Set the age of this species.
 void setBestScore(double bestScore)
          Set the best score.
 void setGensNoImprovement(int gensNoImprovement)
          Set the number of generations with no improvement.
 void setLeader(Genome leader)
          Set the leader.
 void setSpawnsRequired(double spawnsRequired)
          Set the number of spawns required.
 
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 population,
                    Genome first,
                    long speciesID)
Construct a species.

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

calculateSpawnAmount

public void calculateSpawnAmount()
Calculate the amount to spawn.

Specified by:
calculateSpawnAmount in interface Species

chooseParent

public 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 int getAge()
Specified by:
getAge in interface Species
Returns:
The age of this species.

getBestScore

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

getGensNoImprovement

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

getLeader

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

getMembers

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

getNumToSpawn

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

getPopulation

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

getSpawnsRequired

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

getSpeciesID

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

purge

public 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 void setAge(int age)
Set the age of this species.

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

setBestScore

public void setBestScore(double bestScore)
Set the best score.

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

setGensNoImprovement

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

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

setLeader

public void setLeader(Genome leader)
Set the leader.

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

setSpawnsRequired

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

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


Copyright © 2011. All Rights Reserved.