queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
QUESO::StatisticalInverseProblemOptions Class Reference

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

#include <StatisticalInverseProblemOptions.h>

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

Private Attributes

const BaseEnvironmentm_env
 
ScopedPtr
< boost::program_options::options_description >
::Type 
m_optionsDesc
 
std::string m_option_help
 
std::string m_option_computeSolution
 
std::string m_option_dataOutputFileName
 
std::string m_option_dataOutputAllowedSet
 
std::string m_option_solver
 
std::string m_option_seedWithMAPEstimator
 
std::string m_option_useOptimizerMonitor
 

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 149 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 195 of file StatisticalInverseProblemOptions.C.

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

198 :
199  m_ov (),
200  m_prefix ((std::string)(prefix) + "ip_"),
201  m_env (env),
202 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
203  m_optionsDesc (new boost::program_options::options_description("Statistical Inverse Problem options")),
204 #endif // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
205  m_option_help (m_prefix + "help" ),
206  m_option_computeSolution (m_prefix + "computeSolution" ),
207  m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ),
208  m_option_dataOutputAllowedSet(m_prefix + "dataOutputAllowedSet"),
209 #ifdef UQ_SIP_READS_SOLVER_OPTION
210  m_option_solver (m_prefix + "solver" )
211 #endif
212  m_option_seedWithMAPEstimator(m_prefix + "seedWithMAPEstimator"),
213  m_option_useOptimizerMonitor(m_prefix + "useOptimizerMonitor")
214 {
215  queso_deprecated();
216  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"));
217 }
ScopedPtr< boost::program_options::options_description >::Type m_optionsDesc
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"))
std::string optionsInputFileName() const
Access to the attribute m_optionsInputFileName, which stores the name of the input file passed by the...
Definition: Environment.C:354
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 220 of file StatisticalInverseProblemOptions.C.

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

224 :
225  m_ov (alternativeOptionsValues),
226  m_prefix ((std::string)(prefix) + "ip_"),
227  m_env (env),
228 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
229  m_optionsDesc (),
230 #endif // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
231  m_option_help (m_prefix + "help" ),
232  m_option_computeSolution (m_prefix + "computeSolution" ),
233  m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ),
234  m_option_dataOutputAllowedSet(m_prefix + "dataOutputAllowedSet"),
235 #ifdef UQ_SIP_READS_SOLVER_OPTION
236  m_option_solver (m_prefix + "solver" )
237 #endif
238  m_option_seedWithMAPEstimator(m_prefix + "seedWithMAPEstimator"),
239  m_option_useOptimizerMonitor(m_prefix + "useOptimizerMonitor")
240 {
241  queso_deprecated();
242 
243  queso_require_equal_to_msg(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"));
244 
245  if (m_env.subDisplayFile() != NULL) {
246  *m_env.subDisplayFile() << "In StatisticalInverseProblemOptions::constructor(2)"
247  << ": after setting values of options with prefix '" << m_prefix
248  << "', state of object is:"
249  << "\n" << *this
250  << std::endl;
251  }
252 }
ScopedPtr< boost::program_options::options_description >::Type 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:354
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"))
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
QUESO::StatisticalInverseProblemOptions::~StatisticalInverseProblemOptions ( )

Destructor.

Definition at line 254 of file StatisticalInverseProblemOptions.C.

255 {
256  queso_deprecated();
257 }

Member Function Documentation

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

Define my SIP options as the default options.

Definition at line 306 of file StatisticalInverseProblemOptions.C.

References m_option_computeSolution, m_option_dataOutputAllowedSet, m_option_dataOutputFileName, m_option_help, m_option_seedWithMAPEstimator, m_option_solver, and m_option_useOptimizerMonitor.

Referenced by scanOptionsValues().

307 {
308  queso_deprecated();
309 
310  optionsDesc.add_options()
311  (m_option_help.c_str(), "produce help message for statistical inverse problem")
312  (m_option_computeSolution.c_str(), boost::program_options::value<bool >()->default_value(UQ_SIP_COMPUTE_SOLUTION_ODV ), "compute solution process" )
313  (m_option_dataOutputFileName.c_str(), boost::program_options::value<std::string>()->default_value(UQ_SIP_DATA_OUTPUT_FILE_NAME_ODV ), "name of data output file" )
314  (m_option_dataOutputAllowedSet.c_str(), boost::program_options::value<std::string>()->default_value(UQ_SIP_DATA_OUTPUT_ALLOWED_SET_ODV), "subEnvs that will write to data output file" )
315 #ifdef UQ_SIP_READS_SOLVER_OPTION
316  (m_option_solver.c_str(), boost::program_options::value<std::string>()->default_value(UQ_SIP_SOLVER_ODV ), "algorithm for calibration" )
317 #endif
318  (m_option_seedWithMAPEstimator.c_str(), boost::program_options::value<bool>()->default_value(UQ_SIP_SEEDWITHMAPESTIMATOR), "toggle optimisation of posterior pdf before sampling")
319  (m_option_useOptimizerMonitor.c_str(), boost::program_options::value<bool>()->default_value(UQ_SIP_USEOPTIMIZERMONITOR), "toggle printing of optimisation progress when seed with MAP estimator")
320  ;
321 }
void QUESO::StatisticalInverseProblemOptions::getMyOptionValues ( boost::program_options::options_description &  optionsDesc)
private

Gets the option values of the SIP.

Definition at line 327 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_option_seedWithMAPEstimator, m_option_solver, m_option_useOptimizerMonitor, m_ov, QUESO::SipOptionsValues::m_seedWithMAPEstimator, QUESO::SipOptionsValues::m_solverString, QUESO::SipOptionsValues::m_useOptimizerMonitor, QUESO::MiscReadDoublesFromString(), and QUESO::BaseEnvironment::subDisplayFile().

Referenced by scanOptionsValues().

328 {
329  queso_deprecated();
330 
331  if (m_env.allOptionsMap().count(m_option_help)) {
332  if (m_env.subDisplayFile()) {
333  *m_env.subDisplayFile() << optionsDesc
334  << std::endl;
335  }
336  }
337 
339  m_ov.m_computeSolution = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_computeSolution]).as<bool>();
340  }
341 
343  m_ov.m_dataOutputFileName = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_dataOutputFileName]).as<std::string>();
344  }
345 
348  std::vector<double> tmpAllow(0,0.);
349  std::string inputString = m_env.allOptionsMap()[m_option_dataOutputAllowedSet].as<std::string>();
350  MiscReadDoublesFromString(inputString,tmpAllow);
351 
352  if (tmpAllow.size() > 0) {
353  for (unsigned int i = 0; i < tmpAllow.size(); ++i) {
354  m_ov.m_dataOutputAllowedSet.insert((unsigned int) tmpAllow[i]);
355  }
356  }
357  }
358 
359 #ifdef UQ_SIP_READS_SOLVER_OPTION
360  if (m_env.allOptionsMap().count(m_option_solver)) {
361  m_ov.m_solverString = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_solver]).as<std::string>();
362  }
363 #endif
364 
366  m_ov.m_seedWithMAPEstimator = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_seedWithMAPEstimator]).as<bool>();
367  }
368 
370  m_ov.m_useOptimizerMonitor = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_useOptimizerMonitor]).as<bool>();
371  }
372 }
boost::program_options::variables_map & allOptionsMap() const
Definition: Environment.C:386
std::set< unsigned int > m_dataOutputAllowedSet
void MiscReadDoublesFromString(const std::string &inputString, std::vector< double > &outputDoubles)
Definition: Miscellaneous.C:40
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
void QUESO::StatisticalInverseProblemOptions::print ( std::ostream &  os) const

It prints the option values.

Definition at line 284 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, m_option_seedWithMAPEstimator, m_option_solver, m_option_useOptimizerMonitor, m_ov, QUESO::SipOptionsValues::m_seedWithMAPEstimator, QUESO::SipOptionsValues::m_solverString, and QUESO::SipOptionsValues::m_useOptimizerMonitor.

Referenced by QUESO::operator<<().

285 {
286  queso_deprecated();
287 
288  os << "\n" << m_option_computeSolution << " = " << m_ov.m_computeSolution
290  os << "\n" << m_option_dataOutputAllowedSet << " = ";
291  for (std::set<unsigned int>::iterator setIt = m_ov.m_dataOutputAllowedSet.begin(); setIt != m_ov.m_dataOutputAllowedSet.end(); ++setIt) {
292  os << *setIt << " ";
293  }
294 #ifdef UQ_SIP_READS_SOLVER_OPTION
295  << "\n" << m_option_solver << " = " << m_ov.m_solverString
296 #endif
299  os << std::endl;
300 
301  return;
302 }
std::set< unsigned int > m_dataOutputAllowedSet
void QUESO::StatisticalInverseProblemOptions::scanOptionsValues ( )

It scans the option values from the options input file.

Definition at line 261 of file StatisticalInverseProblemOptions.C.

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

262 {
263 #ifndef QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
264  queso_require_msg(m_optionsDesc, "m_optionsDesc variable is NULL");
265 
269 #endif // QUESO_DISABLE_BOOST_PROGRAM_OPTIONS
270 
271  if (m_env.subDisplayFile() != NULL) {
272  *m_env.subDisplayFile() << "In StatisticalInverseProblemOptions::scanOptionsValues()"
273  << ": after reading values of options with prefix '" << m_prefix
274  << "', state of object is:"
275  << "\n" << *this
276  << std::endl;
277  }
278 
279  return;
280 }
ScopedPtr< boost::program_options::options_description >::Type m_optionsDesc
void getMyOptionValues(boost::program_options::options_description &optionsDesc)
Gets the option values of the SIP.
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:397
void defineMyOptions(boost::program_options::options_description &optionsDesc) const
Define my SIP options as the default options.
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320

Member Data Documentation

const BaseEnvironment& QUESO::StatisticalInverseProblemOptions::m_env
private
std::string QUESO::StatisticalInverseProblemOptions::m_option_computeSolution
private

Definition at line 193 of file StatisticalInverseProblemOptions.h.

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

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

Definition at line 195 of file StatisticalInverseProblemOptions.h.

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

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

Definition at line 194 of file StatisticalInverseProblemOptions.h.

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

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

Definition at line 192 of file StatisticalInverseProblemOptions.h.

Referenced by defineMyOptions(), and getMyOptionValues().

std::string QUESO::StatisticalInverseProblemOptions::m_option_seedWithMAPEstimator
private

Definition at line 199 of file StatisticalInverseProblemOptions.h.

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

std::string QUESO::StatisticalInverseProblemOptions::m_option_solver
private

Definition at line 197 of file StatisticalInverseProblemOptions.h.

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

std::string QUESO::StatisticalInverseProblemOptions::m_option_useOptimizerMonitor
private

Definition at line 200 of file StatisticalInverseProblemOptions.h.

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

ScopedPtr<boost::program_options::options_description>::Type QUESO::StatisticalInverseProblemOptions::m_optionsDesc
private

Definition at line 189 of file StatisticalInverseProblemOptions.h.

Referenced by scanOptionsValues().

SipOptionsValues QUESO::StatisticalInverseProblemOptions::m_ov

Definition at line 175 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 Tue Jun 5 2018 19:49:37 for queso-0.57.1 by  doxygen 1.8.5