queso-0.57.1
|
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... | |
GslOptimizer (OptimizerOptions options, 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... | |
virtual std::string | getSolverType () const |
Gets the algorithm to use for minimisation. More... | |
virtual double | getFstepSize () const |
Gets the step size to use in gradient-free solvers. More... | |
virtual double | getFdfstepSize () const |
Gets the step to use in gradient-based solvers. More... | |
virtual double | getLineTolerance () const |
Gets the tolerance to use for line minimisation. More... | |
virtual void | setSolverType (std::string solverType) |
Sets the algorithm to use for minimisation. More... | |
virtual void | setFstepSize (double fstepSize) |
Sets the step size to use in gradient-free solvers. More... | |
virtual void | setFdfstepSize (double fdfstepSize) |
Sets the step to use in gradient-based solvers. More... | |
virtual void | setLineTolerance (double lineTolerance) |
Sets the tolerance to use for line minimisation. More... | |
Public Member Functions inherited from QUESO::BaseOptimizer | |
BaseOptimizer () | |
Default constructor. More... | |
BaseOptimizer (OptimizerOptions options) | |
Constructor that takes an options object. 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 |
std::string | m_solverType |
double | m_fstepSize |
double | m_fdfstepSize |
double | m_lineTolerance |
ScopedPtr< OptimizerOptions >::Type | m_optionsObj |
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 82 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 155 of file GslOptimizer.C.
References QUESO::GslVector::cwSet(), getFstepSize(), getSolverType(), m_fstep_size, m_minimizer, and setSolverType().
QUESO::GslOptimizer::GslOptimizer | ( | OptimizerOptions | options, |
const BaseScalarFunction< GslVector, GslMatrix > & | objectiveFunction | ||
) |
Constructs an object that will maximize a scalar function.
The function objectiveFunction
is the function that will be maximized. This constructor allows the passing of custom options to optimizer to modify things like tolerance, maximum number of iterations, and finite difference step size.
Definition at line 178 of file GslOptimizer.C.
References QUESO::GslVector::cwSet(), getFstepSize(), getSolverType(), m_fstep_size, m_minimizer, and setSolverType().
|
virtual |
|
virtual |
Gets the step to use in gradient-based solvers.
Reimplemented from QUESO::BaseOptimizer.
Definition at line 600 of file GslOptimizer.C.
References QUESO::BaseOptimizer::m_optionsObj.
Referenced by minimize_with_gradient().
|
virtual |
Gets the step size to use in gradient-free solvers.
Reimplemented from QUESO::BaseOptimizer.
Definition at line 594 of file GslOptimizer.C.
References QUESO::BaseOptimizer::m_optionsObj.
Referenced by GslOptimizer().
|
virtual |
Gets the tolerance to use for line minimisation.
Reimplemented from QUESO::BaseOptimizer.
Definition at line 606 of file GslOptimizer.C.
References QUESO::BaseOptimizer::m_optionsObj.
Referenced by minimize_with_gradient().
|
virtual |
Gets the algorithm to use for minimisation.
Reimplemented from QUESO::BaseOptimizer.
Definition at line 588 of file GslOptimizer.C.
References QUESO::BaseOptimizer::m_optionsObj.
Referenced by GslOptimizer().
|
virtual |
Minimize the objective function, starting at m_initialPoint
.
m_initialPoint is handled in the derived class
Implements QUESO::BaseOptimizer.
Definition at line 207 of file GslOptimizer.C.
References dim, m_initialPoint, m_objectiveFunction, m_solver_type, minimize_no_gradient(), minimize_with_gradient(), and solver_needs_gradient().
Referenced by QUESO::StatisticalInverseProblem< P_V, P_M >::solveWithBayesMetropolisHastings().
|
private |
Definition at line 391 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::size, and STEEPEST_DESCENT.
Referenced by minimize().
|
private |
Definition at line 293 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, getFdfstepSize(), getLineTolerance(), QUESO::BaseOptimizer::getMaxIterations(), m_initialPoint, m_objectiveFunction, m_solver_type, NELDER_MEAD, NELDER_MEAD2, NELDER_MEAD2_RAND, POLAK_RIBIERE_CG, 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 251 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 237 of file GslOptimizer.C.
References m_objectiveFunction.
Referenced by QUESO::c_evaluate(), QUESO::c_evaluate_derivative(), and setFstepSize().
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 256 of file GslOptimizer.C.
References m_solver_type.
Referenced by set_solver_type(), and setSolverType().
void QUESO::GslOptimizer::set_solver_type | ( | std::string & | solver | ) |
Definition at line 549 of file GslOptimizer.C.
References set_solver_type(), and string_to_enum().
void QUESO::GslOptimizer::set_step_size | ( | const GslVector & | step_size | ) |
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 493 of file GslOptimizer.C.
References m_fstep_size.
Referenced by setFdfstepSize(), and setFstepSize().
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 499 of file GslOptimizer.C.
References m_fdfstep_size.
|
virtual |
Sets the step to use in gradient-based solvers.
Reimplemented from QUESO::BaseOptimizer.
Definition at line 575 of file GslOptimizer.C.
References QUESO::BaseOptimizer::m_optionsObj, and set_step_size().
|
virtual |
Sets the step size to use in gradient-free solvers.
Reimplemented from QUESO::BaseOptimizer.
Definition at line 563 of file GslOptimizer.C.
References QUESO::GslVector::cwSet(), QUESO::BaseOptimizer::m_optionsObj, objectiveFunction(), and set_step_size().
void QUESO::GslOptimizer::setInitialPoint | ( | const GslVector & | intialPoint | ) |
Set the point at which the optimization starts.
Definition at line 243 of file GslOptimizer.C.
References m_initialPoint, and QUESO::GslVector::sizeLocal().
Referenced by QUESO::StatisticalInverseProblem< P_V, P_M >::solveWithBayesMetropolisHastings().
|
virtual |
Sets the tolerance to use for line minimisation.
Reimplemented from QUESO::BaseOptimizer.
Definition at line 582 of file GslOptimizer.C.
References QUESO::BaseOptimizer::m_optionsObj.
|
virtual |
Sets the algorithm to use for minimisation.
Reimplemented from QUESO::BaseOptimizer.
Definition at line 556 of file GslOptimizer.C.
References QUESO::BaseOptimizer::m_optionsObj, and set_solver_type().
Referenced by GslOptimizer().
|
private |
Helper function.
Definition at line 262 of file GslOptimizer.C.
References BFGS, BFGS2, FLETCHER_REEVES_CG, NELDER_MEAD, NELDER_MEAD2, NELDER_MEAD2_RAND, POLAK_RIBIERE_CG, and STEEPEST_DESCENT.
Referenced by minimize().
GslOptimizer::SolverType QUESO::GslOptimizer::string_to_enum | ( | std::string & | solver | ) |
Definition at line 505 of file GslOptimizer.C.
References BFGS, BFGS2, FLETCHER_REEVES_CG, m_objectiveFunction, NELDER_MEAD, NELDER_MEAD2, NELDER_MEAD2_RAND, POLAK_RIBIERE_CG, and STEEPEST_DESCENT.
Referenced by set_solver_type().
|
private |
For use in gradient-based algorithms.
Definition at line 166 of file GslOptimizer.h.
Referenced by set_step_size().
|
private |
For use in gradient-free algorithms.
Definition at line 163 of file GslOptimizer.h.
Referenced by GslOptimizer(), minimize_no_gradient(), and set_step_size().
|
private |
Definition at line 157 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 169 of file GslOptimizer.h.
|
private |
Definition at line 158 of file GslOptimizer.h.
Referenced by GslOptimizer(), and minimizer().
|
private |
Definition at line 155 of file GslOptimizer.h.
Referenced by minimize(), minimize_no_gradient(), minimize_with_gradient(), objectiveFunction(), and string_to_enum().
|
private |
Definition at line 160 of file GslOptimizer.h.
Referenced by minimize(), minimize_no_gradient(), minimize_with_gradient(), and set_solver_type().