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

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

#include <StatisticalInverseProblemOptions.h>

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

Public Member Functions

Constructor/Destructor methods
 StatisticalInverseProblemOptions (const BaseEnvironment &env, const char *prefix)
 Constructor: reads options from the input file. More...
 
 StatisticalInverseProblemOptions (const BaseEnvironment &env, const char *prefix, const SipOptionsValues &alternativeOptionsValues)
 Constructor: with alternative option values. More...
 
 ~StatisticalInverseProblemOptions ()
 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

SipOptionsValues m_ov
 
std::string m_prefix
 

Private Member Functions

void defineMyOptions (po::options_description &optionsDesc) const
 Define my SIP options as the default options. More...
 
void getMyOptionValues (po::options_description &optionsDesc)
 Gets the option values of the SIP. 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_dataOutputFileName
 
std::string m_option_dataOutputAllowedSet
 

Detailed Description

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

This class reads the option values for the Statistical Inverse Problem (SIP) from an input file provided by the user. The class expects the prefix '<prefix>_ip_'. For instance, if 'prefix' is 'foo_775_', then the constructor will read all options that begin with 'foo_775_ip_'. 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 110 of file StatisticalInverseProblemOptions.h.

Constructor & Destructor Documentation

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

Constructor: reads options from the input file.

Definition at line 82 of file StatisticalInverseProblemOptions.C.

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

85  :
86  m_ov (),
87  m_prefix ((std::string)(prefix) + "ip_"),
88  m_env (env),
89  m_optionsDesc (new po::options_description("Statistical Inverse Problem options")),
90  m_option_help (m_prefix + "help" ),
91  m_option_computeSolution (m_prefix + "computeSolution" ),
92  m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ),
93  m_option_dataOutputAllowedSet(m_prefix + "dataOutputAllowedSet")
94 #ifdef UQ_SIP_READS_SOLVER_OPTION
95  m_option_solver (m_prefix + "solver" )
96 #endif
97 {
99  m_env.worldRank(),
100  "StatisticalInverseProblemOptions::constructor(1)",
101  "this constructor is incompatible with the absence of an options input file");
102 }
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::StatisticalInverseProblemOptions::StatisticalInverseProblemOptions ( const BaseEnvironment env,
const char *  prefix,
const SipOptionsValues 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 105 of file StatisticalInverseProblemOptions.C.

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

109  :
110  m_ov (alternativeOptionsValues),
111  m_prefix ((std::string)(prefix) + "ip_"),
112  m_env (env),
113  m_optionsDesc (NULL),
114  m_option_help (m_prefix + "help" ),
115  m_option_computeSolution (m_prefix + "computeSolution" ),
116  m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ),
117  m_option_dataOutputAllowedSet(m_prefix + "dataOutputAllowedSet")
118 #ifdef UQ_SIP_READS_SOLVER_OPTION
119  m_option_solver (m_prefix + "solver" )
120 #endif
121 {
123  m_env.worldRank(),
124  "StatisticalInverseProblemOptions::constructor(2)",
125  "this constructor is incompatible with the existence of an options input file");
126 
127  if (m_env.subDisplayFile() != NULL) {
128  *m_env.subDisplayFile() << "In StatisticalInverseProblemOptions::constructor(2)"
129  << ": after setting values of options with prefix '" << m_prefix
130  << "', state of object is:"
131  << "\n" << *this
132  << std::endl;
133  }
134 }
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::StatisticalInverseProblemOptions::~StatisticalInverseProblemOptions ( )

Destructor.

Definition at line 136 of file StatisticalInverseProblemOptions.C.

References m_optionsDesc.

137 {
138  if (m_optionsDesc) delete m_optionsDesc;
139 }

Member Function Documentation

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

Define my SIP options as the default options.

Definition at line 187 of file StatisticalInverseProblemOptions.C.

References m_option_computeSolution, m_option_dataOutputAllowedSet, m_option_dataOutputFileName, m_option_help, UQ_SIP_COMPUTE_SOLUTION_ODV, UQ_SIP_DATA_OUTPUT_ALLOWED_SET_ODV, and UQ_SIP_DATA_OUTPUT_FILE_NAME_ODV.

Referenced by scanOptionsValues().

188 {
189  optionsDesc.add_options()
190  (m_option_help.c_str(), "produce help message for statistical inverse problem")
191  (m_option_computeSolution.c_str(), po::value<bool >()->default_value(UQ_SIP_COMPUTE_SOLUTION_ODV ), "compute solution process" )
192  (m_option_dataOutputFileName.c_str(), po::value<std::string>()->default_value(UQ_SIP_DATA_OUTPUT_FILE_NAME_ODV ), "name of data output file" )
193  (m_option_dataOutputAllowedSet.c_str(), po::value<std::string>()->default_value(UQ_SIP_DATA_OUTPUT_ALLOWED_SET_ODV), "subEnvs that will write to data output file" )
194 #ifdef UQ_SIP_READS_SOLVER_OPTION
195  (m_option_solver.c_str(), po::value<std::string>()->default_value(UQ_SIP_SOLVER_ODV ), "algorithm for calibration" )
196 #endif
197  ;
198 
199  return;
200 }
#define UQ_SIP_DATA_OUTPUT_ALLOWED_SET_ODV
#define UQ_SIP_DATA_OUTPUT_FILE_NAME_ODV
#define UQ_SIP_COMPUTE_SOLUTION_ODV
void QUESO::StatisticalInverseProblemOptions::getMyOptionValues ( po::options_description &  optionsDesc)
private

Gets the option values of the SIP.

Definition at line 203 of file StatisticalInverseProblemOptions.C.

References QUESO::BaseEnvironment::allOptionsMap(), QUESO::SipOptionsValues::m_computeSolution, QUESO::SipOptionsValues::m_dataOutputAllowedSet, QUESO::SipOptionsValues::m_dataOutputFileName, m_env, m_option_computeSolution, m_option_dataOutputAllowedSet, m_option_dataOutputFileName, m_option_help, m_ov, QUESO::MiscReadDoublesFromString(), and QUESO::BaseEnvironment::subDisplayFile().

Referenced by scanOptionsValues().

204 {
205  if (m_env.allOptionsMap().count(m_option_help)) {
206  if (m_env.subDisplayFile()) {
207  *m_env.subDisplayFile() << optionsDesc
208  << std::endl;
209  }
210  }
211 
213  m_ov.m_computeSolution = ((const po::variable_value&) m_env.allOptionsMap()[m_option_computeSolution]).as<bool>();
214  }
215 
217  m_ov.m_dataOutputFileName = ((const po::variable_value&) m_env.allOptionsMap()[m_option_dataOutputFileName]).as<std::string>();
218  }
219 
222  std::vector<double> tmpAllow(0,0.);
223  std::string inputString = m_env.allOptionsMap()[m_option_dataOutputAllowedSet].as<std::string>();
224  MiscReadDoublesFromString(inputString,tmpAllow);
225 
226  if (tmpAllow.size() > 0) {
227  for (unsigned int i = 0; i < tmpAllow.size(); ++i) {
228  m_ov.m_dataOutputAllowedSet.insert((unsigned int) tmpAllow[i]);
229  }
230  }
231  }
232 
233 #ifdef UQ_SIP_READS_SOLVER_OPTION
234  if (m_env.allOptionsMap().count(m_option_solver)) {
235  m_ov.m_solverString = ((const po::variable_value&) m_env.allOptionsMap()[m_option_solver]).as<std::string>();
236  }
237 #endif
238 
239  return;
240 }
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
std::set< unsigned int > m_dataOutputAllowedSet
void MiscReadDoublesFromString(const std::string &inputString, std::vector< double > &outputDoubles)
Definition: Miscellaneous.C:39
void QUESO::StatisticalInverseProblemOptions::print ( std::ostream &  os) const

It prints the option values.

Definition at line 170 of file StatisticalInverseProblemOptions.C.

References QUESO::SipOptionsValues::m_computeSolution, QUESO::SipOptionsValues::m_dataOutputAllowedSet, QUESO::SipOptionsValues::m_dataOutputFileName, m_option_computeSolution, m_option_dataOutputAllowedSet, m_option_dataOutputFileName, and m_ov.

Referenced by QUESO::operator<<().

171 {
172  os << "\n" << m_option_computeSolution << " = " << m_ov.m_computeSolution
174  os << "\n" << m_option_dataOutputAllowedSet << " = ";
175  for (std::set<unsigned int>::iterator setIt = m_ov.m_dataOutputAllowedSet.begin(); setIt != m_ov.m_dataOutputAllowedSet.end(); ++setIt) {
176  os << *setIt << " ";
177  }
178 #ifdef UQ_SIP_READS_SOLVER_OPTION
179  << "\n" << m_option_solver << " = " << m_ov.m_solverString
180 #endif
181  os << std::endl;
182 
183  return;
184 }
std::set< unsigned int > m_dataOutputAllowedSet
void QUESO::StatisticalInverseProblemOptions::scanOptionsValues ( )

It scans the option values from the options input file.

Definition at line 143 of file StatisticalInverseProblemOptions.C.

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

Referenced by QUESO::StatisticalInverseProblem< P_V, P_M >::StatisticalInverseProblem().

144 {
146  m_env.worldRank(),
147  "StatisticalInverseProblemOptions::scanOptionsValues()",
148  "m_optionsDesc variable is NULL");
149 
152  //std::cout << "scan 000\n"
153  // << std::endl;
155  //std::cout << "scan 001\n"
156  // << std::endl;
157 
158  if (m_env.subDisplayFile() != NULL) {
159  *m_env.subDisplayFile() << "In StatisticalInverseProblemOptions::scanOptionsValues()"
160  << ": after reading values of options with prefix '" << m_prefix
161  << "', state of object is:"
162  << "\n" << *this
163  << std::endl;
164  }
165 
166  return;
167 }
void getMyOptionValues(po::options_description &optionsDesc)
Gets the option values of the SIP.
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
void defineMyOptions(po::options_description &optionsDesc) const
Define my SIP options as the default options.
#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::StatisticalInverseProblemOptions::m_env
private
std::string QUESO::StatisticalInverseProblemOptions::m_option_computeSolution
private

Definition at line 150 of file StatisticalInverseProblemOptions.h.

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

std::string QUESO::StatisticalInverseProblemOptions::m_option_dataOutputAllowedSet
private

Definition at line 152 of file StatisticalInverseProblemOptions.h.

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

std::string QUESO::StatisticalInverseProblemOptions::m_option_dataOutputFileName
private

Definition at line 151 of file StatisticalInverseProblemOptions.h.

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

std::string QUESO::StatisticalInverseProblemOptions::m_option_help
private

Definition at line 149 of file StatisticalInverseProblemOptions.h.

Referenced by defineMyOptions(), and getMyOptionValues().

po::options_description* QUESO::StatisticalInverseProblemOptions::m_optionsDesc
private
SipOptionsValues QUESO::StatisticalInverseProblemOptions::m_ov

Definition at line 136 of file StatisticalInverseProblemOptions.h.

Referenced by getMyOptionValues(), and print().

std::string QUESO::StatisticalInverseProblemOptions::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