41 #include "../NumTools.h" 42 #include "../../Text/TextTools.h" 63 if (params.size() != 1)
64 throw Exception(
"NewtonOneDimension::init(). This optimizer only deals with one parameter.");
65 _param = params[0].getName();
66 currentValue_ = getFunction()->f(getParameters());
67 getStopCondition()->init();
80 if (secondOrderDerivative <= 0)
85 movement = -firstOrderDerivative / secondOrderDerivative;
87 else movement = firstOrderDerivative / secondOrderDerivative;
88 if (std::isnan(movement))
93 newPoint[0].setValue(
getParameters()[0].getValue() - movement);
97 unsigned int count = 0;
106 printMessage(
"!!! Felsenstein-Churchill correction applied too much time. Stopping here. Convergence probably not reached.");
112 movement = movement / 2;
113 newPoint[0].setValue(
getParameters()[0].getValue() - movement);
void doInit(const ParameterList ¶ms)
This function is called by the init() method and contains all calculations.
virtual void setParameters(const ParameterList ¶meters)=0
Set the point where the function must be computed.
virtual double f(const ParameterList ¶meters)
Get the value of the function according to a given set of parameters.
This class allows to perform a correspondence analysis.
virtual const ParameterList & getParameters() const =0
Get all parameters available.
ParameterList & getParameters_()
NewtonOneDimension(DerivableSecondOrder *function=0)
Stop condition on function value.
virtual double getSecondOrderDerivative(const std::string &variable) const =0
Get the second order derivative of the function at the current point.
virtual double getFirstOrderDerivative(const std::string &variable) const =0
Get the derivative of the function at the current point.
static std::string toString(T t)
General template method to convert to a string.
The parameter list object.
bool tolIsReached_
Tell if the tolerance level has been reached.
void setDefaultStopCondition_(OptimizationStopCondition *osc)
const ParameterList & getParameters() const
const DerivableSecondOrder * getFunction() const
Get the current function being optimized.
double doStep()
This function is called by the step() method and contains all calculations.
unsigned int nbEvalMax_
The maximum number of function evaluations allowed.
This is the abstract class for second order derivable functions.
Partial implementation of the Optimizer interface.
double currentValue_
The current value of the function.
void setStopCondition(const OptimizationStopCondition &stopCondition)
Set the stop condition of the optimization algorithm.
OptimizationStopCondition * getDefaultStopCondition()
Get the default stop condition of the optimization algorithm.
void printMessage(const std::string &message)
Give a message to print to the message handler.
unsigned int _maxCorrection