finMath lib documentation
net.finmath.optimizer

Class GoldenSectionSearch

• public class GoldenSectionSearch
extends Object
This class implements a Golden Section search algorithm, i.e., a minimization, implemented as a question-and-answer search algorithm. Example:
 
GoldenSectionSearch search = new GoldenSectionSearch(-1.0, 5.0);
while(search.getAccuracy() > 1E-11 && !search.isDone()) {
double x = search.getNextPoint();

double y = (x - 0.656) * (x - 0.656);

search.setValue(y);
}


For an example on how to use this class see also its main method.
Version:
1.1
Author:
Christian Fries - http://www.christian-fries.de
• Constructor Summary

Constructors
Constructor and Description
GoldenSectionSearch(double leftPoint, double rightPoint)
• Method Summary

All Methods
Modifier and Type Method and Description
double getAccuracy()
double getBestPoint()
double getNextPoint()
Returns the next point for which a valuation is requested.
int getNumberOfIterations()
boolean isDone()
static void main(String[] args)
GoldenSectionSearch optimize()
void setValue(double value)
Set the value corresponding to the point returned by a previous call of getNextPoint().
double value(double parameter)
• Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• Constructor Detail

• GoldenSectionSearch

public GoldenSectionSearch(double leftPoint,
double rightPoint)
Parameters:
leftPoint - left point of search interval
rightPoint - right point of search interval
• Method Detail

• main

public static void main(String[] args)
• getBestPoint

public double getBestPoint()
Returns:
Returns the best point obtained so far.
• getNextPoint

public double getNextPoint()
Returns the next point for which a valuation is requested.
Returns:
Returns the next point for which a value should be set using setValue.
• setValue

public void setValue(double value)
Set the value corresponding to the point returned by a previous call of getNextPoint(). If setValue is called without prior call to getNextPoint(), e.g., when called twice, a RuntimeException is thrown.
Parameters:
value - Value corresponding to point returned by previous getNextPoint() call.
• optimize

public GoldenSectionSearch optimize()
• value

public double value(double parameter)
• getNumberOfIterations

public int getNumberOfIterations()
Returns:
Returns the number of iterations needed so far.
• getAccuracy

public double getAccuracy()
Returns:
Returns the accuracy obtained so far.
• isDone

public boolean isDone()
Returns:
Returns true if the solver is unable to improve further. This may be either due to reached accuracy or due to no solution existing.