Class mmin_base (o2scl)

O2scl : Class List

template<class func_t = multi_funct, class dfunc_t = func_t, class vec_t = boost::numeric::ublas::vector<double>>
class mmin_base

Multidimensional minimization [abstract base].

The template parameters: The template parameter func_t specifies the function to min and should be a class containing a definition

func_t::operator()(size_t nv, const vec_t &x, double &f);
where f is the value of the function at x , where x is a array-like class defining operator[] of size nv. The parameter dfunc_t (if used) should provide the gradient with
func_t::operator()(size_t nv, vec_t &x, vec_t &g);
where g is the gradient of the function at x.

Verbose I/O is sent through std::cout and std::cin by default, but this can be modified using set_verbose_stream(). Note that this function stores pointers to the user-specified output streams, and these pointers are not copied in child copy constructors.

Subclassed by o2scl::anneal_base< multi_funct, boost::numeric::ublas::vector< double >, o2scl::rng<> >, o2scl::anneal_base< multi_funct, boost::numeric::ublas::vector< double >, int, rng >, o2scl::diff_evo< multi_funct, boost::numeric::ublas::vector< double >, mm_funct >, o2scl::mmin_constr< multi_funct, grad_funct, ool_hfunct, boost::numeric::ublas::vector< double > >, o2scl::mmin_fix_params< multi_funct, boost::numeric::ublas::vector< double > >, 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_simp2< multi_funct, vector< double > >, o2scl::mmin_simp2< multi_funct >, o2scl::mmin_simp2< mmin_fix_params< multi_funct, boost::numeric::ublas::vector< double > >, boost::numeric::ublas::vector< double > >, o2scl::anneal_base< func_t, vec_t, rng_t >, o2scl::diff_evo< func_t, vec_t, init_funct_t >, o2scl::mmin_bfgs2< func_t, vec_t, dfunc_t, auto_grad_t, def_auto_grad_t >, o2scl::mmin_constr< func_t, dfunc_t, hfunc_t, vec_t >, o2scl::mmin_fix_params< func_t, vec_t >, o2scl::mmin_gsl_base< func_t, vec_t, dfunc_t, auto_grad_t, def_auto_grad_t >, o2scl::mmin_simp2< func_t, vec_t >

Public Functions

inline mmin_base()
inline virtual ~mmin_base()
inline int set_verbose_stream(std::ostream &out, std::istream &in)

Set streams for verbose I/O.

Note that this function stores pointers to the user-specified output streams, and these pointers are not copied in child copy constructors.

virtual int mmin(size_t nvar, vec_t &x, double &fmin, func_t &func) = 0

Calculate the minimum min of func w.r.t. the array x of size nvar.

inline virtual int mmin_de(size_t nvar, vec_t &x, double &fmin, func_t &func, dfunc_t &dfunc)

Calculate the minimum min of func w.r.t. the array x of size nvar with gradient dfunc.

template<class vec2_t>
inline int print_iter(size_t nv, vec2_t &x, double y, int iter, double value, double limit, std::string comment)

Print out iteration information.

Depending on the value of the variable verbose, this prints out the iteration information. If verbose=0, then no information is printed, while if verbose>1, then after each iteration, the present values of x and y are output to std::cout along with the iteration number. If verbose>=2 then each iteration waits for a character.

inline const char *type()

Return string denoting type (“mmin_base”)

inline mmin_base(const mmin_base<func_t, dfunc_t, vec_t> &mb)

Copy constructor.

inline mmin_base<func_t, dfunc_t, vec_t> &operator=(const mmin_base<func_t, dfunc_t, vec_t> &mb)

Copy constructor from operator=.

Public Members

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

std::ostream *outs

Stream for verbose output.

std::istream *ins

Stream for verbose input.