Package ec.select

# Class SUSSelection

java.lang.Object
ec.BreedingSource
ec.SelectionMethod
ec.select.SUSSelection

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

public class SUSSelection extends SelectionMethod
Picks individuals in a population using the Stochastic Universal Selection (SUS) process, using fitnesses as returned by their fitness() methods. This is expensive to set up and bring down, so it's not appropriate for steady-state evolution. If you're not familiar with the relative advantages of selection methods and just want a good one, use TournamentSelection instead. Not appropriate for multiobjective fitnesses.

By default this implementation of SUS shuffles the order of the individuals in the distribution before performing selection. This isn't always present in classic implementations of the algorithm but it can't hurt anything and certainly can avoid certain pathological situations. If you'd prefer not to preshuffle, set shuffle=false Note that we don't actually change the order of the individuals in the population -- instead we maintain our own internal array of indices and shuffle that.

Like truncation selection, SUS samples N individuals (with replacement) up front from the population, Then returns those individuals one by one. ECJ's implementation assumes that N is the size of the population -- that is, you're going to ultimately request a whole population out of this one selection method. This could be a false assumption: for example, if you only sometimes call this selection method, and sometimes TournamentSelection; or if you've got multiple pipelines. In these cases, SUS is probably a bad choice anyway.

If you ask for more than a population's worth of individuals, SUS tries to handle this gracefully by reshuffling its array and starting to select over again. But again that might suggest you are doing something wrong.

Note: Fitnesses must be non-negative. 0 is assumed to be the worst fitness.

Typical Number of Individuals Produced Per `produce(...)` call
Always 1.

Parameters

base.`shuffle` bool = `true` (default) or `false` | (should we preshuffle the array before doing selection?)

Default Base
select.sus

See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `double[]`
  `fitnesses`
  The distribution of fitnesses.
  `int[]`
  `indices`
  An array of pointers to individuals in the population, shuffled along with the fitnesses array.
  `int`
  `lastIndex`
  The index in the array of the last individual selected.
  `double`
  `offset`
  The floating point value to consider for the next selected individual.
  `static final String`
  `P_SHUFFLE`
  `static final String`
  `P_SUS`
  Default base
  `boolean`
  `shuffle`
  Should we shuffle first?
  `int`
  `steps`
  How many samples have been done?

  ### Fields inherited from class ec.SelectionMethod

  `INDS_PRODUCED, KEY_PARENTS`

  ### Fields inherited from class ec.BreedingSource

  `NO_PROBABILITY, P_PROB, probability`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SUSSelection()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Parameter`
  `defaultBase()`
  Returns the default base for this prototype.
  `void`
  `prepareToProduce(EvolutionState s, int subpopulation, int thread)`
  A default version of prepareToProduce which does nothing.
  `int`
  `produce(int subpopulation, EvolutionState state, int thread)`
  An alternative form of "produce" special to Selection Methods; selects an individual from the given subpopulation and returns its position in that subpopulation.
  `void`
  `setup(EvolutionState state, Parameter base)`
  Sets up the BreedingPipeline.

  ### Methods inherited from class ec.SelectionMethod

  `finishProducing, produce, produces, produceWithoutCloning, typicalIndsProduced`

  ### Methods inherited from class ec.BreedingSource

  `clone, fillStubs, getProbability, pickRandom, preparePipeline, setProbability, setupProbabilities`

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

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

- ## Field Details

  - ### P_SUS

    public static final String P_SUS
    Default base
    See Also:
      - Constant Field Values

  - ### P_SHUFFLE

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

  - ### indices

    public int[] indices
    An array of pointers to individuals in the population, shuffled along with the fitnesses array.

  - ### fitnesses

    public double[] fitnesses
    The distribution of fitnesses.

  - ### shuffle

    public boolean shuffle
    Should we shuffle first?

  - ### offset

    public double offset
    The floating point value to consider for the next selected individual.

  - ### lastIndex

    public int lastIndex
    The index in the array of the last individual selected.

  - ### steps

    public int steps
    How many samples have been done?

- ## Constructor Details

  - ### SUSSelection

    public SUSSelection()

- ## Method Details

  - ### defaultBase

    public Parameter defaultBase()
    Description copied from interface: `Prototype`
    Returns the default base for this prototype. This should generally be implemented by building off of the static base() method on the DefaultsForm object for the prototype's package. This should be callable during setup(...).

  - ### setup

    public void setup(EvolutionState state, Parameter base)
    Description copied from class: `BreedingSource`
    Sets up the BreedingPipeline. You can use state.output.error here because the top-level caller promises to call exitIfErrors() after calling setup. Note that probability might get modified again by an external source if it doesn't normalize right.

    The most common modification is to normalize it with some other set of probabilities, then set all of them up in increasing summation; this allows the use of the fast static BreedingSource-picking utility method, BreedingSource.pickRandom(...). In order to use this method, for example, if four breeding source probabilities are {0.3, 0.2, 0.1, 0.4}, then they should get normalized and summed by the outside owners as: {0.3, 0.5, 0.6, 1.0}.

    Specified by:
      `setup` in interface `Prototype`
    Specified by:
      `setup` in interface `Setup`
    Overrides:
      `setup` in class `BreedingSource`
    See Also:
      - `Prototype.setup(EvolutionState,Parameter)`

  - ### prepareToProduce

    public void prepareToProduce(EvolutionState s, int subpopulation, int thread)
    Description copied from class: `SelectionMethod`
    A default version of prepareToProduce which does nothing.
    Overrides:
      `prepareToProduce` in class `SelectionMethod`

  - ### produce

    public int produce(int subpopulation, EvolutionState state, int thread)
    Description copied from class: `SelectionMethod`
    An alternative form of "produce" special to Selection Methods; selects an individual from the given subpopulation and returns its position in that subpopulation.
    Specified by:
      `produce` in class `SelectionMethod`