5 #include "../NumTools.h" 24 AbstractOptimizer(function), simplex_(), y_(), pSum_(), iHighest_(0), iNextHighest_(0), iLowest_(0)
43 for (
unsigned int i = 1; i < nDim + 1; i++)
48 for (
unsigned int j = 0; j < nDim; j++)
72 size_t mpts = nDim + 1;
89 for (
unsigned int i = 0; i < mpts; i++)
122 for (
size_t i = 0; i < mpts; i++)
126 for (
size_t j = 0; j < nDim; j++)
135 nbEval_ +=
static_cast<unsigned int>(nDim);
158 size_t mpts = ndim + 1;
163 for (
size_t j = 0; j < ndim; j++)
166 for (
size_t i = 0; i < mpts; i++)
170 pSum[j].setValue(sum);
180 double fac1, fac2, yTry;
182 fac1 = (1.0 - fac) / static_cast<double>(ndim);
188 for (
size_t j = 0; j < ndim; j++)
200 for (
size_t j = 0; j < ndim; j++)
202 pSum_[j].setValue(
pSum_[j].getValue() + pTry[j].getValue() -
simplex_[iHighest_][j].getValue());
double optimize() override
Basic implementation.
double optimize()
Multidimensional minimization of the function function_ by the downhill simplex method of Nelder and ...
ParameterList getPSum()
Update the pSum_ variable.
void doInit(const ParameterList ¶ms)
This function is called by the init() method and contains all calculations.
void setDefaultStopCondition_(std::shared_ptr< OptimizationStopCondition > osc)
ParameterList & getParameters_()
const ParameterList & getParameters() const override
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
double doStep()
This function is called by the step() method and contains all calculations.
DownhillSimplexMethod(std::shared_ptr< FunctionInterface > function)
Build a new Downhill Simplex optimizer.
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.
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.
unsigned int iNextHighest_
void setStopCondition(std::shared_ptr< OptimizationStopCondition > stopCondition) override
Set the stop condition of the optimization algorithm.
This implements the Downhill Simplex method in multidimensions.