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

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