queso-0.53.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
 

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 139 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 154 of file StatisticalInverseProblemOptions.C.

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

157 :
158  m_ov (),
159  m_prefix ((std::string)(prefix) + "ip_"),
160  m_env (env),
161  m_optionsDesc (new boost::program_options::options_description("Statistical Inverse Problem options")),
162  m_option_help (m_prefix + "help" ),
163  m_option_computeSolution (m_prefix + "computeSolution" ),
164  m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ),
165  m_option_dataOutputAllowedSet(m_prefix + "dataOutputAllowedSet")
166 #ifdef UQ_SIP_READS_SOLVER_OPTION
167  m_option_solver (m_prefix + "solver" )
168 #endif
169 {
171  queso_require_not_equal_to_msg(m_env.optionsInputFileName(), "", "this constructor is incompatible with the absence of an options input file");
172 }
#define queso_require_not_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:86
std::string optionsInputFileName() const
Access to the attribute m_optionsInputFileName, which stores the name of the input file passed by the...
Definition: Environment.C:307
#define queso_deprecated()
Definition: Defines.h:120
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 175 of file StatisticalInverseProblemOptions.C.

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

179 :
180  m_ov (alternativeOptionsValues),
181  m_prefix ((std::string)(prefix) + "ip_"),
182  m_env (env),
183  m_optionsDesc (NULL),
184  m_option_help (m_prefix + "help" ),
185  m_option_computeSolution (m_prefix + "computeSolution" ),
186  m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ),
187  m_option_dataOutputAllowedSet(m_prefix + "dataOutputAllowedSet")
188 #ifdef UQ_SIP_READS_SOLVER_OPTION
189  m_option_solver (m_prefix + "solver" )
190 #endif
191 {
193 
194  queso_require_equal_to_msg(m_env.optionsInputFileName(), "", "this constructor is incompatible with the existence of an options input file");
195 
196  if (m_env.subDisplayFile() != NULL) {
197  *m_env.subDisplayFile() << "In StatisticalInverseProblemOptions::constructor(2)"
198  << ": after setting values of options with prefix '" << m_prefix
199  << "', state of object is:"
200  << "\n" << *this
201  << std::endl;
202  }
203 }
#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:307
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
#define queso_deprecated()
Definition: Defines.h:120
boost::program_options::options_description * m_optionsDesc
QUESO::StatisticalInverseProblemOptions::~StatisticalInverseProblemOptions ( )

Destructor.

Definition at line 205 of file StatisticalInverseProblemOptions.C.

References m_optionsDesc, and queso_deprecated.

206 {
208  if (m_optionsDesc) delete m_optionsDesc;
209 }
#define queso_deprecated()
Definition: Defines.h:120
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 257 of file StatisticalInverseProblemOptions.C.

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

Referenced by scanOptionsValues().

258 {
260 
261  optionsDesc.add_options()
262  (m_option_help.c_str(), "produce help message for statistical inverse problem")
263  (m_option_computeSolution.c_str(), boost::program_options::value<bool >()->default_value(UQ_SIP_COMPUTE_SOLUTION_ODV ), "compute solution process" )
264  (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" )
265  (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" )
266 #ifdef UQ_SIP_READS_SOLVER_OPTION
267  (m_option_solver.c_str(), boost::program_options::value<std::string>()->default_value(UQ_SIP_SOLVER_ODV ), "algorithm for calibration" )
268 #endif
269  ;
270 
271  return;
272 }
#define UQ_SIP_DATA_OUTPUT_ALLOWED_SET_ODV
#define UQ_SIP_DATA_OUTPUT_FILE_NAME_ODV
#define UQ_SIP_COMPUTE_SOLUTION_ODV
#define queso_deprecated()
Definition: Defines.h:120
void QUESO::StatisticalInverseProblemOptions::getMyOptionValues ( boost::program_options::options_description &  optionsDesc)
private

Gets the option values of the SIP.

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

Referenced by scanOptionsValues().

276 {
278 
279  if (m_env.allOptionsMap().count(m_option_help)) {
280  if (m_env.subDisplayFile()) {
281  *m_env.subDisplayFile() << optionsDesc
282  << std::endl;
283  }
284  }
285 
287  m_ov.m_computeSolution = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_computeSolution]).as<bool>();
288  }
289 
291  m_ov.m_dataOutputFileName = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_dataOutputFileName]).as<std::string>();
292  }
293 
296  std::vector<double> tmpAllow(0,0.);
297  std::string inputString = m_env.allOptionsMap()[m_option_dataOutputAllowedSet].as<std::string>();
298  MiscReadDoublesFromString(inputString,tmpAllow);
299 
300  if (tmpAllow.size() > 0) {
301  for (unsigned int i = 0; i < tmpAllow.size(); ++i) {
302  m_ov.m_dataOutputAllowedSet.insert((unsigned int) tmpAllow[i]);
303  }
304  }
305  }
306 
307 #ifdef UQ_SIP_READS_SOLVER_OPTION
308  if (m_env.allOptionsMap().count(m_option_solver)) {
309  m_ov.m_solverString = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_solver]).as<std::string>();
310  }
311 #endif
312 
313  return;
314 }
boost::program_options::variables_map & allOptionsMap() const
Definition: Environment.C:336
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
std::set< unsigned int > m_dataOutputAllowedSet
void MiscReadDoublesFromString(const std::string &inputString, std::vector< double > &outputDoubles)
Definition: Miscellaneous.C:40
#define queso_deprecated()
Definition: Defines.h:120
void QUESO::StatisticalInverseProblemOptions::print ( std::ostream &  os) const

It prints the option values.

Definition at line 238 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_ov, and queso_deprecated.

Referenced by QUESO::operator<<().

239 {
241 
242  os << "\n" << m_option_computeSolution << " = " << m_ov.m_computeSolution
244  os << "\n" << m_option_dataOutputAllowedSet << " = ";
245  for (std::set<unsigned int>::iterator setIt = m_ov.m_dataOutputAllowedSet.begin(); setIt != m_ov.m_dataOutputAllowedSet.end(); ++setIt) {
246  os << *setIt << " ";
247  }
248 #ifdef UQ_SIP_READS_SOLVER_OPTION
249  << "\n" << m_option_solver << " = " << m_ov.m_solverString
250 #endif
251  os << std::endl;
252 
253  return;
254 }
std::set< unsigned int > m_dataOutputAllowedSet
#define queso_deprecated()
Definition: Defines.h:120
void QUESO::StatisticalInverseProblemOptions::scanOptionsValues ( )

It scans the option values from the options input file.

Definition at line 213 of file StatisticalInverseProblemOptions.C.

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

214 {
215  queso_require_msg(m_optionsDesc, "m_optionsDesc variable is NULL");
216 
219  //std::cout << "scan 000\n"
220  // << std::endl;
222  //std::cout << "scan 001\n"
223  // << std::endl;
224 
225  if (m_env.subDisplayFile() != NULL) {
226  *m_env.subDisplayFile() << "In StatisticalInverseProblemOptions::scanOptionsValues()"
227  << ": after reading values of options with prefix '" << m_prefix
228  << "', state of object is:"
229  << "\n" << *this
230  << std::endl;
231  }
232 
233  return;
234 }
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:345
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
void getMyOptionValues(boost::program_options::options_description &optionsDesc)
Gets the option values of the SIP.
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
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 179 of file StatisticalInverseProblemOptions.h.

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

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

Definition at line 181 of file StatisticalInverseProblemOptions.h.

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

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

Definition at line 180 of file StatisticalInverseProblemOptions.h.

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

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

Definition at line 178 of file StatisticalInverseProblemOptions.h.

Referenced by defineMyOptions(), and getMyOptionValues().

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

Definition at line 165 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 Jun 11 2015 13:52:36 for queso-0.53.0 by  doxygen 1.8.5