ec.select
Class BestSelection

java.lang.Object
  extended by ec.BreedingSource
      extended by ec.SelectionMethod
          extended by ec.select.BestSelection
All Implemented Interfaces:
Prototype, Setup, RandomChoiceChooser, java.io.Serializable, java.lang.Cloneable

public class BestSelection
extends SelectionMethod

Picks among the best n individuals in a population in direct proportion to their absolute fitnesses as returned by their fitness() methods relative to the fitnesses of the other "best" individuals in that n. 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.

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.pick-worst
bool = true or false (default)
(should we pick from among the worst n individuals in the tournament instead of the best n?)
base.n
int > 0 (default is 1)
(the number of best-individuals to select from)

Default Base
select.best

Version:
1.0
Author:
Sean Luke
See Also:
Serialized Form

Field Summary
 int bestn
           
static java.lang.String P_BEST
          Default base
static java.lang.String P_N
           
static java.lang.String P_PICKWORST
           
 boolean pickWorst
          Do we pick the worst instead of the best?
 float[] sortedFit
          Sorted, normalized, totalized fitnesses for the population
 int[] sortedPop
          Sorted population -- since I *have* to use an int-sized individual (short gives me only 16K), I might as well just have pointers to the population itself.
 
Fields inherited from class ec.SelectionMethod
INDS_PRODUCED
 
Fields inherited from class ec.BreedingSource
CHECKBOUNDARY, DEFAULT_PRODUCED, NO_PROBABILITY, P_PROB, probability, UNUSED
 
Constructor Summary
BestSelection()
           
 
Method Summary
 Parameter defaultBase()
          Returns the default base for this prototype.
 void finishProducing(EvolutionState s, int subpopulation, int thread)
          A default version of finishProducing, which does nothing.
 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
preparePipeline, produce, produces, typicalIndsProduced
 
Methods inherited from class ec.BreedingSource
clone, getProbability, pickRandom, setProbability, setupProbabilities
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

P_BEST

public static final java.lang.String P_BEST
Default base

See Also:
Constant Field Values

P_N

public static final java.lang.String P_N
See Also:
Constant Field Values

P_PICKWORST

public static final java.lang.String P_PICKWORST
See Also:
Constant Field Values

sortedFit

public float[] sortedFit
Sorted, normalized, totalized fitnesses for the population


sortedPop

public int[] sortedPop
Sorted population -- since I *have* to use an int-sized individual (short gives me only 16K), I might as well just have pointers to the population itself. :-(


pickWorst

public boolean pickWorst
Do we pick the worst instead of the best?


bestn

public int bestn
Constructor Detail

BestSelection

public BestSelection()
Method Detail

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

finishProducing

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

Overrides:
finishProducing in class SelectionMethod