20Kernel::Logger
g_log(
"SimplexMinimizer");
39 std::shared_ptr<CostFunctions::CostFuncFitting> fitting =
40 std::dynamic_pointer_cast<CostFunctions::CostFuncFitting>(minimizer.
m_costFunction);
42 fitting->getFittingFunction()->applyTies();
48 : m_epsabs(epsabs),
m_costFunction(),
m_size(1.0), m_simplexStepSize(nullptr), m_startGuess(nullptr),
49 m_gslSolver(nullptr) {
58 const gsl_multimin_fminimizer_type *T = gsl_multimin_fminimizer_nmsimplex;
60 size_t np = function->nParams();
72 for (
size_t i = 0; i < np; ++i) {
73 gsl_vector_set(
m_startGuess, i, function->getParameter(i));
86 int status = gsl_multimin_fminimizer_iterate(
m_gslSolver);
91 double size = gsl_multimin_fminimizer_size(
m_gslSolver);
92 status = gsl_multimin_test_size(size,
m_epsabs);
93 if (status != GSL_CONTINUE) {
size_t m_size
Maximum size of the store.
CostFunctions::CostFuncFitting & m_costFunction
The cost function.
#define DECLARE_FUNCMINIMIZER(classname, username)
Macro for declaring a new type of minimizers to be used with the FuncMinimizerFactory.
std::string m_errorString
Error string.
Implementing Simplex by wrapping the IFuncMinimizer interface around the GSL implementation of this a...
double costFunctionVal() override
Return current value of the cost function.
void clearMemory()
clear memory
gsl_vector * m_simplexStepSize
used by GSL
gsl_multimin_fminimizer * m_gslSolver
pointer to the GSL solver doing the work
~SimplexMinimizer() override
Destructor.
static double fun(const gsl_vector *x, void *params)
Used by the GSL to evaluate the function.
double m_epsabs
Absolute value of the error that is considered a fit.
gsl_vector * m_startGuess
Starting parameter values.
bool iterate(size_t) override
Do one iteration.
SimplexMinimizer(const double epsabs=1e-2)
Constructor setting a value for the relative error acceptance (default=0.01)
gsl_multimin_function gslContainer
GSL simplex minimizer container.
void resetSize(const double &size)
resets the size
double m_size
size of simplex
void initialize(API::ICostFunction_sptr function, size_t maxIterations=0) override
Initialize minimizer, i.e. pass a function to minimize.
API::ICostFunction_sptr m_costFunction
Function to minimize.
Kernel::Logger g_log("ExperimentInfo")
static logger object
std::shared_ptr< ICostFunction > ICostFunction_sptr
define a shared pointer to a cost function