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