Package ec.coevolve

Class CompetitiveEvaluator

java.lang.Object
ec.Evaluator
ec.coevolve.CompetitiveEvaluator
All Implemented Interfaces:
Setup, Singleton, Serializable

public class CompetitiveEvaluator extends Evaluator
CompetitiveEvaluator.java

CompetitiveEvaluator is a Evaluator which performs competitive fitness evaluations. Competitive fitness is where individuals' fitness is determined by testing them against other members of the same subpopulation. Competitive fitness topologies differ from co-evolution topologies in that co-evolution is a term I generally reserve for multiple sbupopulations which breed separately but compete against other subpopulations during evaluation time. Individuals are evaluated regardless of whether or not they've been evaluated in the past.

Your Problem is responsible for setting up the fitness appropriately. CompetitiveEvaluator expects to use Problems which adhere to the GroupedProblemForm interface, which defines a new evaluate(...) function, plus a preprocess(...) and postprocess(...) function.

This competitive fitness evaluator is single-threaded -- maybe we'll hack in multithreading later. And it only has two individuals competing during any fitness evaluation. The order of individuals in the subpopulation will be changed during the evaluation process. There are seven evaluation topologies presently supported:

Single Elimination Tournament
All members of the population are paired up and evaluated. In each pair, the "winner" is the individual which winds up with the superior fitness. If neither fitness is superior, then the "winner" is picked at random. Then all the winners are paired up and evaluated, and so on, just like in a single elimination tournament. It is important that the population size be a power of two, else some individuals will not have the same number of "wins" as others and may lose the tournament as a result.
Round Robin
Every member of the population are paired up and evaluated with all other members of the population, not not including the member itself (we might add in self-play as a future later if people ask for it, it's easy to hack in).
K-Random-Opponents-One-Way
Each individual's fitness is calculated based on K competitions against random opponents. For details, see "A Comparison of Two Competitive Fitness Functions" by Liviu Panait and Sean Luke in the Proceedings of GECCO 2002.
K-Random-Opponents-Two-Way
Each individual's fitness is calculated based on K competitions against random opponents. The advantage of this method over K-Random-Opponents-One-Way is a reduced number of competitions (when I competes against J, both I's and J's fitnesses are updated, while in the previous method only one of the individuals has its fitness updated). For details, see "A Comparison of Two Competitive Fitness Functions" by Liviu Panait and Sean Luke in the Proceedings of GECCO 2002.

Parameters

base.style
string with possible values:
(the style of the tournament)
single-elim-tournament (a single elimination tournament)
round-robin (a round robin tournament)
rand-1-way (K-Random-Opponents, each game counts for only one of the players)
rand-2-way (K-Random-Opponents, each game counts for both players)
base.group-size
int
(how many individuals per group, used in rand-1-way and rand-2-way tournaments)
group-size >= 1 for rand-1-way or rand-2-way
base.over-eval
bool = true or false (default)
(if the tournament style leads to an individual playing more games than others (as can be the case for rand-2-way), should the extra games be used for his fitness evaluatiuon?)
See Also:
  • Field Details

    • STYLE_SINGLE_ELIMINATION

      public static final int STYLE_SINGLE_ELIMINATION
      See Also:
    • STYLE_ROUND_ROBIN

      public static final int STYLE_ROUND_ROBIN
      See Also:
    • STYLE_N_RANDOM_COMPETITORS_ONEWAY

      public static final int STYLE_N_RANDOM_COMPETITORS_ONEWAY
      See Also:
    • STYLE_N_RANDOM_COMPETITORS_TWOWAY

      public static final int STYLE_N_RANDOM_COMPETITORS_TWOWAY
      See Also:
    • P_COMPETE_STYLE

      public static final String P_COMPETE_STYLE
      See Also:
    • style

      public int style
    • P_GROUP_SIZE

      public static final String P_GROUP_SIZE
      See Also:
    • groupSize

      public int groupSize
    • P_OVER_EVAL

      public static final String P_OVER_EVAL
      See Also:
    • allowOverEvaluation

      public boolean allowOverEvaluation
  • Constructor Details

    • CompetitiveEvaluator

      public CompetitiveEvaluator()
  • Method Details

    • setup

      public void setup(EvolutionState state, Parameter base)
      Description copied from interface: Setup
      Sets up the object by reading it from the parameters stored in state, built off of the parameter base base. If an ancestor implements this method, be sure to call super.setup(state,base); before you do anything else.
      Specified by:
      setup in interface Setup
      Overrides:
      setup in class Evaluator
    • runComplete

      public String runComplete(EvolutionState state)
      Description copied from class: Evaluator
      Returns non-NULL if the Evaluator believes that the run is finished: perhaps an ideal individual has been found or some other run result has shortcircuited the run so that it should end prematurely right now. Typically a message is stored in the String for the user to know why the system shut down.
      Specified by:
      runComplete in class Evaluator
    • randomizeOrder

      public void randomizeOrder(EvolutionState state, ArrayList<Individual> individuals)
    • evaluatePopulation

      public void evaluatePopulation(EvolutionState state)
      An evaluator that performs coevolutionary evaluation. Like SimpleEvaluator, it applies evolution pipelines, one per thread, to various subchunks of a new population.
      Specified by:
      evaluatePopulation in class Evaluator
    • evalSingleElimination

      public void evalSingleElimination(EvolutionState state, ArrayList<Individual> individuals, int subpop, GroupedProblemForm prob)
    • evalRoundRobin

      public void evalRoundRobin(EvolutionState state, int[] from, int[] numinds, ArrayList<Individual> individuals, int subpop, GroupedProblemForm prob)
    • evalRoundRobinPopChunk

      public void evalRoundRobinPopChunk(EvolutionState state, int from, int numinds, int threadnum, ArrayList<Individual> individuals, int subpop, GroupedProblemForm prob)
      A private helper function for evalutatePopulation which evaluates a chunk of individuals in a subpopulation for a given thread. Although this method is declared public (for the benefit of a private helper class in this file), you should not call it.
      Parameters:
      state -
      from -
      numinds -
      threadnum -
      prob -
    • evalNRandomOneWay

      public void evalNRandomOneWay(EvolutionState state, int[] from, int[] numinds, ArrayList<Individual> individuals, int subpop, GroupedProblemForm prob)
    • evalNRandomOneWayPopChunk

      public void evalNRandomOneWayPopChunk(EvolutionState state, int from, int numinds, int threadnum, ArrayList<Individual> individuals, int subpop, GroupedProblemForm prob)
    • evalNRandomTwoWay

      public void evalNRandomTwoWay(EvolutionState state, int[] from, int[] numinds, ArrayList<Individual> individuals, int subpop, GroupedProblemForm prob)
    • evalNRandomTwoWayPopChunk

      public void evalNRandomTwoWayPopChunk(EvolutionState state, int from, int numinds, int threadnum, ArrayList<Individual> individuals, int subpop, GroupedProblemForm prob)