41 #include "../NumTools.h" 59 AbstractOptimizer(function), simplex_(), y_(), pSum_(), iHighest_(0), iNextHighest_(0), iLowest_(0)
71 size_t nDim = getParameters().size();
75 simplex_.resize(nDim + 1);
78 for(
unsigned int i = 1; i < nDim + 1; i++)
81 simplex_[i] = getParameters();
83 for(
unsigned int j = 0; j < nDim; j++)
87 simplex_[i][j].setValue(getParameters()[j].getValue() + (j == i - 1 ? lambda : 0.));
90 y_[i] = getFunction()->f(simplex_[i]);
94 simplex_[0] = getParameters();
95 y_[0] = getFunction()->f(simplex_[0]);
107 size_t mpts = nDim + 1;
124 for(
unsigned int i = 0; i < mpts; i++)
155 for (
size_t i = 0; i < mpts; i++)
159 for (
size_t j = 0; j < nDim; j++)
168 nbEval_ +=
static_cast<unsigned int>(nDim);
191 size_t mpts = ndim + 1;
196 for (
size_t j = 0; j < ndim; j++)
199 for (
size_t i = 0; i < mpts; i++)
203 pSum[j].setValue(sum);
213 double fac1, fac2, yTry;
215 fac1 = (1.0 - fac) / static_cast<double>(ndim);
221 for (
size_t j = 0; j < ndim; j++)
233 for (
size_t j = 0; j < ndim; j++)
virtual double f(const ParameterList ¶meters)
Get the value of the function according to a given set of parameters.
double optimize()
Multidimensional minimization of the function function_ by the downhill simplex method of Nelder and ...
This class allows to perform a correspondence analysis.
double optimize()
Basic implementation.
ParameterList getPSum()
Update the pSum_ variable.
This is the function abstract class.
void doInit(const ParameterList ¶ms)
This function is called by the init() method and contains all calculations.
ParameterList & getParameters_()
double getCurrentTolerance() const
Get the current tolerance.
The parameter list object.
double tryExtrapolation(double fac)
Extrapolates by a factor fac through the face of the simplex from the high point. Try the new point a...
size_t getDimension() const
void setDefaultStopCondition_(OptimizationStopCondition *osc)
double doStep()
This function is called by the step() method and contains all calculations.
const Function * getFunction() const
Get the current function being optimized.
const ParameterList & getParameters() const
DownhillSimplexMethod(Function *function)
Build a new Downhill Simplex optimizer.
friend class DSMStopCondition
unsigned int nbEvalMax_
The maximum number of function evaluations allowed.
unsigned int nbEval_
The current number of function evaluations achieved.
Partial implementation of the Optimizer interface.
void setStopCondition(const OptimizationStopCondition &stopCondition)
Set the stop condition of the optimization algorithm.
OptimizationStopCondition * getDefaultStopCondition()
Get the default stop condition of the optimization algorithm.
unsigned int iNextHighest_
This implements the Downhill Simplex method in multidimensions.