queso-0.56.0
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 (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
 
boost::program_options::options_description * 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_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 148 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 192 of file StatisticalInverseProblemOptions.C.

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

195 :
196  m_ov (),
197  m_prefix ((std::string)(prefix) + "ip_"),
198  m_env (env),
199 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
200  m_optionsDesc (new boost::program_options::options_description("Statistical Inverse Problem options")),
201 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
202  m_option_help (m_prefix + "help" ),
203  m_option_computeSolution (m_prefix + "computeSolution" ),
204  m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ),
205  m_option_dataOutputAllowedSet(m_prefix + "dataOutputAllowedSet"),
206 #ifdef UQ_SIP_READS_SOLVER_OPTION
207  m_option_solver (m_prefix + "solver" )
208 #endif
209  m_option_seedWithMAPEstimator(m_prefix + "seedWithMAPEstimator"),
210  m_option_useOptimizerMonitor(m_prefix + "useOptimizerMonitor")
211 {
213  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"));
214 }
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
boost::program_options::options_description * m_optionsDesc
#define queso_require_not_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:74
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 217 of file StatisticalInverseProblemOptions.C.

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

221 :
222  m_ov (alternativeOptionsValues),
223  m_prefix ((std::string)(prefix) + "ip_"),
224  m_env (env),
225 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
226  m_optionsDesc (NULL),
227 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
228  m_option_help (m_prefix + "help" ),
229  m_option_computeSolution (m_prefix + "computeSolution" ),
230  m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ),
231  m_option_dataOutputAllowedSet(m_prefix + "dataOutputAllowedSet"),
232 #ifdef UQ_SIP_READS_SOLVER_OPTION
233  m_option_solver (m_prefix + "solver" )
234 #endif
235  m_option_seedWithMAPEstimator(m_prefix + "seedWithMAPEstimator"),
236  m_option_useOptimizerMonitor(m_prefix + "useOptimizerMonitor")
237 {
239 
240  queso_require_equal_to_msg(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"));
241 
242  if (m_env.subDisplayFile() != NULL) {
243  *m_env.subDisplayFile() << "In StatisticalInverseProblemOptions::constructor(2)"
244  << ": after setting values of options with prefix '" << m_prefix
245  << "', state of object is:"
246  << "\n" << *this
247  << std::endl;
248  }
249 }
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::StatisticalInverseProblemOptions::~StatisticalInverseProblemOptions ( )

Destructor.

Definition at line 251 of file StatisticalInverseProblemOptions.C.

References m_optionsDesc, and queso_deprecated.

252 {
254 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
255  if (m_optionsDesc) delete m_optionsDesc;
256 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
257 }
#define queso_deprecated()
Definition: Defines.h:134
boost::program_options::options_description * m_optionsDesc

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_useOptimizerMonitor, queso_deprecated, UQ_SIP_COMPUTE_SOLUTION_ODV, UQ_SIP_DATA_OUTPUT_ALLOWED_SET_ODV, UQ_SIP_DATA_OUTPUT_FILE_NAME_ODV, UQ_SIP_SEEDWITHMAPESTIMATOR, and UQ_SIP_USEOPTIMIZERMONITOR.

Referenced by scanOptionsValues().

307 {
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 }
#define UQ_SIP_DATA_OUTPUT_ALLOWED_SET_ODV
#define queso_deprecated()
Definition: Defines.h:134
#define UQ_SIP_SEEDWITHMAPESTIMATOR
#define UQ_SIP_USEOPTIMIZERMONITOR
#define UQ_SIP_DATA_OUTPUT_FILE_NAME_ODV
#define UQ_SIP_COMPUTE_SOLUTION_ODV
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_useOptimizerMonitor, m_ov, QUESO::SipOptionsValues::m_seedWithMAPEstimator, QUESO::SipOptionsValues::m_useOptimizerMonitor, QUESO::MiscReadDoublesFromString(), queso_deprecated, and QUESO::BaseEnvironment::subDisplayFile().

Referenced by scanOptionsValues().

328 {
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 }
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::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_useOptimizerMonitor, m_ov, QUESO::SipOptionsValues::m_seedWithMAPEstimator, QUESO::SipOptionsValues::m_useOptimizerMonitor, and queso_deprecated.

Referenced by QUESO::operator<<().

285 {
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 }
#define queso_deprecated()
Definition: Defines.h:134
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_require_msg, QUESO::BaseEnvironment::scanInputFileForMyOptions(), and QUESO::BaseEnvironment::subDisplayFile().

262 {
263 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
264  queso_require_msg(m_optionsDesc, "m_optionsDesc variable is NULL");
265 
269 #endif // 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 }
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
boost::program_options::options_description * m_optionsDesc
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
void getMyOptionValues(boost::program_options::options_description &optionsDesc)
Gets the option values of the SIP.
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
void defineMyOptions(boost::program_options::options_description &optionsDesc) const
Define my SIP options as the default options.

Member Data Documentation

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

Definition at line 192 of file StatisticalInverseProblemOptions.h.

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

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

Definition at line 194 of file StatisticalInverseProblemOptions.h.

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

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

Definition at line 193 of file StatisticalInverseProblemOptions.h.

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

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

Definition at line 191 of file StatisticalInverseProblemOptions.h.

Referenced by defineMyOptions(), and getMyOptionValues().

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

Definition at line 198 of file StatisticalInverseProblemOptions.h.

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

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

Definition at line 199 of file StatisticalInverseProblemOptions.h.

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

boost::program_options::options_description* QUESO::StatisticalInverseProblemOptions::m_optionsDesc
private
SipOptionsValues QUESO::StatisticalInverseProblemOptions::m_ov

Definition at line 174 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 Nov 29 2016 10:53:16 for queso-0.56.0 by  doxygen 1.8.5