queso-0.53.0
GPMSA.h
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 UQ_GPMSA_HELPER_H
26 #define UQ_GPMSA_HELPER_H
27 
28 #include <vector>
29 
30 #include <queso/Environment.h>
31 #include <queso/ScalarFunction.h>
32 #include <queso/VectorSpace.h>
33 #include <queso/VectorRV.h>
34 #include <queso/ConcatenatedVectorRV.h>
35 #include <queso/GammaVectorRV.h>
36 #include <queso/BetaVectorRV.h>
37 #include <queso/UniformVectorRV.h>
38 #include <queso/GPMSAOptions.h>
39 
40 namespace QUESO {
41 
42 class GslVector;
43 class GslMatrix;
44 
45 template <class V = GslVector, class M = GslMatrix>
46 class GPMSAEmulator : public BaseScalarFunction<V, M>
47 {
48 public:
49  GPMSAEmulator(const VectorSet<V, M> & domain,
54  const unsigned int m_numSimulations,
55  const unsigned int m_numExperiments,
56  const std::vector<V *> & m_simulationScenarios,
57  const std::vector<V *> & m_simulationParameters,
58  const std::vector<V *> & m_simulationOutputs,
59  const std::vector<V *> & m_experimentScenarios,
60  const std::vector<V *> & m_experimentOutputs,
61  const M & m_experimentErrors,
63 
64  virtual ~GPMSAEmulator();
65 
66  virtual double lnValue(const V & domainVector,
67  const V * domainDirection,
68  V * gradVector,
69  M * hessianMatrix,
70  V * hessianEffect) const;
71 
72  virtual double actualValue(const V & domainVector,
73  const V * domainDirection,
74  V * gradVector,
75  M * hessianMatrix,
76  V * hessianEffect) const;
77 
82 
83  const unsigned int m_numSimulations;
84  const unsigned int m_numExperiments;
85 
86  const std::vector<V *> & m_simulationScenarios;
87  const std::vector<V *> & m_simulationParameters;
88  const std::vector<V *> & m_simulationOutputs;
89  const std::vector<V *> & m_experimentScenarios;
90  const std::vector<V *> & m_experimentOutputs;
91 
92  // Total observation error covriance matrix
93  const M & m_experimentErrors;
94 
96 };
97 
98 template <class V = GslVector, class M = GslMatrix>
100 {
101 public:
104  GPMSAOptions * opts,
105  const BaseVectorRV<V, M> & parameterPrior,
110  unsigned int numSimulations,
111  unsigned int numExperiments);
112 
114  ~GPMSAFactory();
115 
117 
118 
120  unsigned int numSimulations() const;
121 
123  unsigned int numExperiments() const;
124 
126  const VectorSpace<V, M> & scenarioSpace() const;
127 
129  const VectorSpace<V, M> & parameterSpace() const;
130 
133 
136 
138 
142  const V & simulationScenario(unsigned int simulationId) const;
143 
145 
149  const std::vector<V *> & simulationScenarios() const;
150 
152 
156  const V & simulationParameter(unsigned int simulationId) const;
157 
159 
163  const std::vector<V *> & simulationParameters() const;
164 
166 
169  const V & simulationOutput(unsigned int simulationId) const;
170 
172 
176  const std::vector<V *> & simulationOutputs() const;
177 
179 
183  const V & experimentScenario(unsigned int experimentId) const;
184 
186 
190  const std::vector<V *> & experimentScenarios() const;
191 
193 
196  const V & experimentOutput(unsigned int experimentId) const;
197 
199 
203  const std::vector<V *> & experimentOutputs() const;
204 
206  const M & experimentErrors() const;
207 
209  const BaseEnvironment & env() const;
210 
212  const GPMSAEmulator<V, M> & getGPMSAEmulator() const;
213 
215 
217 
223  void addSimulation(V & simulationScenario,
224  V & simulationParameter,
225  V & simulationOutput);
226 
228 
232  void addSimulations(const std::vector<V *> & simulationScenarios,
233  const std::vector<V *> & simulationParameters,
234  const std::vector<V *> & simulationOutputs);
235 
237 
246  void addExperiments(const std::vector<V *> & experimentScenarios,
247  const std::vector<V *> & experimentOutputs,
248  const M * experimentErrors);
249 
250  const ConcatenatedVectorRV<V, M> & prior() const;
251 
252  void print(std::ostream& os) const;
253  friend std::ostream & operator<<(std::ostream& os,
254  const GPMSAFactory<V, M> & obj)
255  {
256  obj.print(os);
257  return os;
258  }
259 
261 
263 
268 
269  unsigned int m_numSimulations;
270  unsigned int m_numExperiments;
271 
272  std::vector<V *> m_simulationScenarios;
273  std::vector<V *> m_simulationParameters;
274  std::vector<V *> m_simulationOutputs;
275  std::vector<V *> m_experimentScenarios;
276  std::vector<V *> m_experimentOutputs;
277 
278  // Total observation error covriance matrix
280 
281  // Counter for the number of adds that happen
282  unsigned int m_numSimulationAdds;
283  unsigned int m_numExperimentAdds;
284 
285  // The space in which the emulator (simulator) lives
286  // const VectorSpace<V, M> & m_emulatorSpace;
287 
288  // The emulator state
289  // const V & m_emulator;
290 
291  // All the GP priors information for a scalar GP follows:
292  void setUpHyperpriors();
293 
294  // Domains for all the hyperpriors
296 
297  // Emulator mean
301 
302  // Emulator precision
306 
307  // Emulator correlation strength
312 
313  // Discrepancy precision
317 
318  // Discrepancy correlation strength
323 
324  // Emulator data precision
328 
329  // Now form full prior
333 
335 
336  std::vector<const BaseVectorRV<V, M> *> priors;
337 
338  // The hyperpriors
340  GammaVectorRV<V, M> * m_emulatorPrecision; // (scalar) gamma(a, b) shape-rate
341  BetaVectorRV<V, M> * m_emulatorCorrelationStrength; // (dim scenariosspace + dim parameterspace)
342  GammaVectorRV<V, M> * m_discrepancyPrecision; // (scalar) shape-rate
345  ConcatenatedVectorRV<V, M> * m_totalPrior; // prior for joint parameters and hyperparameters
346 
357 
358  // The gaussian process object to build
361 
362 private:
364 
365 };
366 
367 } // End namespace QUESO
368 
369 #endif // UQ_GPMSA_HELPER_H
V * discrepancyCorrelationMin
Definition: GPMSA.h:320
~GPMSAFactory()
Destructor.
Definition: GPMSA.C:289
A class representing a uniform vector RV.
const VectorSpace< V, M > & m_experimentOutputSpace
Definition: GPMSA.h:81
GammaVectorRV< V, M > * m_discrepancyPrecision
Definition: GPMSA.h:342
const std::vector< V * > & m_experimentScenarios
Definition: GPMSA.h:89
const std::vector< V * > & m_experimentOutputs
Definition: GPMSA.h:90
V * m_discrepancyCorrelationStrengthBetaVec
Definition: GPMSA.h:354
A templated class for handling sets.
Definition: VectorSet.h:52
BetaVectorRV< V, M > * m_discrepancyCorrelationStrength
Definition: GPMSA.h:343
VectorSpace< V, M > * totalSpace
Definition: GPMSA.h:330
const V & simulationParameter(unsigned int simulationId) const
Return the point in parameterSpace for simulation simulationId.
Definition: GPMSA.C:357
V * m_emulatorPrecisionScaleVec
Definition: GPMSA.h:348
const std::vector< V * > & m_simulationOutputs
Definition: GPMSA.h:88
bool m_constructedGP
Definition: GPMSA.h:360
BetaVectorRV< V, M > * m_emulatorCorrelationStrength
Definition: GPMSA.h:341
BoxSubset< V, M > * emulatorMeanDomain
Definition: GPMSA.h:300
void addSimulations(const std::vector< V * > &simulationScenarios, const std::vector< V * > &simulationParameters, const std::vector< V * > &simulationOutputs)
Adds multiple simulations to this.
Definition: GPMSA.C:489
A class representing a vector RV constructed via Gamma distribution.
Definition: GammaVectorRV.h:62
const BaseEnvironment & env() const
Return the QUESO environment.
Definition: GPMSA.C:440
V * emulatorCorrelationMax
Definition: GPMSA.h:310
A templated base class for handling vector RV.
Definition: VectorRV.h:54
unsigned int m_numExperiments
Definition: GPMSA.h:270
virtual double lnValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Logarithm of the value of the scalar function.
Definition: GPMSA.C:73
const std::vector< V * > & simulationParameters() const
Return all points in parameterSpace for all simulations.
Definition: GPMSA.C:369
BoxSubset< V, M > * emulatorCorrelationDomain
Definition: GPMSA.h:311
BoxSubset< V, M > * emulatorPrecisionDomain
Definition: GPMSA.h:305
std::vector< V * > m_experimentOutputs
Definition: GPMSA.h:276
const M & m_experimentErrors
Definition: GPMSA.h:93
const unsigned int m_numSimulations
Definition: GPMSA.h:83
V * m_emulatorDataPrecisionShapeVec
Definition: GPMSA.h:355
const ConcatenatedVectorRV< V, M > & prior() const
Definition: GPMSA.C:540
GPMSAEmulator(const VectorSet< V, M > &domain, const VectorSpace< V, M > &m_scenarioSpace, const VectorSpace< V, M > &m_parameterSpace, const VectorSpace< V, M > &m_simulationOutputSpace, const VectorSpace< V, M > &m_experimentOutputSpace, const unsigned int m_numSimulations, const unsigned int m_numExperiments, const std::vector< V * > &m_simulationScenarios, const std::vector< V * > &m_simulationParameters, const std::vector< V * > &m_simulationOutputs, const std::vector< V * > &m_experimentScenarios, const std::vector< V * > &m_experimentOutputs, const M &m_experimentErrors, const ConcatenatedVectorRV< V, M > &m_totalPrior)
Definition: GPMSA.C:32
A class representing a vector RV constructed via Beta distribution.
Definition: BetaVectorRV.h:64
const std::vector< V * > & m_simulationScenarios
Definition: GPMSA.h:86
GPMSAOptions * m_opts
Definition: GPMSA.h:363
const std::vector< V * > & simulationScenarios() const
Return all points in scenarioSpace for all simulations.
Definition: GPMSA.C:350
A templated (base) class for handling scalar functions.
const std::vector< V * > & m_simulationParameters
Definition: GPMSA.h:87
std::vector< V * > m_simulationParameters
Definition: GPMSA.h:273
V * emulatorCorrelationMin
Definition: GPMSA.h:309
std::vector< V * > m_simulationOutputs
Definition: GPMSA.h:274
V * discrepancyPrecisionMax
Definition: GPMSA.h:315
V * m_discrepancyPrecisionShapeVec
Definition: GPMSA.h:351
unsigned int numExperiments() const
Return number of experiments.
Definition: GPMSA.C:303
V * emulatorDataPrecisionMax
Definition: GPMSA.h:326
const std::vector< V * > & experimentScenarios() const
Return all points in scenarioSpace for all experiments.
Definition: GPMSA.C:407
const V & simulationScenario(unsigned int simulationId) const
Return the point in scenarioSpace for simulation simulationId.
Definition: GPMSA.C:338
const VectorSpace< V, M > & m_parameterSpace
Definition: GPMSA.h:79
const V & experimentScenario(unsigned int experimentId) const
Return the point in scenarioSpace for experiment experimentId.
Definition: GPMSA.C:395
const std::vector< V * > & experimentOutputs() const
Return all points in experimentOutputSpace for all experiments.
Definition: GPMSA.C:426
const unsigned int m_numExperiments
Definition: GPMSA.h:84
virtual double actualValue(const V &domainVector, const V *domainDirection, V *gradVector, M *hessianMatrix, V *hessianEffect) const
Actual value of the scalar function.
Definition: GPMSA.C:232
unsigned int m_numSimulations
Definition: GPMSA.h:269
friend std::ostream & operator<<(std::ostream &os, const GPMSAFactory< V, M > &obj)
Definition: GPMSA.h:253
unsigned int m_numSimulationAdds
Definition: GPMSA.h:282
V * m_emulatorPrecisionShapeVec
Definition: GPMSA.h:347
V * m_emulatorDataPrecisionScaleVec
Definition: GPMSA.h:356
V * discrepancyCorrelationMax
Definition: GPMSA.h:321
V * m_emulatorCorrelationStrengthAlphaVec
Definition: GPMSA.h:349
V * m_emulatorCorrelationStrengthBetaVec
Definition: GPMSA.h:350
const BaseVectorRV< V, M > & m_parameterPrior
Definition: GPMSA.h:262
virtual ~GPMSAEmulator()
Definition: GPMSA.C:66
UniformVectorRV< V, M > * m_emulatorMean
Definition: GPMSA.h:339
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:193
VectorSpace< V, M > * emulatorCorrelationSpace
Definition: GPMSA.h:308
VectorSpace< V, M > * discrepancyCorrelationSpace
Definition: GPMSA.h:319
VectorSpace< V, M > * oneDSpace
Definition: GPMSA.h:295
const VectorSpace< V, M > & parameterSpace() const
Return the vector space in which parameters live.
Definition: GPMSA.C:317
V * emulatorDataPrecisionMin
Definition: GPMSA.h:325
GammaVectorRV< V, M > * m_emulatorPrecision
Definition: GPMSA.h:340
V * emulatorPrecisionMax
Definition: GPMSA.h:304
BoxSubset< V, M > * discrepancyPrecisionDomain
Definition: GPMSA.h:316
const VectorSpace< V, M > & simulationOutputSpace() const
Return the vector space in which simulations live.
Definition: GPMSA.C:324
const VectorSpace< V, M > & m_experimentOutputSpace
Definition: GPMSA.h:267
const ConcatenatedVectorRV< V, M > & m_totalPrior
Definition: GPMSA.h:95
GammaVectorRV< V, M > * m_emulatorDataPrecision
Definition: GPMSA.h:344
V * m_discrepancyPrecisionScaleVec
Definition: GPMSA.h:352
This class defines the options that specify the behaviour of the Gaussian process emulator...
Definition: GPMSAOptions.h:40
const VectorSpace< V, M > & m_scenarioSpace
Definition: GPMSA.h:78
BoxSubset< V, M > * discrepancyCorrelationDomain
Definition: GPMSA.h:322
Class representing a subset of a vector space shaped like a hypercube.
Definition: BoxSubset.h:44
GPMSAFactory(const BaseEnvironment &env, GPMSAOptions *opts, const BaseVectorRV< V, M > &parameterPrior, const VectorSpace< V, M > &scenarioSpace, const VectorSpace< V, M > &parameterSpace, const VectorSpace< V, M > &simulationOutputSpace, const VectorSpace< V, M > &experimentOutputSpace, unsigned int numSimulations, unsigned int numExperiments)
Constructor.
Definition: GPMSA.C:243
const VectorSpace< V, M > & m_parameterSpace
Definition: GPMSA.h:265
void addSimulation(V &simulationScenario, V &simulationParameter, V &simulationOutput)
Add a simulation to this.
Definition: GPMSA.C:454
const BaseEnvironment & m_env
Definition: GPMSA.h:260
const std::vector< V * > & simulationOutputs() const
Return all points in simulationOutputSpace for all simulations.
Definition: GPMSA.C:388
void print(std::ostream &os) const
Definition: GPMSA.C:547
unsigned int numSimulations() const
Return number of simulations.
Definition: GPMSA.C:296
A class representing concatenated vector RVs.
void setUpHyperpriors()
Definition: GPMSA.C:555
const M & experimentErrors() const
Return all observation error covarince matrices for all experiments.
Definition: GPMSA.C:433
std::vector< const BaseVectorRV< V, M > * > priors
Definition: GPMSA.h:336
std::vector< V * > m_experimentScenarios
Definition: GPMSA.h:275
BoxSubset< V, M > * totalDomain
Definition: GPMSA.h:334
const V & experimentOutput(unsigned int experimentId) const
Return the experiment output for experiment experimentId.
Definition: GPMSA.C:414
V * m_discrepancyCorrelationStrengthAlphaVec
Definition: GPMSA.h:353
V * emulatorPrecisionMin
Definition: GPMSA.h:303
const VectorSpace< V, M > & scenarioSpace() const
Return the vector space in which scenarios live.
Definition: GPMSA.C:310
A class representing a vector space.
Definition: VectorSet.h:49
const M * m_experimentErrors
Definition: GPMSA.h:279
const VectorSpace< V, M > & m_scenarioSpace
Definition: GPMSA.h:264
V * discrepancyPrecisionMin
Definition: GPMSA.h:314
BoxSubset< V, M > * emulatorDataPrecisionDomain
Definition: GPMSA.h:327
const V & simulationOutput(unsigned int simulationId) const
Return the simulation output for simulation simulationId.
Definition: GPMSA.C:376
const VectorSpace< V, M > & m_simulationOutputSpace
Definition: GPMSA.h:266
unsigned int m_numExperimentAdds
Definition: GPMSA.h:283
const GPMSAEmulator< V, M > & getGPMSAEmulator() const
Return the GPMSAEmulator likelihood object.
Definition: GPMSA.C:447
void addExperiments(const std::vector< V * > &experimentScenarios, const std::vector< V * > &experimentOutputs, const M *experimentErrors)
Add all experiments to this.
Definition: GPMSA.C:502
std::vector< V * > m_simulationScenarios
Definition: GPMSA.h:272
ConcatenatedVectorRV< V, M > * m_totalPrior
Definition: GPMSA.h:345
GPMSAEmulator< V, M > * gpmsaEmulator
Definition: GPMSA.h:359
const VectorSpace< V, M > & experimentOutputSpace() const
Return the vector space in which experiments live.
Definition: GPMSA.C:331
const VectorSpace< V, M > & m_simulationOutputSpace
Definition: GPMSA.h:80

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