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

java.lang.Object
  extended by edu.jhu.bme.smile.commons.optimize.test.FunctionXXplusSinXX
All Implemented Interfaces:
Optimizable1DContinuous, Optimizable1DContinuousDifferentiable

public class FunctionXXplusSinXX
extends java.lang.Object
implements Optimizable1DContinuousDifferentiable

Test case to test 1D optimizers. Function is x^2 + 4*sin(x^2).

Author:
Yufeng Guo, Hanlin Wan

Constructor Summary
FunctionXXplusSinXX()
          Default constuctor.
FunctionXXplusSinXX(double extrema, double domMin, double domMax)
          Constructor to specify extrema and domain.
 
Method Summary
 double get2ndDerivative(double x)
          Gets the second derivative of the function.
 double get2ndDerivative(double x, double step, int method)
          Gets the second derivative of the function.
 double getDerivative(double x)
          Gets the first derivative of the function.
 double getDerivative(double x, double step, int method)
          Gets the first derivative of the function.
 double getDomainMax()
          Gets the domain maximum
 double getDomainMin()
          Gets the domain minimum.
 double getDomainTolerance()
          Gets the tolerance.
 double getValue(double x)
          Evaluates the function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FunctionXXplusSinXX

public FunctionXXplusSinXX()
Default constuctor. Sets the extrema at the origin. Sets domain to maximum values.


FunctionXXplusSinXX

public FunctionXXplusSinXX(double extrema,
                           double domMin,
                           double domMax)
Constructor to specify extrema and domain.

Parameters:
extrema - where the extrema is
domMin - domain minimum
domMax - domain maximum
Method Detail

getDerivative

public double getDerivative(double x)
Gets the first derivative of the function. Uses the default step size and method

Specified by:
getDerivative in interface Optimizable1DContinuousDifferentiable
Parameters:
x - location to calculate derivative
Returns:
derivative at location x

getDerivative

public double getDerivative(double x,
                            double step,
                            int method)
Gets the first derivative of the function. Uses the specified step size and method.

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

get2ndDerivative

public double get2ndDerivative(double x)
Gets the second derivative of the function. Uses the default step size and method

Specified by:
get2ndDerivative in interface Optimizable1DContinuousDifferentiable
Parameters:
x - location to calculate derivative
Returns:
2nd derivative at location x

get2ndDerivative

public double get2ndDerivative(double x,
                               double step,
                               int method)
Gets the second derivative of the function. Uses the specified step size and method.

Parameters:
x - location to calculate derivative
step - step size
method - method
Returns:
2ndderivative at location x

getDomainMax

public double getDomainMax()
Gets the domain maximum

Specified by:
getDomainMax in interface Optimizable1DContinuous
Returns:
domain max

getDomainMin

public double getDomainMin()
Gets the domain minimum.

Specified by:
getDomainMin in interface Optimizable1DContinuous
Returns:
domain min

getValue

public double getValue(double x)
Evaluates the function.

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

getDomainTolerance

public double getDomainTolerance()
Gets the tolerance.

Specified by:
getDomainTolerance in interface Optimizable1DContinuous
Returns:
tolerance