org.encog.ml.ea.population

## Class BasicPopulation

- java.lang.Object
- - org.encog.ml.BasicML
  - - org.encog.ml.ea.population.BasicPopulation

- All Implemented Interfaces:
    Serializable, Population, MLMethod, MLProperties
  Direct Known Subclasses:
    NEATPopulation, PrgPopulation

      public class BasicPopulation
      extends BasicML
      implements Population, Serializable

  Defines the basic functionality for a population of genomes. The population is made up of species. These species contain the individiual genomes that make up the population. If you do not want to use species, then create one species that holds every genome.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BasicPopulation()` Construct an empty population.
    `BasicPopulation(int thePopulationSize, GenomeFactory theGenomeFactory)` Construct a population.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()` Clear all genomes from this population.
    `Species` | `createSpecies()` Create a species.
    `Species` | `determineBestSpecies()` Determine which species has the top genome.
    `List<Genome>` | `flatten()` Flatten the species into a single list of genomes.
    `Genome` | `getBestGenome()`
    `GenomeFactory` | `getGenomeFactory()`
    `int` | `getMaxIndividualSize()`
    `String` | `getName()`
    `int` | `getPopulationSize()`
    `List<Species>` | `getSpecies()`
    `void` | `purgeInvalidGenomes()` Purge any invalid genomes.
    `void` | `setBestGenome(Genome genome)` Set the best genome.
    `void` | `setGenomeFactory(GenomeFactory factory)` Set the gnome factory.
    `void` | `setName(String theName)` Set the name.
    `void` | `setPopulationSize(int thePopulationSize)` Set the max population size.
    `int` | `size()`
    `void` | `updateProperties()` Update any objeccts when a property changes.

    - ### Methods inherited from class org.encog.ml.BasicML

      `getProperties, getPropertyDouble, getPropertyLong, getPropertyString, setProperty, setProperty, setProperty`

    - ### 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 thePopulationSize,
                         GenomeFactory theGenomeFactory)

      Construct a population.
      Parameters:
        `thePopulationSize` - The population size.

  - ### Method Detail

    - #### clear

          public void clear()

      Clear all genomes from this population.
      Specified by:
        `clear` in interface `Population`

    - #### createSpecies

          public Species createSpecies()

      Create a species.
      Specified by:
        `createSpecies` in interface `Population`
      Returns:
        The newly created species.

    - #### determineBestSpecies

          public Species determineBestSpecies()

      Determine which species has the top genome.
      Specified by:
        `determineBestSpecies` in interface `Population`
      Returns:
        The species with the top genome.

    - #### flatten

          public List<Genome> flatten()

      Flatten the species into a single list of genomes.
      Specified by:
        `flatten` in interface `Population`
      Returns:
        The genomes that make up all species in the population.

    - #### getBestGenome

          public Genome getBestGenome()

      Specified by:
        `getBestGenome` in interface `Population`
      Returns:
        The best genome in the population.

    - #### getGenomeFactory

          public GenomeFactory getGenomeFactory()

      Specified by:
        `getGenomeFactory` in interface `Population`
      Returns:
        A factory used to create genomes.

    - #### getMaxIndividualSize

          public int getMaxIndividualSize()

      Specified by:
        `getMaxIndividualSize` in interface `Population`
      Returns:
        The max size that an individual can become.

    - #### getName

          public String getName()

      Returns:
        The name.

    - #### getPopulationSize

          public int getPopulationSize()

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

    - #### getSpecies

          public List<Species> getSpecies()

      Specified by:
        `getSpecies` in interface `Population`
      Returns:
        The species that make up the population.

    - #### setBestGenome

          public void setBestGenome(Genome genome)

      Set the best genome.
      Specified by:
        `setBestGenome` in interface `Population`
      Parameters:
        `genome` - The best genome.

    - #### setGenomeFactory

          public void setGenomeFactory(GenomeFactory factory)

      Set the gnome factory.
      Specified by:
        `setGenomeFactory` in interface `Population`
      Parameters:
        `factory` - The genome factory.

    - #### setName

          public void setName(String theName)

      Set the name.
      Parameters:
        `theName` - The new name.

    - #### setPopulationSize

          public void setPopulationSize(int thePopulationSize)

      Set the max population size.
      Specified by:
        `setPopulationSize` in interface `Population`
      Parameters:
        `thePopulationSize` - The max population size.

    - #### size

          public int size()

      Specified by:
        `size` in interface `Population`
      Returns:
        The size of the population.

    - #### updateProperties

          public void updateProperties()

      Update any objeccts when a property changes.
      Specified by:
        `updateProperties` in interface `MLProperties`
      Specified by:
        `updateProperties` in class `BasicML`

    - #### purgeInvalidGenomes

          public void purgeInvalidGenomes()

      Purge any invalid genomes.
      Specified by:
        `purgeInvalidGenomes` in interface `Population`

Copyright © 2014. All Rights Reserved.