Class CompetitiveEvaluator
- All Implemented Interfaces:
Setup,Singleton,Serializable
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 Summary
FieldsModifier and TypeFieldDescriptionbooleanintstatic final Stringstatic final Stringstatic final Stringintstatic final intstatic final intstatic final intstatic final intFields inherited from class ec.Evaluator
masterproblem, P_IAMSLAVE, P_MASTERPROBLEM, p_problem, P_PROBLEM, runComplete -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidevalNRandomOneWay(EvolutionState state, int[] from, int[] numinds, ArrayList<Individual> individuals, int subpop, GroupedProblemForm prob) voidevalNRandomOneWayPopChunk(EvolutionState state, int from, int numinds, int threadnum, ArrayList<Individual> individuals, int subpop, GroupedProblemForm prob) voidevalNRandomTwoWay(EvolutionState state, int[] from, int[] numinds, ArrayList<Individual> individuals, int subpop, GroupedProblemForm prob) voidevalNRandomTwoWayPopChunk(EvolutionState state, int from, int numinds, int threadnum, ArrayList<Individual> individuals, int subpop, GroupedProblemForm prob) voidevalRoundRobin(EvolutionState state, int[] from, int[] numinds, ArrayList<Individual> individuals, int subpop, GroupedProblemForm prob) voidevalRoundRobinPopChunk(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.voidevalSingleElimination(EvolutionState state, ArrayList<Individual> individuals, int subpop, GroupedProblemForm prob) voidevaluatePopulation(EvolutionState state) An evaluator that performs coevolutionary evaluation.voidrandomizeOrder(EvolutionState state, ArrayList<Individual> individuals) runComplete(EvolutionState state) 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.voidsetup(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, postEvaluationGlobalUpdate, postEvaluationLocalUpdate, reinitializeContacts, setRunComplete
-
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
- See Also:
-
style
public int style -
P_GROUP_SIZE
- See Also:
-
groupSize
public int groupSize -
P_OVER_EVAL
- See Also:
-
allowOverEvaluation
public boolean allowOverEvaluation
-
-
Constructor Details
-
CompetitiveEvaluator
public CompetitiveEvaluator()
-
-
Method Details
-
setup
Description copied from interface:SetupSets 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. -
runComplete
Description copied from class:EvaluatorReturns 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:
runCompletein classEvaluator
-
randomizeOrder
-
evaluatePopulation
An evaluator that performs coevolutionary evaluation. Like SimpleEvaluator, it applies evolution pipelines, one per thread, to various subchunks of a new population.- Specified by:
evaluatePopulationin classEvaluator
-
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)
-