org.apache.commons.math3.genetics

## Class ListPopulation

- java.lang.Object
- - org.apache.commons.math3.genetics.ListPopulation

- All Implemented Interfaces:
    Iterable<Chromosome>, Population
  Direct Known Subclasses:
    ElitisticListPopulation

      public abstract class ListPopulation
      extends Object
      implements Population

  Population of chromosomes represented by a `List`.
  Since:
    2.0
  Version:
    $Id: ListPopulation.java 1244107 2012-02-14 16:17:55Z erans $

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ListPopulation(int populationLimit)` Creates a new ListPopulation instance and initializes its inner chromosome list.
    `ListPopulation(List<Chromosome> chromosomes, int populationLimit)` Creates a new ListPopulation instance.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addChromosome(Chromosome chromosome)` Add the given chromosome to the population.
    `List<Chromosome>` | `getChromosomes()` Access the list of chromosomes.
    `Chromosome` | `getFittestChromosome()` Access the fittest chromosome in this population.
    `int` | `getPopulationLimit()` Access the maximum population size.
    `int` | `getPopulationSize()` Access the current population size.
    `Iterator<Chromosome>` | `iterator()` Chromosome list iterator
    `void` | `setChromosomes(List<Chromosome> chromosomes)` Sets the list of chromosomes.
    `void` | `setPopulationLimit(int populationLimit)` Sets the maximal population size.
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.apache.commons.math3.genetics.Population

      `nextGeneration`

- - ### Constructor Detail

    - #### ListPopulation

          public ListPopulation(List<Chromosome> chromosomes,
                        int populationLimit)

      Creates a new ListPopulation instance.
      Parameters:
        `chromosomes` - list of chromosomes in the population
        `populationLimit` - maximal size of the population
      Throws:
        `NumberIsTooLargeException` - if the list of chromosomes exceeds the population limit
        `NotPositiveException` - if the population limit is not a positive number (< 1)

    - #### ListPopulation

          public ListPopulation(int populationLimit)

      Creates a new ListPopulation instance and initializes its inner chromosome list.
      Parameters:
        `populationLimit` - maximal size of the population
      Throws:
        `NotPositiveException` - if the population limit is not a positive number (< 1)

  - ### Method Detail

    - #### setChromosomes

          public void setChromosomes(List<Chromosome> chromosomes)

      Sets the list of chromosomes.
      Parameters:
        `chromosomes` - the list of chromosomes

    - #### getChromosomes

          public List<Chromosome> getChromosomes()

      Access the list of chromosomes.
      Returns:
        the list of chromosomes

    - #### addChromosome

          public void addChromosome(Chromosome chromosome)

      Add the given chromosome to the population.
      Specified by:
        `addChromosome` in interface `Population`
      Parameters:
        `chromosome` - the chromosome to add.

    - #### getFittestChromosome

          public Chromosome getFittestChromosome()

      Access the fittest chromosome in this population.
      Specified by:
        `getFittestChromosome` in interface `Population`
      Returns:
        the fittest chromosome.

    - #### getPopulationLimit

          public int getPopulationLimit()

      Access the maximum population size.
      Specified by:
        `getPopulationLimit` in interface `Population`
      Returns:
        the maximum population size.

    - #### setPopulationLimit

          public void setPopulationLimit(int populationLimit)

      Sets the maximal population size.
      Parameters:
        `populationLimit` - maximal population size.

    - #### getPopulationSize

          public int getPopulationSize()

      Access the current population size.
      Specified by:
        `getPopulationSize` in interface `Population`
      Returns:
        the current population size.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### iterator

          public Iterator<Chromosome> iterator()

      Chromosome list iterator
      Specified by:
        `iterator` in interface `Iterable<Chromosome>`
      Returns:
        chromosome iterator

Copyright © 2003-2012 The Apache Software Foundation. All Rights Reserved.