42 #include "../../Text/TextTools.h"
43 #include "../NumConstants.h"
44 #include "../NumTools.h"
85 if (params.
size() != 1)
86 throw Exception(
"GoldenSectionSearch::init(). This optimizer only deals with one parameter.");
140 throw Exception(
"GoldenSectionSearch::step. Initial interval not set: call the 'setInitialInterval' method first!");
147 NumTools::shift<double>(
x0,
x1,
x2);
158 NumTools::shift<double>(
x3,
x2,
x1);
173 throw NullPointerException(
"GoldenSectionSearch::getFunctionValue. No function associated to this optimizer.");
double callCount_
Count the number of times the isToleranceReached() function has been called.
double getTolerance() const
Get the tolerance parameter.
Partial implementation of the Optimizer interface.
void printMessage(const std::string &message)
Give a message to print to the message handler.
OptimizationStopCondition * getDefaultStopCondition()
Get the default stop condition of the optimization algorithm.
Parameter & getParameter_(size_t i)
unsigned int nbEvalMax_
The maximum number of function evaluations allowed.
unsigned int nbEval_
The current number of function evaluations achieved.
const ParameterList & getParameters() const
void setStopCondition(const OptimizationStopCondition &stopCondition)
Set the stop condition of the optimization algorithm.
OptimizationStopCondition * getStopCondition()
Get the stop condition of the optimization algorithm.
const Function * getFunction() const
Get the current function being optimized.
double currentValue_
The current value of the function.
bool tolIsReached_
Tell if the tolerance level has been reached.
unsigned int getVerbose() const
Get the verbose level.
bool hasFunction() const
Tell if a funciton is associatied to this optimizer.
void setDefaultStopCondition_(OptimizationStopCondition *osc)
Exception base class. Overload exception constructor (to control the exceptions mechanism)....
This is the function abstract class.
virtual double f(const ParameterList ¶meters)
Get the value of the function according to a given set of parameters.
bool isToleranceReached() const
Tell if the we reached the desired tolerance with a given new set of estimates.
double getCurrentTolerance() const
Get the current tolerance.
Golden Section Search optimization algorithm for one parameter.
void setInitialInterval(double inf, double sup)
Set intial search interval.
double doStep()
This function is called by the step() method and contains all calculations.
bool isInitialIntervalSet_
void doInit(const ParameterList ¶ms)
This function is called by the init() method and contains all calculations.
friend class GSSStopCondition
GoldenSectionSearch(Function *function)
double getFunctionValue() const
Initialize optimizer.
The base class exception for NULL pointer error. This exception may be thrown when an unexpected NULL...
static double GOLDEN_RATIO_R()
static double GOLDEN_RATIO_C()
virtual bool isToleranceReached() const =0
Tell if the we reached the desired tolerance with a given new set of estimates.
The parameter list object.
virtual void setValue(double value)
Set the value of this parameter.
std::string toString(T t)
General template method to convert to a string.