|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectec.Problem
ec.eval.MasterProblem
MasterProblem.java
The MasterProblem is an ECJ problem that performs evaluations by pooling an available slave and sending all information necessary for the evaluation to that slave. In some sense, the MasterProblem is the "master" of the master-slave architecture. As it implements both the SimpleProblemForm and the GroupedProblemForm interfaces, the MasterProblem can perform both traditional EC evaluations, as well as coevolutionary evaluations.
Parameters
base.debug-info boolean |
(whether the system should display information useful for debugging purposes) |
Field Summary | |
boolean |
batchMode
|
static java.lang.String |
P_DEBUG_INFO
|
Problem |
problem
|
MasterProblemServer |
server
|
java.lang.Thread |
serverThread
|
Fields inherited from class ec.Problem |
P_PROBLEM |
Constructor Summary | |
MasterProblem()
|
Method Summary | |
void |
closeContacts(EvolutionState state,
int result)
Gracefully close contacts with the slaves |
void |
describe(Individual ind,
EvolutionState state,
int threadnum,
int log,
int verbosity)
"Reevaluates" an individual, for the purpose of printing out interesting facts about the individual in the context of the Problem, and logs the results. |
void |
evaluate(EvolutionState state,
Individual[] inds,
boolean[] updateFitness,
boolean countVictoriesOnly,
int threadnum)
Evaluates the individuals found in ind together. |
void |
evaluate(EvolutionState state,
Individual ind,
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)
Initialize contacts with the slaves |
void |
postprocessPopulation(EvolutionState state,
Population pop)
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)
Set up the population pop (such as fitness information) prior to evaluation. |
java.lang.Object |
protoClone()
Creates a new individual cloned from a prototype, and suitable to begin use in its own evolutionary context. |
void |
reinitializeContacts(EvolutionState state)
Reinitialize contacts with the slaves |
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.Problem |
defaultBase, protoCloneSimple |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String P_DEBUG_INFO
public Problem problem
public MasterProblemServer server
public java.lang.Thread serverThread
public boolean batchMode
Constructor Detail |
public MasterProblem()
Method Detail |
public java.lang.Object protoClone() throws java.lang.CloneNotSupportedException
Prototype
The question here is whether or not this means to perform a "deep" or "light" ("shallow") clone, or something in-between. You may need to deep-clone parts of your object rather than simply copying their references, depending on the situation:
Implementations.
public Object protoClone() throws CloneNotSupportedException
{
return super.clone();
}
public Object protoClone() throws CloneNotSupportedException
{
myobj = (MyObject) (super.clone());
// put your deep-cloning code here...
// ...you should use protoClone and not
// protoCloneSimple to clone subordinate objects...
return myobj;
}
public Object protoClone() throws CloneNotSupportedException
{
MyObject myobj = (MyObject)(super.protoClone());
// put your deep-cloning code here...
// ...you should use protoClone and not
// protoCloneSimple to clone subordinate objects...
return myobj;
}
If you know that your superclasses will never change their protoClone() implementations, you might try inlining them in your overridden protoClone() method. But this is dangerous (though it yields a small net increase).
In general, you want to keep your deep cloning to an absolute minimum, so that you don't have to call protoClone() but one time.
The approach taken here is the fastest that I am aware of while still permitting objects to be specified at runtime from a parameter file. It would be faster to use the "new" operator; but that would require hard-coding that we can't do. Although using java.lang.Object.clone() entails an extra layer that deals with stripping away the "protected" keyword and also wrapping the exception handling (which is a BIG hit, about three times as slow as using "new"), it's still MUCH faster than using java.lang.Class.newInstance(), and also much faster than rolling our own Clone() method.
protoClone
in interface Prototype
protoClone
in class Problem
java.lang.CloneNotSupportedException
public void setup(EvolutionState state, Parameter base)
Prototype
For 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.
setup
in interface Prototype
setup
in class Problem
public void prepareToEvaluate(EvolutionState state, int threadnum)
Problem
prepareToEvaluate
in class Problem
public void finishEvaluating(EvolutionState state, int threadnum)
Problem
finishEvaluating
in class Problem
public void evaluate(EvolutionState state, Individual ind, int threadnum)
SimpleProblemForm
evaluate
in interface SimpleProblemForm
public void describe(Individual ind, EvolutionState state, int threadnum, int log, int verbosity)
SimpleProblemForm
describe
in interface SimpleProblemForm
public void preprocessPopulation(EvolutionState state, Population pop)
GroupedProblemForm
preprocessPopulation
in interface GroupedProblemForm
public void postprocessPopulation(EvolutionState state, Population pop)
GroupedProblemForm
postprocessPopulation
in interface GroupedProblemForm
public void evaluate(EvolutionState state, Individual[] inds, boolean[] updateFitness, boolean countVictoriesOnly, int threadnum)
GroupedProblemForm
If countVictoriesOnly is true, you should update fitnesses such that if two individuals' fitnesses are compared, the one which has won the most times has a superior fitness. This will be used in single elimination tournament style evaluators.
evaluate
in interface GroupedProblemForm
public void initializeContacts(EvolutionState state)
initializeContacts
in class Problem
public void reinitializeContacts(EvolutionState state)
reinitializeContacts
in class Problem
public void closeContacts(EvolutionState state, int result)
closeContacts
in class Problem
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |