35 size_t nbParams = params.
size();
40 hdg_.resize(nbParams);
45 for (
size_t i = 0; i < nbParams; i++)
50 for (
size_t i = 0; i < nbParams; i++)
52 auto cp = params[i].getConstraint();
66 function().setParameters(params);
70 for (
size_t i = 0; i < nbParams; ++i)
74 for (
size_t j = 0; j < nbParams; ++j)
100 for (i = 0; i < n; ++i)
116 for (i = 0; i < n; ++i)
125 printMessage(
"!!! Optimization might have failed. Try to reparametrize your function to remove constraints.");
151 for (i = 0; i < n; i++)
177 for (i = 0; i < n; i++)
182 for (i = 0; i < n; i++)
185 for (
unsigned int j = 0; j < n; j++)
191 double fae(0), fac(0), sumdg(0), sumxi(0);
193 for (i = 0; i < n; i++)
198 sumxi += xi_[i] * xi_[i];
201 if (fac > sqrt(1e-7 * sumdg * sumxi))
204 double fad = 1.0 / fae;
205 for (i = 0; i < n; i++)
209 for (i = 0; i < n; i++)
211 for (
unsigned int j = i; j < n; j++)
226 for (
unsigned int i = 0; i < gradient.size(); i++)
238 for (
size_t i = 0; i < nbParams; ++i)
241 for (
size_t j = 0; j < nbParams; ++j)
247 double v = 1, alpmax = 1;
248 for (
size_t i = 0; i < nbParams; ++i)
258 for (
size_t i = 0; i < nbParams; i++)
const FirstOrderDerivable & firstOrderDerivableFunction() const
BfgsMultiDimensions(std::shared_ptr< FirstOrderDerivable > function)
virtual void enableFirstOrderDerivatives(bool yn)=0
Tell if derivatives must be computed.
void setDefaultStopCondition_(std::shared_ptr< OptimizationStopCondition > osc)
ParameterList & getParameters_()
const ParameterList & getParameters() const override
void doInit(const ParameterList ¶ms) override
This function is called by the init() method and contains all calculations.
The parameter list object.
bool tolIsReached_
Tell if the tolerance level has been reached.
virtual double getFirstOrderDerivative(const std::string &variable) const =0
Get the derivative of the function at the current point.
std::shared_ptr< DirectionFunction > f1dim_
void setOptimizationProgressCharacter(const std::string &c)
Set the character to be displayed during optimization.
unsigned int getVerbose() const override
Get the verbose level.
double doStep() override
This function is called by the step() method and contains all calculations.
unsigned int nbEval_
The current number of function evaluations achieved.
Partial implementation of the Optimizer interface.
double currentValue_
The current value of the function.
void getGradient(std::vector< double > &gradient) const
std::shared_ptr< const FunctionInterface > getFunction() const override
Get the current function being optimized.
std::shared_ptr< OptimizationStopCondition > getDefaultStopCondition() override
Get the default stop condition of the optimization algorithm.
void printMessage(const std::string &message)
Give a message to print to the message handler.
void setStopCondition(std::shared_ptr< OptimizationStopCondition > stopCondition) override
Set the stop condition of the optimization algorithm.