queso-0.53.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 138 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 174 of file StatisticalForwardProblemOptions.C.

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

177  :
178  m_ov (),
179  m_prefix ((std::string)(prefix) + "fp_" ),
180  m_env (env),
181  m_optionsDesc (new boost::program_options::options_description("Statistical Forward Problem options")),
182  m_option_help (m_prefix + "help" ),
183  m_option_computeSolution (m_prefix + "computeSolution" ),
184  m_option_computeCovariances (m_prefix + "computeCovariances" ),
185  m_option_computeCorrelations (m_prefix + "computeCorrelations" ),
186  m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ),
187  m_option_dataOutputAllowedSet(m_prefix + "dataOutputAllowedSet")
188 #ifdef UQ_SFP_READS_SOLVER_OPTION
189  m_option_solver (m_prefix + "solver" )
190 #endif
191 {
193 
194  queso_require_not_equal_to_msg(m_env.optionsInputFileName(), "", "this constructor is incompatible with the absence of an options input file");
195 }
#define queso_require_not_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:86
boost::program_options::options_description * m_optionsDesc
std::string optionsInputFileName() const
Access to the attribute m_optionsInputFileName, which stores the name of the input file passed by the...
Definition: Environment.C:307
#define queso_deprecated()
Definition: Defines.h:120
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 197 of file StatisticalForwardProblemOptions.C.

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

201  :
202  m_ov (alternativeOptionsValues ),
203  m_prefix ((std::string)(prefix) + "fp_" ),
204  m_env (env),
205  m_optionsDesc (NULL),
206  m_option_help (m_prefix + "help" ),
207  m_option_computeSolution (m_prefix + "computeSolution" ),
208  m_option_computeCovariances (m_prefix + "computeCovariances" ),
209  m_option_computeCorrelations (m_prefix + "computeCorrelations" ),
210  m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ),
211  m_option_dataOutputAllowedSet(m_prefix + "dataOutputAllowedSet")
212 #ifdef UQ_SFP_READS_SOLVER_OPTION
213  m_option_solver (m_prefix + "solver" )
214 #endif
215 {
217 
218  queso_require_equal_to_msg(m_env.optionsInputFileName(), "", "this constructor is incompatible with the existence of an options input file");
219 
220  if (m_env.subDisplayFile() != NULL) {
221  *m_env.subDisplayFile() << "In StatisticalForwardProblemOptions::constructor(2)"
222  << ": after setting values of options with prefix '" << m_prefix
223  << "', state of object is:"
224  << "\n" << *this
225  << std::endl;
226  }
227 }
boost::program_options::options_description * m_optionsDesc
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
std::string optionsInputFileName() const
Access to the attribute m_optionsInputFileName, which stores the name of the input file passed by the...
Definition: Environment.C:307
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
#define queso_deprecated()
Definition: Defines.h:120
QUESO::StatisticalForwardProblemOptions::~StatisticalForwardProblemOptions ( )

Destructor.

Definition at line 229 of file StatisticalForwardProblemOptions.C.

References m_optionsDesc, and queso_deprecated.

230 {
232 
233  if (m_optionsDesc) delete m_optionsDesc;
234 }
boost::program_options::options_description * m_optionsDesc
#define queso_deprecated()
Definition: Defines.h:120

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 282 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().

283 {
285 
286  optionsDesc.add_options()
287  (m_option_help.c_str(), "produce help message for statistical forward problem")
288  (m_option_computeSolution.c_str(), boost::program_options::value<bool >()->default_value(UQ_SFP_COMPUTE_SOLUTION_ODV ), "compute solution process" )
289  (m_option_computeCovariances.c_str(), boost::program_options::value<bool >()->default_value(UQ_SFP_COMPUTE_COVARIANCES_ODV ), "compute pq covariances" )
290  (m_option_computeCorrelations.c_str(), boost::program_options::value<bool >()->default_value(UQ_SFP_COMPUTE_CORRELATIONS_ODV ), "compute pq correlations" )
291  (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" )
292  (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" )
293 #ifdef UQ_SFP_READS_SOLVER_OPTION
294  (m_option_solver.c_str(), boost::program_options::value<std::string>()->default_value(UQ_SFP_SOLVER_ODV ), "algorithm for propagation" )
295 #endif
296  ;
297 
298  return;
299 }
#define UQ_SFP_COMPUTE_SOLUTION_ODV
#define UQ_SFP_COMPUTE_CORRELATIONS_ODV
#define UQ_SFP_DATA_OUTPUT_ALLOWED_SET_ODV
#define UQ_SFP_DATA_OUTPUT_FILE_NAME_ODV
#define queso_deprecated()
Definition: Defines.h:120
#define UQ_SFP_COMPUTE_COVARIANCES_ODV
void QUESO::StatisticalForwardProblemOptions::getMyOptionValues ( boost::program_options::options_description &  optionsDesc)
private

Gets the option values of the SFP.

Definition at line 302 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().

303 {
305 
306  if (m_env.allOptionsMap().count(m_option_help)) {
307  if (m_env.subDisplayFile()) {
308  *m_env.subDisplayFile() << optionsDesc
309  << std::endl;
310  }
311  }
312 
314  m_ov.m_computeSolution = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_computeSolution]).as<bool>();
315  }
316 
318  m_ov.m_computeCovariances = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_computeCovariances]).as<bool>();
319  }
320 
322  m_ov.m_computeCorrelations = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_computeCorrelations]).as<bool>();
323  }
324 
326  m_ov.m_dataOutputFileName = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_dataOutputFileName]).as<std::string>();
327  }
328 
331  std::vector<double> tmpAllow(0,0.);
332  std::string inputString = m_env.allOptionsMap()[m_option_dataOutputAllowedSet].as<std::string>();
333  MiscReadDoublesFromString(inputString,tmpAllow);
334 
335  if (tmpAllow.size() > 0) {
336  for (unsigned int i = 0; i < tmpAllow.size(); ++i) {
337  m_ov.m_dataOutputAllowedSet.insert((unsigned int) tmpAllow[i]);
338  }
339  }
340  }
341 
342 #ifdef UQ_SFP_READS_SOLVER_OPTION
343  if (m_env.allOptionsMap().count(m_option_solver)) {
344  m_ov.m_solverString = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_solver]).as<std::string>();
345  }
346 #endif
347 
348  return;
349 }
std::set< unsigned int > m_dataOutputAllowedSet
boost::program_options::variables_map & allOptionsMap() const
Definition: Environment.C:336
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
void MiscReadDoublesFromString(const std::string &inputString, std::vector< double > &outputDoubles)
Definition: Miscellaneous.C:40
#define queso_deprecated()
Definition: Defines.h:120
void QUESO::StatisticalForwardProblemOptions::print ( std::ostream &  os) const

It prints the option values.

Definition at line 260 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<<().

261 {
263 
268  os << "\n" << m_option_dataOutputAllowedSet << " = ";
269  for (std::set<unsigned int>::iterator setIt = m_ov.m_dataOutputAllowedSet.begin(); setIt != m_ov.m_dataOutputAllowedSet.end(); ++setIt) {
270  os << *setIt << " ";
271  }
272 #ifdef UQ_SFP_READS_SOLVER_OPTION
273  << "\n" << m_option_solver << " = " << m_ov.m_solverString
274 #endif
275  os << std::endl;
276 
277  return;
278 }
std::set< unsigned int > m_dataOutputAllowedSet
#define queso_deprecated()
Definition: Defines.h:120
void QUESO::StatisticalForwardProblemOptions::scanOptionsValues ( )

It scans the option values from the options input file.

Definition at line 238 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().

239 {
241 
242  queso_require_msg(m_optionsDesc, "m_optionsDesc variable is NULL");
243 
247 
248  if (m_env.subDisplayFile() != NULL) {
249  *m_env.subDisplayFile() << "In StatisticalForwardProblemOptions::scanOptionsValues()"
250  << ": after reading values of options with prefix '" << m_prefix
251  << "', state of object is:"
252  << "\n" << *this
253  << std::endl;
254  }
255 
256  return;
257 }
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:345
boost::program_options::options_description * m_optionsDesc
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
void getMyOptionValues(boost::program_options::options_description &optionsDesc)
Gets the option values of the SFP.
#define queso_deprecated()
Definition: Defines.h:120
void defineMyOptions(boost::program_options::options_description &optionsDesc) const
Define my SFP options as the default options.

Member Data Documentation

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

Definition at line 180 of file StatisticalForwardProblemOptions.h.

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

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

Definition at line 179 of file StatisticalForwardProblemOptions.h.

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

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

Definition at line 178 of file StatisticalForwardProblemOptions.h.

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

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

Definition at line 182 of file StatisticalForwardProblemOptions.h.

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

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

Definition at line 181 of file StatisticalForwardProblemOptions.h.

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

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

Definition at line 177 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 164 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 Thu Jun 11 2015 13:52:36 for queso-0.53.0 by  doxygen 1.8.5