edu.stanford.nlp.optimization
Class AbstractCachingDiffFunction

java.lang.Object
  extended by edu.stanford.nlp.optimization.AbstractCachingDiffFunction
All Implemented Interfaces:
DiffFunction, Function, HasInitial
Direct Known Subclasses:
AbstractStochasticCachingDiffFunction, BiasedLogConditionalObjectiveFunction, BiasedLogisticObjectiveFunction, GeneralizedExpectationObjectiveFunction, LogConditionalEqConstraintFunction, LogisticObjectiveFunction, SemiSupervisedLogConditionalObjectiveFunction

public abstract class AbstractCachingDiffFunction
extends java.lang.Object
implements DiffFunction, HasInitial

A differentiable function that caches the last evaluation of its value and derivative.

Author:
Dan Klein

Field Summary
protected  double[] derivative
           
protected  double value
           
 
Constructor Summary
AbstractCachingDiffFunction()
           
 
Method Summary
protected abstract  void calculate(double[] x)
          Calculate the value at x and the derivative and save them in the respective fields.
protected  void clearCache()
          Clears the cache in a way that doesn't require reallocation :-)
protected static void copy(double[] copy, double[] orig)
           
 double[] derivativeAt(double[] x)
          Returns the first-derivative vector at the input location.
 boolean gradientCheck()
           
 double[] initial()
          Returns the intitial point in the domain (but not necessarily a feasible one).
 double lastValue()
           
 double[] randomInitial()
           
 double valueAt(double[] x)
          Returns the value of the function at a single point.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.stanford.nlp.optimization.Function
domainDimension
 

Field Detail

derivative

protected double[] derivative

value

protected double value
Constructor Detail

AbstractCachingDiffFunction

public AbstractCachingDiffFunction()
Method Detail

gradientCheck

public boolean gradientCheck()

calculate

protected abstract void calculate(double[] x)
Calculate the value at x and the derivative and save them in the respective fields.

Parameters:
x - The point at which to calculate the function

clearCache

protected void clearCache()
Clears the cache in a way that doesn't require reallocation :-)


initial

public double[] initial()
Description copied from interface: HasInitial
Returns the intitial point in the domain (but not necessarily a feasible one).

Specified by:
initial in interface HasInitial
Returns:
a domain point

randomInitial

public double[] randomInitial()

copy

protected static void copy(double[] copy,
                           double[] orig)

valueAt

public double valueAt(double[] x)
Description copied from interface: Function
Returns the value of the function at a single point.

Specified by:
valueAt in interface Function
Parameters:
x - a double[] input
Returns:
the function value at the input

derivativeAt

public double[] derivativeAt(double[] x)
Description copied from interface: DiffFunction
Returns the first-derivative vector at the input location.

Specified by:
derivativeAt in interface DiffFunction
Parameters:
x - a double[] input vector
Returns:
the vector of first partial derivatives.

lastValue

public double lastValue()


Stanford NLP Group