Base class for optimization methods. More...
#include <Opt.h>
Public Member Functions | |
Manipulators. | |
void | set_max_function_calls (const int max_function_calls) |
Set the maximum number of function call allowed per optimization. | |
void | reset_num_function_calls () |
Reset the number of function calls to zero. | |
void | set_are_checking_function_calls (const bool are_checking) |
Set whether we are checking the number of function calls. | |
Protected Types | |
typedef Function | function_type |
The function type. | |
typedef T | number_type |
The number type. | |
typedef Point | point_type |
A point in N dimensions. | |
Protected Member Functions | |
Constructors etc. | |
Opt (const function_type &function, const int max_function_calls=10000, const bool are_checking_function_calls=true) | |
Construct from the objective function. | |
virtual | ~Opt () |
Destructor. | |
Calling the objective function. | |
number_type | evaluate_function (const point_type &x) |
Evaluate the objective function and return the result. | |
void | evaluate_gradient (const point_type &x, point_type &gradient) |
Evaluate the gradient. | |
void | evaluate_numeric_gradient (const point_type &x, point_type &gradient, const number_type delta=0.0) |
Numerically evaluate the gradient. | |
Protected Attributes | |
const function_type & | _function |
The objective function. | |
int | _max_function_calls |
The maximum allowed number of function calls. | |
int | _num_function_calls |
The number of function calls required to find the minimum. | |
bool | _are_checking_function_calls |
If we are checking the number of function calls. | |
Accessors. | |
| |
static int | dimension () |
Return the dimension, N. | |
const function_type & | function () const |
Return a constant reference to the objective function. | |
int | max_function_calls () |
Return the maximum allowed number of function calls. | |
int | num_function_calls () const |
Return the number of function calls required to find the minimum. |
Base class for optimization methods.
N | is the problem dimension. | |
Function | is the functor to minimize. | |
T | is the number type. By default it is Function::result_type; | |
Point | is the point type. By default it is Function::argument_type; |
number_type Opt< N, Function, T, Point >::evaluate_function | ( | const point_type & | x | ) | [inline, protected] |
Evaluate the objective function and return the result.
Increment the count of the number of function calls.
Reimplemented in QuasiNewton< N, Function, T, Point >, CoordinateDescent< N, function_with_penalty_type, number_type, point_type >, and QuasiNewton< N, function_with_penalty_type, number_type, point_type >.
Referenced by CoordinateDescent< N, function_with_penalty_type, number_type, point_type >::evaluate_function().
void Opt< N, Function, T, Point >::evaluate_gradient | ( | const point_type & | x, | |
point_type & | gradient | |||
) | [inline, protected] |
Evaluate the gradient.
Increment the count of the number of function calls.
Reimplemented in QuasiNewton< N, Function, T, Point >, and QuasiNewton< N, function_with_penalty_type, number_type, point_type >.
void Opt< N, Function, T, Point >::evaluate_numeric_gradient | ( | const point_type & | x, | |
point_type & | gradient, | |||
const number_type | delta = 0.0 | |||
) | [inline, protected] |
Numerically evaluate the gradient.
Increment the count of the number of function calls.
Reimplemented in QuasiNewton< N, Function, T, Point >, and QuasiNewton< N, function_with_penalty_type, number_type, point_type >.