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

This class reads option values for a Statistical Forward Problem from an input file. More...

#include <StatisticalForwardProblemOptions.h>

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

Public Member Functions

Constructor/Destructor methods
 StatisticalForwardProblemOptions (const BaseEnvironment &env, const char *prefix)
 Constructor: reads options from the input file. More...
 
 StatisticalForwardProblemOptions (const BaseEnvironment &env, const char *prefix, const SfpOptionsValues &alternativeOptionsValues)
 Constructor: with alternative option values. More...
 
 ~StatisticalForwardProblemOptions ()
 Destructor. More...
 
I/O methods
void scanOptionsValues ()
 It scans the option values from the options input file. More...
 
void print (std::ostream &os) const
 It prints the option values. More...
 

Public Attributes

SfpOptionsValues m_ov
 
std::string m_prefix
 

Private Member Functions

void defineMyOptions (boost::program_options::options_description &optionsDesc) const
 Define my SFP options as the default options. More...
 
void getMyOptionValues (boost::program_options::options_description &optionsDesc)
 Gets the option values of the SFP. More...
 

Private Attributes

const BaseEnvironmentm_env
 
boost::program_options::options_description * m_optionsDesc
 
std::string m_option_help
 
std::string m_option_computeSolution
 
std::string m_option_computeCovariances
 
std::string m_option_computeCorrelations
 
std::string m_option_dataOutputFileName
 
std::string m_option_dataOutputAllowedSet
 

Detailed Description

This class reads option values for a Statistical Forward Problem from an input file.

This class reads the option values for the Statistical Forward Problem (SFP) from an input file provided by the user. The class expects the prefix '<prefix>_fp_'. For instance, if 'prefix' is 'foo_775_', then the constructor will read all options that begin with 'foo_775_fp_'. If the options request data to be written in the output file (MATLAB .m format only, for now), the user can run 'grep zeros <OUTPUT FILE NAME>' after the solution procedure ends in order to check which MATLAB variables are defined and set. The names of the variables are self explanatory.

Definition at line 145 of file StatisticalForwardProblemOptions.h.

Constructor & Destructor Documentation

QUESO::StatisticalForwardProblemOptions::StatisticalForwardProblemOptions ( const BaseEnvironment env,
const char *  prefix 
)

Constructor: reads options from the input file.

Definition at line 203 of file StatisticalForwardProblemOptions.C.

References m_env, QUESO::BaseEnvironment::optionsInputFileName(), queso_deprecated, and queso_require_not_equal_to_msg.

206  :
207  m_ov (),
208  m_prefix ((std::string)(prefix) + "fp_" ),
209  m_env (env),
210 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
211  m_optionsDesc (new boost::program_options::options_description("Statistical Forward Problem options")),
212 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
213  m_option_help (m_prefix + "help" ),
214  m_option_computeSolution (m_prefix + "computeSolution" ),
215  m_option_computeCovariances (m_prefix + "computeCovariances" ),
216  m_option_computeCorrelations (m_prefix + "computeCorrelations" ),
217  m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ),
218  m_option_dataOutputAllowedSet(m_prefix + "dataOutputAllowedSet")
219 #ifdef UQ_SFP_READS_SOLVER_OPTION
220  m_option_solver (m_prefix + "solver" )
221 #endif
222 {
224 
225  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"));
226 }
std::string optionsInputFileName() const
Access to the attribute m_optionsInputFileName, which stores the name of the input file passed by the...
Definition: Environment.C:353
#define queso_deprecated()
Definition: Defines.h:134
#define queso_require_not_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:74
boost::program_options::options_description * m_optionsDesc
QUESO::StatisticalForwardProblemOptions::StatisticalForwardProblemOptions ( const BaseEnvironment env,
const char *  prefix,
const SfpOptionsValues alternativeOptionsValues 
)

Constructor: with alternative option values.

In this constructor, the input options are given by alternativeOptionsValues, rather than the options input file

Definition at line 228 of file StatisticalForwardProblemOptions.C.

References m_env, m_prefix, QUESO::BaseEnvironment::optionsInputFileName(), queso_deprecated, queso_require_equal_to_msg, and QUESO::BaseEnvironment::subDisplayFile().

232  :
233  m_ov (alternativeOptionsValues ),
234  m_prefix ((std::string)(prefix) + "fp_" ),
235  m_env (env),
236 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
237  m_optionsDesc (NULL),
238 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
239  m_option_help (m_prefix + "help" ),
240  m_option_computeSolution (m_prefix + "computeSolution" ),
241  m_option_computeCovariances (m_prefix + "computeCovariances" ),
242  m_option_computeCorrelations (m_prefix + "computeCorrelations" ),
243  m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ),
244  m_option_dataOutputAllowedSet(m_prefix + "dataOutputAllowedSet")
245 #ifdef UQ_SFP_READS_SOLVER_OPTION
246  m_option_solver (m_prefix + "solver" )
247 #endif
248 {
250 
251  queso_require_equal_to_msg(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"));
252 
253  if (m_env.subDisplayFile() != NULL) {
254  *m_env.subDisplayFile() << "In StatisticalForwardProblemOptions::constructor(2)"
255  << ": after setting values of options with prefix '" << m_prefix
256  << "', state of object is:"
257  << "\n" << *this
258  << std::endl;
259  }
260 }
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
std::string optionsInputFileName() const
Access to the attribute m_optionsInputFileName, which stores the name of the input file passed by the...
Definition: Environment.C:353
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:73
#define queso_deprecated()
Definition: Defines.h:134
boost::program_options::options_description * m_optionsDesc
QUESO::StatisticalForwardProblemOptions::~StatisticalForwardProblemOptions ( )

Destructor.

Definition at line 262 of file StatisticalForwardProblemOptions.C.

References m_optionsDesc, and queso_deprecated.

263 {
265 
266 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
267  if (m_optionsDesc) delete m_optionsDesc;
268 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
269 }
#define queso_deprecated()
Definition: Defines.h:134
boost::program_options::options_description * m_optionsDesc

Member Function Documentation

void QUESO::StatisticalForwardProblemOptions::defineMyOptions ( boost::program_options::options_description &  optionsDesc) const
private

Define my SFP options as the default options.

Definition at line 320 of file StatisticalForwardProblemOptions.C.

References m_option_computeCorrelations, m_option_computeCovariances, m_option_computeSolution, m_option_dataOutputAllowedSet, m_option_dataOutputFileName, m_option_help, queso_deprecated, UQ_SFP_COMPUTE_CORRELATIONS_ODV, UQ_SFP_COMPUTE_COVARIANCES_ODV, UQ_SFP_COMPUTE_SOLUTION_ODV, UQ_SFP_DATA_OUTPUT_ALLOWED_SET_ODV, and UQ_SFP_DATA_OUTPUT_FILE_NAME_ODV.

Referenced by scanOptionsValues().

321 {
323 
324  optionsDesc.add_options()
325  (m_option_help.c_str(), "produce help message for statistical forward problem")
326  (m_option_computeSolution.c_str(), boost::program_options::value<bool >()->default_value(UQ_SFP_COMPUTE_SOLUTION_ODV ), "compute solution process" )
327  (m_option_computeCovariances.c_str(), boost::program_options::value<bool >()->default_value(UQ_SFP_COMPUTE_COVARIANCES_ODV ), "compute pq covariances" )
328  (m_option_computeCorrelations.c_str(), boost::program_options::value<bool >()->default_value(UQ_SFP_COMPUTE_CORRELATIONS_ODV ), "compute pq correlations" )
329  (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" )
330  (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" )
331 #ifdef UQ_SFP_READS_SOLVER_OPTION
332  (m_option_solver.c_str(), boost::program_options::value<std::string>()->default_value(UQ_SFP_SOLVER_ODV ), "algorithm for propagation" )
333 #endif
334  ;
335 
336  return;
337 }
#define UQ_SFP_COMPUTE_CORRELATIONS_ODV
#define UQ_SFP_COMPUTE_SOLUTION_ODV
#define UQ_SFP_COMPUTE_COVARIANCES_ODV
#define queso_deprecated()
Definition: Defines.h:134
#define UQ_SFP_DATA_OUTPUT_FILE_NAME_ODV
#define UQ_SFP_DATA_OUTPUT_ALLOWED_SET_ODV
void QUESO::StatisticalForwardProblemOptions::getMyOptionValues ( boost::program_options::options_description &  optionsDesc)
private

Gets the option values of the SFP.

Definition at line 343 of file StatisticalForwardProblemOptions.C.

References QUESO::BaseEnvironment::allOptionsMap(), QUESO::SfpOptionsValues::m_computeCorrelations, QUESO::SfpOptionsValues::m_computeCovariances, QUESO::SfpOptionsValues::m_computeSolution, QUESO::SfpOptionsValues::m_dataOutputAllowedSet, QUESO::SfpOptionsValues::m_dataOutputFileName, m_env, m_option_computeCorrelations, m_option_computeCovariances, m_option_computeSolution, m_option_dataOutputAllowedSet, m_option_dataOutputFileName, m_option_help, m_ov, QUESO::MiscReadDoublesFromString(), queso_deprecated, and QUESO::BaseEnvironment::subDisplayFile().

Referenced by scanOptionsValues().

344 {
346 
347  if (m_env.allOptionsMap().count(m_option_help)) {
348  if (m_env.subDisplayFile()) {
349  *m_env.subDisplayFile() << optionsDesc
350  << std::endl;
351  }
352  }
353 
355  m_ov.m_computeSolution = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_computeSolution]).as<bool>();
356  }
357 
359  m_ov.m_computeCovariances = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_computeCovariances]).as<bool>();
360  }
361 
363  m_ov.m_computeCorrelations = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_computeCorrelations]).as<bool>();
364  }
365 
367  m_ov.m_dataOutputFileName = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_dataOutputFileName]).as<std::string>();
368  }
369 
372  std::vector<double> tmpAllow(0,0.);
373  std::string inputString = m_env.allOptionsMap()[m_option_dataOutputAllowedSet].as<std::string>();
374  MiscReadDoublesFromString(inputString,tmpAllow);
375 
376  if (tmpAllow.size() > 0) {
377  for (unsigned int i = 0; i < tmpAllow.size(); ++i) {
378  m_ov.m_dataOutputAllowedSet.insert((unsigned int) tmpAllow[i]);
379  }
380  }
381  }
382 
383 #ifdef UQ_SFP_READS_SOLVER_OPTION
384  if (m_env.allOptionsMap().count(m_option_solver)) {
385  m_ov.m_solverString = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_solver]).as<std::string>();
386  }
387 #endif
388 
389  return;
390 }
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
void MiscReadDoublesFromString(const std::string &inputString, std::vector< double > &outputDoubles)
Definition: Miscellaneous.C:40
boost::program_options::variables_map & allOptionsMap() const
Definition: Environment.C:385
#define queso_deprecated()
Definition: Defines.h:134
std::set< unsigned int > m_dataOutputAllowedSet
void QUESO::StatisticalForwardProblemOptions::print ( std::ostream &  os) const

It prints the option values.

Definition at line 297 of file StatisticalForwardProblemOptions.C.

References QUESO::SfpOptionsValues::m_computeCorrelations, QUESO::SfpOptionsValues::m_computeCovariances, QUESO::SfpOptionsValues::m_computeSolution, QUESO::SfpOptionsValues::m_dataOutputAllowedSet, QUESO::SfpOptionsValues::m_dataOutputFileName, m_option_computeCorrelations, m_option_computeCovariances, m_option_computeSolution, m_option_dataOutputAllowedSet, m_option_dataOutputFileName, m_ov, and queso_deprecated.

Referenced by QUESO::operator<<().

298 {
300 
305  os << "\n" << m_option_dataOutputAllowedSet << " = ";
306  for (std::set<unsigned int>::iterator setIt = m_ov.m_dataOutputAllowedSet.begin(); setIt != m_ov.m_dataOutputAllowedSet.end(); ++setIt) {
307  os << *setIt << " ";
308  }
309 #ifdef UQ_SFP_READS_SOLVER_OPTION
310  << "\n" << m_option_solver << " = " << m_ov.m_solverString
311 #endif
312  os << std::endl;
313 
314  return;
315 }
#define queso_deprecated()
Definition: Defines.h:134
std::set< unsigned int > m_dataOutputAllowedSet
void QUESO::StatisticalForwardProblemOptions::scanOptionsValues ( )

It scans the option values from the options input file.

Definition at line 273 of file StatisticalForwardProblemOptions.C.

References defineMyOptions(), getMyOptionValues(), m_env, m_optionsDesc, m_prefix, queso_deprecated, queso_require_msg, QUESO::BaseEnvironment::scanInputFileForMyOptions(), and QUESO::BaseEnvironment::subDisplayFile().

274 {
276 
277 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
278  queso_require_msg(m_optionsDesc, "m_optionsDesc variable is NULL");
279 
283 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
284 
285  if (m_env.subDisplayFile() != NULL) {
286  *m_env.subDisplayFile() << "In StatisticalForwardProblemOptions::scanOptionsValues()"
287  << ": after reading values of options with prefix '" << m_prefix
288  << "', state of object is:"
289  << "\n" << *this
290  << std::endl;
291  }
292 
293  return;
294 }
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
void defineMyOptions(boost::program_options::options_description &optionsDesc) const
Define my SFP options as the default options.
#define queso_deprecated()
Definition: Defines.h:134
void scanInputFileForMyOptions(const boost::program_options::options_description &optionsDesc) const
This method scans the input file provided by the user to QUESO.
Definition: Environment.C:396
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
void getMyOptionValues(boost::program_options::options_description &optionsDesc)
Gets the option values of the SFP.
boost::program_options::options_description * m_optionsDesc

Member Data Documentation

const BaseEnvironment& QUESO::StatisticalForwardProblemOptions::m_env
private
std::string QUESO::StatisticalForwardProblemOptions::m_option_computeCorrelations
private

Definition at line 191 of file StatisticalForwardProblemOptions.h.

Referenced by defineMyOptions(), getMyOptionValues(), and print().

std::string QUESO::StatisticalForwardProblemOptions::m_option_computeCovariances
private

Definition at line 190 of file StatisticalForwardProblemOptions.h.

Referenced by defineMyOptions(), getMyOptionValues(), and print().

std::string QUESO::StatisticalForwardProblemOptions::m_option_computeSolution
private

Definition at line 189 of file StatisticalForwardProblemOptions.h.

Referenced by defineMyOptions(), getMyOptionValues(), and print().

std::string QUESO::StatisticalForwardProblemOptions::m_option_dataOutputAllowedSet
private

Definition at line 193 of file StatisticalForwardProblemOptions.h.

Referenced by defineMyOptions(), getMyOptionValues(), and print().

std::string QUESO::StatisticalForwardProblemOptions::m_option_dataOutputFileName
private

Definition at line 192 of file StatisticalForwardProblemOptions.h.

Referenced by defineMyOptions(), getMyOptionValues(), and print().

std::string QUESO::StatisticalForwardProblemOptions::m_option_help
private

Definition at line 188 of file StatisticalForwardProblemOptions.h.

Referenced by defineMyOptions(), and getMyOptionValues().

boost::program_options::options_description* QUESO::StatisticalForwardProblemOptions::m_optionsDesc
private
SfpOptionsValues QUESO::StatisticalForwardProblemOptions::m_ov

Definition at line 171 of file StatisticalForwardProblemOptions.h.

Referenced by getMyOptionValues(), and print().

std::string QUESO::StatisticalForwardProblemOptions::m_prefix

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

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