42 #include "../../Text/TextTools.h"
43 #include "../NumConstants.h"
44 #include "../NumTools.h"
74 a(0),
b(0),
d(0),
e(0),
etemp(0),
fu(0),
fv(0),
fw(0),
fx(0),
p(0),
q(0),
r(0),
tol1(0),
tol2(0),
90 if (params.
size() != 1)
91 throw Exception(
"BrentOneDimension::init(). This optimizer only deals with one parameter.");
116 a = (bracket.
a.
x < bracket.
c.
x ? bracket.
a.
x : bracket.
c.
x);
117 b = (bracket.
a.
x > bracket.
c.
x ? bracket.
a.
x : bracket.
c.
x);
120 if (
fx < bracket.
b.
f)
127 x =
w =
v = bracket.
b.
x;
210 else if (
fu <=
fv ||
v ==
x ||
v ==
w)
227 throw Exception(
"BrentOneDimension::optimize. Initial interval not set: call the 'setInitialInterval' method first!");
double callCount_
Count the number of times the isToleranceReached() function has been called.
const Optimizer * optimizer_
Partial implementation of the Optimizer interface.
double optimize()
Basic implementation.
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)
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.
void setMaximumNumberOfEvaluations(unsigned int max)
Set the maximum number of function evaluation to perform during optimization.
double currentValue_
The current value of the function.
unsigned int getVerbose() const
Get the verbose level.
void setDefaultStopCondition_(OptimizationStopCondition *osc)
double getCurrentTolerance() const
Get the current tolerance.
bool isToleranceReached() const
Tell if the we reached the desired tolerance with a given new set of estimates.
Brent's optimization for one parameter.
friend class BODStopCondition
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.
BrentOneDimension(Function *function=0)
double optimize()
Initialize optimizer.
void setInitialInterval(double inf, double sup)
Set intial search interval.
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.
static double GOLDEN_RATIO_C()
virtual double getTolerance() const =0
Get the tolerance parameter.
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.