public abstract class PeriodicAction extends java.lang.Object implements Algorithm
Modifier and Type | Class and Description |
---|---|
static class |
PeriodicAction.FrequencyType
Defines the type of frequency.
|
Modifier and Type | Field and Description |
---|---|
protected Algorithm |
algorithm
The underlying algorithm being decorated.
|
protected int |
frequency
The frequency that the
doAction() method is invoked. |
protected PeriodicAction.FrequencyType |
frequencyType
The type of frequency.
|
protected int |
iteration
The number of invocations of the
Algorithm.step() method. |
protected int |
lastInvocation
The last invocation
doAction() was invoked, either as iterations or
evaluations depending on the frequency type. |
Constructor and Description |
---|
PeriodicAction(Algorithm algorithm,
int frequency,
PeriodicAction.FrequencyType frequencyType)
Decorates an algorithm to perform a period action.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
doAction()
Invoked periodically by this class to perform some function.
|
void |
evaluate(Solution solution)
Evaluates the specified solution for the problem being solved by this
algorithm.
|
int |
getNumberOfEvaluations()
Returns the number of times the
evaluate method was invoked. |
Problem |
getProblem()
Returns the problem being solved by this algorithm.
|
NondominatedPopulation |
getResult()
Returns the current best-known result.
|
boolean |
isTerminated()
Returns
true if this algorithm is terminated; false
otherwise. |
void |
loadState(java.io.ObjectInputStream stream)
Loads the state of this object from the stream.
|
void |
saveState(java.io.ObjectOutputStream stream)
Writes the state of this object to the stream.
|
void |
step()
Performs one logical step of this algorithm.
|
void |
terminate()
Terminates this algorithm.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
checkTypeSafety, getState, setState, writeTypeSafety
protected final Algorithm algorithm
protected int frequency
doAction()
method is invoked.protected final PeriodicAction.FrequencyType frequencyType
protected int iteration
Algorithm.step()
method. Only
used if the frequency type is STEPS
.protected int lastInvocation
doAction()
was invoked, either as iterations or
evaluations depending on the frequency type. A value of -1
indicates
the run hasn't started yet.public PeriodicAction(Algorithm algorithm, int frequency, PeriodicAction.FrequencyType frequencyType)
algorithm
- the algorithm being decoratedfrequency
- the frequency the doAction()
method is invokedfrequencyType
- the type of frequencypublic Problem getProblem()
Algorithm
getProblem
in interface Algorithm
public NondominatedPopulation getResult()
Algorithm
public void step()
Algorithm
This method should not be invoked when Algorithm.isTerminated()
returns
true
.
public void evaluate(Solution solution)
Algorithm
evaluate
in interface Algorithm
solution
- the solution to be evaluatedProblem.evaluate(Solution)
public int getNumberOfEvaluations()
Algorithm
evaluate
method was invoked. This
is the primary measure of runtime for optimization algorithms.getNumberOfEvaluations
in interface Algorithm
evaluate
method was invokedpublic boolean isTerminated()
Algorithm
true
if this algorithm is terminated; false
otherwise.isTerminated
in interface Algorithm
true
if this algorithm is terminated; false
otherwiseAlgorithm.terminate()
public void terminate()
Algorithm
Algorithm.getResult()
and
Algorithm.getNumberOfEvaluations()
methods are still required to work
after termination.public abstract void doAction()
public void saveState(java.io.ObjectOutputStream stream) throws java.io.IOException
Stateful
super.saveState(stream)
followed by writing each
field.public void loadState(java.io.ObjectInputStream stream) throws java.io.IOException, java.lang.ClassNotFoundException
Stateful
Stateful.saveState(ObjectOutputStream)
.Copyright 2009-2024 David Hadka and other contributors. All rights reserved.
Licensed under the GNU Lesser General Public License.
Return to the MOEA Framework homepage.