queso-0.53.0
ExperimentModel.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/ExperimentModel.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>
33  const char* prefix,
34  const EmOptionsValues* alternativeOptionsValues, // dakota
35  const ExperimentStorage<S_V,S_M,D_V,D_M>& experimentStorage,
36  const std::vector<D_M* >& Dmats,
37  const std::vector<D_M* >& Kmats_interp)
38  :
39  m_env (Dmats[0]->env()),
40  m_optionsObj (alternativeOptionsValues),
41  m_paper_p_x (experimentStorage.scenarioSpace().dimLocal()),
42  m_paper_n (Dmats.size()),
43  m_paper_p_delta (Dmats[0]->numCols()),
44  m_paper_n_y (0),
45  m_Dmats (Dmats),
46  m_Kmats_interp (Kmats_interp),
47  m_n_y_space (NULL),
48  m_Dmat_BlockDiag (NULL)
49 {
50  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
51  *m_env.subDisplayFile() << "Entering ExperimentModel<S_V,S_M,D_V,D_M>::constructor()"
52  << ": prefix = " << prefix
53  << ", alternativeOptionsValues = " << alternativeOptionsValues
54  << ", m_env.optionsInputFileName() = " << m_env.optionsInputFileName()
55  << "\n m_paper_p_x = " << m_paper_p_x
56  << "\n m_paper_n = " << m_paper_n
57  << "\n m_paper_p_delta = " << m_paper_p_delta
58  << "\n m_paper_n_y = " << "to be set soon"
59  << std::endl;
60  }
61 
62  // If NULL, we create one
63  if (m_optionsObj == NULL) {
64  EmOptionsValues * tempOptions = new EmOptionsValues(&m_env, prefix);
65 
66  // We did this dance because scanOptionsValues is not a const method, but
67  // m_optionsObj is a pointer to const
68  m_optionsObj = tempOptions;
69  }
70 
71  // We'll need to remove this later
73 
74  queso_require_greater_equal_msg(m_optionsObj->m_Gvalues.size(), 1, "invalid m_Gs");
75 
76  queso_require_equal_to_msg(m_paper_n, experimentStorage.xs_standard().size(), "invalid m_paper_n");
77 
78  unsigned int sumGs = 0;
79  for (unsigned int i = 0; i < m_optionsObj->m_Gvalues.size(); ++i) {
80  sumGs += m_optionsObj->m_Gvalues[i];
81  }
82  queso_require_equal_to_msg(m_paper_p_delta, sumGs, "inconsistent input");
83 
84  //***********************************************************************
85  // Form 'Dmat_BlockDiag' matrix
86  //***********************************************************************
87  for (unsigned int i = 0; i < m_Dmats.size(); ++i) {
88  queso_require_equal_to_msg(m_Dmats[i]->numCols(), m_paper_p_delta, "inconsistent m_Dmats");
89  m_paper_n_y += m_Dmats[i]->numRowsLocal();
90  }
91  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 3)) {
92  *m_env.subDisplayFile() << "In ExperimentModel<S_V,S_M,D_V,D_M>::constructor()"
93  << ": prefix = " << prefix
94  << "\n m_paper_n_y = " << m_paper_n_y
95  << std::endl;
96  }
97  m_n_y_space = new VectorSpace<D_V,D_M>(m_env, "n_y_", m_paper_n_y, NULL),
99  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
100  *m_env.subDisplayFile() << "In ExperimentModel<S_V,S_M,D_V,D_M>::constructor()"
101  << ": key-debug"
102  << ", m_Dmat_BlockDiag just created (not yet populated)"
103  << ", numRowsLocal = " << m_Dmat_BlockDiag->numRowsLocal()
104  << ", numCols = " << m_Dmat_BlockDiag->numCols()
105  << std::endl;
106  }
107  m_Dmat_BlockDiag->fillWithBlocksDiagonally(0,0,m_Dmats,true,true);
108 
109  std::set<unsigned int> tmpSet;
110  tmpSet.insert(m_env.subId());
111  if (false) { //gcmOptionsObj.m_dataOutputAllowedSet.find(m_env.subId()) != gcmOptionsObj.m_dataOutputAllowedSet.end()) {
112  m_Dmat_BlockDiag->subWriteContents("Dmat_BlockDiag",
113  "Dmat_BlockDiag",
114  "m",
115  tmpSet);
116  }
117 
118  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
119  *m_env.subDisplayFile() << "Leaving ExperimentModel<S_V,S_M,D_V,D_M>::constructor()"
120  << ": prefix = " << m_optionsObj->m_prefix
121  << std::endl;
122  }
123 }
124 
125 template<class S_V,class S_M,class D_V,class D_M>
127 {
128  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
129  *m_env.subDisplayFile() << "Entering ExperimentModel<S_V,S_M,P_V,P_M,Q_V,Q_M>::destructor()..."
130  << std::endl;
131  }
132 
133  if (m_Dmat_BlockDiag) delete m_Dmat_BlockDiag; // to be deleted on destructor
134  if (m_n_y_space ) delete m_n_y_space; // to be deleted on destructor
135  if (m_optionsObj ) delete m_optionsObj;
136 
137  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
138  *m_env.subDisplayFile() << "Leaving ExperimentModel<S_V,S_M,P_V,P_M,Q_V,Q_M>::destructor()"
139  << std::endl;
140  }
141 
142  if (m_experimentModelOptions) {
143  delete m_experimentModelOptions;
144  }
145 }
146 
147 template<class S_V,class S_M,class D_V,class D_M>
148 unsigned int
150 {
151  return m_paper_p_delta;
152 }
153 
154 template<class S_V,class S_M,class D_V,class D_M>
155 unsigned int
157 {
158  return m_optionsObj->m_Gvalues.size();
159 }
160 
161 template<class S_V,class S_M,class D_V,class D_M>
162 const std::vector<unsigned int>&
164 {
165  return m_optionsObj->m_Gvalues;
166 }
167 
168 template<class S_V,class S_M,class D_V,class D_M>
169 const std::vector<D_M* >&
171 {
172  return m_Kmats_interp;
173 }
174 
175 template<class S_V,class S_M,class D_V,class D_M>
176 const D_M&
177 ExperimentModel<S_V,S_M,D_V,D_M>::Dmat(unsigned int basisId) const
178 {
179  return *(m_Dmats[basisId]);
180 }
181 
182 template<class S_V,class S_M,class D_V,class D_M>
183 const D_M&
185 {
186  return *m_Dmat_BlockDiag;
187 }
188 
189 
190 template<class S_V,class S_M,class D_V,class D_M>
193 {
194  // This methods returns the old ExperimentModelOptions object. We're using
195  // the new EmOptionsValues so this method is deprecated.
197  return *m_experimentModelOptions;
198 }
199 
200 template<class S_V,class S_M,class D_V,class D_M>
201 void
203 {
204  return;
205 }
206 
207 } // End namespace QUESO
208 
unsigned int displayVerbosity() const
Definition: Environment.C:396
std::vector< D_M * > m_Dmats
const BaseEnvironment & m_env
unsigned int m_paper_p_delta
const Map & map() const
Map.
Definition: VectorSpace.C:157
const std::vector< D_M * > & Kmats_interp() const
ExperimentModelOptions * m_experimentModelOptions
const EmOptionsValues * m_optionsObj
ExperimentModel(const char *prefix, const EmOptionsValues *alternativeOptionsValues, const ExperimentStorage< S_V, S_M, D_V, D_M > &experimentStorage, const std::vector< D_M * > &Dmats, const std::vector< D_M * > &Kmats_interp)
#define queso_require_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:85
std::string optionsInputFileName() const
Access to the attribute m_optionsInputFileName, which stores the name of the input file passed by the...
Definition: Environment.C:307
const std::vector< unsigned int > & Gs() const
const D_M & Dmat(unsigned int basisId) const
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
const std::vector< const S_V * > & xs_standard() const
unsigned int numBasisGroups() const
unsigned int numBasis() const
#define queso_deprecated()
Definition: Defines.h:120
#define queso_require_greater_equal_msg(expr1, expr2, msg)
Definition: asserts.h:90
const D_M & Dmat_BlockDiag() const
void print(std::ostream &os) const
VectorSpace< D_V, D_M > * m_n_y_space
const ExperimentModelOptions & optionsObj() const
std::vector< unsigned int > m_Gvalues

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