List of all members
o2scl::mmin_conf< func_t, vec_t, dfunc_t, auto_grad_t, def_auto_grad_t > Class Template Reference

Multidimensional minimization by the Fletcher-Reeves conjugate gradient algorithm (GSL) More...

#include <mmin_conf.h>

Inheritance diagram for o2scl::mmin_conf< func_t, vec_t, dfunc_t, auto_grad_t, def_auto_grad_t >:
o2scl::mmin_gsl_base< multi_funct, boost::numeric::ublas::vector< double >, grad_funct, gradient< multi_funct, boost::numeric::ublas::vector< double > >, gradient_gsl< multi_funct, boost::numeric::ublas::vector< double > > > o2scl::mmin_base< multi_funct, multi_funct, boost::numeric::ublas::vector< double > >

Detailed Description

template<class func_t = multi_funct, class vec_t = boost::numeric::ublas::vector<double>, class dfunc_t = grad_funct, class auto_grad_t = gradient<multi_funct, boost::numeric::ublas::vector<double> >, class def_auto_grad_t = gradient_gsl<multi_funct,boost::numeric::ublas::vector<double> >>
class o2scl::mmin_conf< func_t, vec_t, dfunc_t, auto_grad_t, def_auto_grad_t >

This class performs multidimensional minimization by the Fletcher-Reeves conjugate gradient algorithm (GSL). The functions mmin() and mmin_de() minimize a given function until the gradient is smaller than the value of mmin::tol_rel (which defaults to $ 10^{-4} $ ).

This class has a high-level interface using mmin() or mmin_de() which automatically performs the memory allocation and minimization, or a GSL-like interface using allocate(), free(), interate() and set() or set_simplex().

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

Default template arguments

Note that the state variable max_iter has not been included here, because it was not really used in the original GSL code for these minimizers.

Definition at line 409 of file mmin_conf.h.

Public Member Functions

GSL-like lower level interface
virtual int iterate ()
 Perform an iteration.
 
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. More...
 
virtual int set_de (vec_t &x, double u_step_size, double tol_u, func_t &ufunc, dfunc_t &udfunc)
 Set the function and initial guess.
 
- Public Member Functions inherited from o2scl::mmin_gsl_base< multi_funct, boost::numeric::ublas::vector< double >, grad_funct, gradient< multi_funct, boost::numeric::ublas::vector< double > >, gradient_gsl< multi_funct, boost::numeric::ublas::vector< double > > >
int base_set (multi_funct &ufunc, gradient< multi_funct, boost::numeric::ublas::vector< double > > &u_def_grad)
 Set the function.
 
int base_set_de (multi_funct &ufunc, grad_funct &udfunc)
 Set the function and the gradient.
 
int base_allocate (size_t nn)
 Allocate memory.
 
int base_free ()
 Clear allocated memory.
 
- Public Member Functions inherited from o2scl::mmin_base< multi_funct, multi_funct, boost::numeric::ublas::vector< double > >
 mmin_base (const mmin_base< multi_funct, multi_funct, boost::numeric::ublas::vector< double > > &mb)
 Copy constructor.
 
int set_verbose_stream (std::ostream &out, std::istream &in)
 Set streams for verbose I/O. More...
 
virtual int mmin (size_t nvar, boost::numeric::ublas::vector< double > &x, double &fmin, multi_funct &func)=0
 Calculate the minimum min of func w.r.t. the array x of size nvar.
 
virtual int mmin_de (size_t nvar, boost::numeric::ublas::vector< double > &x, double &fmin, multi_funct &func, multi_funct &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< multi_funct, multi_funct, boost::numeric::ublas::vector< double > > & operator= (const mmin_base< multi_funct, multi_funct, boost::numeric::ublas::vector< double > > &mb)
 Copy constructor from operator=.
 

Protected Attributes

The original variables from the GSL state structure
int iter
 Iteration number.
 
double step
 Stepsize.
 
double tol
 Tolerance.
 
vec_t x1
 Desc.
 
vec_t dx1
 Desc.
 
vec_t x2
 Desc.
 
double pnorm
 Desc.
 
vec_t p
 Desc.
 
double g0norm
 Desc.
 
vec_t g0
 Desc.
 
- Protected Attributes inherited from o2scl::mmin_gsl_base< multi_funct, boost::numeric::ublas::vector< double >, grad_funct, gradient< multi_funct, boost::numeric::ublas::vector< double > >, gradient_gsl< multi_funct, boost::numeric::ublas::vector< double > > >
multi_functfunc
 User-specified function.
 
grad_functgrad
 User-specified gradient.
 
gradient< multi_funct, boost::numeric::ublas::vector< double > > * agrad
 Automatic gradient object.
 
bool grad_given
 If true, a gradient has been specified.
 
size_t dim
 Memory size.
 
- Protected Attributes inherited from o2scl::mmin_base< multi_funct, multi_funct, boost::numeric::ublas::vector< double > >
std::ostream * outs
 Stream for verbose output.
 
std::istream * ins
 Stream for verbose input.
 

Store the arguments to set() so we can use them for iterate()

vec_t ugx
 Proposed minimum.
 
vec_t ugg
 Gradient.
 
vec_t udx
 Proposed step.
 
double it_min
 Desc.
 
double lmin_tol
 Tolerance for the line minimization (default $ 10^{-4} $)
 
double step_size
 Size of the initial step (default 0.01)
 
 mmin_conf ()
 
virtual ~mmin_conf ()
 

Basic usage

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 nvar.
 
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 nvar.
 
virtual const char * type ()
 Return string denoting type("mmin_conf")
 
 mmin_conf (const mmin_conf< func_t, vec_t, dfunc_t, auto_grad_t, def_auto_grad_t > &)
 
mmin_conf< func_t, vec_t, dfunc_t, auto_grad_t, def_auto_grad_t > & operator= (const mmin_conf< func_t, vec_t, dfunc_t, auto_grad_t, def_auto_grad_t > &)
 

Additional Inherited Members

- Public Attributes inherited from o2scl::mmin_gsl_base< multi_funct, boost::numeric::ublas::vector< double >, grad_funct, gradient< multi_funct, boost::numeric::ublas::vector< double > >, gradient_gsl< multi_funct, boost::numeric::ublas::vector< double > > >
double deriv_h
 Stepsize for finite-differencing ( default $ 10^{-4} $ )
 
int nmaxiter
 Maximum iterations for line minimization (default 10)
 
gradient_gsl< multi_funct, boost::numeric::ublas::vector< double > > def_grad
 Default automatic gradient object.
 
- Public Attributes inherited from o2scl::mmin_base< multi_funct, multi_funct, boost::numeric::ublas::vector< double > >
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 Types inherited from o2scl::mmin_gsl_base< multi_funct, boost::numeric::ublas::vector< double >, grad_funct, gradient< multi_funct, boost::numeric::ublas::vector< double > >, gradient_gsl< multi_funct, boost::numeric::ublas::vector< double > > >
typedef boost::numeric::ublas::vector< double > ubvector
 
typedef boost::numeric::ublas::matrix< double > ubmatrix
 
- Protected Member Functions inherited from o2scl::mmin_gsl_base< multi_funct, boost::numeric::ublas::vector< double >, grad_funct, gradient< multi_funct, boost::numeric::ublas::vector< double > >, gradient_gsl< multi_funct, boost::numeric::ublas::vector< double > > >
void take_step (const boost::numeric::ublas::vector< double > &x, const boost::numeric::ublas::vector< double > &px, double stepx, double lambda, boost::numeric::ublas::vector< double > &x1x, boost::numeric::ublas::vector< double > &dx)
 Take a step.
 
void intermediate_point (const boost::numeric::ublas::vector< double > &x, const boost::numeric::ublas::vector< double > &px, double lambda, double pg, double stepa, double stepc, double fa, double fc, boost::numeric::ublas::vector< double > &x1x, boost::numeric::ublas::vector< double > &dx, boost::numeric::ublas::vector< double > &gradient, double *stepx, double *f)
 Line minimization. More...
 
void min (const boost::numeric::ublas::vector< double > &x, const boost::numeric::ublas::vector< double > &xp, double lambda, double stepa, double stepb, double stepc, double fa, double fb, double fc, double xtol, boost::numeric::ublas::vector< double > &x1x, boost::numeric::ublas::vector< double > &dx1x, boost::numeric::ublas::vector< double > &x2x, boost::numeric::ublas::vector< double > &dx2x, boost::numeric::ublas::vector< double > &gradient, double *xstep, double *f, double *gnorm_u)
 Perform the minimization. More...
 

Member Function Documentation

◆ set()

template<class func_t = multi_funct, class vec_t = boost::numeric::ublas::vector<double>, class dfunc_t = grad_funct, class auto_grad_t = gradient<multi_funct, boost::numeric::ublas::vector<double> >, class def_auto_grad_t = gradient_gsl<multi_funct,boost::numeric::ublas::vector<double> >>
virtual int o2scl::mmin_conf< func_t, vec_t, dfunc_t, auto_grad_t, def_auto_grad_t >::set ( vec_t &  x,
double  u_step_size,
double  tol_u,
func_t &  ufunc 
)
inlinevirtual

Evaluate the function and its gradient

Definition at line 608 of file mmin_conf.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).