Class SUSSelection
- All Implemented Interfaces:
Prototype,Setup,RandomChoiceChooserD,Serializable,Cloneable
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:
-
Field Summary
FieldsModifier and TypeFieldDescriptiondouble[]The distribution of fitnesses.int[]An array of pointers to individuals in the population, shuffled along with the fitnesses array.intThe index in the array of the last individual selected.doubleThe floating point value to consider for the next selected individual.static final Stringstatic final StringDefault basebooleanShould we shuffle first?intHow many samples have been done?Fields inherited from class ec.SelectionMethod
INDS_PRODUCED, KEY_PARENTSFields inherited from class ec.BreedingSource
NO_PROBABILITY, P_PROB, probability -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns 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, produceWithoutCloning, typicalIndsProducedMethods inherited from class ec.BreedingSource
clone, fillStubs, getProbability, pickRandom, preparePipeline, setProbability, setupProbabilities
-
Field Details
-
P_SUS
Default base- See Also:
-
P_SHUFFLE
- See Also:
-
indices
public int[] indicesAn array of pointers to individuals in the population, shuffled along with the fitnesses array. -
fitnesses
public double[] fitnessesThe distribution of fitnesses. -
shuffle
public boolean shuffleShould we shuffle first? -
offset
public double offsetThe floating point value to consider for the next selected individual. -
lastIndex
public int lastIndexThe index in the array of the last individual selected. -
steps
public int stepsHow many samples have been done?
-
-
Constructor Details
-
SUSSelection
public SUSSelection()
-
-
Method Details
-
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
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}.
-
prepareToProduce
Description copied from class:SelectionMethodA default version of prepareToProduce which does nothing.- Overrides:
prepareToProducein classSelectionMethod
-
produce
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
-