queso-0.57.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
MonteCarloSG.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-2017 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/MonteCarloSG.h>
26 #include <queso/GslVector.h>
27 #include <queso/GslMatrix.h>
28 
29 namespace QUESO {
30 
31 // Default constructor -----------------------------
32 template <class P_V,class P_M,class Q_V,class Q_M>
33 MonteCarloSG<P_V,P_M,Q_V,Q_M>::MonteCarloSG( const char* prefix, const McOptionsValues* alternativeOptionsValues, // dakota const BaseVectorRV <P_V,P_M>& paramRv, const BaseVectorFunction<P_V,P_M,Q_V,Q_M>& qoiFunction)
38  :
39  m_env (paramRv.env()),
40  m_paramRv (paramRv),
41  m_qoiFunction (qoiFunction),
42  m_paramSpace (m_paramRv.imageSet().vectorSpace()),
43  m_qoiSpace (m_qoiFunction.imageSet().vectorSpace()),
44  m_qoiFunctionSynchronizer (new VectorFunctionSynchronizer<P_V,P_M,Q_V,Q_M>(m_qoiFunction,m_paramRv.imageSet().vectorSpace().zeroVector(),m_qoiFunction.imageSet().vectorSpace().zeroVector())),
45  m_numPsNotSubWritten (0),
46  m_numQsNotSubWritten (0),
47  m_optionsObj (alternativeOptionsValues),
48  m_userDidNotProvideOptions(false)
49 {
50  if (m_env.subDisplayFile()) {
51  *m_env.subDisplayFile() << "Entering MonteCarloSG<P_V,P_M,Q_V,Q_M>::constructor()"
52  << ": prefix = " << prefix
53  << ", alternativeOptionsValues = " << alternativeOptionsValues
54  << ", m_env.optionsInputFileName() = " << m_env.optionsInputFileName()
55  << std::endl;
56  }
57 
58  // If NULL, we create one
59  if (m_optionsObj == NULL) {
60  McOptionsValues * tempOptions = new McOptionsValues(&m_env, prefix);
61 
62  // We did this dance because scanOptionsValues is not a const method, but
63  // m_optionsObj is a pointer to const
64  m_optionsObj = tempOptions;
65 
66  // We do this so we don't delete the user's object in the dtor
67  m_userDidNotProvideOptions = true;
68  }
69 
70  if (m_optionsObj->m_help != "") {
71  if (m_env.subDisplayFile()) {
72  *m_env.subDisplayFile() << (*m_optionsObj) << std::endl;
73  }
74  }
75 
76  queso_require_equal_to_msg(paramRv.imageSet().vectorSpace().dimLocal(), qoiFunction.domainSet().vectorSpace().dimLocal(), "'paramRv' and 'qoiFunction' are related to vector spaces of different dimensions");
77 
78  if (m_env.subDisplayFile()) {
79  *m_env.subDisplayFile() << "Leaving MonteCarloSG<P_V,P_M,Q_V,Q_M>::constructor()"
80  << std::endl;
81  }
82 }
83 // Destructor ---------------------------------------
84 template <class P_V,class P_M,class Q_V,class Q_M>
86 {
87  if (m_optionsObj && m_userDidNotProvideOptions) {
88  delete m_optionsObj;
89  }
90 
91  if (m_qoiFunctionSynchronizer) delete m_qoiFunctionSynchronizer;
92 }
93 // Statistical methods ------------------------------
94 template <class P_V,class P_M,class Q_V,class Q_M>
95 void
97  BaseVectorSequence<P_V,P_M>& workingPSeq,
98  BaseVectorSequence<Q_V,Q_M>& workingQSeq)
99 {
100  queso_require_equal_to_msg(m_qoiFunction.domainSet().vectorSpace().dimLocal(), workingPSeq.vectorSizeLocal(), "'m_qoiFunction.domainSet' and 'workingPSeq' are related to vector spaces of different dimensions");
101 
102  queso_require_equal_to_msg(m_qoiFunction.imageSet().vectorSpace().dimLocal(), workingQSeq.vectorSizeLocal(), "'m_qoiFunction.imageSet' and 'workingQSeq' are related to vector spaces of different dimensions");
103 
104  MiscCheckTheParallelEnvironment<P_V,Q_V>(m_paramRv.imageSet().vectorSpace().zeroVector(),
105  m_qoiFunction.imageSet().vectorSpace().zeroVector());
106  internGenerateSequence(m_paramRv,workingPSeq,workingQSeq);
107 
108  return;
109 }
110 // I/O methods---------------------------------------
111 template <class P_V,class P_M,class Q_V,class Q_M>
112 void
114 {
115  return;
116 }
117 // Private methods----------------------------------
118 template <class P_V,class P_M,class Q_V,class Q_M>
119 void
121  const BaseVectorRV <P_V,P_M>& paramRv,
122  BaseVectorSequence<P_V,P_M>& workingPSeq,
123  BaseVectorSequence<Q_V,Q_M>& workingQSeq)
124 {
125  workingPSeq.setName(m_optionsObj->m_prefix+"ParamSeq");
126  workingQSeq.setName(m_optionsObj->m_prefix+"QoiSeq");
127 
128  //****************************************************
129  // Generate sequence of QoI values
130  //****************************************************
131  unsigned int subActualSizeBeforeGeneration = std::min(m_optionsObj->m_qseqSize,paramRv.realizer().subPeriod());
132  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 0)) {
133  *m_env.subDisplayFile() << "In MonteCarloSG<P_V,P_M,Q_V,Q_M>::internGenerateSequence()"
134  << ": m_optionsObj->m_qseqSize = " << m_optionsObj->m_qseqSize
135  << ", paramRv.realizer().subPeriod() = " << paramRv.realizer().subPeriod()
136  << ", about to call actualGenerateSequence() with subActualSize = " << subActualSizeBeforeGeneration
137  << std::endl;
138  }
139  if (m_optionsObj->m_qseqDataInputFileName == UQ_MOC_SG_FILENAME_FOR_NO_FILE) {
140  actualGenerateSequence(paramRv,
141  workingPSeq,
142  workingQSeq,
143  subActualSizeBeforeGeneration);
144  }
145  else {
146  actualReadSequence(paramRv,
147  m_optionsObj->m_qseqDataInputFileName,
148  m_optionsObj->m_qseqDataInputFileType,
149  workingPSeq,
150  workingQSeq,
151  subActualSizeBeforeGeneration);
152  }
153  unsigned int subActualSizeAfterGeneration = workingPSeq.subSequenceSize();
154  queso_require_equal_to_msg(subActualSizeAfterGeneration, workingQSeq.subSequenceSize(), "P and Q sequences should have the same size!");
155 
156  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 0)) {
157  *m_env.subDisplayFile() << "In MonteCarloSG<P_V,P_M,Q_V,Q_M>::internGenerateSequence()"
158  << ": returned from call to actualGenerateSequence() with subActualSize = " << subActualSizeAfterGeneration
159  << std::endl;
160  }
161 
162  //****************************************************
163  // Open generic output file
164  //****************************************************
165  if (m_env.subDisplayFile()) {
166  *m_env.subDisplayFile() << "In MonteCarloSG<P_V,P_M,Q_V,Q_M>::internGenerateSequence()"
167  << ", prefix = " << m_optionsObj->m_prefix
168  << ": checking necessity of opening generic output file (qseq name is " << workingQSeq.name()
169  << ") ..."
170  << std::endl;
171  }
172  FilePtrSetStruct genericFilePtrSet;
173  m_env.openOutputFile(m_optionsObj->m_dataOutputFileName,
174  UQ_FILE_EXTENSION_FOR_MATLAB_FORMAT, // Yes, always ".m"
175  m_optionsObj->m_dataOutputAllowedSet,
176  false,
177  genericFilePtrSet);
178 
179  //****************************************************
180  // Eventually:
181  // --> write parameter sequence
182  // --> compute statistics on it
183  //****************************************************
184  if (m_env.subDisplayFile()) {
185  *m_env.subDisplayFile() << "In MonteCarloSG<P_V,P_M,Q_V,Q_M>::internGenerateSequence()"
186  << ", prefix = " << m_optionsObj->m_prefix
187  << ": checking necessity of opening output files for pseq " << workingPSeq.name()
188  << "..."
189  << std::endl;
190  }
191 
192  // Take "sub" care of pseq
193  if ((m_numPsNotSubWritten > 0 ) &&
194  (m_optionsObj->m_pseqDataOutputFileName != UQ_MOC_SG_FILENAME_FOR_NO_FILE)) {
195  workingPSeq.subWriteContents(subActualSizeBeforeGeneration - m_numPsNotSubWritten,
196  m_numPsNotSubWritten,
197  m_optionsObj->m_pseqDataOutputFileName,
198  m_optionsObj->m_pseqDataOutputFileType,
199  m_optionsObj->m_pseqDataOutputAllowedSet);
200  if (m_env.subDisplayFile()) {
201  *m_env.subDisplayFile() << "In MonteCarloG<P_V,P_M>::internGenerateSequence()"
202  << ": just wrote remaining pseq positions (per period request)"
203  << std::endl;
204  }
205  m_numPsNotSubWritten = 0;
206  //if (m_env.subDisplayFile()) {
207  // *m_env.subDisplayFile() << "In MonteCarloSG<P_V,P_M,Q_V,Q_M>::internGenerateSequence()"
208  // << ", prefix = " << m_optionsObj->m_prefix
209  // << ": closed data output file '" << m_optionsObj->m_pseqDataOutputFileName
210  // << "' for pseq " << workingPSeq.name()
211  // << std::endl;
212  //}
213  }
214 
215  // Take "unified" care of pseq
216  if (m_optionsObj->m_pseqDataOutputFileName != UQ_MOC_SG_FILENAME_FOR_NO_FILE) {
217  workingPSeq.unifiedWriteContents(m_optionsObj->m_pseqDataOutputFileName,m_optionsObj->m_pseqDataOutputFileType);
218  if (m_env.subDisplayFile()) {
219  *m_env.subDisplayFile() << "In MonteCarloSG<P_V,P_M,Q_V,Q_M>::internGenerateSequence()"
220  << ", prefix = " << m_optionsObj->m_prefix
221  << ": closed unified data output file '" << m_optionsObj->m_pseqDataOutputFileName
222  << "' for pseq " << workingPSeq.name()
223  << std::endl;
224  }
225  }
226 
227  // Take case of other aspects of pseq
228 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
229  if (m_optionsObj->m_pseqComputeStats) {
230  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 0)) {
231  *m_env.subDisplayFile() << "In MonteCarloSG<P_V,P_M,Q_V,Q_M>::internGenerateSequence()"
232  << ": about to call 'workingPSeq.computeStatistics()'"
233  << std::endl;
234  }
235  workingPSeq.computeStatistics(*m_optionsObj->m_pseqStatisticalOptionsObj,
236  genericFilePtrSet.ofsVar);
237  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 0)) {
238  *m_env.subDisplayFile() << "In MonteCarloSG<P_V,P_M,Q_V,Q_M>::internGenerateSequence()"
239  << ": returned from call to 'workingPSeq.computeStatistics()'"
240  << std::endl;
241  }
242  }
243 #endif
244  //****************************************************
245  // Eventually:
246  // --> write QoI sequence
247  // --> compute statistics on it
248  //****************************************************
249  if (m_env.subDisplayFile()) {
250  *m_env.subDisplayFile() << "In MonteCarloSG<P_V,P_M,Q_V,Q_M>::internGenerateSequence()"
251  << ", prefix = " << m_optionsObj->m_prefix
252  << ": checking necessity of opening output files for qseq " << workingQSeq.name()
253  << "..."
254  << std::endl;
255  }
256 
257  // Take "sub" care of qseq
258  if ((m_numQsNotSubWritten > 0 ) &&
259  (m_optionsObj->m_qseqDataOutputFileName != UQ_MOC_SG_FILENAME_FOR_NO_FILE)) {
260  workingQSeq.subWriteContents(subActualSizeBeforeGeneration - m_numQsNotSubWritten,
261  m_numQsNotSubWritten,
262  m_optionsObj->m_qseqDataOutputFileName,
263  m_optionsObj->m_qseqDataOutputFileType,
264  m_optionsObj->m_qseqDataOutputAllowedSet);
265  if (m_env.subDisplayFile()) {
266  *m_env.subDisplayFile() << "In MonteCarloG<P_V,P_M>::internGenerateSequence()"
267  << ": just wrote remaining qseq positions (per period request)"
268  << std::endl;
269  }
270  m_numQsNotSubWritten = 0;
271  //if (m_env.subDisplayFile()) {
272  // *m_env.subDisplayFile() << "In MonteCarloSG<P_V,P_M,Q_V,Q_M>::internGenerateSequence()"
273  // << ", prefix = " << m_optionsObj->m_prefix
274  // << ": closed data output file '" << m_optionsObj->m_qseqDataOutputFileName
275  // << "' for qseq " << workingQSeq.name()
276  // << std::endl;
277  //}
278  }
279 
280  // Take "unified" care of qseq
281  if (m_optionsObj->m_qseqDataOutputFileName != UQ_MOC_SG_FILENAME_FOR_NO_FILE) {
282  workingQSeq.unifiedWriteContents(m_optionsObj->m_qseqDataOutputFileName,m_optionsObj->m_qseqDataOutputFileType);
283  if (m_env.subDisplayFile()) {
284  *m_env.subDisplayFile() << "In MonteCarloSG<P_V,P_M,Q_V,Q_M>::internGenerateSequence()"
285  << ", prefix = " << m_optionsObj->m_prefix
286  << ": closed unified data output file '" << m_optionsObj->m_qseqDataOutputFileName
287  << "' for qseq " << workingQSeq.name()
288  << std::endl;
289  }
290  }
291 
292  // Take case of other aspects of qseq
293 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
294  if (m_optionsObj->m_qseqComputeStats) {
295  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 0)) {
296  *m_env.subDisplayFile() << "In MonteCarloSG<P_V,P_M,Q_V,Q_M>::internGenerateSequence()"
297  << ": about to call 'workingQSeq.computeStatistics()'"
298  << std::endl;
299  }
300  workingQSeq.computeStatistics(*m_optionsObj->m_qseqStatisticalOptionsObj,
301  genericFilePtrSet.ofsVar);
302  if ((m_env.subDisplayFile()) && (m_env.displayVerbosity() >= 0)) {
303  *m_env.subDisplayFile() << "In MonteCarloSG<P_V,P_M,Q_V,Q_M>::internGenerateSequence()"
304  << ": returned from call to 'workingQSeq.computeStatistics()'"
305  << std::endl;
306  }
307  }
308 #endif
309  //****************************************************
310  // Close generic output file
311  //****************************************************
312  if (genericFilePtrSet.ofsVar) {
313  //std::cout << "TODAY 000" << std::endl;
314  delete genericFilePtrSet.ofsVar;
315  //genericFilePtrSet.ofsVar->close();
316  //std::cout << "TODAY 001" << std::endl;
317  if (m_env.subDisplayFile()) {
318  *m_env.subDisplayFile() << "In MonteCarloSG<P_V,P_M,Q_V,Q_M>::internGenerateSequence()"
319  << ", prefix = " << m_optionsObj->m_prefix
320  << ": closed generic data output file '" << m_optionsObj->m_dataOutputFileName
321  << "' for QoI sequence " << workingQSeq.name()
322  << std::endl;
323  }
324  }
325  if (m_env.subDisplayFile()) {
326  *m_env.subDisplayFile() << std::endl;
327  }
328 
329  return;
330 }
331 // --------------------------------------------------
332 template <class P_V,class P_M,class Q_V,class Q_M>
333 void
335  const BaseVectorRV <P_V,P_M>& paramRv,
336  BaseVectorSequence<P_V,P_M>& workingPSeq,
337  BaseVectorSequence<Q_V,Q_M>& workingQSeq,
338  unsigned int requestedSeqSize)
339 {
340  if (m_env.subDisplayFile()) {
341  *m_env.subDisplayFile() << "Starting the generation of qoi sequence " << workingQSeq.name()
342  << ", with " << requestedSeqSize
343  << " samples..."
344  << std::endl;
345  }
346 
347  int iRC = UQ_OK_RC;
348  struct timeval timevalSeq;
349  struct timeval timevalQoIFunction;
350 
351  double seqRunTime = 0;
352  double qoiFunctionRunTime = 0;
353 
354  iRC = gettimeofday(&timevalSeq, NULL);
355  if (iRC) {}; // just to remover compiler warning
356 
357  workingPSeq.resizeSequence(requestedSeqSize);
358  m_numPsNotSubWritten = 0;
359  workingQSeq.resizeSequence(requestedSeqSize);
360  m_numQsNotSubWritten = 0;
361 
362  P_V tmpP(m_paramSpace.zeroVector());
363  Q_V tmpQ(m_qoiSpace.zeroVector());
364 
365  unsigned int actualSeqSize = 0;
366  for (unsigned int i = 0; i < requestedSeqSize; ++i) {
367  paramRv.realizer().realization(tmpP);
368 
369  if (m_optionsObj->m_qseqMeasureRunTimes) iRC = gettimeofday(&timevalQoIFunction, NULL);
370  m_qoiFunctionSynchronizer->callFunction(&tmpP,NULL,&tmpQ,NULL,NULL,NULL); // Might demand parallel environment
371  if (m_optionsObj->m_qseqMeasureRunTimes) qoiFunctionRunTime += MiscGetEllapsedSeconds(&timevalQoIFunction);
372 
373  bool allQsAreFinite = true;
374  for (unsigned int j = 0; j < tmpQ.sizeLocal(); ++j) {
375  if ((tmpQ[j] == INFINITY) || (tmpQ[j] == -INFINITY)) {
376  std::cerr << "WARNING In MonteCarloSG<P_V,P_M,Q_V,Q_M>::actualGenerateSequence()"
377  << ", worldRank " << m_env.worldRank()
378  << ", fullRank " << m_env.fullRank()
379  << ", subEnvironment " << m_env.subId()
380  << ", subRank " << m_env.subRank()
381  << ", inter0Rank " << m_env.inter0Rank()
382  << ": i = " << i
383  << ", tmpQ[" << j << "] = " << tmpQ[j]
384  << ", tmpP = " << tmpP
385  << ", tmpQ = " << tmpQ
386  << std::endl;
387  allQsAreFinite = false;
388 
389  if (i > 0) {
390  workingPSeq.getPositionValues(i-1,tmpP); // FIXME: temporary code
391  workingQSeq.getPositionValues(i-1,tmpQ); // FIXME: temporary code
392  }
393 
394  break;
395  }
396  }
397  if (allQsAreFinite) {}; // just to remover compiler warning
398 
399  //if (allQsAreFinite) { // FIXME: this will cause different processors to have sequences of different sizes
400  workingPSeq.setPositionValues(i,tmpP);
401  m_numPsNotSubWritten++;
402  if ((m_optionsObj->m_pseqDataOutputPeriod > 0 ) &&
403  (((i+1) % m_optionsObj->m_pseqDataOutputPeriod) == 0 ) &&
404  (m_optionsObj->m_pseqDataOutputFileName != ".")) {
405  workingPSeq.subWriteContents(i + 1 - m_optionsObj->m_pseqDataOutputPeriod,
406  m_optionsObj->m_pseqDataOutputPeriod,
407  m_optionsObj->m_pseqDataOutputFileName,
408  m_optionsObj->m_pseqDataOutputFileType,
409  m_optionsObj->m_pseqDataOutputAllowedSet);
410  if (m_env.subDisplayFile()) {
411  *m_env.subDisplayFile() << "In MonteCarloG<P_V,P_M>::actualGenerateSequence()"
412  << ": just wrote pseq positions (per period request)"
413  << std::endl;
414  }
415  m_numPsNotSubWritten = 0;
416  }
417 
418  workingQSeq.setPositionValues(i,tmpQ);
419  m_numQsNotSubWritten++;
420  if ((m_optionsObj->m_qseqDataOutputPeriod > 0 ) &&
421  (((i+1) % m_optionsObj->m_qseqDataOutputPeriod) == 0 ) &&
422  (m_optionsObj->m_qseqDataOutputFileName != ".")) {
423  workingQSeq.subWriteContents(i + 1 - m_optionsObj->m_qseqDataOutputPeriod,
424  m_optionsObj->m_qseqDataOutputPeriod,
425  m_optionsObj->m_qseqDataOutputFileName,
426  m_optionsObj->m_qseqDataOutputFileType,
427  m_optionsObj->m_qseqDataOutputAllowedSet);
428  if (m_env.subDisplayFile()) {
429  *m_env.subDisplayFile() << "In MonteCarloG<P_V,P_M>::actualGenerateSequence()"
430  << ": just wrote qseq positions (per period request)"
431  << std::endl;
432  }
433  m_numQsNotSubWritten = 0;
434  }
435 
436  actualSeqSize++;
437 
438  //}
439 
440  if ((m_optionsObj->m_qseqDisplayPeriod > 0) &&
441  (((i+1) % m_optionsObj->m_qseqDisplayPeriod) == 0)) {
442  if (m_env.subDisplayFile()) {
443  *m_env.subDisplayFile() << "Finished generating " << i+1
444  << " qoi samples"
445  << std::endl;
446  }
447  }
448  }
449 
450  //if (actualSeqSize != requestedSeqSize) {
451  // workingPSeq.resizeSequence(actualSeqSize);
452  // workingQSeq.resizeSequence(actualSeqSize);
453  //}
454 
455  seqRunTime = MiscGetEllapsedSeconds(&timevalSeq);
456 
457  if (m_env.subDisplayFile()) {
458  *m_env.subDisplayFile() << "Finished the generation of qoi sequence " << workingQSeq.name()
459  << ", with sub " << workingQSeq.subSequenceSize()
460  << " samples"
461  << "\nSome information about this sequence:"
462  << "\n Sequence run time = " << seqRunTime
463  << " seconds"
464  << "\n\n Breaking of the seq run time:\n"
465  << "\n QoI function run time = " << qoiFunctionRunTime
466  << " seconds (" << 100.*qoiFunctionRunTime/seqRunTime
467  << "%)"
468  << std::endl;
469  }
470 
471  return;
472 }
473 // --------------------------------------------------
474 template <class P_V,class P_M,class Q_V,class Q_M>
475 void
477  const BaseVectorRV <P_V,P_M>& paramRv,
478  const std::string& dataInputFileName,
479  const std::string& dataInputFileType,
480  BaseVectorSequence<P_V,P_M>& workingPSeq,
481  BaseVectorSequence<Q_V,Q_M>& workingQSeq,
482  unsigned int requestedSeqSize)
483 {
484  workingPSeq.resizeSequence(requestedSeqSize);
485  P_V tmpP(m_paramSpace.zeroVector());
486  for (unsigned int i = 0; i < requestedSeqSize; ++i) {
487  paramRv.realizer().realization(tmpP);
488  workingPSeq.setPositionValues(i,tmpP);
489  }
490 
491  workingQSeq.unifiedReadContents(dataInputFileName,dataInputFileType,requestedSeqSize);
492 
493  return;
494 }
495 
496 } // End namespace QUESO
497 
virtual void subWriteContents(unsigned int initialPos, unsigned int numPos, const std::string &fileName, const std::string &fileType, const std::set< unsigned int > &allowedSubEnvIds) const =0
Writes info of the sub-sequence to a file. See template specialization.
virtual unsigned int subSequenceSize() const =0
Size of the sub-sequence of vectors. See template specialization.
A templated class for synchronizing the calls of vector-valued functions.
void setName(const std::string &newName)
Changes the name of the sequence of vectors.
This class provides options for the Monte Carlo sequence generator if no input file is available...
void computeStatistics(const SequenceStatisticalOptions &statisticalOptions, std::ofstream *passedOfs)
unsigned int subPeriod() const
Sub-period of the realization. Access to protected attribute m_subPeriod.
const int UQ_OK_RC
Definition: Defines.h:92
virtual void realization(V &nextValues) const =0
Performs a realization (sample) from a probability density function. See template specialization...
MonteCarloSG(const char *prefix, const McOptionsValues *alternativeOptionsValues, const BaseVectorRV< P_V, P_M > &paramRv, const BaseVectorFunction< P_V, P_M, Q_V, Q_M > &qoiFunction)
Constructor.
Definition: MonteCarloSG.C:33
A templated class that implements a Monte Carlo generator of samples.
Definition: MonteCarloSG.h:52
virtual void unifiedWriteContents(const std::string &fileName, const std::string &fileType) const =0
Writes info of the unified sequence to a file. See template specialization.
void actualReadSequence(const BaseVectorRV< P_V, P_M > &paramRv, const std::string &dataInputFileName, const std::string &dataInputFileType, BaseVectorSequence< P_V, P_M > &workingPSeq, BaseVectorSequence< Q_V, Q_M > &workingQSeq, unsigned int seqSize)
Reads the sequence.
Definition: MonteCarloSG.C:476
const std::string & name() const
Access to protected attribute m_name: name of the sequence of vectors.
void actualGenerateSequence(const BaseVectorRV< P_V, P_M > &paramRv, BaseVectorSequence< P_V, P_M > &workingPSeq, BaseVectorSequence< Q_V, Q_M > &workingQSeq, unsigned int seqSize)
This method actually generates the QoI sequence.
Definition: MonteCarloSG.C:334
Base class for handling vector and array samples (sequence of vectors or arrays). ...
virtual void getPositionValues(unsigned int posId, V &vec) const =0
Gets the values of the sequence at position posId and stores them at vec. See template specialization...
virtual void resizeSequence(unsigned int newSubSequenceSize)=0
Resize the sequence. See template specialization.
virtual void unifiedReadContents(const std::string &fileName, const std::string &fileType, const unsigned int subSequenceSize)=0
Reads info of the unified sequence from a file. See template specialization.
void generateSequence(BaseVectorSequence< P_V, P_M > &workingPSeq, BaseVectorSequence< Q_V, Q_M > &workingQSeq)
Generates the QoI (output) sequence, it calls internGenerateSequence().
Definition: MonteCarloSG.C:96
MonteCarloSGOptions::MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix, const McOptionsValues &alternativeOptionsValues queso_require_equal_to_msg)(m_env.optionsInputFileName(), std::string(""), std::string("this constructor is incompatible with the existence of an options input file"))
~MonteCarloSG()
Destructor.
Definition: MonteCarloSG.C:85
void internGenerateSequence(const BaseVectorRV< P_V, P_M > &paramRv, BaseVectorSequence< P_V, P_M > &workingPSeq, BaseVectorSequence< Q_V, Q_M > &workingQSeq)
Generates the QoI (output) sequence; it calls actualGenerateSequence().
Definition: MonteCarloSG.C:120
virtual void setPositionValues(unsigned int posId, const V &vec)=0
Set the values in vec at position posId of the sequence. See template specialization.
std::ofstream * ofsVar
Provides a stream interface to write data to files.
Definition: Environment.h:86
const BaseVectorRealizer< V, M > & realizer() const
Finds a realization (sample) of the PDF of this vector RV; access to private attribute m_realizer...
Definition: VectorRV.C:106
unsigned int vectorSizeLocal() const
Local dimension (size) of the vector space.
Struct for handling data input and output from files.
Definition: Environment.h:77
double MiscGetEllapsedSeconds(struct timeval *timeval0)
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:320
void print(std::ostream &os) const
Prints the sequence.
Definition: MonteCarloSG.C:113

Generated on Tue Jun 5 2018 19:48:56 for queso-0.57.1 by  doxygen 1.8.5