queso-0.51.1
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 (po::options_description &optionsDesc) const
 Define my SFP options as the default options. More...
 
void getMyOptionValues (po::options_description &optionsDesc)
 Gets the option values of the SFP. More...
 

Private Attributes

const BaseEnvironmentm_env
 
po::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 107 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 87 of file StatisticalForwardProblemOptions.C.

References m_env, QUESO::BaseEnvironment::optionsInputFileName(), UQ_FATAL_TEST_MACRO, and QUESO::BaseEnvironment::worldRank().

90  :
91  m_ov (),
92  m_prefix ((std::string)(prefix) + "fp_" ),
93  m_env (env),
94  m_optionsDesc (new po::options_description("Statistical Forward Problem options")),
95  m_option_help (m_prefix + "help" ),
96  m_option_computeSolution (m_prefix + "computeSolution" ),
97  m_option_computeCovariances (m_prefix + "computeCovariances" ),
98  m_option_computeCorrelations (m_prefix + "computeCorrelations" ),
99  m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ),
100  m_option_dataOutputAllowedSet(m_prefix + "dataOutputAllowedSet")
101 #ifdef UQ_SFP_READS_SOLVER_OPTION
102  m_option_solver (m_prefix + "solver" )
103 #endif
104 {
106  m_env.worldRank(),
107  "StatisticalForwardProblemOptions::constructor(1)",
108  "this constructor is incompatible with the absence of an options input file");
109 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
std::string optionsInputFileName() const
Access to the attribute m_optionsInputFileName, which stores the name of the input file passed by the...
Definition: Environment.C:341
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
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 111 of file StatisticalForwardProblemOptions.C.

References m_env, m_prefix, QUESO::BaseEnvironment::optionsInputFileName(), QUESO::BaseEnvironment::subDisplayFile(), UQ_FATAL_TEST_MACRO, and QUESO::BaseEnvironment::worldRank().

115  :
116  m_ov (alternativeOptionsValues ),
117  m_prefix ((std::string)(prefix) + "fp_" ),
118  m_env (env),
119  m_optionsDesc (NULL),
120  m_option_help (m_prefix + "help" ),
121  m_option_computeSolution (m_prefix + "computeSolution" ),
122  m_option_computeCovariances (m_prefix + "computeCovariances" ),
123  m_option_computeCorrelations (m_prefix + "computeCorrelations" ),
124  m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ),
125  m_option_dataOutputAllowedSet(m_prefix + "dataOutputAllowedSet")
126 #ifdef UQ_SFP_READS_SOLVER_OPTION
127  m_option_solver (m_prefix + "solver" )
128 #endif
129 {
131  m_env.worldRank(),
132  "StatisticalForwardProblemOptions::constructor(2)",
133  "this constructor is incompatible with the existence of an options input file");
134 
135  if (m_env.subDisplayFile() != NULL) {
136  *m_env.subDisplayFile() << "In StatisticalForwardProblemOptions::constructor(2)"
137  << ": after setting values of options with prefix '" << m_prefix
138  << "', state of object is:"
139  << "\n" << *this
140  << std::endl;
141  }
142 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
std::string optionsInputFileName() const
Access to the attribute m_optionsInputFileName, which stores the name of the input file passed by the...
Definition: Environment.C:341
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
QUESO::StatisticalForwardProblemOptions::~StatisticalForwardProblemOptions ( )

Destructor.

Definition at line 144 of file StatisticalForwardProblemOptions.C.

References m_optionsDesc.

145 {
146  if (m_optionsDesc) delete m_optionsDesc;
147 }

Member Function Documentation

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

Define my SFP options as the default options.

Definition at line 194 of file StatisticalForwardProblemOptions.C.

References m_option_computeCorrelations, m_option_computeCovariances, m_option_computeSolution, m_option_dataOutputAllowedSet, m_option_dataOutputFileName, m_option_help, 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().

195 {
196  optionsDesc.add_options()
197  (m_option_help.c_str(), "produce help message for statistical forward problem")
198  (m_option_computeSolution.c_str(), po::value<bool >()->default_value(UQ_SFP_COMPUTE_SOLUTION_ODV ), "compute solution process" )
199  (m_option_computeCovariances.c_str(), po::value<bool >()->default_value(UQ_SFP_COMPUTE_COVARIANCES_ODV ), "compute pq covariances" )
200  (m_option_computeCorrelations.c_str(), po::value<bool >()->default_value(UQ_SFP_COMPUTE_CORRELATIONS_ODV ), "compute pq correlations" )
201  (m_option_dataOutputFileName.c_str(), po::value<std::string>()->default_value(UQ_SFP_DATA_OUTPUT_FILE_NAME_ODV ), "name of data output file" )
202  (m_option_dataOutputAllowedSet.c_str(), po::value<std::string>()->default_value(UQ_SFP_DATA_OUTPUT_ALLOWED_SET_ODV), "subEnvs that will write to data output file" )
203 #ifdef UQ_SFP_READS_SOLVER_OPTION
204  (m_option_solver.c_str(), po::value<std::string>()->default_value(UQ_SFP_SOLVER_ODV ), "algorithm for propagation" )
205 #endif
206  ;
207 
208  return;
209 }
#define UQ_SFP_COMPUTE_SOLUTION_ODV
#define UQ_SFP_COMPUTE_COVARIANCES_ODV
#define UQ_SFP_COMPUTE_CORRELATIONS_ODV
#define UQ_SFP_DATA_OUTPUT_FILE_NAME_ODV
#define UQ_SFP_DATA_OUTPUT_ALLOWED_SET_ODV
void QUESO::StatisticalForwardProblemOptions::getMyOptionValues ( po::options_description &  optionsDesc)
private

Gets the option values of the SFP.

Definition at line 212 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(), and QUESO::BaseEnvironment::subDisplayFile().

Referenced by scanOptionsValues().

213 {
214  if (m_env.allOptionsMap().count(m_option_help)) {
215  if (m_env.subDisplayFile()) {
216  *m_env.subDisplayFile() << optionsDesc
217  << std::endl;
218  }
219  }
220 
222  m_ov.m_computeSolution = ((const po::variable_value&) m_env.allOptionsMap()[m_option_computeSolution]).as<bool>();
223  }
224 
226  m_ov.m_computeCovariances = ((const po::variable_value&) m_env.allOptionsMap()[m_option_computeCovariances]).as<bool>();
227  }
228 
230  m_ov.m_computeCorrelations = ((const po::variable_value&) m_env.allOptionsMap()[m_option_computeCorrelations]).as<bool>();
231  }
232 
234  m_ov.m_dataOutputFileName = ((const po::variable_value&) m_env.allOptionsMap()[m_option_dataOutputFileName]).as<std::string>();
235  }
236 
239  std::vector<double> tmpAllow(0,0.);
240  std::string inputString = m_env.allOptionsMap()[m_option_dataOutputAllowedSet].as<std::string>();
241  MiscReadDoublesFromString(inputString,tmpAllow);
242 
243  if (tmpAllow.size() > 0) {
244  for (unsigned int i = 0; i < tmpAllow.size(); ++i) {
245  m_ov.m_dataOutputAllowedSet.insert((unsigned int) tmpAllow[i]);
246  }
247  }
248  }
249 
250 #ifdef UQ_SFP_READS_SOLVER_OPTION
251  if (m_env.allOptionsMap().count(m_option_solver)) {
252  m_ov.m_solverString = ((const po::variable_value&) m_env.allOptionsMap()[m_option_solver]).as<std::string>();
253  }
254 #endif
255 
256  return;
257 }
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
po::variables_map & allOptionsMap() const
Definition: Environment.C:368
void MiscReadDoublesFromString(const std::string &inputString, std::vector< double > &outputDoubles)
Definition: Miscellaneous.C:39
std::set< unsigned int > m_dataOutputAllowedSet
void QUESO::StatisticalForwardProblemOptions::print ( std::ostream &  os) const

It prints the option values.

Definition at line 174 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, and m_ov.

Referenced by QUESO::operator<<().

175 {
180  os << "\n" << m_option_dataOutputAllowedSet << " = ";
181  for (std::set<unsigned int>::iterator setIt = m_ov.m_dataOutputAllowedSet.begin(); setIt != m_ov.m_dataOutputAllowedSet.end(); ++setIt) {
182  os << *setIt << " ";
183  }
184 #ifdef UQ_SFP_READS_SOLVER_OPTION
185  << "\n" << m_option_solver << " = " << m_ov.m_solverString
186 #endif
187  os << std::endl;
188 
189  return;
190 }
std::set< unsigned int > m_dataOutputAllowedSet
void QUESO::StatisticalForwardProblemOptions::scanOptionsValues ( )

It scans the option values from the options input file.

Definition at line 151 of file StatisticalForwardProblemOptions.C.

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

152 {
154  m_env.worldRank(),
155  "StatisticalForwardProblemOptions::scanOptionsValues()",
156  "m_optionsDesc variable is NULL");
157 
161 
162  if (m_env.subDisplayFile() != NULL) {
163  *m_env.subDisplayFile() << "In StatisticalForwardProblemOptions::scanOptionsValues()"
164  << ": after reading values of options with prefix '" << m_prefix
165  << "', state of object is:"
166  << "\n" << *this
167  << std::endl;
168  }
169 
170  return;
171 }
int worldRank() const
Returns the process world rank.
Definition: Environment.C:235
void defineMyOptions(po::options_description &optionsDesc) const
Define my SFP options as the default options.
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:305
void getMyOptionValues(po::options_description &optionsDesc)
Gets the option values of the SFP.
#define UQ_FATAL_TEST_MACRO(test, givenRank, where, what)
Definition: Defines.h:223
void scanInputFileForMyOptions(const po::options_description &optionsDesc) const
This method scans the input file provided by the user to QUESO.
Definition: Environment.C:378

Member Data Documentation

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

Definition at line 149 of file StatisticalForwardProblemOptions.h.

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

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

Definition at line 148 of file StatisticalForwardProblemOptions.h.

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

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

Definition at line 147 of file StatisticalForwardProblemOptions.h.

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

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

Definition at line 151 of file StatisticalForwardProblemOptions.h.

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

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

Definition at line 150 of file StatisticalForwardProblemOptions.h.

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

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

Definition at line 146 of file StatisticalForwardProblemOptions.h.

Referenced by defineMyOptions(), and getMyOptionValues().

po::options_description* QUESO::StatisticalForwardProblemOptions::m_optionsDesc
private
SfpOptionsValues QUESO::StatisticalForwardProblemOptions::m_ov

Definition at line 133 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 Apr 23 2015 19:26:18 for queso-0.51.1 by  doxygen 1.8.5