ec.coevolve
Class CompetitiveEvaluator

java.lang.Object
  extended by ec.Evaluator
      extended by ec.coevolve.CompetitiveEvaluator
All Implemented Interfaces:
Setup, Singleton, java.io.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).
Pseudo Round Robin
The population is split into groups with group-size individuals, and there is a round robin tournament for each such group.
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-Ways
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)
pseudo-round-robin (population is split into groups with group-size individuals, and there is a round robin tournament for each such group)
rand-1-way (K-Random-Opponents, each game counts for only one of the players)
rand-2-ways (K-Random-Opponents, each game counts for both players)
base.group-size
int
(how many individuals per group, used in pseudo-round-robin, rand-1-way and rand-2-ways tournaments)
group-size >= 2 for pseudo-round-robin
group-size >= 1 for rand-1-way or rand-2-ways
base.over-eval
bool = true or false (default)
(if the tournament style leads to an individual playing more games than others, should the extra games be used for his fitness evaluatiuon?)

Version:
1.0
Author:
Sean Luke & Liviu Panait
See Also:
Serialized Form

Field Summary
 boolean allowOverEvaluation
           
static java.lang.String competeStyle
           
 int groupSize
           
static java.lang.String overEval
           
static java.lang.String size
           
 int style
           
static int STYLE_N_RANDOM_COMPETITORS_ONEWAY
           
static int STYLE_N_RANDOM_COMPETITORS_TWOWAY
           
static int STYLE_PSEUDO_ROUND_ROBIN
           
static int STYLE_ROUND_ROBIN
           
static int STYLE_SINGLE_ELIMINATION
           
 
Fields inherited from class ec.Evaluator
P_IAMSLAVE, P_MASTERPROBLEM, p_problem, P_PROBLEM
 
Constructor Summary
CompetitiveEvaluator()
           
 
Method Summary
 void evalNRandomOneWay(EvolutionState state, int[] from, int[] numinds, Individual[] individuals, GroupedProblemForm prob)
           
 void evalNRandomOneWayPopChunk(EvolutionState state, int from, int numinds, int threadnum, Individual[] individuals, GroupedProblemForm prob)
           
 void evalNRandomTwoWay(EvolutionState state, int[] from, int[] numinds, Individual[] individuals, GroupedProblemForm prob)
           
 void evalNRandomTwoWayPopChunk(EvolutionState state, int from, int numinds, int threadnum, Individual[] individuals, GroupedProblemForm prob)
           
 void evalPseudoRoundRobin(EvolutionState state, Individual[] individuals, GroupedProblemForm prob)
           
 void evalPseudoRoundRobinPopChunk(EvolutionState state, int from, int numinds, int threadnum, Individual[] individuals, GroupedProblemForm prob)
           
 void evalRoundRobin(EvolutionState state, int[] from, int[] numinds, Individual[] individuals, GroupedProblemForm prob)
           
 void evalRoundRobinPopChunk(EvolutionState state, int from, int numinds, int threadnum, Individual[] individuals, GroupedProblemForm prob)
          A private helper function for evalutatePopulation which evaluates a chunk of individuals in a subpopulation for a given thread.
 void evalSingleElimination(EvolutionState state, Individual[] individuals, GroupedProblemForm prob)
           
 void evaluatePopulation(EvolutionState state)
          An evaluator that performs coevolutionary evaluation.
 void randomizeOrder(EvolutionState state, Individual[] individuals)
           
 boolean runComplete(EvolutionState state)
          Returns true if an ideal individual has been found or some other run result has shortcircuited the run so that it should end prematurely right now.
 void setup(EvolutionState state, Parameter base)
          Sets up the object by reading it from the parameters stored in state, built off of the parameter base base.
 
Methods inherited from class ec.Evaluator
closeContacts, initializeContacts, reinitializeContacts
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STYLE_SINGLE_ELIMINATION

public static final int STYLE_SINGLE_ELIMINATION
See Also:
Constant Field Values

STYLE_ROUND_ROBIN

public static final int STYLE_ROUND_ROBIN
See Also:
Constant Field Values

STYLE_N_RANDOM_COMPETITORS_ONEWAY

public static final int STYLE_N_RANDOM_COMPETITORS_ONEWAY
See Also:
Constant Field Values

STYLE_N_RANDOM_COMPETITORS_TWOWAY

public static final int STYLE_N_RANDOM_COMPETITORS_TWOWAY
See Also:
Constant Field Values

STYLE_PSEUDO_ROUND_ROBIN

public static final int STYLE_PSEUDO_ROUND_ROBIN
See Also:
Constant Field Values

competeStyle

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

style

public int style

size

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

groupSize

public int groupSize

overEval

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

allowOverEvaluation

public boolean allowOverEvaluation
Constructor Detail

CompetitiveEvaluator

public CompetitiveEvaluator()
Method Detail

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 boolean runComplete(EvolutionState state)
Description copied from class: Evaluator
Returns true if an ideal individual has been found or some other run result has shortcircuited the run so that it should end prematurely right now.

Specified by:
runComplete in class Evaluator

randomizeOrder

public void randomizeOrder(EvolutionState state,
                           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,
                                  Individual[] individuals,
                                  GroupedProblemForm prob)

evalRoundRobin

public void evalRoundRobin(EvolutionState state,
                           int[] from,
                           int[] numinds,
                           Individual[] individuals,
                           GroupedProblemForm prob)

evalRoundRobinPopChunk

public void evalRoundRobinPopChunk(EvolutionState state,
                                   int from,
                                   int numinds,
                                   int threadnum,
                                   Individual[] individuals,
                                   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 -
numinds -
from -
threadnum -
prob -

evalPseudoRoundRobin

public void evalPseudoRoundRobin(EvolutionState state,
                                 Individual[] individuals,
                                 GroupedProblemForm prob)

evalPseudoRoundRobinPopChunk

public void evalPseudoRoundRobinPopChunk(EvolutionState state,
                                         int from,
                                         int numinds,
                                         int threadnum,
                                         Individual[] individuals,
                                         GroupedProblemForm prob)

evalNRandomOneWay

public void evalNRandomOneWay(EvolutionState state,
                              int[] from,
                              int[] numinds,
                              Individual[] individuals,
                              GroupedProblemForm prob)

evalNRandomOneWayPopChunk

public void evalNRandomOneWayPopChunk(EvolutionState state,
                                      int from,
                                      int numinds,
                                      int threadnum,
                                      Individual[] individuals,
                                      GroupedProblemForm prob)

evalNRandomTwoWay

public void evalNRandomTwoWay(EvolutionState state,
                              int[] from,
                              int[] numinds,
                              Individual[] individuals,
                              GroupedProblemForm prob)

evalNRandomTwoWayPopChunk

public void evalNRandomTwoWayPopChunk(EvolutionState state,
                                      int from,
                                      int numinds,
                                      int threadnum,
                                      Individual[] individuals,
                                      GroupedProblemForm prob)