edu.jhu.bme.smile.commons.optimize.test
Class FunctionXXYYND

java.lang.Object
  extended by edu.jhu.bme.smile.commons.optimize.test.FunctionXXYYND
All Implemented Interfaces:
OptimizableNDContinuous, OptimizableNDContinuousDifferentiable

public class FunctionXXYYND
extends java.lang.Object
implements OptimizableNDContinuousDifferentiable

Test case to test ND optimizers. Function is x^2 + y^2 + 0.4*x^2*y^2.

Author:
Hanlin Wan

Constructor Summary
FunctionXXYYND(int dim)
          Default constuctor.
FunctionXXYYND(int dim, double[] extrema, double[] domMin, double[] domMax)
          Constructor to specify extrema and domain.
 
Method Summary
 double[][] get2ndDerivative(double[] x)
          Gets the hessian of the function.
 double[][] get2ndDerivative(double[] x, double step, int method)
          Gets the hessian of the function.
 double get2ndDerivative(double[] x, int dim1, int dim2)
          Gets the 2nd derivative of the function in a specific direction.
 double[] getDerivative(double[] x)
          Gets the gradient of the function.
 double[] getDerivative(double[] x, double step, int method)
          Gets the gradient of the function.
 double[] getDomainMax()
          Gets the domain maximum.
 double[] getDomainMin()
          Gets the domain minimum.
 double getDomainTolerance()
          Gets the tolerance.
 int getNumberOfDimensions()
          Gets the number of dimensions.
 double getValue(double[] x)
          Evaluates the function at location x.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FunctionXXYYND

public FunctionXXYYND(int dim)
Default constuctor. Sets the extrema at the origin. Sets domain to maximum values.

Parameters:
dim - number of dimensions

FunctionXXYYND

public FunctionXXYYND(int dim,
                      double[] extrema,
                      double[] domMin,
                      double[] domMax)
Constructor to specify extrema and domain.

Parameters:
dim - number of dimensions
extrema - where the extrema is
domMin - domain minimum
domMax - domain maximum
Method Detail

getDomainMax

public double[] getDomainMax()
Gets the domain maximum.

Specified by:
getDomainMax in interface OptimizableNDContinuous
Returns:
domain max

getDomainMin

public double[] getDomainMin()
Gets the domain minimum.

Specified by:
getDomainMin in interface OptimizableNDContinuous
Returns:
domain min

getDomainTolerance

public double getDomainTolerance()
Gets the tolerance.

Specified by:
getDomainTolerance in interface OptimizableNDContinuous
Returns:
tolerance

getNumberOfDimensions

public int getNumberOfDimensions()
Gets the number of dimensions.

Specified by:
getNumberOfDimensions in interface OptimizableNDContinuous
Returns:
number of dimensions

getValue

public double getValue(double[] x)
Evaluates the function at location x.

Specified by:
getValue in interface OptimizableNDContinuous
Parameters:
x - location to evaluate function
Returns:
value of the function at x

get2ndDerivative

public double[][] get2ndDerivative(double[] x)
Gets the hessian of the function. Uses the default step size and method

Specified by:
get2ndDerivative in interface OptimizableNDContinuousDifferentiable
Parameters:
x - location to calculate hessian
Returns:
hessian at location x

get2ndDerivative

public double[][] get2ndDerivative(double[] x,
                                   double step,
                                   int method)
Gets the hessian of the function. Uses the specified step size and method.

Parameters:
x - location to calculate hessian
step - step size
method - method
Returns:
hessian at location x

get2ndDerivative

public double get2ndDerivative(double[] x,
                               int dim1,
                               int dim2)
Gets the 2nd derivative of the function in a specific direction. Uses the default step size and method.

Specified by:
get2ndDerivative in interface OptimizableNDContinuousDifferentiable
Parameters:
x - location to calculate derivative
dim1 - dimension to take the first derivative
dim2 - dimension to take the second derivative
Returns:
2nd derivative at location x in the specified direction

getDerivative

public double[] getDerivative(double[] x)
Gets the gradient of the function. Uses the default step size and method

Specified by:
getDerivative in interface OptimizableNDContinuousDifferentiable
Parameters:
x - location to calculate gradient
Returns:
gradient at location x

getDerivative

public double[] getDerivative(double[] x,
                              double step,
                              int method)
Gets the gradient of the function. Uses the specified step size and method.

Parameters:
x - location to calculate gradient
step - step size
method - method
Returns:
gradient at location x