70 size_t nbParams = params.size();
72 gradient_.resize(nbParams);
75 hdg_.resize(nbParams);
79 hessian_.resize(nbParams);
80 for (
size_t i = 0; i < nbParams; i++)
82 hessian_[i].resize(nbParams);
85 for (
size_t i = 0; i < nbParams; i++)
87 const Constraint* cp = params[i].getConstraint();
100 getFunction_()->enableFirstOrderDerivatives(
true);
101 getFunction_()->setParameters(params);
103 getGradient(gradient_);
105 for (
size_t i = 0; i < nbParams; i++)
107 p_[i] = getParameters()[i].getValue();
109 for (
unsigned int j = 0; j < nbParams; j++)
111 hessian_[i][j] = 0.0;
113 hessian_[i][i] = 1.0;
118 for (
size_t i = 0; i < nbParams; i++)
120 sum += p_[i] * p_[i];
134 for (i = 0; i < n; i++)
150 for (i = 0; i < n; i++)
158 printMessage(
"!!! Optimization might have failed. Try to reparametrize your function to remove constraints.");
184 for (i = 0; i < n; i++)
210 for (i = 0; i < n; i++)
215 for (i = 0; i < n; i++)
218 for (
unsigned int j = 0; j < n; j++)
224 double fae(0), fac(0), sumdg(0), sumxi(0);
226 for (i = 0; i < n; i++)
234 if (fac > sqrt(1e-7 * sumdg * sumxi))
237 double fad = 1.0 / fae;
238 for (i = 0; i < n; i++)
242 for (i = 0; i < n; i++)
244 for (
unsigned int j = i; j < n; j++)
259 for (
unsigned int i = 0; i < gradient.size(); i++)
271 for (
size_t i = 0; i < nbParams; i++)
274 for (
unsigned int j = 0; j < nbParams; j++)
280 double v = 1, alpmax = 1;
281 for (
size_t i = 0; i < nbParams; i++)
291 for (
size_t i = 0; i < nbParams; i++)
virtual double f(const ParameterList ¶meters)
Get the value of the function according to a given set of parameters.
unsigned int getVerbose() const
Get the verbose level.
This class allows to perform a correspondence analysis.
double doStep()
This function is called by the step() method and contains all calculations.
ParameterList & getParameters_()
Stop condition on function value.
virtual double getFirstOrderDerivative(const std::string &variable) const =0
Get the derivative of the function at the current point.
The parameter list object.
virtual void enableFirstOrderDerivatives(bool yn)=0
Tell if derivatives must be computed.
bool tolIsReached_
Tell if the tolerance level has been reached.
void setOptimizationProgressCharacter(const std::string &c)
Set the character to be displayed during optimization.
void setDefaultStopCondition_(OptimizationStopCondition *osc)
const ParameterList & getParameters() const
The constraint interface.
void doInit(const ParameterList ¶ms)
This function is called by the init() 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 setStopCondition(const OptimizationStopCondition &stopCondition)
Set the stop condition of the optimization algorithm.
This is the abstract class for first order derivable functions.
void getGradient(std::vector< double > &gradient) const
BfgsMultiDimensions(DerivableFirstOrder *function)
virtual double getAcceptedLimit(double value) const =0
Give the nearest accepted limit for a bad value.
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.
const DerivableFirstOrder * getFunction() const
Get the current function being optimized.