queso-0.56.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 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
26 #include <boost/program_options.hpp>
27 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
28 
29 #include <queso/GPMSAOptions.h>
30 
31 // ODV = option default value
32 #define UQ_GPMSA_HELP ""
33 #define UQ_GPMSA_EMULATOR_PRECISION_SHAPE_ODV 5.0
34 #define UQ_GPMSA_EMULATOR_PRECISION_SCALE_ODV 0.2
35 #define UQ_GPMSA_OBSERVATIONAL_PRECISION_SHAPE_ODV 5.0
36 #define UQ_GPMSA_OBSERVATIONAL_PRECISION_SCALE_ODV 0.2
37 #define UQ_GPMSA_EMULATOR_CORRELATION_STRENGTH_ALPHA_ODV 1.0
38 #define UQ_GPMSA_EMULATOR_CORRELATION_STRENGTH_BETA_ODV 0.1
39 #define UQ_GPMSA_DISCREPANCY_PRECISION_SHAPE_ODV 1.0
40 #define UQ_GPMSA_DISCREPANCY_PRECISION_SCALE_ODV 1e4
41 #define UQ_GPMSA_DISCREPANCY_CORRELATION_STRENGTH_ALPHA_ODV 1.0
42 #define UQ_GPMSA_DISCREPANCY_CORRELATION_STRENGTH_BETA_ODV 0.1
43 #define UQ_GPMSA_EMULATOR_DATA_PRECISION_SHAPE_ODV 3.0
44 #define UQ_GPMSA_EMULATOR_DATA_PRECISION_SCALE_ODV 333.333
45 
46 namespace QUESO {
47 
49  const BaseEnvironment & env,
50  const char * prefix)
51  :
52  m_prefix((std::string)(prefix) + "gpmsa_"),
53  m_help(UQ_GPMSA_HELP),
54  m_emulatorPrecisionShape(UQ_GPMSA_EMULATOR_PRECISION_SHAPE_ODV),
55  m_emulatorPrecisionScale(UQ_GPMSA_EMULATOR_PRECISION_SCALE_ODV),
56  m_observationalPrecisionShape(UQ_GPMSA_OBSERVATIONAL_PRECISION_SHAPE_ODV),
57  m_observationalPrecisionScale(UQ_GPMSA_OBSERVATIONAL_PRECISION_SCALE_ODV),
58  m_emulatorCorrelationStrengthAlpha(UQ_GPMSA_EMULATOR_CORRELATION_STRENGTH_ALPHA_ODV),
59  m_emulatorCorrelationStrengthBeta(UQ_GPMSA_EMULATOR_CORRELATION_STRENGTH_BETA_ODV),
60  m_discrepancyPrecisionShape(UQ_GPMSA_DISCREPANCY_PRECISION_SHAPE_ODV),
61  m_discrepancyPrecisionScale(UQ_GPMSA_DISCREPANCY_PRECISION_SCALE_ODV),
62  m_discrepancyCorrelationStrengthAlpha(UQ_GPMSA_DISCREPANCY_CORRELATION_STRENGTH_ALPHA_ODV),
63  m_discrepancyCorrelationStrengthBeta(UQ_GPMSA_DISCREPANCY_CORRELATION_STRENGTH_BETA_ODV),
64  m_emulatorDataPrecisionShape(UQ_GPMSA_EMULATOR_DATA_PRECISION_SHAPE_ODV),
65  m_emulatorDataPrecisionScale(UQ_GPMSA_EMULATOR_DATA_PRECISION_SCALE_ODV),
66  m_env(env),
67 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
68  m_parser(new BoostInputOptionsParser(env.optionsInputFileName())),
69 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
70  m_option_help(m_prefix + "help"),
71  m_option_emulatorPrecisionShape(m_prefix + "emulator_precision_shape"),
72  m_option_emulatorPrecisionScale(m_prefix + "emulator_precision_scale"),
73  m_option_observationalPrecisionShape(m_prefix + "observational_precision_shape"),
74  m_option_observationalPrecisionScale(m_prefix + "observational_precision_scale"),
75  m_option_emulatorCorrelationStrengthAlpha(m_prefix + "emulator_correlation_strength_alpha"),
76  m_option_emulatorCorrelationStrengthBeta(m_prefix + "emulator_correlation_strength_beta"),
77  m_option_discrepancyPrecisionShape(m_prefix + "discrepancy_precision_shape"),
78  m_option_discrepancyPrecisionScale(m_prefix + "discrepancy_precision_scale"),
79  m_option_discrepancyCorrelationStrengthAlpha(m_prefix + "discrepancy_correlation_strength_alpha"),
80  m_option_discrepancyCorrelationStrengthBeta(m_prefix + "discrepancy_correlation_strength_beta"),
81  m_option_emulatorDataPrecisionShape(m_prefix + "emulator_data_precision_shape"),
82  m_option_emulatorDataPrecisionScale(m_prefix + "emulator_data_precision_scale")
83 {
84  if (m_env.optionsInputFileName() == "") {
85  queso_error_msg("Missing input file is required");
86  }
87 
88 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
89  m_parser->registerOption<std::string>(m_option_help, UQ_GPMSA_HELP, "produce help message Gaussian process emulator");
90  m_parser->registerOption<double>(m_option_emulatorPrecisionShape, UQ_GPMSA_EMULATOR_PRECISION_SHAPE_ODV, "shape hyperprior (Gamma) parameter for emulator precision");
91  m_parser->registerOption<double>(m_option_emulatorPrecisionScale, UQ_GPMSA_EMULATOR_PRECISION_SCALE_ODV, "scale hyperprior (Gamma) parameter for emulator precision");
92  m_parser->registerOption<double>(m_option_observationalPrecisionShape, UQ_GPMSA_OBSERVATIONAL_PRECISION_SHAPE_ODV, "shape hyperprior (Gamma) parameter for observational precision");
93  m_parser->registerOption<double>(m_option_observationalPrecisionScale, UQ_GPMSA_OBSERVATIONAL_PRECISION_SCALE_ODV, "scale hyperprior (Gamma) parameter for observational precision");
94  m_parser->registerOption<double>(m_option_emulatorCorrelationStrengthAlpha, UQ_GPMSA_EMULATOR_CORRELATION_STRENGTH_ALPHA_ODV, "alpha hyperprior (Beta) parameter for emulator correlation strength");
95  m_parser->registerOption<double>(m_option_emulatorCorrelationStrengthBeta, UQ_GPMSA_EMULATOR_CORRELATION_STRENGTH_BETA_ODV, "beta hyperprior (Beta) parameter for emulator correlation strength");
96  m_parser->registerOption<double>(m_option_discrepancyPrecisionShape, UQ_GPMSA_DISCREPANCY_PRECISION_SHAPE_ODV, "shape hyperprior (Gamma) parameter for discrepancy precision");
97  m_parser->registerOption<double>(m_option_discrepancyPrecisionScale, UQ_GPMSA_DISCREPANCY_PRECISION_SCALE_ODV, "scale hyperprior (Gamma) parameter for discrepancy precision");
98  m_parser->registerOption<double>(m_option_discrepancyCorrelationStrengthAlpha, UQ_GPMSA_DISCREPANCY_CORRELATION_STRENGTH_ALPHA_ODV, "alpha hyperprior (Beta) parameter for discrepancy correlation strength");
99  m_parser->registerOption<double>(m_option_discrepancyCorrelationStrengthBeta, UQ_GPMSA_DISCREPANCY_CORRELATION_STRENGTH_BETA_ODV, "beta hyperprior (Beta) parameter for discrepancy correlation strength");
100  m_parser->registerOption<double>(m_option_emulatorDataPrecisionShape, UQ_GPMSA_EMULATOR_DATA_PRECISION_SHAPE_ODV, "shape hyperprior (Gamma) parameter for emulator data precision");
101  m_parser->registerOption<double>(m_option_emulatorDataPrecisionScale, UQ_GPMSA_EMULATOR_DATA_PRECISION_SCALE_ODV, "scale hyperprior (Gamma) parameter for emulator data precision");
102 
104 
105  m_parser->getOption<std::string>(m_option_help, m_help);
118 #else
132 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
133 
134  checkOptions();
135 }
136 
138 {
139 }
140 
141 void
143 {
144  if (m_help != "") {
145  if (m_env.subDisplayFile()) {
146  *m_env.subDisplayFile() << (*this) << std::endl;
147  }
148  }
149 }
150 
151 void
152 GPMSAOptions::print(std::ostream& os) const
153 {
154  os << "\n" << m_option_emulatorPrecisionShape << " = " << this->m_emulatorPrecisionShape
155  << "\n" << m_option_emulatorPrecisionScale << " = " << this->m_emulatorPrecisionScale
166  << std::endl;
167 }
168 
169 std::ostream &
170 operator<<(std::ostream& os, const GPMSAOptions & obj)
171 {
172 #ifndef DISABLE_BOOST_PROGRAM_OPTIONS
173  os << (*(obj.m_parser)) << std::endl;
174 #endif // DISABLE_BOOST_PROGRAM_OPTIONS
175  obj.print(os);
176  return os;
177 }
178 
179 
180 } // End namespace QUESO
double m_emulatorCorrelationStrengthAlpha
The alpha paramter for the Beta hyperprior for the emulator correlation strength. ...
Definition: GPMSAOptions.h:75
std::string m_option_observationalPrecisionShape
Definition: GPMSAOptions.h:113
virtual ~GPMSAOptions()
Destructor.
Definition: GPMSAOptions.C:137
std::string m_option_help
Definition: GPMSAOptions.h:110
#define UQ_GPMSA_DISCREPANCY_CORRELATION_STRENGTH_ALPHA_ODV
Definition: GPMSAOptions.C:41
const GetPot & input() const
The GetPot input file parser.
Definition: Environment.C:1148
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
double m_emulatorPrecisionShape
The shape parameter for the Gamma hyperprior for the emulator precision.
Definition: GPMSAOptions.h:62
std::ostream & operator<<(std::ostream &os, const BaseEnvironment &obj)
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 UQ_GPMSA_OBSERVATIONAL_PRECISION_SCALE_ODV
Definition: GPMSAOptions.C:36
#define UQ_GPMSA_DISCREPANCY_PRECISION_SCALE_ODV
Definition: GPMSAOptions.C:40
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:197
std::string m_option_emulatorPrecisionShape
Definition: GPMSAOptions.h:111
double m_observationalPrecisionShape
The shape parameter for the Gamma hyperprior for the observational precision.
Definition: GPMSAOptions.h:68
std::string m_option_emulatorCorrelationStrengthAlpha
Definition: GPMSAOptions.h:115
std::string m_help
If this string is non-empty, print the options object to the output file.
Definition: GPMSAOptions.h:59
void getOption(std::string &name, T &value)
Get option name from the parser and set value to the parsed value.
std::string m_option_emulatorDataPrecisionScale
Definition: GPMSAOptions.h:122
double m_discrepancyCorrelationStrengthBeta
The beta paramter for the Beta hyperprior for the discrepancy correlation strength.
Definition: GPMSAOptions.h:90
std::string m_option_emulatorDataPrecisionShape
Definition: GPMSAOptions.h:121
std::string m_option_observationalPrecisionScale
Definition: GPMSAOptions.h:114
std::string m_option_emulatorPrecisionScale
Definition: GPMSAOptions.h:112
#define UQ_GPMSA_EMULATOR_DATA_PRECISION_SHAPE_ODV
Definition: GPMSAOptions.C:43
double m_emulatorPrecisionScale
The scale parameter for the Gamma hyperprior for the emulator precision.
Definition: GPMSAOptions.h:65
double m_discrepancyCorrelationStrengthAlpha
The alpha paramter for the Beta hyperprior for the discrepancy correlation strength.
Definition: GPMSAOptions.h:87
std::string m_option_discrepancyPrecisionScale
Definition: GPMSAOptions.h:118
#define UQ_GPMSA_DISCREPANCY_CORRELATION_STRENGTH_BETA_ODV
Definition: GPMSAOptions.C:42
void scanInputFile()
This is the method that parses the input file.
#define UQ_GPMSA_OBSERVATIONAL_PRECISION_SHAPE_ODV
Definition: GPMSAOptions.C:35
#define UQ_GPMSA_EMULATOR_CORRELATION_STRENGTH_ALPHA_ODV
Definition: GPMSAOptions.C:37
std::string m_option_emulatorCorrelationStrengthBeta
Definition: GPMSAOptions.h:116
This class defines the options that specify the behaviour of the Gaussian process emulator...
Definition: GPMSAOptions.h:43
#define UQ_GPMSA_EMULATOR_PRECISION_SHAPE_ODV
Definition: GPMSAOptions.C:33
const BaseEnvironment & m_env
Definition: GPMSAOptions.h:104
std::string m_option_discrepancyPrecisionShape
Definition: GPMSAOptions.h:117
GPMSAOptions(const BaseEnvironment &env, const char *prefix)
Given prefix, read the input file for parameters named prefix_*.
Definition: GPMSAOptions.C:48
#define UQ_GPMSA_EMULATOR_DATA_PRECISION_SCALE_ODV
Definition: GPMSAOptions.C:44
#define UQ_GPMSA_HELP
Definition: GPMSAOptions.C:32
double m_discrepancyPrecisionShape
The shape parameter for the Gamma hyperprior for the discrepancy precision.
Definition: GPMSAOptions.h:81
void registerOption(std::string name, T defaultValue, std::string description)
Call this to register an option with the parser.
double m_emulatorDataPrecisionScale
The scale parameter for the Gamma hyperprior for the emulator data precision.
Definition: GPMSAOptions.h:99
double m_emulatorCorrelationStrengthBeta
The beta paramter for the Beta hyperprior for the emulator correlation strength.
Definition: GPMSAOptions.h:78
#define UQ_GPMSA_EMULATOR_CORRELATION_STRENGTH_BETA_ODV
Definition: GPMSAOptions.C:38
std::string m_option_discrepancyCorrelationStrengthAlpha
Definition: GPMSAOptions.h:119
#define queso_error_msg(msg)
Definition: asserts.h:47
BoostInputOptionsParser * m_parser
Definition: GPMSAOptions.h:107
double m_observationalPrecisionScale
The scale parameter for the Gamma hyperprior for the observational precision.
Definition: GPMSAOptions.h:71
void print(std::ostream &os) const
Prints this to os.
Definition: GPMSAOptions.C:152
std::string m_option_discrepancyCorrelationStrengthBeta
Definition: GPMSAOptions.h:120
#define UQ_GPMSA_DISCREPANCY_PRECISION_SHAPE_ODV
Definition: GPMSAOptions.C:39
double m_discrepancyPrecisionScale
The scale parameter for the Gamma hyperprior for the discrepancy precision.
Definition: GPMSAOptions.h:84
#define UQ_GPMSA_EMULATOR_PRECISION_SCALE_ODV
Definition: GPMSAOptions.C:34
double m_emulatorDataPrecisionShape
The shape parameter for the Gamma hyperprior for the emulator data precision.
Definition: GPMSAOptions.h:96

Generated on Tue Nov 29 2016 10:53:11 for queso-0.56.0 by  doxygen 1.8.5