|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectec.Problem
ec.eval.MasterProblem
public class 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
|
protected static org.apache.commons.logging.Log |
log
|
static java.lang.String |
P_DEBUG_INFO
|
static java.lang.String |
P_JOB_SIZE
|
Problem |
problem
|
IMasterProblemServer |
server
|
java.lang.Thread |
serverThread
|
| Fields inherited from class ec.Problem |
|---|
P_PROBLEM |
| Constructor Summary | |
|---|---|
MasterProblem()
|
|
| Method Summary | |
|---|---|
boolean |
canEvaluate()
Asynchronous Steady-State EC only: Returns true if the problem is ready to evaluate. |
java.lang.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)
Gracefully close contacts with the slaves |
void |
describe(Individual ind,
EvolutionState state,
int threadnum,
int log,
int verbosity)
|
void |
describe(Individual ind,
EvolutionState state,
int subpopulation,
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. |
protected void |
doReadObject(java.io.ObjectInputStream in)
Custom serialization |
protected void |
doWriteObject(java.io.ObjectOutputStream out)
Custom serialization |
void |
evaluate(EvolutionState state,
Individual[] ind,
boolean[] updateFitness,
boolean countVictoriesOnly,
int threadnum)
|
void |
evaluate(EvolutionState state,
Individual[] inds,
boolean[] updateFitness,
boolean countVictoriesOnly,
int[] subpops,
int threadnum)
Evaluates the individuals found in ind together. |
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. |
boolean |
evaluatedIndividualAvailable()
This will only return true if (1) the EvolutionState is a SteadyStateEvolutionState and (2) an individual has returned from the system. |
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 |
flush(EvolutionState state,
int threadnum)
|
int |
getJobSize()
|
Individual |
getNextEvaluatedIndividual(EvolutionState state)
This method blocks until an individual is available from the slaves (which will cause evaluatedIndividualAvailable() to return true), at which time it returns the individual. |
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. |
void |
reinitializeContacts(EvolutionState state)
Reinitialize contacts with the slaves |
void |
setJobSize(int newJobSize)
Sets number of individuals sent to each slave task. |
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, evaluate, getBase, setBase |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface ec.simple.SimpleProblemForm |
|---|
evaluate |
| Field Detail |
|---|
public static final java.lang.String P_DEBUG_INFO
public static final java.lang.String P_JOB_SIZE
protected static final org.apache.commons.logging.Log log
public Problem problem
public IMasterProblemServer server
public java.lang.Thread serverThread
public boolean batchMode
| Constructor Detail |
|---|
public MasterProblem()
| Method Detail |
|---|
public void setJobSize(int newJobSize)
newJobSize - public int getJobSize()
public java.lang.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;
}
clone in interface Prototypeclone in class 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.
setup in interface Prototypesetup in interface Setupsetup 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 subpopulation,
int threadnum)
SimpleProblemForm
evaluate in interface SimpleProblemFormevaluate in class Problem
public void flush(EvolutionState state,
int threadnum)
public void describe(Individual ind,
EvolutionState state,
int threadnum,
int log,
int verbosity)
describe in interface SimpleProblemFormdescribe in class Problem
public void evaluate(EvolutionState state,
Individual[] ind,
boolean[] updateFitness,
boolean countVictoriesOnly,
int threadnum)
evaluate in interface GroupedProblemForm
public void describe(Individual ind,
EvolutionState state,
int subpopulation,
int threadnum,
int log,
int verbosity)
SimpleProblemForm
describe in interface SimpleProblemFormdescribe in class Problem
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[] subpops,
int threadnum)
GroupedProblemFormIf 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
protected void doWriteObject(java.io.ObjectOutputStream out)
throws java.io.IOException
java.io.IOException
protected void doReadObject(java.io.ObjectInputStream in)
throws java.io.IOException,
java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundExceptionpublic void initializeContacts(EvolutionState state)
initializeContacts in class Problempublic void reinitializeContacts(EvolutionState state)
reinitializeContacts in class Problem
public void closeContacts(EvolutionState state,
int result)
closeContacts in class Problempublic boolean canEvaluate()
Problem
canEvaluate in interface SimpleProblemFormcanEvaluate in class Problempublic boolean evaluatedIndividualAvailable()
public Individual getNextEvaluatedIndividual(EvolutionState state)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||