queso-0.53.0
GPMSAOptions.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // QUESO - a library to support the Quantification of Uncertainty
5 // for Estimation, Simulation and Optimization
6 //
7 // Copyright (C) 2008-2015 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 #include <boost/program_options.hpp>
26 
27 #include <queso/GPMSAOptions.h>
28 
29 // ODV = option default value
30 #define UQ_GPMSA_HELP ""
31 #define UQ_GPMSA_EMULATOR_PRECISION_SHAPE_ODV 5.0
32 #define UQ_GPMSA_EMULATOR_PRECISION_SCALE_ODV 0.2
33 #define UQ_GPMSA_EMULATOR_CORRELATION_STRENGTH_ALPHA_ODV 1.0
34 #define UQ_GPMSA_EMULATOR_CORRELATION_STRENGTH_BETA_ODV 0.1
35 #define UQ_GPMSA_DISCREPANCY_PRECISION_SHAPE_ODV 1.0
36 #define UQ_GPMSA_DISCREPANCY_PRECISION_SCALE_ODV 1e4
37 #define UQ_GPMSA_DISCREPANCY_CORRELATION_STRENGTH_ALPHA_ODV 1.0
38 #define UQ_GPMSA_DISCREPANCY_CORRELATION_STRENGTH_BETA_ODV 0.1
39 #define UQ_GPMSA_EMULATOR_DATA_PRECISION_SHAPE_ODV 3.0
40 #define UQ_GPMSA_EMULATOR_DATA_PRECISION_SCALE_ODV 333.333
41 
42 namespace QUESO {
43 
45  const BaseEnvironment & env,
46  const char * prefix)
47  :
48  m_prefix((std::string)(prefix) + "gpmsa_"),
49  m_help(UQ_GPMSA_HELP),
50  m_emulatorPrecisionShape(UQ_GPMSA_EMULATOR_PRECISION_SHAPE_ODV),
51  m_emulatorPrecisionScale(UQ_GPMSA_EMULATOR_PRECISION_SCALE_ODV),
52  m_emulatorCorrelationStrengthAlpha(UQ_GPMSA_EMULATOR_CORRELATION_STRENGTH_ALPHA_ODV),
53  m_emulatorCorrelationStrengthBeta(UQ_GPMSA_EMULATOR_CORRELATION_STRENGTH_BETA_ODV),
54  m_discrepancyPrecisionShape(UQ_GPMSA_DISCREPANCY_PRECISION_SHAPE_ODV),
55  m_discrepancyPrecisionScale(UQ_GPMSA_DISCREPANCY_PRECISION_SCALE_ODV),
56  m_discrepancyCorrelationStrengthAlpha(UQ_GPMSA_DISCREPANCY_CORRELATION_STRENGTH_ALPHA_ODV),
57  m_discrepancyCorrelationStrengthBeta(UQ_GPMSA_DISCREPANCY_CORRELATION_STRENGTH_BETA_ODV),
58  m_emulatorDataPrecisionShape(UQ_GPMSA_EMULATOR_DATA_PRECISION_SHAPE_ODV),
59  m_emulatorDataPrecisionScale(UQ_GPMSA_EMULATOR_DATA_PRECISION_SCALE_ODV),
60  m_env(env),
61  m_parser(new BoostInputOptionsParser(env.optionsInputFileName())),
62  m_option_help(m_prefix + "help"),
63  m_option_emulatorPrecisionShape(m_prefix + "emulator_precision_shape"),
64  m_option_emulatorPrecisionScale(m_prefix + "emulator_precision_scale"),
65  m_option_emulatorCorrelationStrengthAlpha(m_prefix + "emulator_correlation_strength_alpha"),
66  m_option_emulatorCorrelationStrengthBeta(m_prefix + "emulator_correlation_strength_beta"),
67  m_option_discrepancyPrecisionShape(m_prefix + "discrepancy_precision_shape"),
68  m_option_discrepancyPrecisionScale(m_prefix + "discrepancy_precision_scale"),
69  m_option_discrepancyCorrelationStrengthAlpha(m_prefix + "discrepancy_correlation_strength_alpha"),
70  m_option_discrepancyCorrelationStrengthBeta(m_prefix + "discrepancy_correlation_strength_beta"),
71  m_option_emulatorDataPrecisionShape(m_prefix + "emulator_data_precision_shape"),
72  m_option_emulatorDataPrecisionScale(m_prefix + "emulator_data_precision_scale")
73 {
74  if (m_env.optionsInputFileName() == "") {
75  queso_error_msg("Missing input file is required");
76  }
77 
78  m_parser->registerOption<std::string>(m_option_help, UQ_GPMSA_HELP, "produce help message Gaussian process emulator");
79  m_parser->registerOption<double>(m_option_emulatorPrecisionShape, UQ_GPMSA_EMULATOR_PRECISION_SHAPE_ODV, "shape hyperprior (Gamma) parameter for emulator precision");
80  m_parser->registerOption<double>(m_option_emulatorPrecisionScale, UQ_GPMSA_EMULATOR_PRECISION_SCALE_ODV, "scale hyperprior (Gamma) parameter for emulator precision");
81  m_parser->registerOption<double>(m_option_emulatorCorrelationStrengthAlpha, UQ_GPMSA_EMULATOR_CORRELATION_STRENGTH_ALPHA_ODV, "alpha hyperprior (Beta) parameter for emulator correlation strength");
82  m_parser->registerOption<double>(m_option_emulatorCorrelationStrengthBeta, UQ_GPMSA_EMULATOR_CORRELATION_STRENGTH_BETA_ODV, "beta hyperprior (Beta) parameter for emulator correlation strength");
83  m_parser->registerOption<double>(m_option_discrepancyPrecisionShape, UQ_GPMSA_DISCREPANCY_PRECISION_SHAPE_ODV, "shape hyperprior (Gamma) parameter for discrepancy precision");
84  m_parser->registerOption<double>(m_option_discrepancyPrecisionScale, UQ_GPMSA_DISCREPANCY_PRECISION_SCALE_ODV, "scale hyperprior (Gamma) parameter for discrepancy precision");
85  m_parser->registerOption<double>(m_option_discrepancyCorrelationStrengthAlpha, UQ_GPMSA_DISCREPANCY_CORRELATION_STRENGTH_ALPHA_ODV, "alpha hyperprior (Beta) parameter for discrepancy correlation strength");
86  m_parser->registerOption<double>(m_option_discrepancyCorrelationStrengthBeta, UQ_GPMSA_DISCREPANCY_CORRELATION_STRENGTH_BETA_ODV, "beta hyperprior (Beta) parameter for discrepancy correlation strength");
87  m_parser->registerOption<double>(m_option_emulatorDataPrecisionShape, UQ_GPMSA_EMULATOR_DATA_PRECISION_SHAPE_ODV, "shape hyperprior (Gamma) parameter for emulator data precision");
88  m_parser->registerOption<double>(m_option_emulatorDataPrecisionScale, UQ_GPMSA_EMULATOR_DATA_PRECISION_SCALE_ODV, "scale hyperprior (Gamma) parameter for emulator data precision");
89 
91 
92  m_parser->getOption<std::string>(m_option_help, m_help);
103 
104  checkOptions();
105 }
106 
108 {
109 }
110 
111 void
113 {
114  if (m_help != "") {
115  if (m_env.subDisplayFile()) {
116  *m_env.subDisplayFile() << (*this) << std::endl;
117  }
118  }
119 }
120 
121 void
122 GPMSAOptions::print(std::ostream& os) const
123 {
124  os << "\n" << m_option_emulatorPrecisionShape << " = " << this->m_emulatorPrecisionShape
125  << "\n" << m_option_emulatorPrecisionScale << " = " << this->m_emulatorPrecisionScale
134  << std::endl;
135 }
136 
137 std::ostream &
138 operator<<(std::ostream& os, const GPMSAOptions & obj)
139 {
140  os << (*(obj.m_parser)) << std::endl;
141  obj.print(os);
142  return os;
143 }
144 
145 
146 } // End namespace QUESO
const BaseEnvironment & m_env
Definition: GPMSAOptions.h:94
#define UQ_GPMSA_DISCREPANCY_CORRELATION_STRENGTH_ALPHA_ODV
Definition: GPMSAOptions.C:37
#define UQ_GPMSA_DISCREPANCY_PRECISION_SHAPE_ODV
Definition: GPMSAOptions.C:35
double m_discrepancyPrecisionShape
The shape parameter for the Gamma hyperprior for the discrepancy precision.
Definition: GPMSAOptions.h:71
std::string m_option_emulatorCorrelationStrengthBeta
Definition: GPMSAOptions.h:102
double m_discrepancyCorrelationStrengthBeta
The beta paramter for the Beta hyperprior for the discrepancy correlation strength.
Definition: GPMSAOptions.h:80
std::string m_option_emulatorDataPrecisionShape
Definition: GPMSAOptions.h:107
std::string m_option_discrepancyCorrelationStrengthAlpha
Definition: GPMSAOptions.h:105
void print(std::ostream &os) const
Prints this to os.
Definition: GPMSAOptions.C:122
double m_emulatorPrecisionScale
The scale parameter for the Gamma hyperprior for the emulator precision.
Definition: GPMSAOptions.h:62
std::string m_option_emulatorDataPrecisionScale
Definition: GPMSAOptions.h:108
#define queso_error_msg(msg)
Definition: asserts.h:47
std::ostream & operator<<(std::ostream &os, const BaseEnvironment &obj)
double m_emulatorDataPrecisionScale
The scale parameter for the Gamma hyperprior for the emulator data precision.
Definition: GPMSAOptions.h:89
#define UQ_GPMSA_EMULATOR_CORRELATION_STRENGTH_BETA_ODV
Definition: GPMSAOptions.C:34
double m_discrepancyCorrelationStrengthAlpha
The alpha paramter for the Beta hyperprior for the discrepancy correlation strength.
Definition: GPMSAOptions.h:77
double m_emulatorCorrelationStrengthAlpha
The alpha paramter for the Beta hyperprior for the emulator correlation strength. ...
Definition: GPMSAOptions.h:65
virtual ~GPMSAOptions()
Destructor.
Definition: GPMSAOptions.C:107
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
void scanInputFile()
This is the method that parses the input file.
std::string m_option_discrepancyCorrelationStrengthBeta
Definition: GPMSAOptions.h:106
std::string m_option_discrepancyPrecisionScale
Definition: GPMSAOptions.h:104
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:193
#define UQ_GPMSA_EMULATOR_DATA_PRECISION_SCALE_ODV
Definition: GPMSAOptions.C:40
#define UQ_GPMSA_HELP
Definition: GPMSAOptions.C:30
void registerOption(std::string name, T defaultValue, std::string description)
Call this to register an option with the parser.
std::string m_option_emulatorPrecisionShape
Definition: GPMSAOptions.h:99
std::string m_option_emulatorCorrelationStrengthAlpha
Definition: GPMSAOptions.h:101
This class defines the options that specify the behaviour of the Gaussian process emulator...
Definition: GPMSAOptions.h:40
#define UQ_GPMSA_EMULATOR_DATA_PRECISION_SHAPE_ODV
Definition: GPMSAOptions.C:39
double m_emulatorPrecisionShape
The shape parameter for the Gamma hyperprior for the emulator precision.
Definition: GPMSAOptions.h:59
#define UQ_GPMSA_EMULATOR_CORRELATION_STRENGTH_ALPHA_ODV
Definition: GPMSAOptions.C:33
double m_emulatorDataPrecisionShape
The shape parameter for the Gamma hyperprior for the emulator data precision.
Definition: GPMSAOptions.h:86
GPMSAOptions(const BaseEnvironment &env, const char *prefix)
Given prefix, read the input file for parameters named prefix_*.
Definition: GPMSAOptions.C:44
BoostInputOptionsParser * m_parser
Definition: GPMSAOptions.h:96
double m_discrepancyPrecisionScale
The scale parameter for the Gamma hyperprior for the discrepancy precision.
Definition: GPMSAOptions.h:74
#define UQ_GPMSA_EMULATOR_PRECISION_SHAPE_ODV
Definition: GPMSAOptions.C:31
#define UQ_GPMSA_DISCREPANCY_CORRELATION_STRENGTH_BETA_ODV
Definition: GPMSAOptions.C:38
std::string m_help
If this string is non-empty, print the options object to the output file.
Definition: GPMSAOptions.h:56
double m_emulatorCorrelationStrengthBeta
The beta paramter for the Beta hyperprior for the emulator correlation strength.
Definition: GPMSAOptions.h:68
std::string m_option_help
Definition: GPMSAOptions.h:98
#define UQ_GPMSA_DISCREPANCY_PRECISION_SCALE_ODV
Definition: GPMSAOptions.C:36
void getOption(std::string &name, T &value)
Get option name from the parser and set value to the parsed value.
#define UQ_GPMSA_EMULATOR_PRECISION_SCALE_ODV
Definition: GPMSAOptions.C:32
std::string m_option_discrepancyPrecisionShape
Definition: GPMSAOptions.h:103
std::string m_option_emulatorPrecisionScale
Definition: GPMSAOptions.h:100

Generated on Thu Jun 11 2015 13:52:32 for queso-0.53.0 by  doxygen 1.8.5