public class SUSSelection extends SelectionMethod
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
Modifier and Type | Field and 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 java.lang.String |
P_SHUFFLE |
static java.lang.String |
P_SUS
Default base
|
boolean |
shuffle
Should we shuffle first?
|
int |
steps
How many samples have been done?
|
INDS_PRODUCED
NO_PROBABILITY, P_PROB, probability
Constructor and Description |
---|
SUSSelection() |
Modifier and Type | Method and 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.
|
finishProducing, produce, produces, typicalIndsProduced
clone, getProbability, pickRandom, preparePipeline, setProbability, setupProbabilities
public static final java.lang.String P_SUS
public static final java.lang.String P_SHUFFLE
public int[] indices
public double[] fitnesses
public boolean shuffle
public double offset
public int lastIndex
public int steps
public Parameter defaultBase()
Prototype
public void setup(EvolutionState state, Parameter base)
BreedingSource
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}.
setup
in interface Prototype
setup
in interface Setup
setup
in class BreedingSource
Prototype.setup(EvolutionState,Parameter)
public void prepareToProduce(EvolutionState s, int subpopulation, int thread)
SelectionMethod
prepareToProduce
in class SelectionMethod
public int produce(int subpopulation, EvolutionState state, int thread)
SelectionMethod
produce
in class SelectionMethod