queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
QUESO::OptimizerOptions Class Reference

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

#include <OptimizerOptions.h>

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 38 of file OptimizerOptions.C.

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

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

Definition at line 63 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(), and QUESO::BoostInputOptionsParser::scanInputFile().

65  : m_prefix((std::string)(prefix) + "optimizer_"),
66  m_help(UQ_OPT_HELP),
67  m_maxIterations(UQ_OPT_MAX_ITERATIONS),
68  m_tolerance(UQ_OPT_TOLERANCE),
69  m_finiteDifferenceStepSize(UQ_OPT_FINITE_DIFFERENCE_STEP_SIZE),
70  m_solverType(UQ_OPT_SOLVER_TYPE),
71  m_fstepSize(UQ_OPT_FSTEP_SIZE),
72  m_fdfstepSize(UQ_OPT_FDFSTEP_SIZE),
73  m_lineTolerance(UQ_OPT_LINE_TOLERANCE),
74  m_env(env),
75 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
76  m_parser(new BoostInputOptionsParser(env->optionsInputFileName())),
77 #endif // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
78  m_option_help(m_prefix + "help"),
79  m_option_maxIterations(m_prefix + "maxIterations"),
80  m_option_tolerance(m_prefix + "tolerance"),
81  m_option_finiteDifferenceStepSize(m_prefix + "finiteDifferenceStepSize"),
82  m_option_solverType(m_prefix + "solverType"),
83  m_option_fstepSize(m_prefix + "fstepSize"),
84  m_option_fdfstepSize(m_prefix + "fdfStepSize"),
85  m_option_lineTolerance(m_prefix + "lineTolerance")
86 {
87 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
88  m_parser->registerOption<std::string>(m_option_help, UQ_OPT_HELP,
89  "produce help message for statistical inverse problem");
90 
92  UQ_OPT_MAX_ITERATIONS,
93  "max number of optimizer iterations to do");
94  m_parser->registerOption<double>(m_option_tolerance, UQ_OPT_TOLERANCE,
95  "optimize until gradient is less than tolerance");
97  UQ_OPT_FINITE_DIFFERENCE_STEP_SIZE,
98  "if no deriv is given, do finite difference with this step size");
99  m_parser->registerOption<std::string>(m_option_solverType, UQ_OPT_SOLVER_TYPE,
100  "which optimisation algorithm to use");
101  m_parser->registerOption<double>(m_option_fstepSize, UQ_OPT_FSTEP_SIZE,
102  "sets the step size used in gradient-free solvers");
103  m_parser->registerOption<double>(m_option_fdfstepSize, UQ_OPT_FDFSTEP_SIZE,
104  "sets the step size used in gradient-based solvers");
105  m_parser->registerOption<double>(m_option_lineTolerance, UQ_OPT_LINE_TOLERANCE,
106  "sets the line minimisation tolerance");
107 
109 
110  m_parser->getOption<std::string>(m_option_help, m_help);
119 #else
120  m_help = m_env->input()(m_option_help, UQ_OPT_HELP);
121  m_maxIterations = m_env->input()(m_option_maxIterations, UQ_OPT_MAX_ITERATIONS);
122  m_tolerance = m_env->input()(m_option_tolerance, UQ_OPT_TOLERANCE);
123  m_finiteDifferenceStepSize = m_env->input()(m_option_finiteDifferenceStepSize, UQ_OPT_FINITE_DIFFERENCE_STEP_SIZE);
124  m_solverType = m_env->input()(m_option_solverType, UQ_OPT_SOLVER_TYPE);
125  m_fstepSize = m_env->input()(m_option_fstepSize, UQ_OPT_FSTEP_SIZE);
126  m_fdfstepSize = m_env->input()(m_option_fdfstepSize, UQ_OPT_FDFSTEP_SIZE);
127  m_lineTolerance = m_env->input()(m_option_lineTolerance, UQ_OPT_LINE_TOLERANCE);
128 #endif // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
129 
130  checkOptions();
131 }
void getOption(const std::string &name, T &value) const
Get option name from the parser and set value to the parsed value.
std::string m_option_lineTolerance
Option name for OptimizerOptions::m_lineTolerance. Default is m_prefix + &quot;optimizer_lineTolerance&quot;.
const GetPot & input() const
The GetPot input file parser.
Definition: Environment.C:1149
std::string m_help
If this string is non-empty, options are print to the output file.
void registerOption(const std::string &name, const T &defaultValue, const std::string &description)
Call this to register an option with the parser.
std::string m_option_solverType
Option name for OptimizerOptions::m_solverType. Default is m_prefix + &quot;optimizer_solverType&quot;.
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.
BoostInputOptionsParser * m_parser
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.
double m_fstepSize
The size of the initial trial steps for optimizing without gradients. Default is 0.1.
std::string m_option_finiteDifferenceStepSize
Option name for OptimizerOptions::m_finiteDifferenceStepSize. Default is m_prefix + &quot;optimizer_finite...
const BaseEnvironment * m_env
std::string m_option_fstepSize
Option name for OptimizerOptions::m_fstepSize. Default is m_prefix + &quot;optimizer_fstepSize&quot;.
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.
std::string m_option_fdfstepSize
Option name for OptimizerOptions::m_fdfstepSize. Default is m_prefix + &quot;optimizer_fdfStepSize&quot;.
unsigned int m_maxIterations
The maximum number of iterations to do for optimization. Default is 100.
std::string m_option_maxIterations
Option name for OptimizerOptions::m_maxIterations. Default is m_prefix + &quot;optimizer_maxIterations&quot;.
double m_finiteDifferenceStepSize
The step size used to compute gradients from finite differencing. Default is 1e-4.
QUESO::OptimizerOptions::OptimizerOptions ( const OptimizerOptions rhs)

Copy constructor.

Definition at line 133 of file OptimizerOptions.C.

134  :
135  m_prefix(rhs.m_prefix),
136  m_help(rhs.m_help),
137  m_maxIterations(rhs.m_maxIterations),
138  m_tolerance(rhs.m_tolerance),
139  m_finiteDifferenceStepSize(rhs.m_finiteDifferenceStepSize),
140  m_solverType(rhs.m_solverType),
141  m_fstepSize(rhs.m_fstepSize),
142  m_fdfstepSize(rhs.m_fdfstepSize),
143  m_lineTolerance(rhs.m_lineTolerance),
144  m_parser(rhs.m_parser), // We'll never touch the input file in a copied object
145  m_option_help(rhs.m_option_help),
146  m_option_maxIterations(rhs.m_option_maxIterations),
147  m_option_tolerance(rhs.m_option_tolerance),
148  m_option_finiteDifferenceStepSize(rhs.m_option_finiteDifferenceStepSize),
149  m_option_solverType(rhs.m_option_solverType),
150  m_option_fstepSize(rhs.m_option_fstepSize),
151  m_option_fdfstepSize(rhs.m_option_fdfstepSize),
152  m_option_lineTolerance(rhs.m_option_lineTolerance)
153 {
154 }
std::string m_option_lineTolerance
Option name for OptimizerOptions::m_lineTolerance. Default is m_prefix + &quot;optimizer_lineTolerance&quot;.
std::string m_help
If this string is non-empty, options are print to the output file.
std::string m_option_solverType
Option name for OptimizerOptions::m_solverType. Default is m_prefix + &quot;optimizer_solverType&quot;.
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.
BoostInputOptionsParser * m_parser
double m_lineTolerance
Accuracy to which to solve line minization to. Default is 0.1.
double m_fstepSize
The size of the initial trial steps for optimizing without gradients. Default is 0.1.
std::string m_option_finiteDifferenceStepSize
Option name for OptimizerOptions::m_finiteDifferenceStepSize. Default is m_prefix + &quot;optimizer_finite...
std::string m_option_fstepSize
Option name for OptimizerOptions::m_fstepSize. Default is m_prefix + &quot;optimizer_fstepSize&quot;.
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.
std::string m_option_fdfstepSize
Option name for OptimizerOptions::m_fdfstepSize. Default is m_prefix + &quot;optimizer_fdfStepSize&quot;.
unsigned int m_maxIterations
The maximum number of iterations to do for optimization. Default is 100.
std::string m_option_maxIterations
Option name for OptimizerOptions::m_maxIterations. Default is m_prefix + &quot;optimizer_maxIterations&quot;.
double m_finiteDifferenceStepSize
The step size used to compute gradients from finite differencing. Default is 1e-4.
QUESO::OptimizerOptions::~OptimizerOptions ( )
virtual

Destructor.

Definition at line 156 of file OptimizerOptions.C.

157 {
158 }

Member Function Documentation

void QUESO::OptimizerOptions::checkOptions ( )
private

Definition at line 161 of file OptimizerOptions.C.

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

Referenced by OptimizerOptions().

162 {
163  queso_require_greater_msg(m_tolerance, 0.0, "optimizer tolerance must be > 0");
164  queso_require_greater_msg(m_finiteDifferenceStepSize, 0.0, "finite difference step must be > 0");
165  queso_require_greater_msg(m_maxIterations, 0, "max iterations must be > 0");
166  queso_require_greater_msg(m_fstepSize, 0.0, "fstepSize must be > 0");
167  queso_require_greater_msg(m_fdfstepSize, 0.0, "fdfstepSize must be > 0");
168  queso_require_greater_msg(m_lineTolerance, 0.0, "line tolerance must be > 0");
169 }
double m_tolerance
The tolerance at which optimization stops. Default is 1e-3.
double m_lineTolerance
Accuracy to which to solve line minization to. Default is 0.1.
double m_fstepSize
The size of the initial trial steps for optimizing without gradients. Default is 0.1.
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_finiteDifferenceStepSize
The step size used to compute gradients from finite differencing. Default is 1e-4.

Friends And Related Function Documentation

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

Definition at line 172 of file OptimizerOptions.C.

173 {
174  os << "\n" << obj.m_option_maxIterations << " = " << obj.m_maxIterations
175  << "\n" << obj.m_option_tolerance << " = " << obj.m_tolerance;
176  os << "\n" << obj.m_option_finiteDifferenceStepSize << " = "
177  << obj.m_finiteDifferenceStepSize;
178  os << "\n" << obj.m_option_solverType << " = " << obj.m_solverType;
179  os << "\n" << obj.m_option_fstepSize << " = " << obj.m_fstepSize;
180  os << "\n" << obj.m_option_fdfstepSize << " = " << obj.m_fdfstepSize;
181  os << "\n" << obj.m_option_lineTolerance << " = " << obj.m_lineTolerance;
182  os << std::endl;
183  return os;
184 }

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 Jun 5 2018 19:49:11 for queso-0.57.1 by  doxygen 1.8.5