gov.sandia.cognition.learning.algorithm.regression
Class AbstractParameterCostMinimizer<ResultType extends VectorizableVectorFunction,CostFunctionType extends SupervisedCostFunction<Vector,Vector>>

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>
              extended by gov.sandia.cognition.learning.algorithm.AbstractAnytimeBatchLearner<Collection<? extends InputOutputPair<? extends InputType,OutputType>>,ResultType>
                  extended by gov.sandia.cognition.learning.algorithm.AbstractAnytimeSupervisedBatchLearner<Vector,Vector,ResultType>
                      extended by gov.sandia.cognition.learning.algorithm.regression.AbstractParameterCostMinimizer<ResultType,CostFunctionType>
Type Parameters:
ResultType - Type of result to expect, such as GradientDescendable
CostFunctionType - Type of cost function to use, such as SumSquaredErrorCostFunction
All Implemented Interfaces:
AnytimeAlgorithm<ResultType>, IterativeAlgorithm, MeasurablePerformanceAlgorithm, StoppableAlgorithm, AnytimeBatchLearner<Collection<? extends InputOutputPair<? extends Vector,Vector>>,ResultType>, BatchCostMinimizationLearner<Collection<? extends InputOutputPair<? extends Vector,Vector>>,ResultType>, BatchLearner<Collection<? extends InputOutputPair<? extends Vector,Vector>>,ResultType>, ParameterCostMinimizer<ResultType>, SupervisedBatchLearner<Vector,Vector,ResultType>, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
LeastSquaresEstimator

public abstract class AbstractParameterCostMinimizer<ResultType extends VectorizableVectorFunction,CostFunctionType extends SupervisedCostFunction<Vector,Vector>>
extends AbstractAnytimeSupervisedBatchLearner<Vector,Vector,ResultType>
implements BatchCostMinimizationLearner<Collection<? extends InputOutputPair<? extends Vector,Vector>>,ResultType>, ParameterCostMinimizer<ResultType>

Partial implementation of ParameterCostMinimizer.

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

Field Summary
static int DEFAULT_MAX_ITERATIONS
          Default maximum number of iterations before stopping 1000
static double DEFAULT_TOLERANCE
          Default convergence criterion 1.0E-7
 
Fields inherited from class gov.sandia.cognition.learning.algorithm.AbstractAnytimeBatchLearner
data, keepGoing
 
Fields inherited from class gov.sandia.cognition.algorithm.AbstractAnytimeAlgorithm
maxIterations
 
Fields inherited from class gov.sandia.cognition.algorithm.AbstractIterativeAlgorithm
DEFAULT_ITERATION, iteration
 
Constructor Summary
AbstractParameterCostMinimizer(CostFunctionType costFunction, int maxIterations, double tolerance)
          Creates a new instance of AbstractParameterCostMinimizer
 
Method Summary
 CostFunctionType getCostFunction()
          Gets the cost function that the learner is minimizing.
 ResultType getObjectToOptimize()
          Getter for objectToOptimize
 NamedValue<Double> getPerformance()
          Gets the name-value pair that describes the current performance of the algorithm.
 ResultType getResult()
          Gets the current result of the algorithm.
protected  Double getResultCost()
          Getter for resultCost
 double getTolerance()
          Getter for tolerance
 void setCostFunction(CostFunctionType costFunction)
          Setter for costFunction
 void setObjectToOptimize(ResultType objectToOptimize)
          Setter for objectToOptimize
protected  void setResult(ResultType result)
          Setter for result
protected  void setResultCost(Double resultCost)
          Setter for resultCost
 void setTolerance(double tolerance)
          Setter for tolerance
 
Methods inherited from class gov.sandia.cognition.learning.algorithm.AbstractAnytimeBatchLearner
cleanupAlgorithm, clone, getData, getKeepGoing, initializeAlgorithm, learn, setData, setKeepGoing, step, stop
 
Methods inherited from class gov.sandia.cognition.algorithm.AbstractAnytimeAlgorithm
getMaxIterations, isResultValid, setMaxIterations
 
Methods inherited from class gov.sandia.cognition.algorithm.AbstractIterativeAlgorithm
addIterativeAlgorithmListener, 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.learning.algorithm.BatchCostMinimizationLearner
learn
 
Methods inherited from interface gov.sandia.cognition.util.CloneableSerializable
clone
 
Methods inherited from interface gov.sandia.cognition.algorithm.AnytimeAlgorithm
getMaxIterations, setMaxIterations
 
Methods inherited from interface gov.sandia.cognition.algorithm.IterativeAlgorithm
addIterativeAlgorithmListener, getIteration, removeIterativeAlgorithmListener
 
Methods inherited from interface gov.sandia.cognition.algorithm.StoppableAlgorithm
isResultValid, stop
 

Field Detail

DEFAULT_TOLERANCE

public static final double DEFAULT_TOLERANCE
Default convergence criterion 1.0E-7

See Also:
Constant Field Values

DEFAULT_MAX_ITERATIONS

public static final int DEFAULT_MAX_ITERATIONS
Default maximum number of iterations before stopping 1000

See Also:
Constant Field Values
Constructor Detail

AbstractParameterCostMinimizer

public AbstractParameterCostMinimizer(CostFunctionType costFunction,
                                      int maxIterations,
                                      double tolerance)
Creates a new instance of AbstractParameterCostMinimizer

Parameters:
costFunction - Cost function that computes the cost of the object to optimize
maxIterations - Maximum number of iterations before stopping
tolerance - Stopping criterion for the algorithm, typically ~1e-5
Method Detail

getObjectToOptimize

public ResultType getObjectToOptimize()
Getter for objectToOptimize

Specified by:
getObjectToOptimize in interface ParameterCostMinimizer<ResultType extends VectorizableVectorFunction>
Returns:
Vectorizable whose parameters result minimize the cost function

setObjectToOptimize

public void setObjectToOptimize(ResultType objectToOptimize)
Setter for objectToOptimize

Specified by:
setObjectToOptimize in interface ParameterCostMinimizer<ResultType extends VectorizableVectorFunction>
Parameters:
objectToOptimize - Vectorizable whose parameters result minimize the cost function

getResult

public ResultType getResult()
Description copied from interface: AnytimeAlgorithm
Gets the current result of the algorithm.

Specified by:
getResult in interface AnytimeAlgorithm<ResultType extends VectorizableVectorFunction>
Returns:
Current result of the algorithm.

setResult

protected void setResult(ResultType result)
Setter for result

Parameters:
result - Result to return

getTolerance

public double getTolerance()
Getter for tolerance

Returns:
Stopping criterion for the algorithm, typically ~1e-5

setTolerance

public void setTolerance(double tolerance)
Setter for tolerance

Parameters:
tolerance - Stopping criterion for the algorithm, typically ~1e-5

getCostFunction

public CostFunctionType getCostFunction()
Description copied from interface: BatchCostMinimizationLearner
Gets the cost function that the learner is minimizing.

Specified by:
getCostFunction in interface BatchCostMinimizationLearner<Collection<? extends InputOutputPair<? extends Vector,Vector>>,ResultType extends VectorizableVectorFunction>
Returns:
The CostFunction that the learner's algorithm is minimizing.

setCostFunction

public void setCostFunction(CostFunctionType costFunction)
Setter for costFunction

Parameters:
costFunction - Cost function that computes the cost of the object to optimize

getResultCost

protected Double getResultCost()
Getter for resultCost

Returns:
Cost of the result

setResultCost

protected void setResultCost(Double resultCost)
Setter for resultCost

Parameters:
resultCost - Cost of the result

getPerformance

public NamedValue<Double> getPerformance()
Description copied from interface: MeasurablePerformanceAlgorithm
Gets the name-value pair that describes the current performance of the algorithm. For most algorithms, this is the value that they are attempting to optimize.

Specified by:
getPerformance in interface MeasurablePerformanceAlgorithm
Returns:
The name-value pair that describes the current performance of the algorithm.