KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | List of all members
kjb::Gsl_Multimin_fdf Class Reference

Wrapper for GSL's multidimensional minimizer, when you have gradient. More...

#include <gsl_multimin.h>

Public Member Functions

 Gsl_Multimin_fdf (const gsl_multimin_fdfminimizer_type *type, gsl_multimin_function_fdf *fdf, const gsl_vector *x0, double step_size, double tol, bool verbosity=true)
 ctor builds the minimizer by allocating and setting up params More...
 
int iterate ()
 Perform one iteration of the minimizer. More...
 
gsl_vectorargmin () const
 query the current best argmin of the minimizer More...
 
double min () const
 query the current best min value of the function to be minimized More...
 
gsl_vectorgradient () const
 query the gradient of the function at the current location More...
 
const char * name () const
 access a string describing the algorithm More...
 
int test_gradient (double epsabs) const
 check the magnitude the gradient of the function now More...
 
void restart ()
 Restart the minimizer at the current argmin value. More...
 
void swap (Gsl_Multimin_fdf &that)
 Swap the contents of this minimizer and another (fast). More...
 
bool verbosity (bool v)
 Alter the verbosity attribute of the object. More...
 

Detailed Description

Wrapper for GSL's multidimensional minimizer, when you have gradient.

GSL is the GNU Scientific Library.

This object is not copyable or assignable, but it does have a swap() method.

Constructor & Destructor Documentation

kjb::Gsl_Multimin_fdf::Gsl_Multimin_fdf ( const gsl_multimin_fdfminimizer_type type,
gsl_multimin_function_fdf fdf,
const gsl_vector x0,
double  step_size,
double  tol,
bool  verbosity = true 
)
inline

ctor builds the minimizer by allocating and setting up params

Parameters
typeindicates the minimization algorithm you would like to use; supported choices are listed at the link below: http://www.gnu.org/software/gsl/manual/html_node/Multimin-Algorithms-with-Derivatives.html
x0Initial vector location in domain from which search begins.
step_sizeplease see the GSL documentation, or use clarivoyance, to determine what this should be set to; apparently it controls the size of (only) the first step.
tolplease see the GSL documentation for this one too.
verbosityIf true, then a bad iterate() call will emit a message to stderr.
Exceptions
KJB_errorif the input is bad: e.g., x0 equal to NULL or cannot allocate memory.

Member Function Documentation

gsl_vector* kjb::Gsl_Multimin_fdf::argmin ( ) const
inline

query the current best argmin of the minimizer

gsl_vector* kjb::Gsl_Multimin_fdf::gradient ( ) const
inline

query the gradient of the function at the current location

int kjb::Gsl_Multimin_fdf::iterate ( )
inline

Perform one iteration of the minimizer.

Returns
GSL_SUCCESS if successful, or a GSL error code otherwise: http://www.gnu.org/software/gsl/manual/html_node/Error-Codes.html

If you want to throw an exception in the case of a failed iteration, consider using the GSL_ETX macro.

double kjb::Gsl_Multimin_fdf::min ( ) const
inline

query the current best min value of the function to be minimized

const char* kjb::Gsl_Multimin_fdf::name ( ) const
inline

access a string describing the algorithm

void kjb::Gsl_Multimin_fdf::restart ( )
inline

Restart the minimizer at the current argmin value.

Exceptions
KJB_errorif an error occurs (not sure what that would be)

Bad news: If you want to restart the whole thing at a new point in the domain, I'm afraid you must instantiate a new object. If you alter argmin() (which you CAN do) then subsequent calls to iterate() will tell you that you are not making progress towards the solution.

Hint: the swap() method helps you resume work after instantiating a new object for the above purpose.

void kjb::Gsl_Multimin_fdf::swap ( Gsl_Multimin_fdf that)
inline

Swap the contents of this minimizer and another (fast).

This method is useful if, for example, you want to restart the minimizer at a new location; just instantiate a new minimizer object at the new location and swap() it with the old minimizer object.

int kjb::Gsl_Multimin_fdf::test_gradient ( double  epsabs) const
inline

check the magnitude the gradient of the function now

Returns
GSL_SUCCESS if gradient magnitude is less than epsabs, or GSL_CONTINUE otherwise.
bool kjb::Gsl_Multimin_fdf::verbosity ( bool  v)
inline

Alter the verbosity attribute of the object.

Returns
the previous value of the verbosity attribute. Currently if the object has true-verbosity then you will get an error message if iterate() fails.

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