Geogram
Version 1.9.1
A programming library of geometric algorithms
|
Optimizer minimizes a multivariate function. More...
#include <geogram/numerics/optimizer.h>
Public Types | |
typedef void(* | funcgrad_callback) (index_t N, double *x, double &f, double *g) |
Optimizer callback that evaluates a function and its gradient. More... | |
typedef void(* | newiteration_callback) (index_t N, const double *x, double f, const double *g, double gnorm) |
Optimizer callback that is called at each iteration. More... | |
typedef void(* | evalhessian_callback) (index_t N, double *x, double &f, double *g, HESSIAN_MATRIX &hessian) |
Optimizer callback that evaluates a function, its gradient and its Hessian. More... | |
Public Member Functions | |
virtual void | optimize (double *x)=0 |
Minimizes a function, starting from initial value x. More... | |
void | set_N (index_t N) |
Defines the number of variables. | |
index_t | get_N () const |
Returns the number of variables. | |
void | set_M (index_t M) |
Defines the inner number of iterations. More... | |
index_t | get_M () const |
Returns the inner number of iterations. | |
void | set_max_iter (index_t maxiter) |
Defines the maximum number of iterations. | |
index_t | get_max_iter () const |
Returns the maximum number of iterations. | |
void | set_funcgrad_callback (funcgrad_callback fp) |
Defines the callback that evaluates the function to be minimized and its gradient. | |
void | set_newiteration_callback (newiteration_callback fp) |
Defines a callback that will be called at each iteration. | |
void | set_evalhessian_callback (evalhessian_callback fp) |
Defines the callback that evaluates the Hessian of function to be minimized (second order derivatives). More... | |
void | set_epsg (double eg) |
Defines the stopping criterion in terms of gradient magnitude. | |
void | set_epsf (double ef) |
Defines the stopping criterion in terms of function value. | |
void | set_epsx (double ex) |
Defines the stopping criterion in terms of variation of x. | |
void | set_verbose (bool verb) |
Enables or disables verbose logs. | |
Public Member Functions inherited from GEO::Counted | |
void | ref () const |
Increments the reference count. More... | |
void | unref () const |
Decrements the reference count. More... | |
bool | is_shared () const |
Check if the object is shared. More... | |
int | nb_refs () const |
Gets the number of references that point to this object. More... | |
Static Public Member Functions | |
static Optimizer * | create (const std::string &name="default") |
Creates an Optimizer. More... | |
Static Public Member Functions inherited from GEO::Counted | |
static void | ref (const Counted *counted) |
Increments the reference count. More... | |
static void | unref (const Counted *counted) |
Decrements the reference count. More... | |
Protected Member Functions | |
Optimizer () | |
Optimizer constructor. More... | |
~Optimizer () override | |
Optimizer destructor. | |
Protected Member Functions inherited from GEO::Counted | |
Counted () | |
Creates a reference counted object. More... | |
virtual | ~Counted () |
Destroys a reference counted object. More... | |
Protected Attributes | |
index_t | n_ |
index_t | m_ |
index_t | max_iter_ |
funcgrad_callback | funcgrad_callback_ |
newiteration_callback | newiteration_callback_ |
evalhessian_callback | evalhessian_callback_ |
double | epsg_ |
double | epsf_ |
double | epsx_ |
bool | verbose_ |
Related Functions | |
(Note that these are not member functions.) | |
typedef SmartPointer< Optimizer > | Optimizer_var |
Smart pointer that contains an Optimizer object. | |
typedef Factory0< Optimizer > | OptimizerFactory |
Optimizer Factory. More... | |
Optimizer minimizes a multivariate function.
The dimension of the problem is defined by set_N(). The multivariate function to be minimized is defined by a callback that evaluates the function and its gradient, specified by set_funcgrad_callback(). Optimizer implements the numeric part of CentroidalVoronoiTesselation.
Optimizer objects are created using method create() which uses the Factory service. New Optimizers can be implemented and registered to the factory using geo_register_Optimizer_creator().
Definition at line 77 of file optimizer.h.
typedef void(* GEO::Optimizer::evalhessian_callback) (index_t N, double *x, double &f, double *g, HESSIAN_MATRIX &hessian) |
Optimizer callback that evaluates a function, its gradient and its Hessian.
Definition at line 101 of file optimizer.h.
typedef void(* GEO::Optimizer::funcgrad_callback) (index_t N, double *x, double &f, double *g) |
Optimizer callback that evaluates a function and its gradient.
Definition at line 84 of file optimizer.h.
typedef void(* GEO::Optimizer::newiteration_callback) (index_t N, const double *x, double f, const double *g, double gnorm) |
Optimizer callback that is called at each iteration.
Definition at line 92 of file optimizer.h.
|
protected |
|
static |
Creates an Optimizer.
[in] | name | name of the Optimizer to create:
|
nullptr | if name is not a valid Optimizer algorithm name |
otherwise,a | pointer to an Optimizer object. The returned pointer must be stored in a Optimizer_var that does automatic destruction: static Optimizer * create(const std::string &name="default") Creates an Optimizer. SmartPointer< Optimizer > Optimizer_var Smart pointer that contains an Optimizer object. Definition: optimizer.h:267 |
|
pure virtual |
Minimizes a function, starting from initial value x.
[in] | x | is of size n, where n was defined with set_N() |
|
inline |
Defines the callback that evaluates the Hessian of function to be minimized (second order derivatives).
Only used in "HLBFGS_HESS" mode.
Definition at line 195 of file optimizer.h.
|
inline |
Defines the inner number of iterations.
Used by HLBFGSOptimizer.
Definition at line 147 of file optimizer.h.
|
related |
This Factory is used to create Optimizer objects. It can also be used to register new Optimizer implementations.
Definition at line 277 of file optimizer.h.
|
protected |
Error tolerance on x, f and g
Definition at line 258 of file optimizer.h.
|
protected |
Number of corrections in the BFGS scheme of Hessian approximation update
Definition at line 249 of file optimizer.h.
|
protected |
Max iterations
Definition at line 251 of file optimizer.h.
|
protected |
Size of the problem
Definition at line 244 of file optimizer.h.