1 #ifndef theplu_yat_utility_multi_minimizer_derivative 2 #define theplu_yat_utility_multi_minimizer_derivative 21 #include "multivariable/df.h" 22 #include "multivariable/f.h" 24 #include <yat/utility/Vector.h> 25 #include <yat/utility/VectorMutable.h> 28 #include <gsl/gsl_multimin.h> 56 unsigned int epochs(
void)
const;
94 virtual bool operator()(
const gsl_multimin_fdfminimizer*)=0;
113 bool operator()(
const gsl_multimin_fdfminimizer*);
144 unsigned int max_epochs);
155 const gsl_multimin_fdfminimizer_type* type_;
156 unsigned int epochs_;
160 void operator()(gsl_multimin_fdfminimizer*)
const;
162 std::unique_ptr<gsl_multimin_fdfminimizer, GslFree> solver_;
177 (*this)(x, func, std::move(stopper), max_epochs);
186 unsigned int max_epochs)
188 assert(size_ == x.
size());
189 gsl_multimin_function_fdf gsl_func;
191 gsl_func.f = multivariable::f<FUNC>;
192 gsl_func.df = multivariable::df<FUNC>;
193 gsl_func.fdf = multivariable::fdf<FUNC>;
194 gsl_func.params = &func;
196 gsl_multimin_fdfminimizer_set(solver_.get(), &gsl_func, x.
gsl_vector_p(),
200 for (epochs_=0; epochs_<max_epochs; ++epochs_) {
201 status = gsl_multimin_fdfminimizer_iterate(solver_.get());
203 if (status == GSL_ENOPROG)
208 if (stopper(solver_.get()))
Class for errors reported from underlying GSL calls.
Definition: Exception.h:102
The Department of Theoretical Physics namespace as we define it.
double tolerance(void) const
unsigned int epochs(void) const
Number of epochs (iterations) used in last minimisation.
Definition: MultiMinimizerDerivative.h:100
T max(const T &a, const T &b, const T &c)
Definition: stl_utility.h:699
gsl_vector * gsl_vector_p(void)
Read-only view.
Definition: VectorConstView.h:56
bool operator()(const gsl_multimin_fdfminimizer *)
Wrapper class around gsl_multimin_fdfminimizer in GSL.
Definition: MultiMinimizerDerivative.h:43
This is the mutable interface to GSL vector.
Definition: VectorMutable.h:56
Definition: MultiMinimizerDerivative.h:90
void operator()(yat::utility::VectorMutable &, FUNC &func, MultiMinimizerDerivative::Stopper &&stopper)
Definition: MultiMinimizerDerivative.h:172
MultiMinimizerDerivative(const MultiMinimizerDerivative &)=delete
Copy is not allowed.
virtual bool operator()(const gsl_multimin_fdfminimizer *)=0
return true is search should stop
double step_size(void) const
MultiMinimizerDerivative & operator=(const MultiMinimizerDerivative &)=delete
Assignment not allowed.