queso-0.55.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 141 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 165 of file StatisticalInverseProblemOptions.C.

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

168 :
169  m_ov (),
170  m_prefix ((std::string)(prefix) + "ip_"),
171  m_env (env),
172  m_optionsDesc (new boost::program_options::options_description("Statistical Inverse Problem options")),
173  m_option_help (m_prefix + "help" ),
174  m_option_computeSolution (m_prefix + "computeSolution" ),
175  m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ),
176  m_option_dataOutputAllowedSet(m_prefix + "dataOutputAllowedSet"),
177 #ifdef UQ_SIP_READS_SOLVER_OPTION
178  m_option_solver (m_prefix + "solver" )
179 #endif
180  m_option_seedWithMAPEstimator(m_prefix + "seedWithMAPEstimator"),
181  m_option_useOptimizerMonitor(m_prefix + "useOptimizerMonitor")
182 {
184  queso_require_not_equal_to_msg(m_env.optionsInputFileName(), "", "this constructor is incompatible with the absence of an options input file");
185 }
#define queso_require_not_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:86
#define queso_deprecated()
Definition: Defines.h:134
std::string optionsInputFileName() const
Access to the attribute m_optionsInputFileName, which stores the name of the input file passed by the...
Definition: Environment.C:311
boost::program_options::options_description * m_optionsDesc
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 188 of file StatisticalInverseProblemOptions.C.

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

192 :
193  m_ov (alternativeOptionsValues),
194  m_prefix ((std::string)(prefix) + "ip_"),
195  m_env (env),
196  m_optionsDesc (NULL),
197  m_option_help (m_prefix + "help" ),
198  m_option_computeSolution (m_prefix + "computeSolution" ),
199  m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ),
200  m_option_dataOutputAllowedSet(m_prefix + "dataOutputAllowedSet"),
201 #ifdef UQ_SIP_READS_SOLVER_OPTION
202  m_option_solver (m_prefix + "solver" )
203 #endif
204  m_option_seedWithMAPEstimator(m_prefix + "seedWithMAPEstimator"),
205  m_option_useOptimizerMonitor(m_prefix + "useOptimizerMonitor")
206 {
208 
209  queso_require_equal_to_msg(m_env.optionsInputFileName(), "", "this constructor is incompatible with the existence of an options input file");
210 
211  if (m_env.subDisplayFile() != NULL) {
212  *m_env.subDisplayFile() << "In StatisticalInverseProblemOptions::constructor(2)"
213  << ": after setting values of options with prefix '" << m_prefix
214  << "', state of object is:"
215  << "\n" << *this
216  << std::endl;
217  }
218 }
#define queso_deprecated()
Definition: Defines.h:134
#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:311
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:278
boost::program_options::options_description * m_optionsDesc
QUESO::StatisticalInverseProblemOptions::~StatisticalInverseProblemOptions ( )

Destructor.

Definition at line 220 of file StatisticalInverseProblemOptions.C.

References m_optionsDesc, and queso_deprecated.

221 {
223  if (m_optionsDesc) delete m_optionsDesc;
224 }
#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 270 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().

271 {
273 
274  optionsDesc.add_options()
275  (m_option_help.c_str(), "produce help message for statistical inverse problem")
276  (m_option_computeSolution.c_str(), boost::program_options::value<bool >()->default_value(UQ_SIP_COMPUTE_SOLUTION_ODV ), "compute solution process" )
277  (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" )
278  (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" )
279 #ifdef UQ_SIP_READS_SOLVER_OPTION
280  (m_option_solver.c_str(), boost::program_options::value<std::string>()->default_value(UQ_SIP_SOLVER_ODV ), "algorithm for calibration" )
281 #endif
282  (m_option_seedWithMAPEstimator.c_str(), boost::program_options::value<bool>()->default_value(UQ_SIP_SEEDWITHMAPESTIMATOR), "toggle optimisation of posterior pdf before sampling")
283  (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")
284  ;
285 }
#define UQ_SIP_COMPUTE_SOLUTION_ODV
#define UQ_SIP_DATA_OUTPUT_FILE_NAME_ODV
#define queso_deprecated()
Definition: Defines.h:134
#define UQ_SIP_SEEDWITHMAPESTIMATOR
#define UQ_SIP_DATA_OUTPUT_ALLOWED_SET_ODV
#define UQ_SIP_USEOPTIMIZERMONITOR
void QUESO::StatisticalInverseProblemOptions::getMyOptionValues ( boost::program_options::options_description &  optionsDesc)
private

Gets the option values of the SIP.

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

289 {
291 
292  if (m_env.allOptionsMap().count(m_option_help)) {
293  if (m_env.subDisplayFile()) {
294  *m_env.subDisplayFile() << optionsDesc
295  << std::endl;
296  }
297  }
298 
300  m_ov.m_computeSolution = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_computeSolution]).as<bool>();
301  }
302 
304  m_ov.m_dataOutputFileName = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_dataOutputFileName]).as<std::string>();
305  }
306 
309  std::vector<double> tmpAllow(0,0.);
310  std::string inputString = m_env.allOptionsMap()[m_option_dataOutputAllowedSet].as<std::string>();
311  MiscReadDoublesFromString(inputString,tmpAllow);
312 
313  if (tmpAllow.size() > 0) {
314  for (unsigned int i = 0; i < tmpAllow.size(); ++i) {
315  m_ov.m_dataOutputAllowedSet.insert((unsigned int) tmpAllow[i]);
316  }
317  }
318  }
319 
320 #ifdef UQ_SIP_READS_SOLVER_OPTION
321  if (m_env.allOptionsMap().count(m_option_solver)) {
322  m_ov.m_solverString = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_solver]).as<std::string>();
323  }
324 #endif
325 
327  m_ov.m_seedWithMAPEstimator = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_seedWithMAPEstimator]).as<bool>();
328  }
329 
331  m_ov.m_useOptimizerMonitor = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_useOptimizerMonitor]).as<bool>();
332  }
333 }
#define queso_deprecated()
Definition: Defines.h:134
boost::program_options::variables_map & allOptionsMap() const
Definition: Environment.C:340
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:278
std::set< unsigned int > m_dataOutputAllowedSet
void MiscReadDoublesFromString(const std::string &inputString, std::vector< double > &outputDoubles)
Definition: Miscellaneous.C:40
void QUESO::StatisticalInverseProblemOptions::print ( std::ostream &  os) const

It prints the option values.

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

250 {
252 
253  os << "\n" << m_option_computeSolution << " = " << m_ov.m_computeSolution
255  os << "\n" << m_option_dataOutputAllowedSet << " = ";
256  for (std::set<unsigned int>::iterator setIt = m_ov.m_dataOutputAllowedSet.begin(); setIt != m_ov.m_dataOutputAllowedSet.end(); ++setIt) {
257  os << *setIt << " ";
258  }
259 #ifdef UQ_SIP_READS_SOLVER_OPTION
260  << "\n" << m_option_solver << " = " << m_ov.m_solverString
261 #endif
264  os << std::endl;
265 
266  return;
267 }
#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 228 of file StatisticalInverseProblemOptions.C.

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

229 {
230  queso_require_msg(m_optionsDesc, "m_optionsDesc variable is NULL");
231 
235 
236  if (m_env.subDisplayFile() != NULL) {
237  *m_env.subDisplayFile() << "In StatisticalInverseProblemOptions::scanOptionsValues()"
238  << ": after reading values of options with prefix '" << m_prefix
239  << "', state of object is:"
240  << "\n" << *this
241  << std::endl;
242  }
243 
244  return;
245 }
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:349
void defineMyOptions(boost::program_options::options_description &optionsDesc) const
Define my SIP options as the default options.
#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:278
boost::program_options::options_description * m_optionsDesc

Member Data Documentation

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

Definition at line 180 of file StatisticalInverseProblemOptions.h.

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

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

Definition at line 182 of file StatisticalInverseProblemOptions.h.

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

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

Definition at line 181 of file StatisticalInverseProblemOptions.h.

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

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

Definition at line 179 of file StatisticalInverseProblemOptions.h.

Referenced by defineMyOptions(), and getMyOptionValues().

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

Definition at line 186 of file StatisticalInverseProblemOptions.h.

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

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

Definition at line 187 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 167 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 Fri Jun 17 2016 14:17:46 for queso-0.55.0 by  doxygen 1.8.5