anneal_mt Class Template Reference

Multidimensional minimization by simulated annealing (Boost multi-threaded version). More...

#include <anneal_mt.h>


Detailed Description

template<class param_t, class param_vec_t = std::vector<param_t>, class func_t = multi_funct<param_t>, class vec_t = ovector_base, class alloc_vec_t = ovector, class alloc_t = ovector_alloc, class rng_t = gsl_rnga>
class anneal_mt< param_t, param_vec_t, func_t, vec_t, alloc_vec_t, alloc_t, rng_t >

Multidimensional minimization by simulated annealing (Boost multi-threaded version).

See also the unthreaded version of this class in gsl_anneal.

Idea for future:
There may be a good way to remove the function indirection here to make this class a bit faster.

Definition at line 51 of file anneal_mt.h.


Public Member Functions

virtual const char * type ()
 Return string denoting type ("anneal_mt").
virtual int print_iter (size_t nv, vec_t &xx, double y, int iter, double tptr, std::string comment)
 Print out iteration information.
Basic usage
virtual int mmin (size_t nv, vec_t &x0, double &fmin, func_t &func, size_t np, param_vec_t &pars)
 Calculate the minimum fmin of func w.r.t the array x0 of size nv using np threads.
Iteration control
virtual int next (size_t nv, vec_t &x_old, double min_old, vec_t &x_new, double min_new, double &T, size_t n_moves, bool &finished)
 Determine how to change the minimization for the next iteration.
virtual int start (size_t nv, double &T)
 Setup initial temperature and stepsize.

Data Fields

rng_t def_rng
 The default random number generator.
Parameters
double boltz
 Boltzmann factor (default 1.0).
int ntrial
 Number of iterations.
int verbose
 Output control.
double tolx
 The independent variable tolerance.

Protected Member Functions

void func_wrapper (size_t ip)
 The function wrapper executed by thread with index ip.
virtual int allocate (size_t nv, size_t np)
 Allocate memory for a minimizer over n dimensions with stepsize step.
virtual int free (size_t np)
 Free allocated memory.
virtual int step (vec_t &sx, int nv)
 Make a step to a new attempted minimum.

Protected Attributes

std::ostream * outs
 Stream for verbose output.
std::istream * ins
 Stream for verbose input.
size_t nproc
 The number of threads to run.
param_vec_t * params
 The user-specified parameters.
size_t nvar
 The number of variables over which we minimize.
func_t * f
 The function to minimize.
alloc_t ao
 Allocation object.
size_t nstep
 Number of step sizes.
double * step_sizes
 Step sizes.
Storage for present, next, and best vectors
alloc_vec_t x
alloc_vec_t * new_x
alloc_vec_t best_x
alloc_vec_t new_E
alloc_vec_t old_x

Member Function Documentation

virtual int print_iter ( size_t  nv,
vec_t &  xx,
double  y,
int  iter,
double  tptr,
std::string  comment 
) [inline, virtual]

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.

Definition at line 247 of file anneal_mt.h.


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

Documentation generated with Doxygen and provided under the GNU Free Documentation License. See License Information for details.

Project hosting provided by SourceForge.net Logo, O2scl Sourceforge Project Page