1 #ifndef theplu_yat_utility_multi_minimizer_ 2 #define theplu_yat_utility_multi_minimizer_ 25 #include "Exception.h" 26 #include "multivariable/f.h" 29 #include "yat_assert.h" 31 #include <gsl/gsl_multimin.h> 59 unsigned int epochs(
void)
const;
82 virtual bool operator()(
const gsl_multimin_fminimizer*)=0;
94 explicit Size(
double epsabs);
103 bool operator()(
const gsl_multimin_fminimizer*);
128 Stopper&& stopper,
unsigned int max_epochs);
136 MultiMinimizer(
const gsl_multimin_fminimizer_type* t,
size_t size);
138 const gsl_multimin_fminimizer_type* type_;
142 void operator()(gsl_multimin_fminimizer*)
const;
144 std::unique_ptr<gsl_multimin_fminimizer, GslFree> solver_;
146 unsigned int epochs_;
158 (*this)(x, func, std::move(stopper), max_epochs);
166 unsigned int max_epochs)
168 YAT_ASSERT(size_ == x.
size());
169 gsl_multimin_function gsl_func;
170 gsl_func.n = x.
size();
171 gsl_func.f = multivariable::f<FUNC>;
172 gsl_func.params = &func;
174 gsl_multimin_fminimizer_set(solver_.get(), &gsl_func, x.
gsl_vector_p(),
178 for (epochs_=0; epochs_<max_epochs; ++epochs_) {
179 status = gsl_multimin_fminimizer_iterate(solver_.get());
181 if (status == GSL_ENOPROG)
183 throw GSL_error(
"MultiMinimizer", status);
185 if (stopper(solver_.get()))
Definition: MultiMinimizer.h:78
Class for errors reported from underlying GSL calls.
Definition: Exception.h:102
The Department of Theoretical Physics namespace as we define it.
virtual bool operator()(const gsl_multimin_fminimizer *)=0
return true when search should stop
MultiMinimizer & operator=(const MultiMinimizer &)=delete
Assignment is not allowed.
bool operator()(const gsl_multimin_fminimizer *)
const yat::utility::Vector & step(void) const
The size of the first step.
Wrapper class around gsl_multimin_fminimizer in GSL.
Definition: MultiMinimizer.h:47
MultiMinimizer(const MultiMinimizer &)=delete
Copy is not allowed.
unsigned int epochs(void) const
Number of epochs (iterations) used in last minimisation.
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
This is the yat interface to GSL vector.
Definition: Vector.h:59
void operator()(yat::utility::VectorMutable &x, FUNC &func, Stopper &&stopper)
Definition: MultiMinimizer.h:153
This is the mutable interface to GSL vector.
Definition: VectorMutable.h:56
Definition: MultiMinimizer.h:90