Public Member Functions | Public Attributes | List of all members
o2scl::anneal_base< func_t, vec_t, rng_t > Class Template Referenceabstract

Simulated annealing base. More...

#include <anneal.h>

Inheritance diagram for o2scl::anneal_base< func_t, vec_t, rng_t >:
o2scl::mmin_base< func_t, func_t, vec_t > o2scl::anneal_gsl< func_t, vec_t, rng_t >

Public Member Functions

virtual int mmin (size_t nvar, vec_t &x, double &fmin, func_t &func)=0
 Calculate the minimum fmin of func w.r.t the array x of size nvar.
 
virtual int print_iter (size_t nv, vec_t &x, double y, int iter, double tptr, std::string comment)
 Print out iteration information. More...
 
virtual const char * type ()
 Return string denoting type, "anneal_base".
 
 anneal_base (const anneal_base< func_t, vec_t, rng_t > &ab)
 Copy constructor.
 
anneal_base< func_t, vec_t, rng_t > & operator= (const anneal_base< func_t, vec_t, rng_t > &ab)
 Copy constructor from operator=.
 
- 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

rng_t rng
 The default random number generator.
 
o2scl::prob_dens_uniform dist
 The random distribution 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".
 

Additional Inherited Members

- 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.
 

Detailed Description

template<class func_t = multi_funct11, class vec_t = boost::numeric::ublas::vector<double>, class rng_t = rng_gsl>
class o2scl::anneal_base< func_t, vec_t, rng_t >

The seed of the generator is not fixed initially by calls to mmin(), so if successive calls should reproduce the same results, then the random seed should be set by the user before each call.

For the algorithms here, it is important that all of the inputs x[i] to the function are scaled similarly relative to the temperature. For example, if the inputs x[i] are all of order 1, one might consider a temperature schedule which begins with $ T=1 $ .

The number of iterations at each temperature is controlled by o2scl::mmin_base::ntrial which defaults to 100.

Todo:
I'm having trouble with std::uniform_real_distribution on clang at the moment, so this class uses o2scl::prob_dens_uniform for the moment.

Definition at line 67 of file anneal.h.

Member Function Documentation

◆ print_iter()

template<class func_t = multi_funct11, class vec_t = boost::numeric::ublas::vector<double>, class rng_t = rng_gsl>
virtual int o2scl::anneal_base< func_t, vec_t, rng_t >::print_iter ( size_t  nv,
vec_t &  x,
double  y,
int  iter,
double  tptr,
std::string  comment 
)
inlinevirtual

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.

Reimplemented in o2scl::anneal_mt< func_t, vec_t, rng_t, rng_dist_t >.

Definition at line 98 of file anneal.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).