Package org.moeaframework.core
Class PeriodicAction
java.lang.Object
org.moeaframework.core.PeriodicAction
- All Implemented Interfaces:
Extensible
,Algorithm
,Stateful
- Direct Known Subclasses:
AdaptiveTimeContinuation
,Checkpoints
Deprecated.
Decorates an algorithm to perform some action periodically throughout the execution of the algorithm. Note that
due to the underlying implementation of the algorithm, the action may be invoked less frequently than requested
or not at all.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Deprecated.Defines the type of frequency. -
Field Summary
Modifier and TypeFieldDescriptionprotected final Algorithm
Deprecated.The underlying algorithm being decorated.protected int
Deprecated.The frequency that thedoAction()
method is invoked.protected final PeriodicAction.FrequencyType
Deprecated.The type of frequency.protected int
Deprecated.The number of invocations of theAlgorithm.step()
method.protected int
Deprecated.The last invocationdoAction()
was invoked, either as iterations or evaluations depending on the frequency type. -
Constructor Summary
ConstructorDescriptionPeriodicAction
(Algorithm algorithm, int frequency, PeriodicAction.FrequencyType frequencyType) Deprecated.Decorates an algorithm to perform a periodic action. -
Method Summary
Modifier and TypeMethodDescriptionabstract void
doAction()
Deprecated.Invoked periodically by this class to perform some function.void
Deprecated.Evaluates the specified solution for the problem being solved by this algorithm.protected Algorithm
Deprecated.Returns the algorithm that is wrapped by this periodic action.Deprecated.Returns the extensions associated with the algorithm.int
Deprecated.Returns the number of times theevaluate
method was invoked.Deprecated.Returns the problem being solved by this algorithm.Deprecated.Returns the current best-known result.void
Deprecated.Performs any initialization that is required by this algorithm.boolean
Deprecated.Returnstrue
if this algorithm has been initialized;false
otherwise.boolean
Deprecated.Returnstrue
if this algorithm has reached its termination condition;false
otherwise.void
loadState
(ObjectInputStream stream) Deprecated.Loads the state of this object from the stream.void
saveState
(ObjectOutputStream stream) Deprecated.Writes the state of this object to the stream.void
step()
Deprecated.Performs one logical step of this algorithm.void
Deprecated.Called when the termination condition is reached and the run is complete.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.moeaframework.core.Algorithm
evaluateAll, evaluateAll, run, run
Methods inherited from interface org.moeaframework.algorithm.extension.Extensible
addExtension, removeExtension
-
Field Details
-
algorithm
Deprecated.The underlying algorithm being decorated. -
frequency
protected int frequencyDeprecated.The frequency that thedoAction()
method is invoked. -
frequencyType
Deprecated.The type of frequency. -
iteration
protected int iterationDeprecated.The number of invocations of theAlgorithm.step()
method. Only used if the frequency type isSTEPS
. -
lastInvocation
protected int lastInvocationDeprecated.The last invocationdoAction()
was invoked, either as iterations or evaluations depending on the frequency type. A value of-1
indicates the run hasn't started yet.
-
-
Constructor Details
-
PeriodicAction
public PeriodicAction(Algorithm algorithm, int frequency, PeriodicAction.FrequencyType frequencyType) Deprecated.Decorates an algorithm to perform a periodic action.- Parameters:
algorithm
- the algorithm being decoratedfrequency
- the frequency thedoAction()
method is invokedfrequencyType
- the type of frequency
-
-
Method Details
-
getAlgorithm
Deprecated.Returns the algorithm that is wrapped by this periodic action.- Returns:
- the inner algorithm
-
getProblem
Deprecated.Description copied from interface:Algorithm
Returns the problem being solved by this algorithm.- Specified by:
getProblem
in interfaceAlgorithm
- Returns:
- the problem being solved by this algorithm
-
getResult
Deprecated.Description copied from interface:Algorithm
Returns the current best-known result. -
isInitialized
public boolean isInitialized()Deprecated.Description copied from interface:Algorithm
Returnstrue
if this algorithm has been initialized;false
otherwise.- Specified by:
isInitialized
in interfaceAlgorithm
- Returns:
true
if this algorithm has been initialized;false
otherwise- See Also:
-
initialize
public void initialize()Deprecated.Description copied from interface:Algorithm
Performs any initialization that is required by this algorithm. This method should only be called once, though the specific implementation may choose to no-op or throwAlgorithmInitializationException
if called multiple times.Implementations should always call
super.initialize()
to ensure the algorithm is initialized correctly.- Specified by:
initialize
in interfaceAlgorithm
-
step
public void step()Deprecated.Description copied from interface:Algorithm
Performs one logical step of this algorithm. The amount of work performed depends on the implementation. One invocation of this method may produce one or many trial solutions.In general, calling this method after
Algorithm.terminate()
is permitted. When this happens,Algorithm.isTerminated()
is reset. We recommend checkingAlgorithm.isTerminated()
after each step to detect when termination conditions are reached. However, if the implementation is unable to continue, this method should throwAlgorithmTerminationException
. -
evaluate
Deprecated.Description copied from interface:Algorithm
Evaluates the specified solution for the problem being solved by this algorithm. -
getNumberOfEvaluations
public int getNumberOfEvaluations()Deprecated.Description copied from interface:Algorithm
Returns the number of times theevaluate
method was invoked. This is the primary measure of runtime for optimization algorithms.- Specified by:
getNumberOfEvaluations
in interfaceAlgorithm
- Returns:
- the number of times the
evaluate
method was invoked
-
isTerminated
public boolean isTerminated()Deprecated.Description copied from interface:Algorithm
Returnstrue
if this algorithm has reached its termination condition;false
otherwise.- Specified by:
isTerminated
in interfaceAlgorithm
- Returns:
true
if this algorithm has reached its termination condition;false
otherwise- See Also:
-
terminate
public void terminate()Deprecated.Description copied from interface:Algorithm
Called when the termination condition is reached and the run is complete. This method is automatically called when usingAlgorithm.run(TerminationCondition)
, but can also be invoked directly if executing the algorithm step-by-step withAlgorithm.step()
.Implementations should always call
super.terminate()
to ensure the algorithm is terminated correctly. -
getExtensions
Deprecated.Description copied from interface:Extensible
Returns the extensions associated with the algorithm.- Specified by:
getExtensions
in interfaceExtensible
- Returns:
- the extensions
-
doAction
public abstract void doAction()Deprecated.Invoked periodically by this class to perform some function. This function should not depend on the frequency that it is invoked, since it is not guaranteed that this method is invoked at any specific frequency and, in some cases, may not be invoked at all. -
saveState
Deprecated.Description copied from interface:Stateful
Writes the state of this object to the stream. The order that objects are written to the stream is important. We recommend first callingsuper.saveState(stream)
followed by writing each field.- Specified by:
saveState
in interfaceStateful
- Parameters:
stream
- the stream- Throws:
IOException
- if an I/O error occurred
-
loadState
Deprecated.Description copied from interface:Stateful
Loads the state of this object from the stream. The order for reading objects from the stream must match the order they are written to the stream inStateful.saveState(ObjectOutputStream)
.- Specified by:
loadState
in interfaceStateful
- Parameters:
stream
- the stream- Throws:
IOException
- if an I/O error occurredClassNotFoundException
- if the stream referenced a class that is not defined
-
PeriodicExtension
instead