Package ec

# Class Population

java.lang.Object
ec.Population

All Implemented Interfaces:
  `Setup`, `Serializable`, `Cloneable`

public class Population extends Object implements Cloneable, Setup
A Population is the repository for all the Individuals being bred or evaluated in the evolutionary run at a given time. A Population is basically an array of Subpopulations, each of which are arrays of Individuals coupled with a single Species per Subpoulation.

The first Population is created using the initializePopulation method of the Initializer object, which typically calls the Population's populate() method in turn. On generational systems, subsequent populations are created on a generation-by-generation basis by the Breeder object, replacing the previous Population.

In a multithreaded area of a run, Populations should be considered immutable. That is, once they are created, they should not be modified, nor anything they contain. This protocol helps ensure read-safety under multithreading race conditions.

Parameters

base.`subpops` int >= 1 | (the number of subpopulations)
base.`subpop`.n classname, inherits or = ec.Subpopulation | (the class for subpopulation #n)
base.`default-subpop` int >= 0 | (the default subpopulation index. The parameter base of this subpopulation will be used as the default base for all subpopulations which do not define one themselves./tr>

Parameter bases

base.`subpop`.n | Subpopulation #n.

See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `Parameter`
  `file`
  `boolean`
  `loadInds`
  `static final String`
  `NUM_SUBPOPS_PREAMBLE`
  `static final String`
  `P_DEFAULT_SUBPOP`
  `static final String`
  `P_FILE`
  `static final String`
  `P_SIZE`
  `static final String`
  `P_SUBPOP`
  `static final String`
  `SUBPOP_INDEX_PREAMBLE`
  `ArrayList<Subpopulation>`
  `subpops`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Population()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `clear()`
  `Population`
  `emptyClone()`
  Returns an instance of Population just like it had been before it was populated with individuals.
  `void`
  `populate(EvolutionState state, int thread)`
  Populates the population with new random individuals.
  `void`
  `printPopulation(EvolutionState state, int log)`
  Prints an entire population in a form readable by humans but also parseable by the computer using readPopulation(EvolutionState, LineNumberReader), with a verbosity of Output.V_NO_GENERAL.
  `final void`
  `printPopulation(EvolutionState state, int log, int verbosity)`
  Prints an entire population in a form readable by humans but also parseable by the computer using readPopulation(EvolutionState, LineNumberReader).
  `void`
  `printPopulation(EvolutionState state, PrintWriter writer)`
  Prints an entire population in a form readable by humans but also parseable by the computer using readPopulation(EvolutionState, LineNumberReader).
  `void`
  `printPopulationForHumans(EvolutionState state, int log)`
  Prints an entire population in a form readable by humans, with a verbosity of Output.V_NO_GENERAL.
  `final void`
  `printPopulationForHumans(EvolutionState state, int log, int verbosity)`
  Prints an entire population in a form readable by humans.
  `void`
  `readPopulation(EvolutionState state, DataInput dataInput)`
  Reads a population in binary form, from the format generated by writePopulation(...).
  `void`
  `readPopulation(EvolutionState state, LineNumberReader reader)`
  Reads a population from the format generated by printPopulation(....).
  `void`
  `setup(EvolutionState state, Parameter base)`
  Sets up the object by reading it from the parameters stored in state, built off of the parameter base base.
  `void`
  `writePopulation(EvolutionState state, DataOutput dataOutput)`
  Writes a population in binary form, in a format readable by readPopulation(EvolutionState, DataInput).

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

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

- ## Field Details

  - ### subpops

    public ArrayList<Subpopulation> subpops

  - ### P_SIZE

    public static final String P_SIZE
    See Also:
      - Constant Field Values

  - ### P_SUBPOP

    public static final String P_SUBPOP
    See Also:
      - Constant Field Values

  - ### P_DEFAULT_SUBPOP

    public static final String P_DEFAULT_SUBPOP
    See Also:
      - Constant Field Values

  - ### P_FILE

    public static final String P_FILE
    See Also:
      - Constant Field Values

  - ### NUM_SUBPOPS_PREAMBLE

    public static final String NUM_SUBPOPS_PREAMBLE
    See Also:
      - Constant Field Values

  - ### SUBPOP_INDEX_PREAMBLE

    public static final String SUBPOP_INDEX_PREAMBLE
    See Also:
      - Constant Field Values

  - ### loadInds

    public boolean loadInds

  - ### file

    public Parameter file

- ## Constructor Details

  - ### Population

    public Population()

- ## Method Details

  - ### emptyClone

    public Population emptyClone()
    Returns an instance of Population just like it had been before it was populated with individuals. You may need to override this if you override Population. IMPORTANT NOTE: if the size of the array in Population has been changed, then the clone will take on the new array size. This helps some evolution strategies.

  - ### clear

    public void clear()

  - ### setup

    public void setup(EvolutionState state, Parameter base)
    Description copied from interface: `Setup`
    Sets up the object by reading it from the parameters stored in state, built off of the parameter base base. If an ancestor implements this method, be sure to call super.setup(state,base); before you do anything else.
    Specified by:
      `setup` in interface `Setup`

  - ### populate

    public void populate(EvolutionState state, int thread)
    Populates the population with new random individuals.

  - ### printPopulationForHumans

    public final void printPopulationForHumans(EvolutionState state, int log, int verbosity)
    Prints an entire population in a form readable by humans.

  - ### printPopulation

    public final void printPopulation(EvolutionState state, int log, int verbosity)
    Prints an entire population in a form readable by humans but also parseable by the computer using readPopulation(EvolutionState, LineNumberReader).

  - ### printPopulationForHumans

    public void printPopulationForHumans(EvolutionState state, int log)
    Prints an entire population in a form readable by humans, with a verbosity of Output.V_NO_GENERAL.

  - ### printPopulation

    public void printPopulation(EvolutionState state, int log)
    Prints an entire population in a form readable by humans but also parseable by the computer using readPopulation(EvolutionState, LineNumberReader), with a verbosity of Output.V_NO_GENERAL.

  - ### printPopulation

    public void printPopulation(EvolutionState state, PrintWriter writer)
    Prints an entire population in a form readable by humans but also parseable by the computer using readPopulation(EvolutionState, LineNumberReader).

  - ### readPopulation

    public void readPopulation(EvolutionState state, LineNumberReader reader) throws IOException
    Reads a population from the format generated by printPopulation(....). The number of subpopulations and the species information must be identical.
    Throws:
      `IOException`

  - ### writePopulation

    public void writePopulation(EvolutionState state, DataOutput dataOutput) throws IOException
    Writes a population in binary form, in a format readable by readPopulation(EvolutionState, DataInput).
    Throws:
      `IOException`

  - ### readPopulation

    public void readPopulation(EvolutionState state, DataInput dataInput) throws IOException
    Reads a population in binary form, from the format generated by writePopulation(...). The number of subpopulations and the species information must be identical.
    Throws:
      `IOException`