de.jstacs.algorithms.optimization
Class OneDimensionalFunction

java.lang.Object
  extended by de.jstacs.algorithms.optimization.OneDimensionalFunction
All Implemented Interfaces:
Function
Direct Known Subclasses:
NegativeOneDimensionalFunction, OneDimensionalSubFunction, QuadraticFunction

public abstract class OneDimensionalFunction
extends Object
implements Function

This class implements the interface Function for an one-dimensional function.

Author:
Jens Keilwagen

Constructor Summary
OneDimensionalFunction()
           
 
Method Summary
abstract  double evaluateFunction(double x)
          Evaluates the function at position x.
 double evaluateFunction(double[] x)
          Evaluates the function at a certain vector (in mathematical sense) x.
 double[] findMin(double lower, double fLower, double eps, double startDistance)
          This method returns a minimum x and the value f(x), starting the search at lower.
 int getDimensionOfScope()
          Returns the dimension of the scope of the Function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OneDimensionalFunction

public OneDimensionalFunction()
Method Detail

evaluateFunction

public double evaluateFunction(double[] x)
                        throws DimensionException,
                               EvaluationException
Description copied from interface: Function
Evaluates the function at a certain vector (in mathematical sense) x.

Specified by:
evaluateFunction in interface Function
Parameters:
x - the current vector
Returns:
the evaluation of the function
Throws:
DimensionException - if dim(x) != n, with $f: \mathbb{R}^n \to \mathbb{R}$
EvaluationException - if there was something wrong during the evaluation of the function

evaluateFunction

public abstract double evaluateFunction(double x)
                                 throws EvaluationException
Evaluates the function at position x.

Parameters:
x - the current position
Returns:
f(x)
Throws:
EvaluationException - if there was a mistake during evaluation of the function

findMin

public double[] findMin(double lower,
                        double fLower,
                        double eps,
                        double startDistance)
                 throws EvaluationException
This method returns a minimum x and the value f(x), starting the search at lower. First the minimum is tried to be bracketed and then the interval is tried to be reduced.
This method is a standard implementation and can be overwritten any time. It uses methods from the class Optimizer.

Parameters:
lower - the initial value of x
fLower - the value f(x)
eps - the threshold to stop the search of the minimum
startDistance - the initial distance for bracketing the minimum
Returns:
an array containing x at position 0 and f(x) at position 1
Throws:
EvaluationException - if there was a mistake during the evaluation of the function
See Also:
Optimizer

getDimensionOfScope

public final int getDimensionOfScope()
Description copied from interface: Function
Returns the dimension of the scope of the Function.

Specified by:
getDimensionOfScope in interface Function
Returns:
the dimension of the scope: n with $f: \mathbb{R}^n \to \mathbb{R}$