gov.sandia.cognition.learning.algorithm.minimization.line
Class DirectionalVectorToScalarFunction

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.math.AbstractScalarFunction<Double>
          extended by gov.sandia.cognition.math.AbstractUnivariateScalarFunction
              extended by gov.sandia.cognition.math.AbstractDifferentiableUnivariateScalarFunction
                  extended by gov.sandia.cognition.learning.algorithm.minimization.line.DirectionalVectorToScalarFunction
All Implemented Interfaces:
Evaluator<Double,Double>, DifferentiableEvaluator<Double,Double,Double>, DifferentiableUnivariateScalarFunction, ScalarFunction<Double>, UnivariateScalarFunction, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
DirectionalVectorToDifferentiableScalarFunction

@CodeReview(reviewer="Kevin R. Dixon",
            date="2009-07-06",
            changesNeeded=false,
            comments={"Fixed bug introduced into the numerical differentiation procedure.","Made clone() call super.clone().","Fixed the brittleness in the copy constructor."})
public class DirectionalVectorToScalarFunction
extends AbstractDifferentiableUnivariateScalarFunction

Maps a vector function onto a scalar one by using a directional vector and vector offset, and the parameter to the function is a scalar value along the direction from the start-point offset. This class also approximates the derivative by a method of forward differences.

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

Field Summary
static double FORWARD_DIFFERENCE
          Value used in the forward-difference derivative approximation
 
Constructor Summary
DirectionalVectorToScalarFunction(DirectionalVectorToScalarFunction other)
          Copy constructor
DirectionalVectorToScalarFunction(Evaluator<? super Vector,? extends Double> vectorScalarFunction, Vector vectorOffset, Vector direction)
          Creates a new function that restricts the vectorFunction to a particular vector direction
 
Method Summary
 DirectionalVectorToScalarFunction clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 Vector computeVector(double scaleFactor)
          Transforms the scaleFactor into a multidimensional Vector using the direction
 double differentiate(double input)
          Differentiates the output of the function about the given input
 double evaluate(double input)
          Evaluates the vector function along the direction using the scale factor "input" and vectorOffset
 Vector getDirection()
          Getter for direction
 Vector getVectorOffset()
          Getter for vectorOffset
 Evaluator<? super Vector,? extends Double> getVectorScalarFunction()
          Getter for vectorScalarFunction
 void setDirection(Vector direction)
          Setter for direction
 void setVectorOffset(Vector vectorOffset)
          Point to use as input to vectorFunction
 void setVectorScalarFunction(Evaluator<? super Vector,? extends Double> vectorScalarFunction)
          Setter for vectorScalarFunction
 
Methods inherited from class gov.sandia.cognition.math.AbstractDifferentiableUnivariateScalarFunction
differentiate
 
Methods inherited from class gov.sandia.cognition.math.AbstractUnivariateScalarFunction
evaluate, evaluateAsDouble
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.math.ScalarFunction
evaluateAsDouble
 
Methods inherited from interface gov.sandia.cognition.evaluator.Evaluator
evaluate
 

Field Detail

FORWARD_DIFFERENCE

public static final double FORWARD_DIFFERENCE
Value used in the forward-difference derivative approximation

See Also:
Constant Field Values
Constructor Detail

DirectionalVectorToScalarFunction

public DirectionalVectorToScalarFunction(Evaluator<? super Vector,? extends Double> vectorScalarFunction,
                                         Vector vectorOffset,
                                         Vector direction)
Creates a new function that restricts the vectorFunction to a particular vector direction

Parameters:
vectorScalarFunction - Function that maps a Vector onto a Double
vectorOffset - offset vector from which to scale along direction to evaluate vectorFunction
direction - Direction to optimize along

DirectionalVectorToScalarFunction

public DirectionalVectorToScalarFunction(DirectionalVectorToScalarFunction other)
Copy constructor

Parameters:
other - DirectionalVectorToScalarFunction to copy
Method Detail

clone

public DirectionalVectorToScalarFunction 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 AbstractCloneableSerializable
Returns:
A clone of this object.

getDirection

public Vector getDirection()
Getter for direction

Returns:
Direction along vectorFunction

setDirection

public void setDirection(Vector direction)
Setter for direction

Parameters:
direction - Direction to optimize along

getVectorOffset

public Vector getVectorOffset()
Getter for vectorOffset

Returns:
Point to use as input to vectorFunction

setVectorOffset

public void setVectorOffset(Vector vectorOffset)
Point to use as input to vectorFunction

Parameters:
vectorOffset - Point to use as input to vectorFunction

computeVector

public Vector computeVector(double scaleFactor)
Transforms the scaleFactor into a multidimensional Vector using the direction

Parameters:
scaleFactor - scale factor to move along the direction from vectorOffset
Returns:
Multidimensional vector corresponding to the scale factor along the direction

getVectorScalarFunction

public Evaluator<? super Vector,? extends Double> getVectorScalarFunction()
Getter for vectorScalarFunction

Returns:
Function that maps a Vector onto a Double

setVectorScalarFunction

public void setVectorScalarFunction(Evaluator<? super Vector,? extends Double> vectorScalarFunction)
Setter for vectorScalarFunction

Parameters:
vectorScalarFunction - Function that maps a Vector onto a Double

evaluate

public double evaluate(double input)
Evaluates the vector function along the direction using the scale factor "input" and vectorOffset

Parameters:
input - scale factor to move along direction from vectorOffset
Returns:
vectorFunction evaluated at the Vector corresponding to the scale factor

differentiate

public double differentiate(double input)
Description copied from interface: DifferentiableUnivariateScalarFunction
Differentiates the output of the function about the given input

Parameters:
input - Input about which to compute the derivative of the function output
Returns:
Derivative of the output with respect to the input