queso-0.53.0
GcmTotalInfo.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 <queso/GcmTotalInfo.h>
26 #include <queso/GslVector.h>
27 #include <queso/GslMatrix.h>
28 
29 namespace QUESO {
30 
31 template <class S_V,class S_M,class D_V,class D_M,class P_V,class P_M,class Q_V,class Q_M>
34  :
35  m_env (s.m_env),
36  m_numConstituents (4),
37  m_constitutiveDomains (m_numConstituents,(const VectorSet <P_V,P_M>*) NULL),
38  m_constitutivePriorRvs(m_numConstituents,(const BaseVectorRV<P_V,P_M>*) NULL),
39  m_totalDim (initializeTotalDim(s)),
40  m_totalSpace (m_env,"total_",m_totalDim,NULL),
41  m_totalDomainVolume (1.),
42  m_totalDomain ("total_",m_totalSpace,m_totalDomainVolume,m_constitutiveDomains),
43  m_totalPriorRv ("total_prior_",m_constitutivePriorRvs,m_totalDomain),
44  m_totalPostRv ("total_post_",m_totalSpace),
45  m_like_previousTotal (m_totalSpace.zeroVector()),
46  m_totalPostMean (m_totalSpace.zeroVector()),
47  m_totalPostMedian (m_totalSpace.zeroVector()),
48  m_totalPostMode (m_totalSpace.zeroVector()),
49  m_totalPostMaxLnValue (-INFINITY),
50  m_totalMLE (m_totalSpace.zeroVector()),
51  m_totalLikeMaxLnValue (-INFINITY),
52  m_solutionDomain (NULL),
53  m_solutionPdf (NULL),
54  m_solutionRealizer (NULL),
55  m_mhSeqGenerator (NULL),
56  m_mlSampler (NULL),
57  m_chain (NULL)
58 {
59  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
60  *m_env.subDisplayFile() << "Entering GcmTotalInfo<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor(1)"
61  << std::endl;
62  }
63 
65 
66  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
67  *m_env.subDisplayFile() << "Leaving GcmTotalInfo<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor(1)"
68  << std::endl;
69  }
70 }
71 
72 template <class S_V,class S_M,class D_V,class D_M,class P_V,class P_M,class Q_V,class Q_M>
76  :
77  m_env (s.m_env),
78  m_numConstituents (8),
79  m_constitutiveDomains (m_numConstituents,(const VectorSet<P_V,P_M>*) NULL),
80  m_constitutivePriorRvs(m_numConstituents,(const BaseVectorRV<P_V,P_M>*) NULL),
81  m_totalDim (initializeTotalDim(s,e)),
82  m_totalSpace (m_env, "total_", m_totalDim, NULL),
83  m_totalDomainVolume (1.),
84  m_totalDomain ("total_",m_totalSpace,m_totalDomainVolume,m_constitutiveDomains),
85  m_totalPriorRv ("total_prior_",m_constitutivePriorRvs,m_totalDomain),
86  m_totalPostRv ("total_post_",m_totalSpace),
87  m_like_previousTotal (m_totalSpace.zeroVector()),
88  m_totalPostMean (m_totalSpace.zeroVector()),
89  m_totalPostMedian (m_totalSpace.zeroVector()),
90  m_totalPostMode (m_totalSpace.zeroVector()),
91  m_totalPostMaxLnValue (-INFINITY),
92  m_totalMLE (m_totalSpace.zeroVector()),
93  m_totalLikeMaxLnValue (-INFINITY),
94  m_solutionDomain (NULL),
95  m_solutionPdf (NULL),
96  m_solutionRealizer (NULL),
97  m_mhSeqGenerator (NULL),
98  m_mlSampler (NULL),
99  m_chain (NULL)
100 {
101  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
102  *m_env.subDisplayFile() << "Entering GcmTotalInfo<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor(2)"
103  << std::endl;
104  }
105 
107 
108  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
109  *m_env.subDisplayFile() << "Leaving GcmTotalInfo<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor(2)"
110  << std::endl;
111  }
112 }
113 
114 template <class S_V,class S_M,class D_V,class D_M,class P_V,class P_M,class Q_V,class Q_M>
116 {
117  if (m_chain) {
118  m_chain->clear();
119  delete m_chain;
120  }
121  if (m_mlSampler ) delete m_mlSampler;
122  if (m_mhSeqGenerator ) delete m_mhSeqGenerator;
123  if (m_solutionRealizer) delete m_solutionRealizer;
124  if (m_solutionPdf ) delete m_solutionPdf;
125  if (m_solutionDomain ) delete m_solutionDomain;
126 }
127 
128 template <class S_V,class S_M,class D_V,class D_M,class P_V,class P_M,class Q_V,class Q_M>
129 unsigned int
131 {
132  m_constitutiveDomains[0] = &(s.m_1lambdaEtaDomain);
133  m_constitutiveDomains[1] = &(s.m_2lambdaWDomain);
134  m_constitutiveDomains[2] = &(s.m_3rhoWDomain);
135  m_constitutiveDomains[3] = &(s.m_4lambdaSDomain);
136 
137  m_constitutivePriorRvs[0] = &(s.m_1lambdaEtaPriorRv);
138  m_constitutivePriorRvs[1] = &(s.m_2lambdaWPriorRv);
139  m_constitutivePriorRvs[2] = &(s.m_3rhoWPriorRv);
140  m_constitutivePriorRvs[3] = &(s.m_4lambdaSPriorRv);
141 
142  return (s.m_1lambdaEtaDim + s.m_2lambdaWDim + s.m_3rhoWDim + s.m_4lambdaSDim);
143 }
144 
145 
146 template <class S_V,class S_M,class D_V,class D_M,class P_V,class P_M,class Q_V,class Q_M>
147 unsigned int
151 {
152  m_constitutiveDomains[0] = &(s.m_1lambdaEtaDomain);
153  m_constitutiveDomains[1] = &(s.m_2lambdaWDomain);
154  m_constitutiveDomains[2] = &(s.m_3rhoWDomain);
155  m_constitutiveDomains[3] = &(s.m_4lambdaSDomain);
156  m_constitutiveDomains[4] = &(e.m_5lambdaYDomain);
157  m_constitutiveDomains[5] = &(e.m_6lambdaVDomain);
158  m_constitutiveDomains[6] = &(e.m_7rhoVDomain);
159  m_constitutiveDomains[7] = &(e.m_8thetaPriorRv.imageSet());
160 
161  m_constitutivePriorRvs[0] = &(s.m_1lambdaEtaPriorRv);
162  m_constitutivePriorRvs[1] = &(s.m_2lambdaWPriorRv);
163  m_constitutivePriorRvs[2] = &(s.m_3rhoWPriorRv);
164  m_constitutivePriorRvs[3] = &(s.m_4lambdaSPriorRv);
165  m_constitutivePriorRvs[4] = &(e.m_5lambdaYPriorRv);
166  m_constitutivePriorRvs[5] = &(e.m_6lambdaVPriorRv);
167  m_constitutivePriorRvs[6] = &(e.m_7rhoVPriorRv);
168  m_constitutivePriorRvs[7] = &(e.m_8thetaPriorRv);
169 
171 }
172 
173 template <class S_V,class S_M,class D_V,class D_M,class P_V,class P_M,class Q_V,class Q_M>
174 void
176 {
177  m_totalPriorRv.pdf().setNormalizationStyle(0); // CSRI - 2013-Aug-06 - with Laura
178  for (unsigned int i = 0; i < m_numConstituents; ++i) {
179  m_totalDomainVolume *= m_constitutiveDomains[i]->volume();
180  }
181 
182  //********************************************************************************
183  // Display information
184  //********************************************************************************
185  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
186  *m_env.subDisplayFile() << "In GcmTotalInfo<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::commonConstructor()"
187  << "\n m_totalDim = " << m_totalDim
188  << "\n m_numConstituents = " << m_numConstituents
189  << "\n m_totalDomainVolume = " << m_totalDomainVolume
190  << std::endl;
191  }
192 
193  return;
194 }
195 
196 } // End namespace QUESO
197 
unsigned int displayVerbosity() const
Definition: Environment.C:396
BoxSubset< P_V, P_M > m_5lambdaYDomain
A templated class for handling sets.
Definition: VectorSet.h:52
BoxSubset< P_V, P_M > m_2lambdaWDomain
const BaseEnvironment & m_env
Definition: GcmTotalInfo.h:57
BoxSubset< P_V, P_M > m_7rhoVDomain
A templated base class for handling vector RV.
Definition: VectorRV.h:54
BetaVectorRV< P_V, P_M > m_3rhoWPriorRv
BoxSubset< P_V, P_M > m_3rhoWDomain
unsigned int initializeTotalDim(const GcmSimulationInfo< S_V, S_M, P_V, P_M, Q_V, Q_M > &s)
Definition: GcmTotalInfo.C:130
BoxSubset< P_V, P_M > m_4lambdaSDomain
BetaVectorRV< P_V, P_M > m_7rhoVPriorRv
GammaVectorRV< P_V, P_M > m_1lambdaEtaPriorRv
GammaVectorRV< P_V, P_M > m_4lambdaSPriorRv
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
GammaVectorRV< P_V, P_M > m_6lambdaVPriorRv
const BaseVectorRV< P_V, P_M > & m_8thetaPriorRv
GcmTotalInfo(const GcmSimulationInfo< S_V, S_M, P_V, P_M, Q_V, Q_M > &s)
Definition: GcmTotalInfo.C:32
BoxSubset< P_V, P_M > m_6lambdaVDomain
const VectorSet< V, M > & imageSet() const
Image set of the vector RV; access to private attribute m_imageSet.
Definition: VectorRV.C:79
GammaVectorRV< P_V, P_M > m_5lambdaYPriorRv
GammaVectorRV< P_V, P_M > m_2lambdaWPriorRv
BoxSubset< P_V, P_M > m_1lambdaEtaDomain

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