gov.sandia.cognition.learning.algorithm.regression
Class AbstractMinimizerBasedParameterCostMinimizer<ResultType extends VectorizableVectorFunction,EvaluatorType extends Evaluator<? super Vector,? extends Double>>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.algorithm.AbstractIterativeAlgorithm
          extended by gov.sandia.cognition.algorithm.AnytimeAlgorithmWrapper<ResultType,FunctionMinimizer<Vector,Double,? super EvaluatorType>>
              extended by gov.sandia.cognition.learning.algorithm.regression.AbstractMinimizerBasedParameterCostMinimizer<ResultType,EvaluatorType>
Type Parameters:
ResultType - Type of result to expect, such as GradientDescendable
EvaluatorType - Type of Evaluator to use internally, such as DifferentiableEvaluator
All Implemented Interfaces:
AnytimeAlgorithm<ResultType>, IterativeAlgorithm, IterativeAlgorithmListener, MeasurablePerformanceAlgorithm, StoppableAlgorithm, 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:
ParameterDerivativeFreeCostMinimizer, ParameterDifferentiableCostMinimizer

public abstract class AbstractMinimizerBasedParameterCostMinimizer<ResultType extends VectorizableVectorFunction,EvaluatorType extends Evaluator<? super Vector,? extends Double>>
extends AnytimeAlgorithmWrapper<ResultType,FunctionMinimizer<Vector,Double,? super EvaluatorType>>
implements ParameterCostMinimizer<ResultType>

Partial implementation of ParameterCostMinimizer, based on the algorithms from the minimization package. These classes apply minimization algorithms to the purpose of estimating locally minimum-cost parameter sets of an object.

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

Field Summary
static DifferentiableCostFunction DEFAULT_COST_FUNCTION
          Default cost function, SumSquaredErrorCostFunction
 
Fields inherited from class gov.sandia.cognition.algorithm.AbstractIterativeAlgorithm
DEFAULT_ITERATION, iteration
 
Constructor Summary
AbstractMinimizerBasedParameterCostMinimizer(FunctionMinimizer<Vector,Double,? super EvaluatorType> algorithm)
          Creates a new instance of AbstractMinimizerBasedParameterCostMinimizer
AbstractMinimizerBasedParameterCostMinimizer(FunctionMinimizer<Vector,Double,? super EvaluatorType> algorithm, SupervisedCostFunction<Vector,Vector> costFunction)
          Creates a new instance of AbstractMinimizerBasedParameterCostMinimizer
 
Method Summary
 AbstractMinimizerBasedParameterCostMinimizer<ResultType,EvaluatorType> clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
abstract  EvaluatorType createInternalFunction()
          Creates the internal function that maps the parameter set of result as the input to the function, so that the minimization algorithms can perturb this input in their minimization schemes.
 SupervisedCostFunction<Vector,Vector> getCostFunction()
          Gets the cost function that the learner is minimizing.
 ResultType getObjectToOptimize()
          Gets the object to optimize
 NamedValue<Double> getPerformance()
          Gets the performance, which is the cost of the minimizer on the last iteration.
 ResultType getResult()
          Gets the current result of the algorithm.
 ResultType learn(Collection<? extends InputOutputPair<? extends Vector,Vector>> data)
          The learn method creates an object of ResultType using data of type DataType, using some form of "learning" algorithm.
 void setCostFunction(SupervisedCostFunction<Vector,Vector> costFunction)
          Setter for costFunction
 void setObjectToOptimize(ResultType objectToOptimize)
          Set the object to optimize
 void setResult(ResultType result)
          Setter for result
 
Methods inherited from class gov.sandia.cognition.algorithm.AnytimeAlgorithmWrapper
algorithmEnded, algorithmStarted, getAlgorithm, getIteration, getMaxIterations, isResultValid, readResolve, setAlgorithm, setMaxIterations, stepEnded, stepStarted, stop
 
Methods inherited from class gov.sandia.cognition.algorithm.AbstractIterativeAlgorithm
addIterativeAlgorithmListener, fireAlgorithmEnded, fireAlgorithmStarted, fireStepEnded, fireStepStarted, 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
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_COST_FUNCTION

public static final DifferentiableCostFunction DEFAULT_COST_FUNCTION
Default cost function, SumSquaredErrorCostFunction

Constructor Detail

AbstractMinimizerBasedParameterCostMinimizer

public AbstractMinimizerBasedParameterCostMinimizer(FunctionMinimizer<Vector,Double,? super EvaluatorType> algorithm)
Creates a new instance of AbstractMinimizerBasedParameterCostMinimizer

Parameters:
algorithm - Minimization algorithm to use.

AbstractMinimizerBasedParameterCostMinimizer

public AbstractMinimizerBasedParameterCostMinimizer(FunctionMinimizer<Vector,Double,? super EvaluatorType> algorithm,
                                                    SupervisedCostFunction<Vector,Vector> costFunction)
Creates a new instance of AbstractMinimizerBasedParameterCostMinimizer

Parameters:
algorithm - Minimization algorithm to use.
costFunction - Cost function to compute the cost of objectToOptimize
Method Detail

clone

public AbstractMinimizerBasedParameterCostMinimizer<ResultType,EvaluatorType> clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the 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.

Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AnytimeAlgorithmWrapper<ResultType extends VectorizableVectorFunction,FunctionMinimizer<Vector,Double,? super EvaluatorType extends Evaluator<? super Vector,? extends Double>>>
Returns:
A clone of this object.

createInternalFunction

public abstract EvaluatorType createInternalFunction()
Creates the internal function that maps the parameter set of result as the input to the function, so that the minimization algorithms can perturb this input in their minimization schemes.

Returns:
Evaluator to use internally.

getObjectToOptimize

public ResultType getObjectToOptimize()
Description copied from interface: ParameterCostMinimizer
Gets the object to optimize

Specified by:
getObjectToOptimize in interface ParameterCostMinimizer<ResultType extends VectorizableVectorFunction>
Returns:
object to optimize

setObjectToOptimize

public void setObjectToOptimize(ResultType objectToOptimize)
Description copied from interface: ParameterCostMinimizer
Set the object to optimize

Specified by:
setObjectToOptimize in interface ParameterCostMinimizer<ResultType extends VectorizableVectorFunction>
Parameters:
objectToOptimize - object to optimize

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

public void setResult(ResultType result)
Setter for result

Parameters:
result - Result of the minimization

learn

public ResultType learn(Collection<? extends InputOutputPair<? extends Vector,Vector>> data)
Description copied from interface: BatchLearner
The learn method creates an object of ResultType using data of type DataType, using some form of "learning" algorithm.

Specified by:
learn in interface BatchCostMinimizationLearner<Collection<? extends InputOutputPair<? extends Vector,Vector>>,ResultType extends VectorizableVectorFunction>
Specified by:
learn in interface BatchLearner<Collection<? extends InputOutputPair<? extends Vector,Vector>>,ResultType extends VectorizableVectorFunction>
Parameters:
data - The data that the learning algorithm will use to create an object of ResultType.
Returns:
The object that is created based on the given data using the learning algorithm.

getCostFunction

public SupervisedCostFunction<Vector,Vector> 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(SupervisedCostFunction<Vector,Vector> costFunction)
Setter for costFunction

Parameters:
costFunction - Cost function that maps the object to optimize onto a scalar cost

getPerformance

public NamedValue<Double> getPerformance()
Gets the performance, which is the cost of the minimizer on the last iteration.

Specified by:
getPerformance in interface MeasurablePerformanceAlgorithm
Returns:
The performance of the algorithm.