public abstract class Problem extends Object implements Prototype
Since Problems are Prototypes, you should expect a new Problem class to be cloned and used, on a per-thread basis, for the evolution of each chunk of individuals in a new population. If you for some reason need global Problem information, you will have to provide it statically, or copy pointers over during the clone() process (there is likely only one Problem prototype, depending on the Evaluator class used).
Note that Problem does not implement a specific evaluation method. Your particular Problem subclass will need to implement a some kind of Problem Form (for example, SimpleProblemForm) appropriate to the kind of evaluation being performed on the Problem. These Problem Forms will provide the evaluation methods necessary.
Problem forms will define some kind of evaluation method. This method may be called in one of two ways by the Evaluator.
Problems should be prepared for both of the above situations. The easiest way to handle it is to simply evaluate each individual as his evaluate(...) method is called, and do nothing during prepareToEvaluate or finishEvaluating. That should be true for the vast majority of Problem types.
Constructor and Description |
---|
Problem() |
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.
|
Parameter |
defaultBase()
Here's a nice default base for you -- you can change it if you like
|
void |
describe(EvolutionState state,
Individual ind,
int subpopulation,
int threadnum,
int log)
Part of SimpleProblemForm.
|
void |
describe(Individual ind,
EvolutionState state,
int subpopulation,
int threadnum,
int log,
int verbosity)
Deprecated.
Use the version without verbosity
|
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 |
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 |
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.
|
public static final String P_PROBLEM
public Parameter defaultBase()
defaultBase
in interface Prototype
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.
public Object clone()
Prototype
Typically 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)
public void finishEvaluating(EvolutionState state, int threadnum)
public void initializeContacts(EvolutionState state)
public void reinitializeContacts(EvolutionState state)
public void closeContacts(EvolutionState state, int result)
public boolean canEvaluate()
public void describe(EvolutionState state, Individual ind, int subpopulation, int threadnum, int log)
public final void describe(Individual ind, EvolutionState state, int subpopulation, int threadnum, int log, int verbosity)
Copyright © 2019. All rights reserved.