queso-0.56.0
Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
QUESO::OptimizerOptions Class Reference

This class provides options for a Optimizer. More...

#include <OptimizerOptions.h>

Collaboration diagram for QUESO::OptimizerOptions:
Collaboration graph
[legend]

Public Member Functions

Constructor/Destructor methods
 OptimizerOptions ()
 Default constructor. All options have their default values. More...
 
 OptimizerOptions (const BaseEnvironment *env, const char *prefix="")
 A constructor that takes the environment for parsing input file options. More...
 
 OptimizerOptions (const OptimizerOptions &rhs)
 Copy constructor. More...
 
virtual ~OptimizerOptions ()
 Destructor. More...
 

Public Attributes

std::string m_prefix
 
std::string m_help
 If this string is non-empty, options are print to the output file. More...
 
unsigned int m_maxIterations
 The maximum number of iterations to do for optimization. Default is 100. More...
 
double m_tolerance
 The tolerance at which optimization stops. Default is 1e-3. More...
 
double m_finiteDifferenceStepSize
 The step size used to compute gradients from finite differencing. Default is 1e-4. More...
 
std::string m_solverType
 The optimization algorithm to use. Default is bfgs2. More...
 
double m_fstepSize
 The size of the initial trial steps for optimizing without gradients. Default is 0.1. More...
 
double m_fdfstepSize
 The size of the first step when optimizing with gradients. Default is 1.0. More...
 
double m_lineTolerance
 Accuracy to which to solve line minization to. Default is 0.1. More...
 

Private Member Functions

void checkOptions ()
 

Private Attributes

const BaseEnvironmentm_env
 
BoostInputOptionsParserm_parser
 
std::string m_option_help
 
std::string m_option_maxIterations
 Option name for OptimizerOptions::m_maxIterations. Default is m_prefix + "optimizer_maxIterations". More...
 
std::string m_option_tolerance
 Option name for OptimizerOptions::m_tolerance. Default is m_prefix + "optimizer_tolerance". More...
 
std::string m_option_finiteDifferenceStepSize
 Option name for OptimizerOptions::m_finiteDifferenceStepSize. Default is m_prefix + "optimizer_finiteDifferenceStepSize". More...
 
std::string m_option_solverType
 Option name for OptimizerOptions::m_solverType. Default is m_prefix + "optimizer_solverType". More...
 
std::string m_option_fstepSize
 Option name for OptimizerOptions::m_fstepSize. Default is m_prefix + "optimizer_fstepSize". More...
 
std::string m_option_fdfstepSize
 Option name for OptimizerOptions::m_fdfstepSize. Default is m_prefix + "optimizer_fdfStepSize". More...
 
std::string m_option_lineTolerance
 Option name for OptimizerOptions::m_lineTolerance. Default is m_prefix + "optimizer_lineTolerance". More...
 

Friends

std::ostream & operator<< (std::ostream &os, const OptimizerOptions &obj)
 

Detailed Description

This class provides options for a Optimizer.

Definition at line 60 of file OptimizerOptions.h.

Constructor & Destructor Documentation

QUESO::OptimizerOptions::OptimizerOptions ( )

Default constructor. All options have their default values.

Definition at line 32 of file OptimizerOptions.C.

33  : m_prefix("ip_"),
42  m_env(NULL),
43 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
44  m_parser(NULL),
45 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
46  m_option_help(m_prefix + "help"),
47  m_option_maxIterations(m_prefix + "maxIterations"),
48  m_option_tolerance(m_prefix + "tolerance"),
49  m_option_finiteDifferenceStepSize(m_prefix + "finiteDifferenceStepSize"),
50  m_option_solverType(m_prefix + "solverType"),
51  m_option_fstepSize(m_prefix + "fstepSize"),
52  m_option_fdfstepSize(m_prefix + "fdfStepSize"),
53  m_option_lineTolerance(m_prefix + "lineTolerance")
54 {
55 }
std::string m_solverType
The optimization algorithm to use. Default is bfgs2.
double m_tolerance
The tolerance at which optimization stops. Default is 1e-3.
#define UQ_OPT_TOLERANCE
#define UQ_OPT_FINITE_DIFFERENCE_STEP_SIZE
std::string m_option_tolerance
Option name for OptimizerOptions::m_tolerance. Default is m_prefix + &quot;optimizer_tolerance&quot;.
double m_fdfstepSize
The size of the first step when optimizing with gradients. Default is 1.0.
unsigned int m_maxIterations
The maximum number of iterations to do for optimization. Default is 100.
BoostInputOptionsParser * m_parser
#define UQ_OPT_LINE_TOLERANCE
std::string m_option_finiteDifferenceStepSize
Option name for OptimizerOptions::m_finiteDifferenceStepSize. Default is m_prefix + &quot;optimizer_finite...
std::string m_option_lineTolerance
Option name for OptimizerOptions::m_lineTolerance. Default is m_prefix + &quot;optimizer_lineTolerance&quot;.
std::string m_option_fdfstepSize
Option name for OptimizerOptions::m_fdfstepSize. Default is m_prefix + &quot;optimizer_fdfStepSize&quot;.
#define UQ_OPT_MAX_ITERATIONS
std::string m_option_maxIterations
Option name for OptimizerOptions::m_maxIterations. Default is m_prefix + &quot;optimizer_maxIterations&quot;.
double m_lineTolerance
Accuracy to which to solve line minization to. Default is 0.1.
const BaseEnvironment * m_env
#define UQ_OPT_HELP
#define UQ_OPT_FDFSTEP_SIZE
double m_finiteDifferenceStepSize
The step size used to compute gradients from finite differencing. Default is 1e-4.
#define UQ_OPT_SOLVER_TYPE
double m_fstepSize
The size of the initial trial steps for optimizing without gradients. Default is 0.1.
std::string m_help
If this string is non-empty, options are print to the output file.
#define UQ_OPT_FSTEP_SIZE
std::string m_option_fstepSize
Option name for OptimizerOptions::m_fstepSize. Default is m_prefix + &quot;optimizer_fstepSize&quot;.
std::string m_option_solverType
Option name for OptimizerOptions::m_solverType. Default is m_prefix + &quot;optimizer_solverType&quot;.
QUESO::OptimizerOptions::OptimizerOptions ( const BaseEnvironment env,
const char *  prefix = "" 
)

A constructor that takes the environment for parsing input file options.

Definition at line 57 of file OptimizerOptions.C.

References checkOptions(), QUESO::BoostInputOptionsParser::getOption(), QUESO::BaseEnvironment::input(), m_env, m_fdfstepSize, m_finiteDifferenceStepSize, m_fstepSize, m_help, m_lineTolerance, m_maxIterations, m_option_fdfstepSize, m_option_finiteDifferenceStepSize, m_option_fstepSize, m_option_help, m_option_lineTolerance, m_option_maxIterations, m_option_solverType, m_option_tolerance, m_parser, m_solverType, m_tolerance, QUESO::BoostInputOptionsParser::registerOption(), QUESO::BoostInputOptionsParser::scanInputFile(), UQ_OPT_FDFSTEP_SIZE, UQ_OPT_FINITE_DIFFERENCE_STEP_SIZE, UQ_OPT_FSTEP_SIZE, UQ_OPT_HELP, UQ_OPT_LINE_TOLERANCE, UQ_OPT_MAX_ITERATIONS, UQ_OPT_SOLVER_TYPE, and UQ_OPT_TOLERANCE.

59  : m_prefix((std::string)(prefix) + "optimizer_"),
68  m_env(env),
69 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
70  m_parser(new BoostInputOptionsParser(env->optionsInputFileName())),
71 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
72  m_option_help(m_prefix + "help"),
73  m_option_maxIterations(m_prefix + "maxIterations"),
74  m_option_tolerance(m_prefix + "tolerance"),
75  m_option_finiteDifferenceStepSize(m_prefix + "finiteDifferenceStepSize"),
76  m_option_solverType(m_prefix + "solverType"),
77  m_option_fstepSize(m_prefix + "fstepSize"),
78  m_option_fdfstepSize(m_prefix + "fdfStepSize"),
79  m_option_lineTolerance(m_prefix + "lineTolerance")
80 {
81 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
83  "produce help message for statistical inverse problem");
84 
87  "max number of optimizer iterations to do");
89  "optimize until gradient is less than tolerance");
92  "if no deriv is given, do finite difference with this step size");
94  "which optimisation algorithm to use");
96  "sets the step size used in gradient-free solvers");
98  "sets the step size used in gradient-based solvers");
100  "sets the line minimisation tolerance");
101 
103 
104  m_parser->getOption<std::string>(m_option_help, m_help);
113 #else
122 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
123 
124  checkOptions();
125 }
std::string m_solverType
The optimization algorithm to use. Default is bfgs2.
double m_tolerance
The tolerance at which optimization stops. Default is 1e-3.
#define UQ_OPT_TOLERANCE
#define UQ_OPT_FINITE_DIFFERENCE_STEP_SIZE
const GetPot & input() const
The GetPot input file parser.
Definition: Environment.C:1148
std::string m_option_tolerance
Option name for OptimizerOptions::m_tolerance. Default is m_prefix + &quot;optimizer_tolerance&quot;.
double m_fdfstepSize
The size of the first step when optimizing with gradients. Default is 1.0.
unsigned int m_maxIterations
The maximum number of iterations to do for optimization. Default is 100.
BoostInputOptionsParser * m_parser
void getOption(std::string &name, T &value)
Get option name from the parser and set value to the parsed value.
#define UQ_OPT_LINE_TOLERANCE
std::string m_option_finiteDifferenceStepSize
Option name for OptimizerOptions::m_finiteDifferenceStepSize. Default is m_prefix + &quot;optimizer_finite...
std::string m_option_lineTolerance
Option name for OptimizerOptions::m_lineTolerance. Default is m_prefix + &quot;optimizer_lineTolerance&quot;.
std::string m_option_fdfstepSize
Option name for OptimizerOptions::m_fdfstepSize. Default is m_prefix + &quot;optimizer_fdfStepSize&quot;.
#define UQ_OPT_MAX_ITERATIONS
std::string m_option_maxIterations
Option name for OptimizerOptions::m_maxIterations. Default is m_prefix + &quot;optimizer_maxIterations&quot;.
void scanInputFile()
This is the method that parses the input file.
double m_lineTolerance
Accuracy to which to solve line minization to. Default is 0.1.
const BaseEnvironment * m_env
#define UQ_OPT_HELP
#define UQ_OPT_FDFSTEP_SIZE
void registerOption(std::string name, T defaultValue, std::string description)
Call this to register an option with the parser.
double m_finiteDifferenceStepSize
The step size used to compute gradients from finite differencing. Default is 1e-4.
#define UQ_OPT_SOLVER_TYPE
double m_fstepSize
The size of the initial trial steps for optimizing without gradients. Default is 0.1.
std::string m_help
If this string is non-empty, options are print to the output file.
#define UQ_OPT_FSTEP_SIZE
std::string m_option_fstepSize
Option name for OptimizerOptions::m_fstepSize. Default is m_prefix + &quot;optimizer_fstepSize&quot;.
std::string m_option_solverType
Option name for OptimizerOptions::m_solverType. Default is m_prefix + &quot;optimizer_solverType&quot;.
QUESO::OptimizerOptions::OptimizerOptions ( const OptimizerOptions rhs)

Copy constructor.

Definition at line 127 of file OptimizerOptions.C.

128  :
129  m_prefix(rhs.m_prefix),
130  m_help(rhs.m_help),
131  m_maxIterations(rhs.m_maxIterations),
132  m_tolerance(rhs.m_tolerance),
133  m_finiteDifferenceStepSize(rhs.m_finiteDifferenceStepSize),
134  m_solverType(rhs.m_solverType),
135  m_fstepSize(rhs.m_fstepSize),
136  m_fdfstepSize(rhs.m_fdfstepSize),
137  m_lineTolerance(rhs.m_lineTolerance),
138  m_parser(rhs.m_parser), // We'll never touch the input file in a copied object
139  m_option_help(rhs.m_option_help),
140  m_option_maxIterations(rhs.m_option_maxIterations),
141  m_option_tolerance(rhs.m_option_tolerance),
142  m_option_finiteDifferenceStepSize(rhs.m_option_finiteDifferenceStepSize),
143  m_option_solverType(rhs.m_option_solverType),
144  m_option_fstepSize(rhs.m_option_fstepSize),
145  m_option_fdfstepSize(rhs.m_option_fdfstepSize),
146  m_option_lineTolerance(rhs.m_option_lineTolerance)
147 {
148 }
std::string m_solverType
The optimization algorithm to use. Default is bfgs2.
double m_tolerance
The tolerance at which optimization stops. Default is 1e-3.
std::string m_option_tolerance
Option name for OptimizerOptions::m_tolerance. Default is m_prefix + &quot;optimizer_tolerance&quot;.
double m_fdfstepSize
The size of the first step when optimizing with gradients. Default is 1.0.
unsigned int m_maxIterations
The maximum number of iterations to do for optimization. Default is 100.
BoostInputOptionsParser * m_parser
std::string m_option_finiteDifferenceStepSize
Option name for OptimizerOptions::m_finiteDifferenceStepSize. Default is m_prefix + &quot;optimizer_finite...
std::string m_option_lineTolerance
Option name for OptimizerOptions::m_lineTolerance. Default is m_prefix + &quot;optimizer_lineTolerance&quot;.
std::string m_option_fdfstepSize
Option name for OptimizerOptions::m_fdfstepSize. Default is m_prefix + &quot;optimizer_fdfStepSize&quot;.
std::string m_option_maxIterations
Option name for OptimizerOptions::m_maxIterations. Default is m_prefix + &quot;optimizer_maxIterations&quot;.
double m_lineTolerance
Accuracy to which to solve line minization to. Default is 0.1.
double m_finiteDifferenceStepSize
The step size used to compute gradients from finite differencing. Default is 1e-4.
double m_fstepSize
The size of the initial trial steps for optimizing without gradients. Default is 0.1.
std::string m_help
If this string is non-empty, options are print to the output file.
std::string m_option_fstepSize
Option name for OptimizerOptions::m_fstepSize. Default is m_prefix + &quot;optimizer_fstepSize&quot;.
std::string m_option_solverType
Option name for OptimizerOptions::m_solverType. Default is m_prefix + &quot;optimizer_solverType&quot;.
QUESO::OptimizerOptions::~OptimizerOptions ( )
virtual

Destructor.

Definition at line 150 of file OptimizerOptions.C.

151 {
152 }

Member Function Documentation

void QUESO::OptimizerOptions::checkOptions ( )
private

Definition at line 155 of file OptimizerOptions.C.

References m_fdfstepSize, m_finiteDifferenceStepSize, m_fstepSize, m_lineTolerance, m_maxIterations, m_tolerance, and queso_require_greater_msg.

Referenced by OptimizerOptions().

156 {
157  queso_require_greater_msg(m_tolerance, 0.0, "optimizer tolerance must be > 0");
158  queso_require_greater_msg(m_finiteDifferenceStepSize, 0.0, "finite difference step must be > 0");
159  queso_require_greater_msg(m_maxIterations, 0, "max iterations must be > 0");
160  queso_require_greater_msg(m_fstepSize, 0.0, "fstepSize must be > 0");
161  queso_require_greater_msg(m_fdfstepSize, 0.0, "fdfstepSize must be > 0");
162  queso_require_greater_msg(m_lineTolerance, 0.0, "line tolerance must be > 0");
163 }
double m_tolerance
The tolerance at which optimization stops. Default is 1e-3.
double m_fdfstepSize
The size of the first step when optimizing with gradients. Default is 1.0.
unsigned int m_maxIterations
The maximum number of iterations to do for optimization. Default is 100.
double m_lineTolerance
Accuracy to which to solve line minization to. Default is 0.1.
#define queso_require_greater_msg(expr1, expr2, msg)
Definition: asserts.h:76
double m_finiteDifferenceStepSize
The step size used to compute gradients from finite differencing. Default is 1e-4.
double m_fstepSize
The size of the initial trial steps for optimizing without gradients. Default is 0.1.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const OptimizerOptions obj 
)
friend

Definition at line 166 of file OptimizerOptions.C.

167 {
168  os << "\n" << obj.m_option_maxIterations << " = " << obj.m_maxIterations
169  << "\n" << obj.m_option_tolerance << " = " << obj.m_tolerance;
170  os << "\n" << obj.m_option_finiteDifferenceStepSize << " = "
171  << obj.m_finiteDifferenceStepSize;
172  os << "\n" << obj.m_option_solverType << " = " << obj.m_solverType;
173  os << "\n" << obj.m_option_fstepSize << " = " << obj.m_fstepSize;
174  os << "\n" << obj.m_option_fdfstepSize << " = " << obj.m_fdfstepSize;
175  os << "\n" << obj.m_option_lineTolerance << " = " << obj.m_lineTolerance;
176  os << std::endl;
177  return os;
178 }

Member Data Documentation

const BaseEnvironment* QUESO::OptimizerOptions::m_env
private

Definition at line 136 of file OptimizerOptions.h.

Referenced by OptimizerOptions().

double QUESO::OptimizerOptions::m_fdfstepSize

The size of the first step when optimizing with gradients. Default is 1.0.

Definition at line 126 of file OptimizerOptions.h.

Referenced by checkOptions(), QUESO::operator<<(), and OptimizerOptions().

double QUESO::OptimizerOptions::m_finiteDifferenceStepSize

The step size used to compute gradients from finite differencing. Default is 1e-4.

This is only done when analytical gradients are not provided (either by the user or by QUESO).

Definition at line 101 of file OptimizerOptions.h.

Referenced by checkOptions(), QUESO::operator<<(), and OptimizerOptions().

double QUESO::OptimizerOptions::m_fstepSize

The size of the initial trial steps for optimizing without gradients. Default is 0.1.

The initial trial steps is actually a vector of size equal to the number of parameters, and this vector is set to m_fstepSize in each component.

Definition at line 123 of file OptimizerOptions.h.

Referenced by checkOptions(), QUESO::operator<<(), and OptimizerOptions().

std::string QUESO::OptimizerOptions::m_help

If this string is non-empty, options are print to the output file.

Definition at line 81 of file OptimizerOptions.h.

Referenced by OptimizerOptions().

double QUESO::OptimizerOptions::m_lineTolerance

Accuracy to which to solve line minization to. Default is 0.1.

The exact meaning of this parameter depends on the method used. It's not used for algorithms that don't use derivatives.

Definition at line 133 of file OptimizerOptions.h.

Referenced by checkOptions(), QUESO::operator<<(), and OptimizerOptions().

unsigned int QUESO::OptimizerOptions::m_maxIterations

The maximum number of iterations to do for optimization. Default is 100.

Definition at line 84 of file OptimizerOptions.h.

Referenced by checkOptions(), QUESO::operator<<(), and OptimizerOptions().

std::string QUESO::OptimizerOptions::m_option_fdfstepSize
private

Option name for OptimizerOptions::m_fdfstepSize. Default is m_prefix + "optimizer_fdfStepSize".

Definition at line 154 of file OptimizerOptions.h.

Referenced by QUESO::operator<<(), and OptimizerOptions().

std::string QUESO::OptimizerOptions::m_option_finiteDifferenceStepSize
private

Option name for OptimizerOptions::m_finiteDifferenceStepSize. Default is m_prefix + "optimizer_finiteDifferenceStepSize".

Definition at line 148 of file OptimizerOptions.h.

Referenced by QUESO::operator<<(), and OptimizerOptions().

std::string QUESO::OptimizerOptions::m_option_fstepSize
private

Option name for OptimizerOptions::m_fstepSize. Default is m_prefix + "optimizer_fstepSize".

Definition at line 152 of file OptimizerOptions.h.

Referenced by QUESO::operator<<(), and OptimizerOptions().

std::string QUESO::OptimizerOptions::m_option_help
private

Definition at line 141 of file OptimizerOptions.h.

Referenced by OptimizerOptions().

std::string QUESO::OptimizerOptions::m_option_lineTolerance
private

Option name for OptimizerOptions::m_lineTolerance. Default is m_prefix + "optimizer_lineTolerance".

Definition at line 156 of file OptimizerOptions.h.

Referenced by QUESO::operator<<(), and OptimizerOptions().

std::string QUESO::OptimizerOptions::m_option_maxIterations
private

Option name for OptimizerOptions::m_maxIterations. Default is m_prefix + "optimizer_maxIterations".

Definition at line 144 of file OptimizerOptions.h.

Referenced by QUESO::operator<<(), and OptimizerOptions().

std::string QUESO::OptimizerOptions::m_option_solverType
private

Option name for OptimizerOptions::m_solverType. Default is m_prefix + "optimizer_solverType".

Definition at line 150 of file OptimizerOptions.h.

Referenced by QUESO::operator<<(), and OptimizerOptions().

std::string QUESO::OptimizerOptions::m_option_tolerance
private

Option name for OptimizerOptions::m_tolerance. Default is m_prefix + "optimizer_tolerance".

Definition at line 146 of file OptimizerOptions.h.

Referenced by QUESO::operator<<(), and OptimizerOptions().

BoostInputOptionsParser* QUESO::OptimizerOptions::m_parser
private

Definition at line 138 of file OptimizerOptions.h.

Referenced by OptimizerOptions().

std::string QUESO::OptimizerOptions::m_prefix

Definition at line 78 of file OptimizerOptions.h.

std::string QUESO::OptimizerOptions::m_solverType

The optimization algorithm to use. Default is bfgs2.

Choices are:

  • fletcher_reeves_cg
  • polak_ribiere_cg
  • bfgs
  • bfgs2
  • steepest_descent
  • nelder_mead
  • nelder_mead2
  • nelder_mead2_rand

Definition at line 115 of file OptimizerOptions.h.

Referenced by QUESO::operator<<(), and OptimizerOptions().

double QUESO::OptimizerOptions::m_tolerance

The tolerance at which optimization stops. Default is 1e-3.

The tolerance is measured in terms of the 2-norm of the gradient of the objective function for optimizers that use derivatives.

For optimizers that do not use derivatives, the tolerance is measured in terms of the size of the size of the simplex for the simplex optimizers.

Definition at line 94 of file OptimizerOptions.h.

Referenced by checkOptions(), QUESO::operator<<(), and OptimizerOptions().


The documentation for this class was generated from the following files:

Generated on Tue Nov 29 2016 10:53:14 for queso-0.56.0 by  doxygen 1.8.5