queso-0.53.0
SimulationStorage.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/SimulationStorage.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 P_V,class P_M,class Q_V,class Q_M>
33  const VectorSpace<S_V,S_M>& scenarioSpace,
34  const VectorSpace<P_V,P_M>& parameterSpace,
35  const VectorSpace<Q_V,Q_M>& outputSpace,
36  unsigned int numSimulations)
37  :
38  m_env (scenarioSpace.env()),
39  m_scenarioSpace (scenarioSpace),
40  m_parameterSpace (parameterSpace),
41  m_outputSpace (outputSpace),
42  m_paper_m (numSimulations),
43  m_paper_n_eta (outputSpace.dimLocal()),
44  m_addId (0),
45  m_scenarioVecs_original (m_paper_m, (S_V*) NULL),
46  m_parameterVecs_original(m_paper_m, (P_V*) NULL),
47  m_outputVecs_original (m_paper_m, (Q_V*) NULL),
48  m_eta_space (NULL),
49  m_etaVec_original (NULL)
50 {
51  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
52  *m_env.subDisplayFile() << "Entering SimulationStorage<S_V,S_M,P_V,P_M,Q_V,Q_M>::constructor()"
53  << "\n m_paper_m = " << m_paper_m
54  << "\n m_paper_n_eta = " << m_paper_n_eta
55  << std::endl;
56  }
57 
58  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
59  *m_env.subDisplayFile() << "Leaving SimulationStorage<S_V,S_M,P_V,P_M,Q_V,Q_M>::constructor()"
60  << std::endl;
61  }
62 }
63 
64 template<class S_V,class S_M,class P_V,class P_M,class Q_V,class Q_M>
66 {
67  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
68  *m_env.subDisplayFile() << "Entering SimulationStorage<S_V,S_M,P_V,P_M,Q_V,Q_M>::destructor()..."
69  << std::endl;
70  }
71 
72  delete m_etaVec_original;
73  delete m_eta_space;
74 
75  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
76  *m_env.subDisplayFile() << "Leaving SimulationStorage<S_V,S_M,P_V,P_M,Q_V,Q_M>::destructor()"
77  << std::endl;
78  }
79 }
80 
81 template<class S_V,class S_M,class P_V,class P_M,class Q_V,class Q_M>
82 void
83 SimulationStorage<S_V,S_M,P_V,P_M,Q_V,Q_M>::addSimulation(const S_V& scenarioVec, const P_V& parameterVec, const Q_V& outputVec)
84 {
85  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
86  *m_env.subDisplayFile() << "Entering SimulationStorage<S_V,S_M,P_V,P_M,Q_V,Q_M>::addSimulation()"
87  << ": m_addId = " << m_addId
88  << std::endl;
89  }
90 
91  queso_require_less_msg(m_addId, m_paper_m, "too many adds...");
92 
93  m_scenarioVecs_original [m_addId] = &scenarioVec;
94  m_parameterVecs_original[m_addId] = &parameterVec;
95  m_outputVecs_original [m_addId] = &outputVec;
96  m_addId++;
97 
98  if (m_addId == m_paper_m) {
99  //***********************************************************************
100  // Form 'etaVec_original'
101  //***********************************************************************
102  m_eta_space = new VectorSpace<Q_V,Q_M>(m_env, "m_eta_simul_storage", m_paper_m * m_paper_n_eta, NULL),
103  m_etaVec_original = new Q_V(m_eta_space->zeroVector());
104  m_etaVec_original->cwSetConcatenated(m_outputVecs_original);
105 
106  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
107  *m_env.subDisplayFile() << "KEY In SimulationStorage<S_V,S_M,D_V,D_M>::addSimulation()"
108  << ": m_addId = " << m_addId
109  << ", populated etaVec_original of size " << m_etaVec_original->sizeLocal()
110  //<< ", m_etaVec_original = " << m_etaVec_original
111  //<< ", *m_etaVec_original = " << *m_etaVec_original
112  << std::endl;
113  }
114  }
115 
116  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 2)) {
117  *m_env.subDisplayFile() << "Leaving SimulationStorage<S_V,S_M,P_V,P_M,Q_V,Q_M>::addSimulation()"
118  << ": m_addId = " << m_addId
119  << std::endl;
120  }
121 
122  return;
123 }
124 
125 template<class S_V,class S_M,class P_V,class P_M,class Q_V,class Q_M>
126 unsigned int
128 {
129  return m_paper_m;
130 }
131 
132 template<class S_V,class S_M,class P_V,class P_M,class Q_V,class Q_M>
133 const std::vector<const S_V* >&
135 {
136  return m_scenarioVecs_original;
137 }
138 
139 template<class S_V,class S_M,class P_V,class P_M,class Q_V,class Q_M>
140 const std::vector<const P_V* >&
142 {
143  return m_parameterVecs_original;
144 }
145 
146 template<class S_V,class S_M,class P_V,class P_M,class Q_V,class Q_M>
149 {
150  return m_scenarioSpace;
151 }
152 
153 template<class S_V,class S_M,class P_V,class P_M,class Q_V,class Q_M>
156 {
157  return m_parameterSpace;
158 }
159 
160 template<class S_V,class S_M,class P_V,class P_M,class Q_V,class Q_M>
163 {
164  return m_outputSpace;
165 }
166 
167 template<class S_V,class S_M,class P_V,class P_M,class Q_V,class Q_M>
168 const S_V&
170 {
171  queso_require_less_msg(simulationId, m_scenarioVecs_original.size(), "simulationId is too large");
172 
173  queso_require_msg(m_scenarioVecs_original[simulationId], "vector is NULL");
174 
175  return *(m_scenarioVecs_original[simulationId]);
176 }
177 
178 template<class S_V,class S_M,class P_V,class P_M,class Q_V,class Q_M>
179 const P_V&
181 {
182  queso_require_less_msg(simulationId, m_parameterVecs_original.size(), "simulationId is too large");
183 
184  queso_require_msg(m_parameterVecs_original[simulationId], "vector is NULL");
185 
186  return *(m_parameterVecs_original[simulationId]);
187 }
188 
189 template<class S_V,class S_M,class P_V,class P_M,class Q_V,class Q_M>
190 const Q_V&
192 {
193  queso_require_less_msg(simulationId, m_outputVecs_original.size(), "simulationId is too large");
194 
195  queso_require_msg(m_outputVecs_original[simulationId], "vector is NULL");
196 
197  return *(m_outputVecs_original[simulationId]);
198 }
199 
200 template<class S_V,class S_M,class P_V,class P_M,class Q_V,class Q_M>
201 const Q_V&
203 {
204  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
205  *m_env.subDisplayFile() << "Entering SimulationStorage<S_V,S_M,P_V,P_M,Q_V,Q_M>::etaVec_original()"
206  << ": m_etaVec_original = " << m_etaVec_original
207  << std::endl;
208  }
209 
210  queso_require_msg(m_etaVec_original, "'m_etaVec_original' is NULL");
211 
212  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 99)) {
213  *m_env.subDisplayFile() << "In SimulationStorage<S_V,S_M,P_V,P_M,Q_V,Q_M>::etaVec_original()"
214  << ": *m_etaVec_original = " << *m_etaVec_original
215  << std::endl;
216  }
217 
218  return *m_etaVec_original;
219 }
220 
221 template<class S_V,class S_M,class P_V,class P_M,class Q_V,class Q_M>
222 const BaseEnvironment&
224 {
225  return m_env;
226 }
227 
228 template<class S_V,class S_M,class P_V,class P_M,class Q_V,class Q_M>
229 void
231 {
232  return;
233 }
234 
235 } // End namespace QUESO
236 
unsigned int displayVerbosity() const
Definition: Environment.C:396
const Q_V & etaVec_original() const
const std::vector< const S_V * > & xs_asterisks_original() const
const VectorSpace< S_V, S_M > & scenarioSpace() const
void addSimulation(const S_V &scenarioVec, const P_V &parameterVec, const Q_V &outputVec)
const VectorSpace< Q_V, Q_M > & outputSpace() const
const P_V & parameterVec_original(unsigned int simulationId) const
void print(std::ostream &os) const
SimulationStorage(const VectorSpace< S_V, S_M > &scenarioSpace, const VectorSpace< P_V, P_M > &parameterSpace, const VectorSpace< Q_V, Q_M > &outputSpace, unsigned int numSimulations)
const S_V & scenarioVec_original(unsigned int simulationId) const
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
#define queso_require_less_msg(expr1, expr2, msg)
Definition: asserts.h:87
const BaseEnvironment & env() const
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:193
const std::vector< const P_V * > & ts_asterisks_original() const
const VectorSpace< P_V, P_M > & parameterSpace() const
const Q_V & outputVec_original(unsigned int simulationId) const
unsigned int numSimulations() const
const BaseEnvironment & m_env

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