queso-0.56.0
GpmsaComputerModel.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_GCM_H
26 #define UQ_GCM_H
27 
28 #include <queso/GpmsaComputerModelOptions.h>
29 #include <queso/ExperimentStorage.h>
30 #include <queso/ExperimentModel.h>
31 #include <queso/SimulationStorage.h>
32 #include <queso/SimulationModel.h>
33 #include <queso/GcmSimulationInfo.h> // 1
34 #include <queso/GcmExperimentInfo.h> // 2
35 #include <queso/GcmJointInfo.h> // 3
36 #include <queso/GcmZInfo.h> // 4
37 #include <queso/GcmTotalInfo.h> // 5
38 #include <queso/GcmSimulationTildeInfo.h> // 6
39 #include <queso/GcmJointTildeInfo.h> // 7
40 #include <queso/GcmZTildeInfo.h> // 8
41 #include <queso/VectorRV.h>
42 #include <queso/InstantiateIntersection.h>
43 #include <queso/Miscellaneous.h>
44 
45 namespace QUESO {
46 
47 class GslVector;
48 class GslMatrix;
49 
50 template <class S_V = GslVector, class S_M = GslMatrix, class D_V = GslVector,
51  class D_M = GslMatrix, class P_V = GslVector, class P_M = GslMatrix,
52  class Q_V = GslVector, class Q_M = GslMatrix>
54 {
55 public:
56  GpmsaComputerModel(const char* prefix,
57  const GcmOptionsValues* alternativeOptionsValues, // dakota
58  const SimulationStorage<S_V,S_M,P_V,P_M,Q_V,Q_M>& simulationStorage,
59  const SimulationModel <S_V,S_M,P_V,P_M,Q_V,Q_M>& simulationModel,
60  const ExperimentStorage<S_V,S_M,D_V,D_M>* experimentStorage,
61  const ExperimentModel <S_V,S_M,D_V,D_M>* experimentModel,
62  const BaseVectorRV <P_V,P_M>* thetaPriorRv);
64 
65  void calibrateWithBayesMetropolisHastings (const MhOptionsValues* alternativeOptionsValues, // dakota
66  const P_V& totalInitialValues,
67  const P_M* totalInitialProposalCovMatrix);
68  void calibrateWithLanlMcmc (const MhOptionsValues* alternativeOptionsValues, // dakota
69  const P_V& totalInitialValues,
70  const P_M* totalInitialProposalCovMatrix);
72 
73  // This routine calls formSigma_z_hat()
74  // This routine might call formSigma_z_tilde_hat() in the future
75  // This routine calls fillR_formula2_for_Sigma_v_hat_v_asterisk()
76  // This routine calls fillR_formula1_for_Sigma_u_hat_u_asterisk()
77  // This routine calls fillR_formula1_for_Sigma_w_hat_u_asterisk()
78  void predictVUsAtGridPoint (const S_V& newScenarioVec,
79  const P_V& newParameterVec,
80  P_V& vuMeanVec,
81  P_M& vuCovMatrix,
82  P_V& vMeanVec,
83  P_M& vCovMatrix,
84  P_V& uMeanVec,
85  P_M& uCovMatrix);
86 
87  // This routine calls formSigma_w_hat()
88  // This routine calls fillR_formula1_for_Sigma_w_hat_w_asterisk()
89  void predictWsAtGridPoint (const S_V& newScenarioVec,
90  const P_V& newParameterVec,
91  const P_V* forcingSampleVecForDebug, // Usually NULL
92  P_V& wMeanVec,
93  P_M& wCovMatrix);
94  void predictExperimentResults (const S_V& newScenarioVec,
95  const D_M& newKmat_interp,
96  const D_M& newDmat,
97  D_V& simulationOutputMeanVec,
98  D_V& discrepancyMeanVec);
99  void predictSimulationOutputs (const S_V& newScenarioVec,
100  const P_V& newParameterVec,
101  Q_V& simulationOutputMeanVec);
102 
103  const VectorSpace <P_V,P_M>& totalSpace () const;
104  const VectorSpace <P_V,P_M>& unique_vu_space () const;
105  const BaseVectorRV <P_V,P_M>& totalPriorRv () const;
106  const GenericVectorRV<P_V,P_M>& totalPostRv () const;
107 
108  void print (std::ostream& os) const;
109  friend std::ostream& operator<<(std::ostream& os,
111  obj.print(os);
112  return os;
113  }
114 
115 
116 private:
117  void memoryCheck (unsigned int codePositionId);
118  void generatePriorSeq ();
119  static double staticLikelihoodRoutine (const P_V& totalValues,
120  const P_V* totalDirection,
121  const void* functionDataPtr,
122  P_V* gradVector,
123  P_M* hessianMatrix,
124  P_V* hessianEffect);
125 
126  // This routine calls formSigma_z_hat()
127  // This routine might call formSigma_z_tilde_hat() in the future
128  double likelihoodRoutine (const P_V& totalValues,
129  const P_V* totalDirection,
130  const void* functionDataPtr,
131  P_V* gradVector,
132  P_M* hessianMatrix,
133  P_V* hessianEffect);
134 
135  // This routine is called by likelihoodRoutine()
136  // This routine is called by predictVUsAtGridPoint()
137  // This routine calls formSigma_z()
138  void formSigma_z_hat (const P_V& input_1lambdaEtaVec, // ppp: does multiple Gs affect this routine?
139  const P_V& input_2lambdaWVec,
140  const P_V& input_3rhoWVec,
141  const P_V& input_4lambdaSVec,
142  const P_V& input_5lambdaYVec, // ppp: what if there is no experimental data?
143  const P_V& input_6lambdaVVec,
144  const P_V& input_7rhoVVec,
145  const P_V& input_8thetaVec,
146  unsigned int outerCounter);
147  void formSigma_z_hat (const P_V& input_1lambdaEtaVec, // ppp: does multiple Gs affect this routine?
148  const P_V& input_2lambdaWVec,
149  const P_V& input_3rhoWVec,
150  const P_V& input_4lambdaSVec,
151  unsigned int outerCounter);
152 
153  // This routine is called by likelihoodRoutine()
154  // This routine might be called by predictVUsAtGridPoint() in the future
155  // This routine calls formSigma_z()
156  void formSigma_z_tilde_hat (const P_V& input_1lambdaEtaVec, // ppp: does multiple Gs affect this routine?
157  const P_V& input_2lambdaWVec,
158  const P_V& input_3rhoWVec,
159  const P_V& input_4lambdaSVec,
160  const P_V& input_5lambdaYVec, // ppp: what if there is no experimental data?
161  const P_V& input_6lambdaVVec,
162  const P_V& input_7rhoVVec,
163  const P_V& input_8thetaVec,
164  unsigned int outerCounter);
165 
166  // This routine is called by formSigma_z_hat()
167  // This routine is called by formSigma_z_tilde_hat()
168  // This routine calls fillR_formula2_for_Sigma_v ()
169  // This routine calls fillR_formula1_for_Sigma_u ()
170  // This routine calls fillR_formula1_for_Sigma_w ()
171  // This routine calls fillR_formula1_for_Sigma_uw()
172  void formSigma_z (const P_V& input_2lambdaWVec, // ppp: does multiple Gs affect this routine?
173  const P_V& input_3rhoWVec,
174  const P_V& input_4lambdaSVec,
175  const P_V& input_6lambdaVVec, // ppp: what if there is no experimental data?
176  const P_V& input_7rhoVVec,
177  const P_V& input_8thetaVec,
178  unsigned int outerCounter);
179  void formSigma_z (const P_V& input_2lambdaWVec, // ppp: does multiple Gs affect this routine?
180  const P_V& input_3rhoWVec,
181  const P_V& input_4lambdaSVec,
182  unsigned int outerCounter);
183 
184  // This routine calls fillR_formula1_for_Sigma_w()
185  void formSigma_w_hat (const P_V& input_1lambdaEtaVec,
186  const P_V& input_2lambdaWVec,
187  const P_V& input_3rhoWVec,
188  const P_V& input_4lambdaSVec,
189  const P_V& input_8thetaVec,
190  unsigned int outerCounter);
191 
192  void fillR_formula2_for_Sigma_v (const std::vector<const S_V* >& xVecs, // ppp: does multiple Gs affect this routine?
193  const P_V& rho_v_vec,
194  D_M& Rmat,
195  unsigned int outerCounter);
196  void fillR_formula1_for_Sigma_u (const std::vector<const S_V* >& xVecs, // ppp: does multiple Gs affect this routine?
197  const P_V& tVec,
198  const P_V& rho_w_vec,
199  D_M& Rmat,
200  unsigned int outerCounter);
201 
202  // This routine is called by formSigma_z()
203  // This routine is called by formSigma_w_hat()
204  void fillR_formula1_for_Sigma_w (const std::vector<const S_V* >& xVecs, // ppp: does multiple Gs affect this routine?
205  const std::vector<const P_V* >& tVecs,
206  const P_V& rho_w_vec,
207  D_M& Rmat,
208  unsigned int outerCounter);
209  void fillR_formula1_for_Sigma_uw (const std::vector<const S_V* >& xVecs1,
210  const P_V& tVec1,
211  const std::vector<const S_V* >& xVecs2,
212  const std::vector<const P_V* >& tVecs2,
213  const P_V& rho_w_vec,
214  D_M& Rmat,
215  unsigned int outerCounter);
216 
217  void fillR_formula2_for_Sigma_v_hat_v_asterisk(const std::vector<const S_V* >& xVecs1,
218  const std::vector<const P_V* >& tVecs1,
219  const S_V& xVec2,
220  const P_V& tVec2,
221  const P_V& rho_v_vec,
222  D_M& Rmat,
223  unsigned int outerCounter);
224  void fillR_formula1_for_Sigma_u_hat_u_asterisk(const std::vector<const S_V* >& xVecs1,
225  const std::vector<const P_V* >& tVecs1,
226  const S_V& xVec2,
227  const P_V& tVec2,
228  const P_V& rho_w_vec,
229  D_M& Rmat,
230  unsigned int outerCounter);
231  void fillR_formula1_for_Sigma_w_hat_u_asterisk(const std::vector<const S_V* >& xVecs1,
232  const std::vector<const P_V* >& tVecs1,
233  const S_V& xVec2,
234  const P_V& tVec2,
235  const P_V& rho_w_vec,
236  D_M& Rmat,
237  unsigned int outerCounter);
238  void fillR_formula1_for_Sigma_w_hat_w_asterisk(const std::vector<const S_V* >& xVecs1,
239  const std::vector<const P_V* >& tVecs1,
240  const S_V& xVec2,
241  const P_V& tVec2,
242  const P_V& rho_w_vec,
243  D_M& Rmat,
244  unsigned int outerCounter);
245 
249 
263  unsigned int m_like_counter;
264 
265 };
266 
267 } // End namespace QUESO
268 
269 #endif // UQ_GCM_H
const GcmOptionsValues * m_optionsObj
GcmJointInfo< S_V, S_M, D_V, D_M, P_V, P_M, Q_V, Q_M > * m_j
const BaseVectorRV< P_V, P_M > & totalPriorRv() const
void predictSimulationOutputs(const S_V &newScenarioVec, const P_V &newParameterVec, Q_V &simulationOutputMeanVec)
void memoryCheck(unsigned int codePositionId)
GcmJointTildeInfo< S_V, S_M, D_V, D_M, P_V, P_M, Q_V, Q_M > * m_jt
BaseScalarFunction< P_V, P_M > * m_likelihoodFunction
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:197
void fillR_formula1_for_Sigma_w_hat_u_asterisk(const std::vector< const S_V * > &xVecs1, const std::vector< const P_V * > &tVecs1, const S_V &xVec2, const P_V &tVec2, const P_V &rho_w_vec, D_M &Rmat, unsigned int outerCounter)
void formSigma_z_hat(const P_V &input_1lambdaEtaVec, const P_V &input_2lambdaWVec, const P_V &input_3rhoWVec, const P_V &input_4lambdaSVec, const P_V &input_5lambdaYVec, const P_V &input_6lambdaVVec, const P_V &input_7rhoVVec, const P_V &input_8thetaVec, unsigned int outerCounter)
void fillR_formula1_for_Sigma_uw(const std::vector< const S_V * > &xVecs1, const P_V &tVec1, const std::vector< const S_V * > &xVecs2, const std::vector< const P_V * > &tVecs2, const P_V &rho_w_vec, D_M &Rmat, unsigned int outerCounter)
GcmSimulationInfo< S_V, S_M, P_V, P_M, Q_V, Q_M > * m_s
void calibrateWithLanlMcmc(const MhOptionsValues *alternativeOptionsValues, const P_V &totalInitialValues, const P_M *totalInitialProposalCovMatrix)
Struct for handling data input and output from files.
Definition: Environment.h:76
void formSigma_z_tilde_hat(const P_V &input_1lambdaEtaVec, const P_V &input_2lambdaWVec, const P_V &input_3rhoWVec, const P_V &input_4lambdaSVec, const P_V &input_5lambdaYVec, const P_V &input_6lambdaVVec, const P_V &input_7rhoVVec, const P_V &input_8thetaVec, unsigned int outerCounter)
GcmTotalInfo< S_V, S_M, D_V, D_M, P_V, P_M, Q_V, Q_M > * m_t
void calibrateWithBayesMetropolisHastings(const MhOptionsValues *alternativeOptionsValues, const P_V &totalInitialValues, const P_M *totalInitialProposalCovMatrix)
GcmSimulationTildeInfo< S_V, S_M, P_V, P_M, Q_V, Q_M > * m_st
void formSigma_w_hat(const P_V &input_1lambdaEtaVec, const P_V &input_2lambdaWVec, const P_V &input_3rhoWVec, const P_V &input_4lambdaSVec, const P_V &input_8thetaVec, unsigned int outerCounter)
FilePtrSetStruct m_dataOutputFilePtrSet
friend std::ostream & operator<<(std::ostream &os, const GpmsaComputerModel< S_V, S_M, D_V, D_M, P_V, P_M, Q_V, Q_M > &obj)
void fillR_formula1_for_Sigma_u(const std::vector< const S_V * > &xVecs, const P_V &tVec, const P_V &rho_w_vec, D_M &Rmat, unsigned int outerCounter)
GcmExperimentInfo< S_V, S_M, D_V, D_M, P_V, P_M > * m_e
static double staticLikelihoodRoutine(const P_V &totalValues, const P_V *totalDirection, const void *functionDataPtr, P_V *gradVector, P_M *hessianMatrix, P_V *hessianEffect)
void fillR_formula1_for_Sigma_w_hat_w_asterisk(const std::vector< const S_V * > &xVecs1, const std::vector< const P_V * > &tVecs1, const S_V &xVec2, const P_V &tVec2, const P_V &rho_w_vec, D_M &Rmat, unsigned int outerCounter)
GcmZInfo< S_V, S_M, D_V, D_M, P_V, P_M, Q_V, Q_M > * m_z
const BaseEnvironment & m_env
const VectorSpace< P_V, P_M > & unique_vu_space() const
void print(std::ostream &os) const
double likelihoodRoutine(const P_V &totalValues, const P_V *totalDirection, const void *functionDataPtr, P_V *gradVector, P_M *hessianMatrix, P_V *hessianEffect)
void fillR_formula1_for_Sigma_w(const std::vector< const S_V * > &xVecs, const std::vector< const P_V * > &tVecs, const P_V &rho_w_vec, D_M &Rmat, unsigned int outerCounter)
const GenericVectorRV< P_V, P_M > & totalPostRv() const
GpmsaComputerModel(const char *prefix, const GcmOptionsValues *alternativeOptionsValues, const SimulationStorage< S_V, S_M, P_V, P_M, Q_V, Q_M > &simulationStorage, const SimulationModel< S_V, S_M, P_V, P_M, Q_V, Q_M > &simulationModel, const ExperimentStorage< S_V, S_M, D_V, D_M > *experimentStorage, const ExperimentModel< S_V, S_M, D_V, D_M > *experimentModel, const BaseVectorRV< P_V, P_M > *thetaPriorRv)
void predictVUsAtGridPoint(const S_V &newScenarioVec, const P_V &newParameterVec, P_V &vuMeanVec, P_M &vuCovMatrix, P_V &vMeanVec, P_M &vCovMatrix, P_V &uMeanVec, P_M &uCovMatrix)
This class provides options for the Metropolis-Hastings generator of samples if no input file is avai...
void formSigma_z(const P_V &input_2lambdaWVec, const P_V &input_3rhoWVec, const P_V &input_4lambdaSVec, const P_V &input_6lambdaVVec, const P_V &input_7rhoVVec, const P_V &input_8thetaVec, unsigned int outerCounter)
void fillR_formula1_for_Sigma_u_hat_u_asterisk(const std::vector< const S_V * > &xVecs1, const std::vector< const P_V * > &tVecs1, const S_V &xVec2, const P_V &tVec2, const P_V &rho_w_vec, D_M &Rmat, unsigned int outerCounter)
void fillR_formula2_for_Sigma_v(const std::vector< const S_V * > &xVecs, const P_V &rho_v_vec, D_M &Rmat, unsigned int outerCounter)
void predictWsAtGridPoint(const S_V &newScenarioVec, const P_V &newParameterVec, const P_V *forcingSampleVecForDebug, P_V &wMeanVec, P_M &wCovMatrix)
void fillR_formula2_for_Sigma_v_hat_v_asterisk(const std::vector< const S_V * > &xVecs1, const std::vector< const P_V * > &tVecs1, const S_V &xVec2, const P_V &tVec2, const P_V &rho_v_vec, D_M &Rmat, unsigned int outerCounter)
GcmZTildeInfo< S_V, S_M, D_V, D_M, P_V, P_M, Q_V, Q_M > * m_zt
const VectorSpace< P_V, P_M > & totalSpace() const
void predictExperimentResults(const S_V &newScenarioVec, const D_M &newKmat_interp, const D_M &newDmat, D_V &simulationOutputMeanVec, D_V &discrepancyMeanVec)

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