gov.sandia.cognition.algorithm
Class AbstractAnytimeAlgorithm<ResultType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.algorithm.AbstractIterativeAlgorithm
          extended by gov.sandia.cognition.algorithm.AbstractAnytimeAlgorithm<ResultType>
Type Parameters:
ResultType - The type of object produced by the algorithm.
All Implemented Interfaces:
AnytimeAlgorithm<ResultType>, IterativeAlgorithm, StoppableAlgorithm, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
AbstractAnytimeBatchLearner, LentzMethod

@CodeReview(reviewer="Justin Basilico",
            date="2008-07-17",
            changesNeeded=false,
            comments="Abstract class looks fine.")
public abstract class AbstractAnytimeAlgorithm<ResultType>
extends AbstractIterativeAlgorithm
implements AnytimeAlgorithm<ResultType>

A partial implementation of the common functionality of an AnytimeAlgorithm.

Since:
2.1
Author:
Kevin R. Dixon, Justin Basilico
See Also:
Serialized Form

Field Summary
protected  int maxIterations
          Maximum number of iterations before stopping
 
Fields inherited from class gov.sandia.cognition.algorithm.AbstractIterativeAlgorithm
DEFAULT_ITERATION, iteration
 
Constructor Summary
AbstractAnytimeAlgorithm(int maxIterations)
          Creates a new instance of AbstractAnytimeAlgorithm.
 
Method Summary
 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.
 void setMaxIterations(int maxIterations)
          Sets the maximum number of total iterations before stopping.
 
Methods inherited from class gov.sandia.cognition.algorithm.AbstractIterativeAlgorithm
addIterativeAlgorithmListener, clone, fireAlgorithmEnded, fireAlgorithmStarted, fireStepEnded, fireStepStarted, getIteration, getListeners, removeIterativeAlgorithmListener, setIteration, setListeners
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.algorithm.AnytimeAlgorithm
getResult
 
Methods inherited from interface gov.sandia.cognition.algorithm.IterativeAlgorithm
addIterativeAlgorithmListener, getIteration, removeIterativeAlgorithmListener
 
Methods inherited from interface gov.sandia.cognition.algorithm.StoppableAlgorithm
stop
 

Field Detail

maxIterations

protected int maxIterations
Maximum number of iterations before stopping

Constructor Detail

AbstractAnytimeAlgorithm

public AbstractAnytimeAlgorithm(int maxIterations)
Creates a new instance of AbstractAnytimeAlgorithm.

Parameters:
maxIterations - Maximum number of iterations before stopping
Method Detail

isResultValid

public boolean isResultValid()
Description copied from interface: StoppableAlgorithm
Indicates whether or not the algorithm results are in a consistent state or not. A 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.

Specified by:
isResultValid in interface StoppableAlgorithm
Returns:
True if the results of the algorithm are in valid state and false if they are not valid.

getMaxIterations

public int getMaxIterations()
Description copied from interface: AnytimeAlgorithm
Gets the maximum number of total iterations before stopping.

Specified by:
getMaxIterations in interface AnytimeAlgorithm<ResultType>
Returns:
Maximum number of total iterations before stopping. Must be greater than zero.

setMaxIterations

public void setMaxIterations(int maxIterations)
Description copied from interface: AnytimeAlgorithm
Sets the maximum number of total iterations before stopping.

Specified by:
setMaxIterations in interface AnytimeAlgorithm<ResultType>
Parameters:
maxIterations - Maximum number of iterations before stopping. Must be greater than zero.