Package ec.simple

# Class SimpleBreeder

java.lang.Object
ec.Breeder
ec.simple.SimpleBreeder

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

Direct Known Subclasses:
  `NSGA2Breeder`, `SpatialBreeder`, `SPEA2Breeder`, `SteadyStateBreeder`

public class SimpleBreeder extends Breeder
Breeds each subpopulation separately, with no inter-population exchange, and using a generational approach. A SimpleBreeder may have multiple threads; it divvys up a subpopulation into chunks and hands one chunk to each thread to populate. One array of BreedingSources is obtained from a population's Species for each operating breeding thread.

Prior to breeding a subpopulation, a SimpleBreeder may first fill part of the new subpopulation up with the best n individuals from the old subpopulation. By default, n is 0 for each subpopulation (that is, this "elitism" is not done). The elitist step is performed by a single thread.

If the sequential parameter below is true, then breeding is done specially: instead of breeding all Subpopulations each generation, we only breed one each generation. The subpopulation index to breed is determined by taking the generation number, modulo the total number of subpopulations. Use of this parameter outside of a coevolutionary context (see ec.coevolve.MultiPopCoevolutionaryEvaluator) is very rare indeed.

SimpleBreeder adheres to the default-subpop parameter in Population: if either an 'elite' or 'reevaluate-elites' parameter is missing, it will use the default subpopulation's value and signal a warning.

Parameters

`base.elite.i` int >= 0 (default=0) | (the number of elitist individuals for subpopulation i)
`base.reevaluate-elites.i` boolean (default = false) | (should we reevaluate the elites of subpopulation i each generation?)
`base.sequential` boolean (default = false) | (should we breed just one subpopulation each generation (as opposed to all of them)?)

See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `Population`
  `backupPopulation`
  `boolean`
  `clonePipelineAndPopulation`
  `int[]`
  `elite`
  An array[subpop] of the number of elites to keep for that subpopulation
  `double[]`
  `eliteFrac`
  An array[subpop] of the *fraction* of elites to keep for that subpopulation
  `ArrayList<Individual>[][]`
  `newIndividuals`
  `static final int`
  `NOT_SET`
  `static final String`
  `P_CLONE_PIPELINE_AND_POPULATION`
  `static final String`
  `P_ELITE`
  `static final String`
  `P_ELITE_FRAC`
  `static final String`
  `P_REEVALUATE_ELITES`
  `static final String`
  `P_SEQUENTIAL_BREEDING`
  `ThreadPool`
  `pool`
  `boolean[]`
  `reevaluateElites`

  ### Fields inherited from class ec.Breeder

  `sequentialBreeding`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SimpleBreeder()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected void`
  `breedPopChunk(Population newpop, EvolutionState state, int[] numinds, int[] from, int threadnum)`
  A private helper function for breedPopulation which breeds a chunk of individuals in a subpopulation for a given thread.
  `protected void`
  `breedPopChunkProduce(int position)`
  `Population`
  `breedPopulation(EvolutionState state)`
  A simple breeder that doesn't attempt to do any cross- population breeding.
  `protected void`
  `loadElites(EvolutionState state, Population newpop)`
  A protected helper function for breedPopulation which loads elites into a subpopulation.
  `protected int`
  `nextSubpopulationSize(EvolutionState state, int subpop)`
  Returns the next subpopulation size.
  `int`
  `numElites(EvolutionState state, int subpopulation)`
  `void`
  `postProcess(EvolutionState state)`
  A hook to do final modifications as necessary to the population after breeding has concluded.
  `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.
  `boolean`
  `shouldBreedSubpop(EvolutionState state, int subpop, int threadnum)`
  Returns true if we're doing sequential breeding and it's the subpopulation's turn (round robin, one subpopulation per generation).
  `protected void`
  `unmarkElitesEvaluated(EvolutionState state, Population newpop)`
  `boolean`
  `usingElitism(int subpopulation)`

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

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

- ## Field Details

  - ### P_ELITE

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

  - ### P_ELITE_FRAC

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

  - ### P_REEVALUATE_ELITES

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

  - ### P_SEQUENTIAL_BREEDING

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

  - ### P_CLONE_PIPELINE_AND_POPULATION

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

  - ### elite

    public int[] elite
    An array[subpop] of the number of elites to keep for that subpopulation

  - ### eliteFrac

    public double[] eliteFrac
    An array[subpop] of the *fraction* of elites to keep for that subpopulation

  - ### reevaluateElites

    public boolean[] reevaluateElites

  - ### clonePipelineAndPopulation

    public boolean clonePipelineAndPopulation

  - ### backupPopulation

    public Population backupPopulation

  - ### newIndividuals

    public ArrayList<Individual>[][] newIndividuals

  - ### NOT_SET

    public static final int NOT_SET
    See Also:
      - Constant Field Values

  - ### pool

    public ThreadPool pool

- ## Constructor Details

  - ### SimpleBreeder

    public SimpleBreeder()

- ## Method Details

  - ### usingElitism

    public boolean usingElitism(int subpopulation)

  - ### numElites

    public int numElites(EvolutionState state, int subpopulation)

  - ### 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.

  - ### nextSubpopulationSize

    protected int nextSubpopulationSize(EvolutionState state, int subpop)
    Returns the next subpopulation size. By default this is the CURRENT subpopulation size, but it could be overridden if you have modified the current subpopulation size (as in NSGA-II) but don't want the next subpopulation size to be affected.

  - ### breedPopulation

    public Population breedPopulation(EvolutionState state)
    A simple breeder that doesn't attempt to do any cross- population breeding. Basically it applies pipelines, one per thread, to various subchunks of a new population.
    Specified by:
      `breedPopulation` in class `Breeder`

  - ### postProcess

    public void postProcess(EvolutionState state)
    A hook to do final modifications as necessary to the population after breeding has concluded. By default this does nothing, but multiobjective breeders, which temporarily replace the old population while it's being breeded, may use this to put the popuplation back again just in case statistics needs it.

  - ### shouldBreedSubpop

    public boolean shouldBreedSubpop(EvolutionState state, int subpop, int threadnum)
    Returns true if we're doing sequential breeding and it's the subpopulation's turn (round robin, one subpopulation per generation).
    Overrides:
      `shouldBreedSubpop` in class `Breeder`

  - ### breedPopChunk

    protected void breedPopChunk(Population newpop, EvolutionState state, int[] numinds, int[] from, int threadnum)
    A private helper function for breedPopulation which breeds a chunk of individuals in a subpopulation for a given thread. Although this method is declared public (for the benefit of a private helper class in this file), you should not call it.

  - ### breedPopChunkProduce

    protected void breedPopChunkProduce(int position)

  - ### unmarkElitesEvaluated

    protected void unmarkElitesEvaluated(EvolutionState state, Population newpop)

  - ### loadElites

    protected void loadElites(EvolutionState state, Population newpop)
    A protected helper function for breedPopulation which loads elites into a subpopulation.