25 #include <queso/GcmExperimentInfo.h>
26 #include <queso/GslVector.h>
27 #include <queso/GslMatrix.h>
31 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M>
34 bool allOutputsAreScalar,
39 m_env (experimentStorage.env()),
40 m_experimentStorage (experimentStorage),
41 m_experimentModel (experimentModel),
42 m_paper_p_x (experimentStorage.scenarioSpace().dimLocal()),
43 m_paper_n (experimentStorage.numExperiments()),
44 m_paper_xs_standard (experimentStorage.xs_standard()),
45 m_paper_n_ys_transformed (experimentStorage.n_ys_transformed()),
46 m_paper_n_y (experimentStorage.n_y()),
47 m_paper_p_delta (experimentModel.numBasis()),
48 m_paper_F (experimentModel.numBasisGroups()),
49 m_paper_Gs (experimentModel.Gs()),
50 m_paper_n_space (m_env,
"paper_n_", m_paper_n, NULL),
52 m_5lambdaYSpace (m_env,
"5lambdaY_", m_5lambdaYDim, NULL),
53 m_5lambdaYMins (m_env,m_5lambdaYSpace.map(),0.),
54 m_5lambdaYMaxs (m_env,m_5lambdaYSpace.map(),+INFINITY),
55 m_5lambdaYDomain (
"5lambdaY_",m_5lambdaYSpace,m_5lambdaYMins,m_5lambdaYMaxs),
56 m_5lambdaYGammaAVec (m_env,m_5lambdaYSpace.map(),experimentModel.optionsObj().m_ov.m_a_y),
57 m_5lambdaYGammaBVec (m_env,m_5lambdaYSpace.map(),1./experimentModel.optionsObj().m_ov.m_b_y),
58 m_5lambdaYPriorRv (
"5lambdaY_",m_5lambdaYDomain,m_5lambdaYGammaAVec,m_5lambdaYGammaBVec),
59 m_like_previous5 (m_5lambdaYSpace.zeroVector()),
60 m_tmp_5lambdaYVec (m_5lambdaYSpace.zeroVector()),
62 m_6lambdaVSpace (m_env,
"6lambdaV_", m_6lambdaVDim, NULL),
63 m_6lambdaVMins (m_env,m_6lambdaVSpace.map(),0.),
64 m_6lambdaVMaxs (m_env,m_6lambdaVSpace.map(),+INFINITY),
65 m_6lambdaVDomain (
"6lambdaV_",m_6lambdaVSpace,m_6lambdaVMins,m_6lambdaVMaxs),
66 m_6lambdaVGammaAVec (m_env,m_6lambdaVSpace.map(),experimentModel.optionsObj().m_ov.m_a_v),
67 m_6lambdaVGammaBVec (m_env,m_6lambdaVSpace.map(),1./experimentModel.optionsObj().m_ov.m_b_v),
68 m_6lambdaVPriorRv (
"6lambdaV_",m_6lambdaVDomain,m_6lambdaVGammaAVec,m_6lambdaVGammaBVec),
69 m_like_previous6 (m_6lambdaVSpace.zeroVector()),
70 m_tmp_6lambdaVVec (m_6lambdaVSpace.zeroVector()),
72 m_7rhoVSpace (m_env,
"7rhoV_", m_7rhoVDim, NULL),
73 m_7rhoVMins (m_env,m_7rhoVSpace.map(),0.),
74 m_7rhoVMaxs (m_env,m_7rhoVSpace.map(),1.),
75 m_7rhoVDomain (
"7rhoV_",m_7rhoVSpace,m_7rhoVMins,m_7rhoVMaxs),
76 m_7rhoVBetaAVec (m_env,m_7rhoVSpace.map(),experimentModel.optionsObj().m_ov.m_a_rho_v),
77 m_7rhoVBetaBVec (m_env,m_7rhoVSpace.map(),experimentModel.optionsObj().m_ov.m_b_rho_v),
78 m_7rhoVPriorRv (
"7rhoV_",m_7rhoVDomain,m_7rhoVBetaAVec,m_7rhoVBetaBVec),
79 m_like_previous7 (m_7rhoVSpace.zeroVector()),
80 m_tmp_7rhoVVec (m_7rhoVSpace.zeroVector()),
82 m_8thetaSpace (m_env,
"8theta_", m_8thetaDim, NULL),
83 m_8thetaPriorRv (thetaPriorRv),
84 m_like_previous8 (m_8thetaSpace.zeroVector()),
85 m_tmp_8thetaVec (m_8thetaSpace.zeroVector()),
86 m_v_size (m_paper_n*m_paper_p_delta),
87 m_v_space (m_env,
"v_", m_v_size, NULL),
88 m_unique_v_space (m_env,
"unique_v_", m_paper_p_delta, NULL),
89 m_rho_v_space (m_env,
"rho_v_", m_paper_p_x, NULL),
90 m_y_space (m_env,
"n_y_", m_paper_n_y, NULL),
91 m_tmp_rho_v_vec (m_rho_v_space.zeroVector()),
92 m_Imat_v_i_spaces (m_paper_F, (
VectorSpace<D_V,D_M>*) NULL),
93 m_Imat_v_is (m_paper_F, (D_M*) NULL),
94 m_Rmat_v_i_spaces (m_paper_F, (
VectorSpace<D_V,D_M>*) NULL),
95 m_Rmat_v_is (m_paper_F, (D_M*) NULL),
96 m_Smat_v_i_spaces (m_paper_F, (
VectorSpace<D_V,D_M>*) NULL),
97 m_Smat_v_is (m_paper_F, (D_M*) NULL),
98 m_Smat_v (m_v_space.zeroVector()),
99 m_Rmat_v_hat_v_asterisk_is (m_paper_p_delta, (D_M*) NULL),
100 m_Smat_v_hat_v_asterisk_is (m_paper_p_delta, (D_M*) NULL),
101 m_Smat_v_hat_v_asterisk (m_env, m_v_space.map(), m_paper_p_delta),
102 m_Smat_v_hat_v_asterisk_t (m_env, m_unique_v_space.map(), m_v_size),
104 m_Dmat_BlockDiag (NULL),
105 m_Dmat_BlockDiag_permut (NULL),
107 m_Smat_v_asterisk_v_asterisk(m_unique_v_space.zeroVector())
110 *
m_env.
subDisplayFile() <<
"Entering GcmExperimentInfo<S_V,S_M,D_V,D_M,P_V,P_M>::constructor()"
112 <<
", some entities just created (not yet populated)"
113 <<
", m_Smat_v.numRowsLocal() = " <<
m_Smat_v.numRowsLocal()
114 <<
", m_Smat_v.numCols() = " <<
m_Smat_v.numCols()
118 std::set<unsigned int> tmpSet;
121 if (allOutputsAreScalar) {
129 <<
", m_PD just created (not yet populated)"
130 <<
", numRowsLocal() = " <<
m_PD->numRowsLocal()
131 <<
", numCols() = " <<
m_PD->numCols()
139 <<
", m_Dmat_BlockDiag just created (not yet populated)"
144 m_Wy = &experimentStorage.
Wy();
150 m_Wy->subWriteContents(
"Wy",
156 D_M Wy_filtered(*
m_Wy);
157 Wy_filtered.setPrintHorizontally(
false);
158 Wy_filtered.filterSmallValues(1.e-6);
160 <<
": Wy_filtered.numRowsLocal() = " << Wy_filtered.numRowsLocal()
161 <<
", Wy_filtered.numCols() = " << Wy_filtered.numCols()
162 <<
", Wy_filtered contents =\n" << Wy_filtered
170 for (
unsigned int j = 0; j <
m_paper_n; ++j) {
171 unsigned int row = j + (m_paper_n*i);
173 (*m_PD)(row,col) = 1.;
179 D_M PDt(
m_PD->transpose());
181 *
m_env.
subDisplayFile() <<
"In GcmExperimentInfo<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
183 <<
": m_PD->numRowsLocal() = " <<
m_PD->numRowsLocal()
184 <<
", m_PD->numCols() = " <<
m_PD->numCols()
185 <<
": PDt.numRowsLocal() = " << PDt.numRowsLocal()
186 <<
", PDt.numCols() = " << PDt.numCols()
190 D_M matShouldBeI1( *
m_PD * PDt );
192 for (
unsigned int i = 0; i < matI1.numRowsLocal(); ++i) {
195 matShouldBeI1 -= matI1;
196 double auxNorm1 = matShouldBeI1.normFrob();
198 D_M matShouldBeI2( PDt * *
m_PD );
200 for (
unsigned int i = 0; i < matI2.numRowsLocal(); ++i) {
203 matShouldBeI2 -= matI2;
204 double auxNorm2 = matShouldBeI2.normFrob();
207 *
m_env.
subDisplayFile() <<
"In GcmExperimentInfo<S_V,S_M,D_V,D_M,P_V,P_M,Q_V,Q_M>::constructor()"
209 <<
": matShouldBeI1.numRowsLocal() = " << matShouldBeI1.numRowsLocal()
210 <<
", ||matI1||_2^2 = " << matI1.normFrob() * matI1.normFrob()
211 <<
", ||matShouldBeI1 - matI1||_2^2 = " << auxNorm1 * auxNorm1
212 <<
"; matShouldBeI2.numRowsLocal() = " << matShouldBeI2.numRowsLocal()
213 <<
", ||matI2||_2^2 = " << matI2.normFrob() * matI2.normFrob()
214 <<
", ||matShouldBeI2 - matI2||_2^2 = " << auxNorm2 * auxNorm2
221 <<
": finished forming 'P_D'"
230 <<
": m_Dmat_BlockDiag->numRowsLocal() = " <<
m_Dmat_BlockDiag->numRowsLocal()
232 <<
", m_PD->numRowsLocal() = " <<
m_PD->numRowsLocal()
233 <<
", m_PD->numCols() = " <<
m_PD->numCols()
241 <<
": finished computing 'm_Dmat_BlockDiag_permut'"
252 <<
": before instantiating a m_Imat_v_i space"
253 <<
", m_paper_Gs[" << i <<
"] = " <<
m_paper_Gs[i]
264 <<
": before instantiating the m_Rmat_v_i spaces"
273 unsigned int sumDims = 0;
277 <<
": before instantiating a m_Smat_v_i space"
278 <<
", m_paper_Gs[" << i <<
"] = " <<
m_paper_Gs[i]
287 <<
": finished instantiating the m_Smat_v_i spaces"
290 <<
", sumDims = " << sumDims
298 unsigned int sumNumRows = 0;
299 unsigned int sumNumCols = 0;
308 <<
": finished instantiating the m_Smat_v_hat_v_asterisk_i matrices"
318 *
m_env.
subDisplayFile() <<
"KEY In GcmExperimentInfo<S_V,S_M,D_V,D_M,P_V,P_M>::constructor()"
322 <<
"\n KEY m_paper_n_ys_transformed =";
329 <<
"\n KEY m_paper_Gs.size() = " <<
m_paper_Gs.size()
330 <<
"\n KEY m_paper_Gs =";
331 for (
unsigned int i = 0; i <
m_paper_Gs.size(); ++i) {
357 unsigned int sumGs = 0;
358 for (
unsigned int i = 0; i <
m_paper_F; ++i) {
361 <<
": m_paper_Gs[" << i <<
"] = " <<
m_paper_Gs[i]
368 <<
": sumGs = " << sumGs
374 *
m_env.
subDisplayFile() <<
"Leaving GcmExperimentInfo<S_V,S_M,D_V,D_M,P_V,P_M>::constructor()"
379 template <
class S_V,
class S_M,
class D_V,
class D_M,
class P_V,
class P_M>
382 for (
unsigned int i = 0; i < m_Smat_v_hat_v_asterisk_is.size(); ++i) {
383 delete m_Smat_v_hat_v_asterisk_is[i];
384 m_Smat_v_hat_v_asterisk_is[i] = NULL;
385 delete m_Rmat_v_hat_v_asterisk_is[i];
386 m_Rmat_v_hat_v_asterisk_is[i] = NULL;
389 for (
unsigned int i = 0; i < m_Smat_v_i_spaces.size(); ++i) {
390 delete m_Smat_v_is[i];
391 m_Smat_v_is[i] = NULL;
392 delete m_Smat_v_i_spaces[i];
393 m_Smat_v_i_spaces[i] = NULL;
395 delete m_Rmat_v_is[i];
396 m_Rmat_v_is[i] = NULL;
397 delete m_Rmat_v_i_spaces[i];
398 m_Rmat_v_i_spaces[i] = NULL;
400 delete m_Imat_v_is[i];
401 m_Imat_v_is[i] = NULL;
402 delete m_Imat_v_i_spaces[i];
403 m_Imat_v_i_spaces[i] = NULL;
406 delete m_Dmat_BlockDiag_permut;
unsigned int displayVerbosity() const
std::vector< unsigned int > m_paper_n_ys_transformed
unsigned int dimLocal() const
std::vector< D_M * > m_Smat_v_is
std::vector< D_M * > m_Smat_v_hat_v_asterisk_is
std::vector< VectorSpace< D_V, D_M > * > m_Imat_v_i_spaces
const Map & map() const
Map.
unsigned int m_paper_p_delta
std::vector< VectorSpace< D_V, D_M > * > m_Smat_v_i_spaces
const BaseEnvironment & m_env
D_M * m_Dmat_BlockDiag_permut
std::set< unsigned int > m_dataOutputAllowedSet
const V & zeroVector() const
Returns a vector filled with zeros.
GcmExperimentInfo(const GpmsaComputerModelOptions &gcmOptionsObj, bool allOutputsAreScalar, 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)
VectorSpace< D_V, D_M > m_v_space
#define queso_require_equal_to_msg(expr1, expr2, msg)
unsigned int m_5lambdaYDim
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
unsigned int MiscUintDebugMessage(unsigned int value, const char *message)
std::vector< D_M * > m_Rmat_v_is
unsigned int m_6lambdaVDim
unsigned int subId() const
Access function to the number of each sub-environment Id: m_subId.
VectorSpace< P_V, P_M > m_paper_n_space
const D_V & yVec_transformed() const
std::vector< D_M * > m_Imat_v_is
const D_M * m_Dmat_BlockDiag
VectorSpace< D_V, D_M > m_y_space
unsigned int checkingLevel() const
Access function to private attribute m_checkingLevel.
const D_M & Dmat_BlockDiag() const
std::vector< unsigned int > m_paper_Gs
A class representing a vector space.
std::vector< VectorSpace< D_V, D_M > * > m_Rmat_v_i_spaces
std::vector< D_M * > m_Rmat_v_hat_v_asterisk_is