Warning: this documentation for the development version is under construction.
NLopt optimization. More...
#include <NLoptSolver.hxx>
Public Member Functions | |
NLoptSolver () | |
Default constructor. | |
~NLoptSolver () | |
Destructor. | |
void | Initialize (int Nparameter, string algorithm, double parameter_tolerance=1.e-6, double cost_function_tolerance=1.e-6, int Niteration_max=-1) |
Initializations. | |
void | SetLowerBound (const Vector< double > &) |
Sets lower bounds on the parameters. | |
void | SetUpperBound (const Vector< double > &) |
Sets upper bounds on the parameters. | |
void | SetParameterTolerance (double) |
Sets the relative tolerance on the parameters. | |
void | SetCostFunctionTolerance (double) |
Sets the relative tolerance on the cost function. | |
void | SetNiterationMax (int) |
Sets the maximum number of cost function evaluations. | |
void | GetParameterTolerance (double &) const |
Gets the relative tolerance on the parameters. | |
void | GetCostFunctionTolerance (double &) const |
Gets the relative tolerance on the cost function. | |
void | GetNiterationMax (int &) const |
Gets the maximum number of cost function evaluations. | |
void | SetParameter (const Vector< double > ¶meter) |
Sets the parameters. | |
void | GetParameter (Vector< double > ¶meter) const |
Gets the parameters. | |
void | Optimize (cost_ptr cost, void *argument) |
Optimization. | |
double | GetCost () const |
Returns the value of the cost function. | |
Protected Types | |
typedef double(* | cost_ptr )(const Vector< double > &, Vector< double > &, void *) |
Protected Attributes | |
nlopt::SeldonOpt | opt_ |
NLopt optimization solver. | |
nlopt::algorithm | algorithm_ |
Optimization algorithm. | |
double | parameter_tolerance_ |
Relative tolerance on the optimization parameters. | |
double | cost_function_tolerance_ |
Relative tolerance on the cost function. | |
int | Niteration_max_ |
Maximum number of function evaluations. It is ignored if it is non-positive. | |
Vector< double > | parameter_ |
The vector that stores parameters values. Before optimization, stores the initial parameter vector; after optimization, it returns the optimized parameters. | |
Vector< double > | gradient_ |
The vector that stores gradient values. Before optimization, unspecified; after optimization, it returns the gradient vector for optimized parameters. | |
double | cost_ |
The value of cost function for given parameter values. |
NLopt optimization.
Definition at line 38 of file NLoptSolver.hxx.
double Seldon::NLoptSolver::GetCost | ( | ) | const |
Returns the value of the cost function.
This method should be called after the optimization, and it returns the value of the cost function associated with the optimized parameters.
Definition at line 314 of file NLoptSolver.cxx.
void Seldon::NLoptSolver::GetCostFunctionTolerance | ( | double & | tolerance | ) | const |
Gets the relative tolerance on the cost function.
[out] | tolerance | relative tolerance on the cost function . When the variation of the cost function, after one step of the algorithm, has changed by less than tolerance multiplied by the value of the cost function, the optimization is stopped. |
Definition at line 238 of file NLoptSolver.cxx.
void Seldon::NLoptSolver::GetNiterationMax | ( | int & | Niteration_max | ) | const |
Gets the maximum number of cost function evaluations.
[out] | Niteration_max | maximum number of cost function evaluations. |
Definition at line 248 of file NLoptSolver.cxx.
void Seldon::NLoptSolver::GetParameter | ( | Vector< double > & | parameter | ) | const |
Gets the parameters.
[out] | parameter | the parameters vector. |
Definition at line 269 of file NLoptSolver.cxx.
void Seldon::NLoptSolver::GetParameterTolerance | ( | double & | tolerance | ) | const |
Gets the relative tolerance on the parameters.
[out] | tolerance | relative tolerance on the parameters . When the variation of every parameter, after one step of the algorithm, has changed by less than tolerance multiplied by the value of the parameter, the optimization is stopped. |
Definition at line 225 of file NLoptSolver.cxx.
void Seldon::NLoptSolver::Initialize | ( | int | Nparameter, | |
string | algorithm, | |||
double | parameter_tolerance = 1.e-6 , |
|||
double | cost_function_tolerance = 1.e-6 , |
|||
int | Niteration_max = -1 | |||
) |
Initializations.
[in] | Nparameter | total number of parameters to be optimized. |
[in] | algorithm | name of the optimization algorithm, one of: GN_DIRECT, GN_DIRECT_L, GN_DIRECT_L_RAND, GN_DIRECT_NOSCAL, GN_DIRECT_L_NOSCAL, GN_DIRECT_L_RAND_NOSCAL, GN_ORIG_DIRECT, GN_ORIG_DIRECT_L, GD_STOGO, GD_STOGO_RAND, LD_LBFGS_NOCEDAL, LD_LBFGS, LN_PRAXIS, LD_VAR1, LD_VAR2, LD_TNEWTON, LD_TNEWTON_RESTART, LD_TNEWTON_PRECOND, LD_TNEWTON_PRECOND_RESTART, GN_CRS2_LM, GN_MLSL, GD_MLSL, GN_MLSL_LDS, GD_MLSL_LDS, LD_MMA, LN_COBYLA, LN_NEWUOA, LN_NEWUOA_BOUND, LN_NELDERMEAD, LN_SBPLX, LN_AUGLAG, LD_AUGLAG, LN_AUGLAG_EQ, LD_AUGLAG_EQ, LN_BOBYQA, GN_ISRES, AUGLAG, AUGLAG_EQ, G_MLSL, G_MLSL_LDS, LD_SLSQP, NUM_ALGORITHMS. |
[in] | parameter_tolerance | relative tolerance on the parameters. When the variation of the parameters, after one step of the algorithm, has changed by less than parameter_tolerance multiplied by the value of the parameters, the optimization is stopped. If you do not want to use a particular tolerance termination, you can just set that tolerance to zero and it will be ignored. |
[in] | cost_function_tolerance | relative tolerance on the cost function. When the variation of the cost function, after one step of the algorithm, has changed by less than cost_function_tolerance multiplied by the value of the cost function, the optimization is stopped. If you do not want to use a particular tolerance termination, you can just set that tolerance to zero and it will be ignored. |
[in] | Niteration_max | maximum number of cost function evaluations. It is ignored if it is non-positive. |
Definition at line 69 of file NLoptSolver.cxx.
void Seldon::NLoptSolver::Optimize | ( | cost_ptr | cost, | |
void * | argument | |||
) |
Optimization.
[in] | cost | pointer to the cost function. This function takes as first argument a 'const Vector<double>&' of parameters. The second argument of the function is a 'Vector<double>&' which must be, on exit, the gradient of the cost function. NLopt will allocate it before the call. Note that, in case a derivative-free algorithm is used, this gradient vector is empty, and the cost function is not supposed to compute it (it is thus recommended to test the length of the vector in the cost function). The third argument of the function is argument, provided as 'void *'. The cost function returns the cost value in 'double'. |
[in] | argument | third argument of the cost function. This argument is passed to the cost function after the parameters vector and the gradient. |
Definition at line 290 of file NLoptSolver.cxx.
void Seldon::NLoptSolver::SetCostFunctionTolerance | ( | double | tolerance | ) |
Sets the relative tolerance on the cost function.
[in] | tolerance | relative tolerance on the cost function. When the variation of the cost function, after one step of the algorithm, has changed by less than tolerance multiplied by the value of the cost function, the optimization is stopped. If you do not want to use a particular tolerance termination, you can just set that tolerance to zero and it will be ignored. |
Definition at line 201 of file NLoptSolver.cxx.
void Seldon::NLoptSolver::SetLowerBound | ( | const Vector< double > & | lower_bound | ) |
Sets lower bounds on the parameters.
[in] | lower_bound | the lower bound vector. |
Definition at line 159 of file NLoptSolver.cxx.
void Seldon::NLoptSolver::SetNiterationMax | ( | int | Niteration_max | ) |
Sets the maximum number of cost function evaluations.
[in] | Niteration_max | maximum number of cost function evaluations. It is ignored if it is non-positive. |
Definition at line 212 of file NLoptSolver.cxx.
void Seldon::NLoptSolver::SetParameter | ( | const Vector< double > & | parameter | ) |
Sets the parameters.
[in] | parameter | the parameters vector. |
Definition at line 258 of file NLoptSolver.cxx.
void Seldon::NLoptSolver::SetParameterTolerance | ( | double | tolerance | ) |
Sets the relative tolerance on the parameters.
[in] | tolerance | relative tolerance on the parameters. When the variation of every parameter, after one step of the algorithm, has changed by less than tolerance multiplied by the value of the parameter, the optimization is stopped. If you do not want to use a particular tolerance termination, you can just set that tolerance to zero and it will be ignored. |
Definition at line 186 of file NLoptSolver.cxx.
void Seldon::NLoptSolver::SetUpperBound | ( | const Vector< double > & | upper_bound | ) |
Sets upper bounds on the parameters.
[in] | upper_bound | the lower bound vector. |
Definition at line 170 of file NLoptSolver.cxx.