queso-0.53.0
|
A base class for handling optimisation of scalar functions. More...
#include <GslOptimizer.h>
Public Types | |
enum | SolverType { FLETCHER_REEVES_CG, POLAK_RIBIERE_CG, BFGS, BFGS2, STEEPEST_DESCENT, NELDER_MEAD, NELDER_MEAD2, NELDER_MEAD2_RAND } |
Public Member Functions | |
GslOptimizer (const BaseScalarFunction< GslVector, GslMatrix > &objectiveFunction) | |
Constructs an object that will maximize a scalar function. More... | |
virtual | ~GslOptimizer () |
Destructor. More... | |
virtual void | minimize (OptimizerMonitor *monitor=NULL) |
Minimize the objective function, starting at m_initialPoint . More... | |
const BaseScalarFunction < GslVector, GslMatrix > & | objectiveFunction () const |
Returns the objective function. More... | |
void | setInitialPoint (const GslVector &intialPoint) |
Set the point at which the optimization starts. More... | |
const GslVector & | minimizer () const |
Return the point that minimizes the objective function. More... | |
void | set_solver_type (SolverType solver) |
void | set_solver_type (std::string &solver) |
SolverType | string_to_enum (std::string &solver) |
void | set_step_size (const GslVector &step_size) |
Sets step size used in gradient-free solvers. More... | |
void | set_step_size (double step_size) |
Sets step size used in gradient-based solvers. More... | |
void | set_line_tol (double tol) |
Set GSL line minimization tolerance. More... | |
Public Member Functions inherited from QUESO::BaseOptimizer | |
BaseOptimizer () | |
Default constructor. More... | |
virtual | ~BaseOptimizer () |
Destructor. More... | |
unsigned int | getMaxIterations () const |
Returns the maximum number of iterations the optimizer will do. More... | |
double | getTolerance () const |
Returns the tolerance used to test for an extremum in the optimizer. More... | |
double | getFiniteDifferenceStepSize () const |
Returns the step size used in the finite difference formula. More... | |
void | setMaxIterations (unsigned int maxIterations) |
Sets the maximum number of iterations to be used by the optimizer. More... | |
void | setTolerance (double tolerance) |
Sets the tolerance the optimizer will use to test for an extremum. More... | |
void | setFiniteDifferenceStepSize (double h) |
Sets the step to use in the finite difference derivative. More... | |
Private Member Functions | |
bool | solver_needs_gradient (SolverType solver) |
Helper function. More... | |
void | minimize_with_gradient (unsigned int dim, OptimizerMonitor *monitor) |
void | minimize_no_gradient (unsigned int dim, OptimizerMonitor *monitor) |
Private Attributes | |
const BaseScalarFunction < GslVector, GslMatrix > & | m_objectiveFunction |
GslVector * | m_initialPoint |
GslVector * | m_minimizer |
SolverType | m_solver_type |
GslVector | m_fstep_size |
For use in gradient-free algorithms. More... | |
double | m_fdfstep_size |
For use in gradient-based algorithms. More... | |
double | m_line_tol |
Line minimization tolerance in gradient-based algorithms. More... | |
Additional Inherited Members | |
Protected Attributes inherited from QUESO::BaseOptimizer | |
unsigned int | m_maxIterations |
double | m_tolerance |
double | m_finiteDifferenceStepSize |
A base class for handling optimisation of scalar functions.
WRITE DOCS HERE
Definition at line 50 of file GslOptimizer.h.
Enumerator | |
---|---|
FLETCHER_REEVES_CG | |
POLAK_RIBIERE_CG | |
BFGS | |
BFGS2 | |
STEEPEST_DESCENT | |
NELDER_MEAD | |
NELDER_MEAD2 | |
NELDER_MEAD2_RAND |
Definition at line 71 of file GslOptimizer.h.
QUESO::GslOptimizer::GslOptimizer | ( | const BaseScalarFunction< GslVector, GslMatrix > & | objectiveFunction | ) |
Constructs an object that will maximize a scalar function.
The function objectiveFunction
is the function that will be maximized.
Definition at line 157 of file GslOptimizer.C.
References QUESO::GslVector::cwSet(), m_fstep_size, and m_minimizer.
|
virtual |
|
virtual |
Minimize the objective function, starting at m_initialPoint
.
m_initialPoint is handled in the derived class
Implements QUESO::BaseOptimizer.
Definition at line 182 of file GslOptimizer.C.
References dim, m_initialPoint, m_objectiveFunction, m_solver_type, minimize_no_gradient(), minimize_with_gradient(), queso_error, and solver_needs_gradient().
Referenced by QUESO::StatisticalInverseProblem< P_V, P_M >::solveWithBayesMetropolisHastings().
|
private |
Definition at line 363 of file GslOptimizer.C.
References QUESO::OptimizerMonitor::append(), BFGS, BFGS2, QUESO::c_evaluate(), dim, FLETCHER_REEVES_CG, QUESO::BaseOptimizer::getMaxIterations(), QUESO::BaseOptimizer::getTolerance(), m_fstep_size, m_initialPoint, m_objectiveFunction, m_solver_type, NELDER_MEAD, NELDER_MEAD2, NELDER_MEAD2_RAND, POLAK_RIBIERE_CG, queso_error, and STEEPEST_DESCENT.
Referenced by minimize().
|
private |
Definition at line 266 of file GslOptimizer.C.
References QUESO::OptimizerMonitor::append(), BFGS, BFGS2, QUESO::c_evaluate(), QUESO::c_evaluate_derivative(), QUESO::c_evaluate_with_derivative(), dim, FLETCHER_REEVES_CG, QUESO::BaseOptimizer::getMaxIterations(), m_fdfstep_size, m_initialPoint, m_line_tol, m_objectiveFunction, m_solver_type, NELDER_MEAD, NELDER_MEAD2, NELDER_MEAD2_RAND, POLAK_RIBIERE_CG, queso_error, and STEEPEST_DESCENT.
Referenced by minimize().
const GslVector & QUESO::GslOptimizer::minimizer | ( | ) | const |
Return the point that minimizes the objective function.
This state will be filled with GSL_NAN if, for some reason, the optimization failed
Definition at line 225 of file GslOptimizer.C.
References m_minimizer.
Referenced by QUESO::StatisticalInverseProblem< P_V, P_M >::solveWithBayesMetropolisHastings().
const BaseScalarFunction< GslVector, GslMatrix > & QUESO::GslOptimizer::objectiveFunction | ( | ) | const |
Returns the objective function.
Definition at line 211 of file GslOptimizer.C.
References m_objectiveFunction.
Referenced by QUESO::c_evaluate(), and QUESO::c_evaluate_derivative().
void QUESO::GslOptimizer::set_line_tol | ( | double | tol | ) |
Set GSL line minimization tolerance.
Applicable only to gradient-based solvers. Default is 0.1, as recommended by GSL documentation. See GSL documentation for more details.
void QUESO::GslOptimizer::set_solver_type | ( | SolverType | solver | ) |
Definition at line 230 of file GslOptimizer.C.
References m_solver_type.
Referenced by set_solver_type().
void QUESO::GslOptimizer::set_solver_type | ( | std::string & | solver | ) |
Definition at line 515 of file GslOptimizer.C.
References set_solver_type(), and string_to_enum().
Sets step size used in gradient-free solvers.
By default, the step size used will be a vector of 0.1. Use this method to reset the step_size to the desired values.
Definition at line 465 of file GslOptimizer.C.
References m_fstep_size.
void QUESO::GslOptimizer::set_step_size | ( | double | step_size | ) |
Sets step size used in gradient-based solvers.
GSL doesn't document this parameter well, but it seems to be related to the line search, so we default to 1.0 for full step.
Definition at line 470 of file GslOptimizer.C.
References m_fdfstep_size.
Set the point at which the optimization starts.
Definition at line 217 of file GslOptimizer.C.
References m_initialPoint, and QUESO::GslVector::sizeLocal().
Referenced by QUESO::StatisticalInverseProblem< P_V, P_M >::solveWithBayesMetropolisHastings().
|
private |
Helper function.
Definition at line 235 of file GslOptimizer.C.
References BFGS, BFGS2, FLETCHER_REEVES_CG, NELDER_MEAD, NELDER_MEAD2, NELDER_MEAD2_RAND, POLAK_RIBIERE_CG, queso_error, and STEEPEST_DESCENT.
Referenced by minimize().
GslOptimizer::SolverType QUESO::GslOptimizer::string_to_enum | ( | std::string & | solver | ) |
Definition at line 475 of file GslOptimizer.C.
References BFGS, BFGS2, FLETCHER_REEVES_CG, m_objectiveFunction, NELDER_MEAD, NELDER_MEAD2, NELDER_MEAD2_RAND, POLAK_RIBIERE_CG, queso_error, and STEEPEST_DESCENT.
Referenced by set_solver_type().
|
private |
For use in gradient-based algorithms.
Definition at line 131 of file GslOptimizer.h.
Referenced by minimize_with_gradient(), and set_step_size().
|
private |
For use in gradient-free algorithms.
Definition at line 128 of file GslOptimizer.h.
Referenced by GslOptimizer(), minimize_no_gradient(), and set_step_size().
|
private |
Definition at line 122 of file GslOptimizer.h.
Referenced by minimize(), minimize_no_gradient(), minimize_with_gradient(), setInitialPoint(), and ~GslOptimizer().
|
private |
Line minimization tolerance in gradient-based algorithms.
Definition at line 134 of file GslOptimizer.h.
Referenced by minimize_with_gradient().
|
private |
Definition at line 123 of file GslOptimizer.h.
Referenced by GslOptimizer(), and minimizer().
|
private |
Definition at line 120 of file GslOptimizer.h.
Referenced by minimize(), minimize_no_gradient(), minimize_with_gradient(), objectiveFunction(), and string_to_enum().
|
private |
Definition at line 125 of file GslOptimizer.h.
Referenced by minimize(), minimize_no_gradient(), minimize_with_gradient(), and set_solver_type().