public class GEProblem extends Problem implements SimpleProblemForm, GroupedProblemForm
The procedure is as follows. Let's say your GPProblem is the Artificial Ant problem. Instead of saying...
eval.problem = ec.app.ant.Ant
eval.problem = ec.app.ant.Ant
eval.problem.data = ec.app.ant.AntData
eval.problem.moves = 400
eval.problem.file = santafe.trl
... you instead make your problem a GEProblem like this:
eval.problem = ec.gp.ge.GEProblem
... and then you hang the Ant problem, and all its subsidiary data, as the 'problem' parameter from the GEProblem like so:
eval.problem.problem = ec.app.ant.Ant
eval.problem.problem.data = ec.app.ant.AntData
eval.problem.problem.moves = 400
eval.problem.problem.file = santafe.trl
Everything else should be handled for you. GEProblem is also compatible with the MasterProblem procedure for distributed evaluation, and is also both a SimpleProblemForm and a GroupedProblemForm. We've got you covered.
Parameters
| base.problem classname, inherits from GPProblem |
(The GPProblem which actually performs the evaluation of the mapped GPIndividual) |
| Modifier and Type | Field and Description |
|---|---|
static String |
P_PROBLEM |
GPProblem |
problem |
private static long |
serialVersionUID |
| Constructor and Description |
|---|
GEProblem() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canEvaluate()
Asynchronous Steady-State EC only: Returns true if the problem is ready to evaluate.
|
Object |
clone()
Creates a new individual cloned from a prototype,
and suitable to begin use in its own evolutionary
context.
|
void |
closeContacts(EvolutionState state,
int result)
Called to shut down remote evaluation network contacts when the run is completed.
|
void |
describe(EvolutionState state,
Individual ind,
int subpopulation,
int threadnum,
int log)
Part of SimpleProblemForm.
|
void |
evaluate(EvolutionState state,
Individual[] ind,
boolean[] updateFitness,
boolean countVictoriesOnly,
int[] subpops,
int threadnum)
Default version assumes that every individual is a GEIndividual.
|
void |
evaluate(EvolutionState state,
Individual ind,
int subpopulation,
int threadnum)
Evaluates the individual in ind, if necessary (perhaps
not evaluating them if their evaluated flags are true),
and sets their fitness appropriately.
|
void |
finishEvaluating(EvolutionState state,
int threadnum)
Will be called by the Evaluator after prepareToEvaluate(...) is called
and then a series of individuals are evaluated.
|
void |
initializeContacts(EvolutionState state)
Called to set up remote evaluation network contacts when the run is started.
|
void |
postprocessPopulation(EvolutionState state,
Population pop,
boolean[] assessFitness,
boolean countVictoriesOnly)
Finish processing the population (such as fitness information) after evaluation.
|
void |
prepareToEvaluate(EvolutionState state,
int threadnum)
May be called by the Evaluator prior to a series of individuals to
evaluate, and then ended with a finishEvaluating(...).
|
void |
preprocessPopulation(EvolutionState state,
Population pop,
boolean[] prepareForFitnessAssessment,
boolean countVictoriesOnly)
Set up the population pop (such as fitness information) prior to evaluation.
|
void |
reinitializeContacts(EvolutionState state)
Called to reinitialize remote evaluation network contacts when the run is restarted from checkpoint.
|
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.
|
defaultBase, describeprivate static final long serialVersionUID
public static final String P_PROBLEM
public GPProblem problem
public void setup(EvolutionState state, Parameter base)
PrototypeFor prototypes, setup(...) is typically called once for the prototype instance; cloned instances do not receive the setup(...) call. setup(...) may be called more than once; the only guarantee is that it will get called at least once on an instance or some "parent" object from which it was ultimately cloned.
public Object clone()
PrototypeTypically this should be a full "deep" clone. However, you may share certain elements with other objects rather than clone hem, depending on the situation:
Implementations.
public Object clone()
{
try
{
return super.clone();
}
catch ((CloneNotSupportedException e)
{ throw new InternalError(); } // never happens
}
public Object clone()
{
try
{
MyObject myobj = (MyObject) (super.clone());
// put your deep-cloning code here...
}
catch ((CloneNotSupportedException e)
{ throw new InternalError(); } // never happens
return myobj;
}
public Object clone()
{
MyObject myobj = (MyObject) (super.clone());
// put your deep-cloning code here...
return myobj;
}
public void prepareToEvaluate(EvolutionState state, int threadnum)
ProblemprepareToEvaluate in class Problempublic void finishEvaluating(EvolutionState state, int threadnum)
ProblemfinishEvaluating in class Problempublic void initializeContacts(EvolutionState state)
ProbleminitializeContacts in class Problempublic void reinitializeContacts(EvolutionState state)
ProblemreinitializeContacts in class Problempublic void closeContacts(EvolutionState state, int result)
ProblemcloseContacts in class Problempublic boolean canEvaluate()
ProblemcanEvaluate in class Problempublic void preprocessPopulation(EvolutionState state, Population pop, boolean[] prepareForFitnessAssessment, boolean countVictoriesOnly)
GroupedProblemFormcountVictoriesOnly will be set if Individuals' fitness is to be based on whether they're the winner of a test, instead of based on the specifics of the scores in the tests. This really only happens for Single-Elimination Tournament one-population competitive coevolution.
prepareForFitnessAssessment will indicate which subpopulations will have their fitness values updated this time around, during postprocessPopulation. It may not be the same as updateFitness[] in evaluate(...).
If you are basing fitness on trials, this method should create the initial trials if the prepareForFitnessAssessment[...] is true for that subpopulation.
preprocessPopulation in interface GroupedProblemFormpublic void postprocessPopulation(EvolutionState state, Population pop, boolean[] assessFitness, boolean countVictoriesOnly)
GroupedProblemFormcountVictoriesOnly will be set if Individuals' fitness is to be based on whether they're the winner of a test, instead of based on the specifics of the scores in the tests. This really only happens for Single-Elimination Tournament one-population competitive coevolution. If this is set, probably would leave the Fitnesses as they are here (they've been set and incremented in evaluate(...)), but if it's not set, you may want to set the Fitnesses to the maximum or average or the various trials performed.
assessFitness will indicate which subpopulations should have their final fitness values assessed. You should not clear the trials of individuals for which assessFitness[] is false. Instead allow trials to accumulate and ultimately update the fitnesses later when the flag is set. assessFitness[] may not be the same as updateFitness[] in evaluate(...).
postprocessPopulation in interface GroupedProblemFormpublic void evaluate(EvolutionState state, Individual[] ind, boolean[] updateFitness, boolean countVictoriesOnly, int[] subpops, int threadnum)
evaluate in interface GroupedProblemFormpublic void evaluate(EvolutionState state, Individual ind, int subpopulation, int threadnum)
SimpleProblemFormevaluate in interface SimpleProblemFormpublic void describe(EvolutionState state, Individual ind, int subpopulation, int threadnum, int log)
Problemdescribe in interface SimpleProblemFormdescribe in class ProblemCopyright © 2014 Evolutionary Computation Laboratory at George Mason University. All rights reserved.