org.encog.solve.genetic.population
Class BasicPopulation

java.lang.Object
  extended by org.encog.solve.genetic.population.BasicPopulation
All Implemented Interfaces:
Serializable, EncogPersistedObject, Population

public class BasicPopulation
extends Object
implements Population, EncogPersistedObject

Defines the basic functionality for a population of genomes.

See Also:
Serialized Form

Constructor Summary
BasicPopulation()
          Construct an empty population.
BasicPopulation(int populationSize)
          Construct a population.
 
Method Summary
 void add(Genome genome)
          Add a genome to the population.
 void addAll(List<? extends Genome> newPop)
          Add all of the specified members to this population.
 long assignGeneID()
           
 long assignGenomeID()
           
 long assignInnovationID()
           
 long assignSpeciesID()
           
 void clear()
          Clear all genomes from this population.
 Persistor createPersistor()
          Create a persistor for this object.
 Genome get(int i)
          Get a genome by index.
 Genome getBest()
           
 EncogCollection getCollection()
           
 String getDescription()
           
 List<Genome> getGenomes()
           
 InnovationList getInnovations()
           
 String getName()
           
 double getOldAgePenalty()
           
 int getOldAgeThreshold()
           
 int getPopulationSize()
          Get the population size.
 List<Species> getSpecies()
           
 double getSurvivalRate()
           
 int getYoungBonusAgeThreshold()
           
 double getYoungScoreBonus()
           
 void setCollection(EncogCollection collection)
          Set the Encog collection that this object belongs to.
 void setDescription(String theDescription)
          Set the description.
 void setInnovations(InnovationList innovations)
          Set the innovation list.
 void setName(String theName)
          Set the name.
 void setOldAgePenalty(double oldAgePenalty)
          Set the old age penalty.
 void setOldAgeThreshold(int oldAgeThreshold)
          Set the threshold at which a genome is considered "old".
 void setPopulationSize(int populationSize)
          Set the population size.
 void setSurvivalRate(double survivalRate)
          Set the survival rate.
 void setYoungBonusAgeThreshhold(int youngBonusAgeThreshold)
          Set the young bonus age threshold.
 void setYoungScoreBonus(double youngScoreBonus)
          Set the young genome bonus.
 int size()
           
 void sort()
          Sort the population.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicPopulation

public BasicPopulation()
Construct an empty population.


BasicPopulation

public BasicPopulation(int populationSize)
Construct a population.

Parameters:
populationSize - The population size.
Method Detail

add

public void add(Genome genome)
Add a genome to the population.

Specified by:
add in interface Population
Parameters:
genome - The genome to add.

addAll

public void addAll(List<? extends Genome> newPop)
Add all of the specified members to this population.

Specified by:
addAll in interface Population
Parameters:
newPop - A list of new genomes to add.

assignGeneID

public long assignGeneID()
Specified by:
assignGeneID in interface Population
Returns:
Assign a gene id.

assignGenomeID

public long assignGenomeID()
Specified by:
assignGenomeID in interface Population
Returns:
Assign a genome id.

assignInnovationID

public long assignInnovationID()
Specified by:
assignInnovationID in interface Population
Returns:
Assign an innovation id.

assignSpeciesID

public long assignSpeciesID()
Specified by:
assignSpeciesID in interface Population
Returns:
Assign a species id.

clear

public void clear()
Clear all genomes from this population.

Specified by:
clear in interface Population

createPersistor

public Persistor createPersistor()
Description copied from interface: EncogPersistedObject
Create a persistor for this object.

Specified by:
createPersistor in interface EncogPersistedObject
Returns:
A persistor for this object.

get

public Genome get(int i)
Get a genome by index. Index 0 is the best genome.

Specified by:
get in interface Population
Parameters:
i - The genome to get.
Returns:
The genome found at the specified index.

getBest

public Genome getBest()
Specified by:
getBest in interface Population
Returns:
The best genome in the population.

getDescription

public String getDescription()
Specified by:
getDescription in interface EncogPersistedObject
Returns:
This object's description.

getGenomes

public List<Genome> getGenomes()
Specified by:
getGenomes in interface Population
Returns:
The genomes in the population.

getInnovations

public InnovationList getInnovations()
Specified by:
getInnovations in interface Population
Returns:
A list of innovations in this population.

getName

public String getName()
Specified by:
getName in interface EncogPersistedObject
Returns:
The name.

getOldAgePenalty

public double getOldAgePenalty()
Specified by:
getOldAgePenalty in interface Population
Returns:
The old age penalty, or zero for none.

getOldAgeThreshold

public int getOldAgeThreshold()
Specified by:
getOldAgeThreshold in interface Population
Returns:
The old age threshold.

getPopulationSize

public int getPopulationSize()
Get the population size.

Specified by:
getPopulationSize in interface Population
Returns:
The population size.

getSpecies

public List<Species> getSpecies()
Specified by:
getSpecies in interface Population
Returns:
The species in this population.

getSurvivalRate

public double getSurvivalRate()
Specified by:
getSurvivalRate in interface Population
Returns:
The survival rate.

getYoungBonusAgeThreshold

public int getYoungBonusAgeThreshold()
Specified by:
getYoungBonusAgeThreshold in interface Population
Returns:
The age at which a genome is considered "young".

getYoungScoreBonus

public double getYoungScoreBonus()
Specified by:
getYoungScoreBonus in interface Population
Returns:
The bonus applied to young genomes.

setDescription

public void setDescription(String theDescription)
Set the description.

Specified by:
setDescription in interface EncogPersistedObject
Parameters:
theDescription - The description.

setInnovations

public void setInnovations(InnovationList innovations)
Set the innovation list.

Specified by:
setInnovations in interface Population
Parameters:
innovations - The innovations, or null to disable.

setName

public void setName(String theName)
Set the name.

Specified by:
setName in interface EncogPersistedObject
Parameters:
theName - The new name.

setOldAgePenalty

public void setOldAgePenalty(double oldAgePenalty)
Set the old age penalty.

Specified by:
setOldAgePenalty in interface Population
Parameters:
oldAgePenalty - The percent the score is affected by.

setOldAgeThreshold

public void setOldAgeThreshold(int oldAgeThreshold)
Set the threshold at which a genome is considered "old".

Specified by:
setOldAgeThreshold in interface Population
Parameters:
oldAgeThreshold - The age.

setPopulationSize

public void setPopulationSize(int populationSize)
Set the population size.

Specified by:
setPopulationSize in interface Population
Parameters:
populationSize - The population size.

setSurvivalRate

public void setSurvivalRate(double survivalRate)
Set the survival rate.

Specified by:
setSurvivalRate in interface Population
Parameters:
survivalRate - The survival rate.

setYoungBonusAgeThreshhold

public void setYoungBonusAgeThreshhold(int youngBonusAgeThreshold)
Set the young bonus age threshold.

Specified by:
setYoungBonusAgeThreshhold in interface Population
Parameters:
youngBonusAgeThreshold - The age.

setYoungScoreBonus

public void setYoungScoreBonus(double youngScoreBonus)
Set the young genome bonus.

Specified by:
setYoungScoreBonus in interface Population
Parameters:
youngScoreBonus - The score bonus.

size

public int size()
Specified by:
size in interface Population
Returns:
The max size of the population.

sort

public void sort()
Sort the population.

Specified by:
sort in interface Population

getCollection

public EncogCollection getCollection()
Specified by:
getCollection in interface EncogPersistedObject
Returns:
The collection this Encog object belongs to, null if none.

setCollection

public void setCollection(EncogCollection collection)
Set the Encog collection that this object belongs to.

Specified by:
setCollection in interface EncogPersistedObject


Copyright © 2011. All Rights Reserved.