25 #include <queso/Defines.h>
26 #include <queso/Environment.h>
28 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
29 #include <queso/BoostInputOptionsParser.h>
31 #include <queso/getpot.h>
34 #include <queso/OptimizerOptions.h>
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),
49 #ifndef 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")
65 : m_prefix((std::string)(prefix) +
"optimizer_"),
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),
75 #ifndef 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")
87 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
89 "produce help message for statistical inverse problem");
92 UQ_OPT_MAX_ITERATIONS,
93 "max number of optimizer iterations to do");
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");
100 "which optimisation algorithm to use");
102 "sets the step size used in gradient-free solvers");
104 "sets the step size used in gradient-based solvers");
106 "sets the line minimisation tolerance");
128 #endif // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
135 m_prefix(rhs.m_prefix),
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),
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)
163 queso_require_greater_msg(
m_tolerance, 0.0,
"optimizer tolerance 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");
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
void getOption(const std::string &name, T &value) const
Get option name from the parser and set value to the parsed value.
std::ostream & operator<<(std::ostream &os, const SequenceStatisticalOptions &obj)
std::string m_option_lineTolerance
Option name for OptimizerOptions::m_lineTolerance. Default is m_prefix + "optimizer_lineTolerance".
const GetPot & input() const
The GetPot input file parser.
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.
virtual ~OptimizerOptions()
Destructor.
std::string m_option_solverType
Option name for OptimizerOptions::m_solverType. Default is m_prefix + "optimizer_solverType".
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.
This class provides options for a Optimizer.
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.
OptimizerOptions()
Default constructor. All options have their default values.
std::string m_option_finiteDifferenceStepSize
Option name for OptimizerOptions::m_finiteDifferenceStepSize. Default is m_prefix + "optimizer_finite...
const BaseEnvironment * m_env
std::string m_option_fstepSize
Option name for OptimizerOptions::m_fstepSize. Default is m_prefix + "optimizer_fstepSize".
std::string m_option_tolerance
Option name for OptimizerOptions::m_tolerance. Default is m_prefix + "optimizer_tolerance".
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 + "optimizer_fdfStepSize".
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 + "optimizer_maxIterations".
std::string m_option_help
double m_finiteDifferenceStepSize
The step size used to compute gradients from finite differencing. Default is 1e-4.