Public Member Functions | Public Attributes | Protected Attributes | Private Member Functions | List of all members
o2scl::mmin_bfgs2< func_t, vec_t, dfunc_t, auto_grad_t, def_auto_grad_t > Class Template Reference

Multidimensional minimization by the BFGS algorithm (GSL) More...

#include <mmin_bfgs2.h>

Inheritance diagram for o2scl::mmin_bfgs2< func_t, vec_t, dfunc_t, auto_grad_t, def_auto_grad_t >:
o2scl::mmin_base< func_t, func_t, vec_t >

Public Member Functions

virtual int iterate ()
 Perform an iteration.
 
virtual const char * type ()
 Return string denoting type("mmin_bfgs2")
 
virtual int allocate (size_t n)
 Allocate the memory.
 
virtual int free ()
 Free the allocated memory.
 
int restart ()
 Reset the minimizer to use the current point as a new starting point.
 
virtual int set (vec_t &x, double u_step_size, double tol_u, func_t &ufunc)
 Set the function and initial guess.
 
virtual int set_de (vec_t &x, double u_step_size, double tol_u, func_t &ufunc, dfunc_t &udfunc)
 Set the function, the gradient, and the initial guess.
 
virtual int mmin (size_t nn, vec_t &xx, double &fmin, func_t &ufunc)
 Calculate the minimum min of func w.r.t the array x of size nn.
 
virtual int mmin_de (size_t nn, vec_t &xx, double &fmin, func_t &ufunc, dfunc_t &udfunc)
 Calculate the minimum min of func w.r.t the array x of size nn.
 
- Public Member Functions inherited from o2scl::mmin_base< func_t, func_t, vec_t >
 mmin_base (const mmin_base< func_t, func_t, vec_t > &mb)
 Copy constructor.
 
int set_verbose_stream (std::ostream &out, std::istream &in)
 Set streams for verbose I/O. More...
 
virtual int mmin_de (size_t nvar, vec_t &x, double &fmin, func_t &func, func_t &dfunc)
 Calculate the minimum min of func w.r.t. the array x of size nvar with gradient dfunc.
 
int print_iter (size_t nv, vec2_t &x, double y, int iter, double value, double limit, std::string comment)
 Print out iteration information. More...
 
const char * type ()
 Return string denoting type ("mmin_base")
 
mmin_base< func_t, func_t, vec_t > & operator= (const mmin_base< func_t, func_t, vec_t > &mb)
 Copy constructor from operator=.
 

Public Attributes

double step_size
 The size of the first trial step (default 0.01)
 
double lmin_tol
 The tolerance for the 1-dimensional minimizer.
 
def_auto_grad_t def_grad
 Default automatic gradient object.
 
- Public Attributes inherited from o2scl::mmin_base< func_t, func_t, vec_t >
int verbose
 Output control.
 
int ntrial
 Maximum number of iterations.
 
double tol_rel
 Function value tolerance.
 
double tol_abs
 The independent variable tolerance.
 
int last_ntrial
 The number of iterations for in the most recent minimization.
 
bool err_nonconv
 If true, call the error handler if the routine does not "converge".
 

Protected Attributes

mmin_linmin_gsl lm
 The line minimizer.
 
size_t dim
 Memory size.
 
auto_grad_t * agrad
 Automatic gradient object.
 
The original variables from the GSL state structure
int iter
 
double step
 
double g0norm
 
double pnorm
 
double delta_f
 
double fp0
 
vec_t x0
 
vec_t g0
 
vec_t p
 
vec_t dx0
 
vec_t dg0
 
mmin_wrapper_gsl< func_t, vec_t, dfunc_t, auto_grad_t > wrap
 
double rho
 
double sigma
 
double tau1
 
double tau2
 
double tau3
 
int order
 
Store the arguments to set() so we can use them for iterate()
vec_t * st_x
 
vec_t st_dx
 
vec_t st_grad
 
double st_f
 
- Protected Attributes inherited from o2scl::mmin_base< func_t, func_t, vec_t >
std::ostream * outs
 Stream for verbose output.
 
std::istream * ins
 Stream for verbose input.
 

Private Member Functions

 mmin_bfgs2 (const mmin_bfgs2< func_t, vec_t, dfunc_t, auto_grad_t, def_auto_grad_t > &)
 
mmin_bfgs2< func_t, vec_t, dfunc_t, auto_grad_t, def_auto_grad_t > & operator= (const mmin_bfgs2< func_t, vec_t, dfunc_t, auto_grad_t, def_auto_grad_t > &)
 

Detailed Description

template<class func_t = multi_funct11, class vec_t = boost::numeric::ublas::vector<double>, class dfunc_t = grad_funct11, class auto_grad_t = gradient<multi_funct11,boost::numeric::ublas::vector<double> >, class def_auto_grad_t = gradient_gsl<multi_funct11,boost::numeric::ublas::vector<double> >>
class o2scl::mmin_bfgs2< func_t, vec_t, dfunc_t, auto_grad_t, def_auto_grad_t >

The functions mmin() and mmin_de() min a given function until the gradient is smaller than the value of mmin::tol_rel (which defaults to $ 10^{-4} $ ).

See an example for the usage of this class in Multidimensional minimizer example .

This class includes the optimizations from the GSL minimizer vector_bfgs2.

Default template arguments

Todo:
While BFGS does well in the ex_mmin example with the initial guess of $ (1,0,7\pi) $ it seems to converge more poorly for the spring function than the other minimizers with other initial guesses, and I think this will happen in the GSL versions too. I need to examine this more closely with some code designed to clearly show this.
Idea for Future:
When the bfgs2 line minimizer returns a zero status, the minimization fails. When err_nonconv is false, the minimizer isn't able to update the x vector so the mmin() function doesn't return the best minimum obtained so far. This is a bit confusing, and could be improved.

Definition at line 387 of file mmin_bfgs2.h.


The documentation for this class was generated from the following file:

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).