25 #include <queso/Defines.h>
27 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
28 #include <boost/program_options.hpp>
30 #include <queso/getpot.h>
33 #include <queso/StatisticalForwardProblemOptions.h>
34 #include <queso/Miscellaneous.h>
52 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
55 m_option_help (m_prefix +
"help" ),
56 m_option_computeSolution (m_prefix +
"computeSolution" ),
57 m_option_computeCovariances (m_prefix +
"computeCovariances" ),
58 m_option_computeCorrelations (m_prefix +
"computeCorrelations" ),
59 m_option_dataOutputFileName (m_prefix +
"dataOutputFileName" ),
60 m_option_dataOutputAllowedSet(m_prefix +
"dataOutputAllowedSet")
61 #ifdef UQ_SFP_READS_SOLVER_OPTION
62 m_option_solver (m_prefix +
"solver" ),
63 m_solverString (UQ_SFP_SOLVER_ODV )
71 m_prefix ((std::string)(prefix) +
"fp_"),
78 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
79 m_parser(new BoostInputOptionsParser(env->optionsInputFileName())),
81 m_option_help (m_prefix +
"help" ),
82 m_option_computeSolution (m_prefix +
"computeSolution" ),
83 m_option_computeCovariances (m_prefix +
"computeCovariances" ),
84 m_option_computeCorrelations (m_prefix +
"computeCorrelations" ),
85 m_option_dataOutputFileName (m_prefix +
"dataOutputFileName" ),
86 m_option_dataOutputAllowedSet(m_prefix +
"dataOutputAllowedSet")
87 #ifdef UQ_SFP_READS_SOLVER_OPTION
88 m_option_solver (m_prefix +
"solver" ),
89 m_solverString (UQ_SFP_SOLVER_ODV )
92 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
93 m_parser->registerOption<std::string>(m_option_help, UQ_SFP_HELP,
"produce help message for statistical forward problem");
94 m_parser->registerOption<
bool >(m_option_computeSolution, UQ_SFP_COMPUTE_SOLUTION_ODV ,
"compute solution process" );
95 m_parser->registerOption<
bool >(m_option_computeCovariances, UQ_SFP_COMPUTE_COVARIANCES_ODV ,
"compute pq covariances" );
96 m_parser->registerOption<
bool >(m_option_computeCorrelations, UQ_SFP_COMPUTE_CORRELATIONS_ODV ,
"compute pq correlations" );
97 m_parser->registerOption<std::string>(m_option_dataOutputFileName, UQ_SFP_DATA_OUTPUT_FILE_NAME_ODV ,
"name of data output file" );
98 m_parser->registerOption<std::string>(m_option_dataOutputAllowedSet, UQ_SFP_DATA_OUTPUT_ALLOWED_SET_ODV,
"subEnvs that will write to data output file" );
99 #ifdef UQ_SFP_READS_SOLVER_OPTION
100 m_parser->registerOption<std::string>(m_option_solver, UQ_SFP_SOLVER_ODV ,
"algorithm for propagation" );
103 m_parser->scanInputFile();
105 m_parser->getOption<std::string>(m_option_help,
m_help);
110 m_parser->getOption<std::set<unsigned int> >(m_option_dataOutputAllowedSet, m_dataOutputAllowedSet);
111 #ifdef UQ_SFP_READS_SOLVER_OPTION
112 m_parser->getOption<std::string>(m_option_solver,
m_solver);
115 m_help = env->input()(m_option_help, UQ_SFP_HELP);
122 unsigned int size = env->input().vector_variable_size(m_option_dataOutputAllowedSet);
123 for (
unsigned int i = 0; i <
size; i++) {
126 unsigned int allowed = env->input()(m_option_dataOutputAllowedSet, i, i);
127 m_dataOutputAllowedSet.insert(allowed);
130 #ifdef UQ_SFP_READS_SOLVER_OPTION
131 m_solver = env->input()(m_option_solver, UQ_SFP_SOLVER_ODV);
133 #endif // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
170 #ifdef UQ_SFP_READS_SOLVER_OPTION
182 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
183 os << (*(obj.
m_parser)) << std::endl;
184 #endif // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
194 #ifdef UQ_SFP_READS_SOLVER_OPTION
207 const BaseEnvironment& env,
211 m_prefix ((std::string)(prefix) +
"fp_" ),
213 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
214 m_optionsDesc (new boost::program_options::options_description(
"Statistical Forward Problem options")),
216 m_option_help (m_prefix +
"help" ),
217 m_option_computeSolution (m_prefix +
"computeSolution" ),
218 m_option_computeCovariances (m_prefix +
"computeCovariances" ),
219 m_option_computeCorrelations (m_prefix +
"computeCorrelations" ),
220 m_option_dataOutputFileName (m_prefix +
"dataOutputFileName" ),
221 m_option_dataOutputAllowedSet(m_prefix +
"dataOutputAllowedSet")
222 #ifdef UQ_SFP_READS_SOLVER_OPTION
223 m_option_solver (m_prefix +
"solver" )
228 queso_require_not_equal_to_msg(m_env.optionsInputFileName(), std::string(
""), std::string(
"this constructor is incompatible with the absence of an options input file"));
231 StatisticalForwardProblemOptions::StatisticalForwardProblemOptions(
232 const BaseEnvironment& env,
234 const SfpOptionsValues& alternativeOptionsValues)
236 m_ov (alternativeOptionsValues ),
237 m_prefix ((std::string)(prefix) +
"fp_" ),
239 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
240 m_optionsDesc (NULL),
242 m_option_help (m_prefix +
"help" ),
243 m_option_computeSolution (m_prefix +
"computeSolution" ),
244 m_option_computeCovariances (m_prefix +
"computeCovariances" ),
245 m_option_computeCorrelations (m_prefix +
"computeCorrelations" ),
246 m_option_dataOutputFileName (m_prefix +
"dataOutputFileName" ),
247 m_option_dataOutputAllowedSet(m_prefix +
"dataOutputAllowedSet")
248 #ifdef UQ_SFP_READS_SOLVER_OPTION
249 m_option_solver (m_prefix +
"solver" )
254 queso_require_equal_to_msg(m_env.optionsInputFileName(), std::string(
""), std::string(
"this constructor is incompatible with the existence of an options input file"));
256 if (m_env.subDisplayFile() != NULL) {
257 *m_env.
subDisplayFile() <<
"In StatisticalForwardProblemOptions::constructor(2)"
258 <<
": after setting values of options with prefix '" << m_prefix
259 <<
"', state of object is:"
265 StatisticalForwardProblemOptions::~StatisticalForwardProblemOptions()
269 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
270 if (m_optionsDesc)
delete m_optionsDesc;
271 #endif // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
276 StatisticalForwardProblemOptions::scanOptionsValues()
280 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
281 queso_require_msg(m_optionsDesc,
"m_optionsDesc variable is NULL");
283 defineMyOptions (*m_optionsDesc);
284 m_env.scanInputFileForMyOptions(*m_optionsDesc);
285 getMyOptionValues (*m_optionsDesc);
286 #endif // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
288 if (m_env.subDisplayFile() != NULL) {
289 *m_env.subDisplayFile() <<
"In StatisticalForwardProblemOptions::scanOptionsValues()"
290 <<
": after reading values of options with prefix '" << m_prefix
291 <<
"', state of object is:"
300 StatisticalForwardProblemOptions::print(std::ostream& os)
const
304 os << m_option_computeSolution <<
" = " << m_ov.m_computeSolution
305 <<
"\n" << m_option_computeCovariances <<
" = " << m_ov.m_computeCovariances
306 <<
"\n" << m_option_computeCorrelations <<
" = " << m_ov.m_computeCorrelations
307 <<
"\n" << m_option_dataOutputFileName <<
" = " << m_ov.m_dataOutputFileName;
308 os <<
"\n" << m_option_dataOutputAllowedSet <<
" = ";
309 for (std::set<unsigned int>::iterator setIt = m_ov.m_dataOutputAllowedSet.begin(); setIt != m_ov.m_dataOutputAllowedSet.end(); ++setIt) {
312 #ifdef UQ_SFP_READS_SOLVER_OPTION
313 <<
"\n" << m_option_solver <<
" = " << m_ov.m_solverString
320 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
323 StatisticalForwardProblemOptions::defineMyOptions(boost::program_options::options_description& optionsDesc)
const
327 optionsDesc.add_options()
328 (m_option_help.c_str(),
"produce help message for statistical forward problem")
329 (m_option_computeSolution.c_str(), boost::program_options::value<bool >()->default_value(UQ_SFP_COMPUTE_SOLUTION_ODV ),
"compute solution process" )
330 (m_option_computeCovariances.c_str(), boost::program_options::value<bool >()->default_value(UQ_SFP_COMPUTE_COVARIANCES_ODV ),
"compute pq covariances" )
331 (m_option_computeCorrelations.c_str(), boost::program_options::value<bool >()->default_value(UQ_SFP_COMPUTE_CORRELATIONS_ODV ),
"compute pq correlations" )
332 (m_option_dataOutputFileName.c_str(), boost::program_options::value<std::string>()->default_value(UQ_SFP_DATA_OUTPUT_FILE_NAME_ODV ),
"name of data output file" )
333 (m_option_dataOutputAllowedSet.c_str(), boost::program_options::value<std::string>()->default_value(UQ_SFP_DATA_OUTPUT_ALLOWED_SET_ODV),
"subEnvs that will write to data output file" )
334 #ifdef UQ_SFP_READS_SOLVER_OPTION
335 (m_option_solver.c_str(), boost::program_options::value<std::string>()->default_value(UQ_SFP_SOLVER_ODV ),
"algorithm for propagation" )
341 #endif // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
343 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
346 StatisticalForwardProblemOptions::getMyOptionValues(boost::program_options::options_description& optionsDesc)
350 if (m_env.allOptionsMap().count(m_option_help)) {
351 if (m_env.subDisplayFile()) {
352 *m_env.subDisplayFile() << optionsDesc
357 if (m_env.allOptionsMap().count(m_option_computeSolution)) {
358 m_ov.m_computeSolution = ((
const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_computeSolution]).as<bool>();
361 if (m_env.allOptionsMap().count(m_option_computeCovariances)) {
362 m_ov.m_computeCovariances = ((
const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_computeCovariances]).as<bool>();
365 if (m_env.allOptionsMap().count(m_option_computeCorrelations)) {
366 m_ov.m_computeCorrelations = ((
const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_computeCorrelations]).as<bool>();
369 if (m_env.allOptionsMap().count(m_option_dataOutputFileName)) {
370 m_ov.m_dataOutputFileName = ((
const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_dataOutputFileName]).as<std::string>();
373 if (m_env.allOptionsMap().count(m_option_dataOutputAllowedSet)) {
374 m_ov.m_dataOutputAllowedSet.clear();
375 std::vector<double> tmpAllow(0,0.);
376 std::string inputString = m_env.allOptionsMap()[m_option_dataOutputAllowedSet].as<std::string>();
379 if (tmpAllow.size() > 0) {
380 for (
unsigned int i = 0; i < tmpAllow.size(); ++i) {
381 m_ov.m_dataOutputAllowedSet.insert((
unsigned int) tmpAllow[i]);
386 #ifdef UQ_SFP_READS_SOLVER_OPTION
387 if (m_env.allOptionsMap().count(m_option_solver)) {
388 m_ov.m_solverString = ((
const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_solver]).as<std::string>();
394 #endif // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
SfpOptionsValues()
Constructor/Destructor methods.
std::ostream & operator<<(std::ostream &os, const SequenceStatisticalOptions &obj)
std::string m_option_computeCorrelations
This class reads option values for a Statistical Forward Problem from an input file.
This class provides options for a Statistical Forward Problem if no input file is available...
bool m_computeCorrelations
std::string m_dataOutputFileName
std::string m_option_computeCovariances
std::string m_option_solver
BoostInputOptionsParser * m_parser
std::ostream & operator<<(std::ostream &os, const SequenceStatisticalOptions &obj)
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix queso_require_not_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the absence of an options input file"))
void copy(const SfpOptionsValues &src)
Copies the option values from src to this.
bool m_computeCovariances
std::set< unsigned int > m_dataOutputAllowedSet
std::string m_solverString
void print(std::ostream &os) const
It prints the option values.
virtual ~SfpOptionsValues()
Destructor.
std::string m_option_computeSolution
std::string m_option_dataOutputAllowedSet
std::string m_option_dataOutputFileName
StatisticalForwardProblemOptions(const BaseEnvironment &env, const char *prefix)
Constructor: reads options from the input file.
void MiscReadDoublesFromString(const std::string &inputString, std::vector< double > &outputDoubles)
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
SfpOptionsValues & operator=(const SfpOptionsValues &rhs)
Assignment operator; it copies rhs to this.
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).