Class SUSSelection
- java.lang.Object
-
- ec.BreedingSource
-
- ec.SelectionMethod
-
- ec.select.SUSSelection
-
- All Implemented Interfaces:
- Prototype, Setup, RandomChoiceChooserD, java.io.Serializable, java.lang.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 and Description double[]fitnessesThe distribution of fitnesses.int[]indicesAn array of pointers to individuals in the population, shuffled along with the fitnesses array.intlastIndexThe index in the array of the last individual selected.doubleoffsetThe floating point value to consider for the next selected individual.static java.lang.StringP_SHUFFLEstatic java.lang.StringP_SUSDefault basebooleanshuffleShould we shuffle first?intstepsHow many samples have been done?-
Fields inherited from class ec.SelectionMethod
INDS_PRODUCED
-
Fields inherited from class ec.BreedingSource
NO_PROBABILITY, P_PROB, probability
-
-
Constructor Summary
Constructors Constructor and Description SUSSelection()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description ParameterdefaultBase()Returns the default base for this prototype.voidprepareToProduce(EvolutionState s, int subpopulation, int thread)A default version of prepareToProduce which does nothing.intproduce(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.voidsetup(EvolutionState state, Parameter base)Sets up the BreedingPipeline.-
Methods inherited from class ec.SelectionMethod
finishProducing, produce, produces, typicalIndsProduced
-
Methods inherited from class ec.BreedingSource
clone, getProbability, pickRandom, preparePipeline, setProbability, setupProbabilities
-
-
-
-
Field Detail
-
P_SUS
public static final java.lang.String P_SUS
Default base- See Also:
- Constant Field Values
-
P_SHUFFLE
public static final java.lang.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?
-
-
Method Detail
-
defaultBase
public Parameter defaultBase()
Description copied from interface:PrototypeReturns 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:BreedingSourceSets 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:
setupin interfacePrototype- Specified by:
setupin interfaceSetup- Overrides:
setupin classBreedingSource- See Also:
Prototype.setup(EvolutionState,Parameter)
-
prepareToProduce
public void prepareToProduce(EvolutionState s, int subpopulation, int thread)
Description copied from class:SelectionMethodA default version of prepareToProduce which does nothing.- Overrides:
prepareToProducein classSelectionMethod
-
produce
public int produce(int subpopulation, EvolutionState state, int thread)Description copied from class:SelectionMethodAn alternative form of "produce" special to Selection Methods; selects an individual from the given subpopulation and returns its position in that subpopulation.- Specified by:
producein classSelectionMethod
-
-
DMelt 3.0 © DataMelt by jWork.ORG