ResultType
- Result type of the algorithm.InternalAlgorithm
- Internal algorithm to wrap.public abstract class AnytimeAlgorithmWrapper<ResultType,InternalAlgorithm extends AnytimeAlgorithm<?>> extends AbstractIterativeAlgorithm implements AnytimeAlgorithm<ResultType>, IterativeAlgorithmListener
DEFAULT_ITERATION, iteration
Constructor and Description |
---|
AnytimeAlgorithmWrapper()
Creates a new instance of AnytimeAlgorithmWrapper
|
AnytimeAlgorithmWrapper(InternalAlgorithm algorithm)
Creates a new instance of AnytimeAlgorithmWrapper
|
Modifier and Type | Method and Description |
---|---|
void |
algorithmEnded(IterativeAlgorithm algorithm)
This method is called when the algorithm has ended, after the last step
of the algorithm.
|
void |
algorithmStarted(IterativeAlgorithm algorithm)
This method is called when a algorithm has started, before the first
step of the algorithm.
|
AnytimeAlgorithmWrapper<ResultType,InternalAlgorithm> |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
InternalAlgorithm |
getAlgorithm()
Gets the underlying wrapped algorithm.
|
int |
getIteration()
Gets the current number of iterations executed by this algorithm since
its it was started.
|
int |
getMaxIterations()
Gets the maximum number of total iterations before stopping.
|
boolean |
isResultValid()
Indicates whether or not the algorithm results are in a consistent state
or not.
|
protected java.lang.Object |
readResolve()
This method is detected by the Java Serialization code and is called on
deserialization.
|
void |
setAlgorithm(InternalAlgorithm algorithm)
Sets the underlying algorithm.
|
void |
setMaxIterations(int maxIterations)
Sets the maximum number of total iterations before stopping.
|
void |
stepEnded(IterativeAlgorithm algorithm)
This method is called when the algorithm has ended a step of its
execution.
|
void |
stepStarted(IterativeAlgorithm algorithm)
This method is called when the algorithm has started a step in its
execution.
|
void |
stop()
Requests that the algorithm stop at the next appropriate point.
|
addIterativeAlgorithmListener, fireAlgorithmEnded, fireAlgorithmStarted, fireStepEnded, fireStepStarted, getListeners, removeIterativeAlgorithmListener, setIteration, setListeners
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getResult
addIterativeAlgorithmListener, removeIterativeAlgorithmListener
public AnytimeAlgorithmWrapper()
public AnytimeAlgorithmWrapper(InternalAlgorithm algorithm)
algorithm
- Underlying algorithm to wrap.public AnytimeAlgorithmWrapper<ResultType,InternalAlgorithm> clone()
AbstractCloneableSerializable
Object
class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone()
to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil
may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone()
as the basis for your implementation.clone
in interface CloneableSerializable
clone
in class AbstractIterativeAlgorithm
public int getMaxIterations()
AnytimeAlgorithm
getMaxIterations
in interface AnytimeAlgorithm<ResultType>
public void setMaxIterations(int maxIterations)
AnytimeAlgorithm
setMaxIterations
in interface AnytimeAlgorithm<ResultType>
maxIterations
- Maximum number of iterations before stopping. Must be greater
than zero.public InternalAlgorithm getAlgorithm()
public void setAlgorithm(InternalAlgorithm algorithm)
algorithm
- The underlying algorithm to wrap.public void stop()
StoppableAlgorithm
stop
in interface StoppableAlgorithm
public int getIteration()
IterativeAlgorithm
getIteration
in interface IterativeAlgorithm
getIteration
in class AbstractIterativeAlgorithm
public boolean isResultValid()
StoppableAlgorithm
StoppableAlgorithm
may not always be able to stop in a
manner that makes its results valid. This method is used to check whether
the results are in a consistent state or not.isResultValid
in interface StoppableAlgorithm
public void algorithmStarted(IterativeAlgorithm algorithm)
IterativeAlgorithmListener
algorithmStarted
in interface IterativeAlgorithmListener
algorithm
- The algorithm that has started.public void algorithmEnded(IterativeAlgorithm algorithm)
IterativeAlgorithmListener
algorithmEnded
in interface IterativeAlgorithmListener
algorithm
- The algorithm that has ended.public void stepStarted(IterativeAlgorithm algorithm)
IterativeAlgorithmListener
stepStarted
in interface IterativeAlgorithmListener
algorithm
- The algorithm that has started another step of its execution.public void stepEnded(IterativeAlgorithm algorithm)
IterativeAlgorithmListener
stepEnded
in interface IterativeAlgorithmListener
algorithm
- The algorithm that has ended another step of its execution.protected java.lang.Object readResolve()