72 size_t nbParams = params.
size();
77 hdg_.resize(nbParams);
82 for (
size_t i = 0; i < nbParams; i++)
87 for (
size_t i = 0; i < nbParams; i++)
89 std::shared_ptr<Constraint> cp = params[i].getConstraint();
107 for (
size_t i = 0; i < nbParams; i++)
111 for (
unsigned int j = 0; j < nbParams; j++)
120 for (
size_t i = 0; i < nbParams; i++)
122 sum +=
p_[i] *
p_[i];
136 for (i = 0; i < n; i++)
152 for (i = 0; i < n; i++)
161 printMessage(
"!!! Optimization might have failed. Try to reparametrize your function to remove constraints.");
187 for (i = 0; i < n; i++)
213 for (i = 0; i < n; i++)
218 for (i = 0; i < n; i++)
221 for (
unsigned int j = 0; j < n; j++)
227 double fae(0), fac(0), sumdg(0), sumxi(0);
229 for (i = 0; i < n; i++)
237 if (fac > sqrt(1e-7 * sumdg * sumxi))
240 double fad = 1.0 / fae;
241 for (i = 0; i < n; i++)
245 for (i = 0; i < n; i++)
247 for (
unsigned int j = i; j < n; j++)
262 for (
unsigned int i = 0; i < gradient.size(); i++)
274 for (
size_t i = 0; i < nbParams; i++)
277 for (
unsigned int j = 0; j < nbParams; j++)
283 double v = 1, alpmax = 1;
284 for (
size_t i = 0; i < nbParams; i++)
294 for (
size_t i = 0; i < nbParams; i++)
Partial implementation of the Optimizer interface.
void setOptimizationProgressCharacter(const std::string &c)
Set the character to be displayed during optimization.
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.
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.
ParameterList & getParameters_()
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.
void setDefaultStopCondition_(OptimizationStopCondition *osc)
void getGradient(std::vector< double > &gradient) const
double doStep()
This function is called by the step() method and contains all calculations.
DerivableFirstOrder * getFunction_()
const DerivableFirstOrder * getFunction() const
Get the current function being optimized.
BfgsMultiDimensions(DerivableFirstOrder *function)
void doInit(const ParameterList ¶ms)
This function is called by the init() method and contains all calculations.
This is the abstract class for first order derivable functions.
virtual double getFirstOrderDerivative(const std::string &variable) const =0
Get the derivative of the function at the current point.
virtual void enableFirstOrderDerivatives(bool yn)=0
Tell if derivatives must be computed.
Stop condition on function value.
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.
The parameter list object.