Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.epochx.op.selection
Class TournamentSelector<TYPE>

    java.lang.Object
      com.epochx.op.selection.TournamentSelector<TYPE>

All Implemented Interfaces:
  PoolSelector<TYPE>, ProgramSelector<TYPE>

    public class TournamentSelector<TYPE>

extends java.lang.Object
implements ProgramSelector<TYPE>, PoolSelector<TYPE>

Tournament selection provides both program and pool selection. In tournament selection, x programs are randomly selected from the population to enter a 'tournament'. The program with the best fitness in the tournament then becomes the selected program. The tournament size, x, is given as an argument to the constructor.

Constructor Summary
`TournamentSelector(GPModel<TYPE> model, int tournamentSize)` Construct a tournament selector with the specified tournament size.

Method Summary
`java.util.List<CandidateProgram<TYPE>>` | `getPool(java.util.List<CandidateProgram<TYPE>> pop, int poolSize)` Constructs a pool of programs from the population, choosing each one with the program selection element of TournamentSelector.
`CandidateProgram<TYPE>` | `getProgram()` Randomly creates a tournament, then selects the candidate program with the best fitness from that tournament.
`void` | `setSelectionPool(java.util.List<CandidateProgram<TYPE>> pop)` Store the population for creating tournaments from.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### TournamentSelector

    public TournamentSelector(GPModel<TYPE> model,
                              int tournamentSize)

  Construct a tournament selector with the specified tournament size.

  Parameters:
    `tournamentSize` - the number of programs in each tournament.

Method Detail

### setSelectionPool

    public void setSelectionPool(java.util.List<CandidateProgram<TYPE>> pop)

  Store the population for creating tournaments from.

  Specified by:
    `setSelectionPool` in interface `ProgramSelector<TYPE>`
  Parameters:
    `pop` - the current population for this generation.

### getProgram

    public CandidateProgram<TYPE> getProgram()

  Randomly creates a tournament, then selects the candidate program with the best fitness from that tournament. The size of the tournament is given at instantiation.

  Specified by:
    `getProgram` in interface `ProgramSelector<TYPE>`
  Returns:
    the best program from a randomly generated tournament.

### getPool

    public java.util.List<CandidateProgram<TYPE>> getPool(java.util.List<CandidateProgram<TYPE>> pop,
                                                          int poolSize)

  Constructs a pool of programs from the population, choosing each one with the program selection element of TournamentSelector. The size of the pool created will be equal to the poolSize argument. The generated pool may contain duplicate programs, and as such the pool size may be greater than the population size.

  Specified by:
    `getPool` in interface `PoolSelector<TYPE>`
  Parameters:
    `pop` - the population of CandidatePrograms from which the programs in the pool should be chosen.
    `poolSize` - the number of programs that should be selected from the population to form the pool. If poolSize is zero or less then no selection takes place and the given population is returned unaltered.
  Returns:
    the pool of candidate programs selected using tournament selection.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD