org.encog.ml.ea.opp.selection
Class TournamentSelection

java.lang.Object
  extended by org.encog.ml.ea.opp.selection.TournamentSelection
All Implemented Interfaces:
Serializable, SelectionOperator

public class TournamentSelection
extends Object
implements SelectionOperator, Serializable

Tournament select can be used to select a fit (or unfit) genome from a species. The selection is run a set number of rounds. Each round two random participants are chosen. The more fit participant continues to the next round. http://en.wikipedia.org/wiki/Tournament_selection

See Also:
Serialized Form

Constructor Summary
TournamentSelection(EvolutionaryAlgorithm theTrainer, int theRounds)
          Construct a tournament selection.
 
Method Summary
 int getRounds()
           
 EvolutionaryAlgorithm getTrainer()
          
 int performAntiSelection(Random rnd, Species species)
          Selects an unfit genome.
 int performSelection(Random rnd, Species species)
          Selects an fit genome.
 void setRounds(int rounds)
          Set the number of rounds.
 void setTrainer(EvolutionaryAlgorithm trainer)
          Set the trainer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TournamentSelection

public TournamentSelection(EvolutionaryAlgorithm theTrainer,
                           int theRounds)
Construct a tournament selection.

Parameters:
theTrainer - The trainer.
theRounds - The number of rounds to use.
Method Detail

getRounds

public int getRounds()
Returns:
The number of rounds.

getTrainer

public EvolutionaryAlgorithm getTrainer()

Specified by:
getTrainer in interface SelectionOperator
Returns:
The trainer being used.

performAntiSelection

public int performAntiSelection(Random rnd,
                                Species species)
Selects an unfit genome.

Specified by:
performAntiSelection in interface SelectionOperator
Parameters:
rnd - A random number generator.
species - The species to select the genome from.
Returns:
The selected genome.

performSelection

public int performSelection(Random rnd,
                            Species species)
Selects an fit genome.

Specified by:
performSelection in interface SelectionOperator
Parameters:
rnd - A random number generator.
species - The species to select the genome from.
Returns:
The selected genome.

setRounds

public void setRounds(int rounds)
Set the number of rounds.

Parameters:
rounds - The number of rounds.

setTrainer

public void setTrainer(EvolutionaryAlgorithm trainer)
Set the trainer.

Parameters:
trainer - The trainer.


Copyright © 2014. All Rights Reserved.