queso-0.53.0
MonteCarloSGOptions.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 <boost/program_options.hpp>
26 
27 #include <queso/MonteCarloSGOptions.h>
28 #include <queso/Miscellaneous.h>
29 
30 // -------------------------------------------------
31 // McOptionsValues --------------------------
32 // -------------------------------------------------
33 
34 namespace QUESO {
35 
36 // Default constructor -----------------------------
38 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
39  const SsOptionsValues* alternativePSsOptionsValues,
40  const SsOptionsValues* alternativeQSsOptionsValues
41 #endif
42  )
43  :
44  m_prefix ("mc_"),
45  m_help (UQ_MOC_SG_HELP),
46  m_dataOutputFileName (UQ_MOC_SG_DATA_OUTPUT_FILE_NAME_ODV ),
47  //m_dataOutputAllowedSet (),
48  m_pseqDataOutputPeriod (UQ_MOC_SG_PSEQ_DATA_OUTPUT_PERIOD_ODV ),
49  m_pseqDataOutputFileName (UQ_MOC_SG_PSEQ_DATA_OUTPUT_FILE_NAME_ODV),
50  m_pseqDataOutputFileType (UQ_MOC_SG_PSEQ_DATA_OUTPUT_FILE_TYPE_ODV),
51  //m_pseqDataOutputAllowedSet (),
52 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
53  m_pseqComputeStats (UQ_MOC_SG_PSEQ_COMPUTE_STATS_ODV ),
54 #endif
55  m_qseqDataInputFileName (UQ_MOC_SG_QSEQ_DATA_INPUT_FILE_NAME_ODV ),
56  m_qseqDataInputFileType (UQ_MOC_SG_QSEQ_DATA_INPUT_FILE_TYPE_ODV ),
57  m_qseqSize (UQ_MOC_SG_QSEQ_SIZE_ODV ),
58  m_qseqDisplayPeriod (UQ_MOC_SG_QSEQ_DISPLAY_PERIOD_ODV ),
59  m_qseqMeasureRunTimes (UQ_MOC_SG_QSEQ_MEASURE_RUN_TIMES_ODV ),
60  m_qseqDataOutputPeriod (UQ_MOC_SG_QSEQ_DATA_OUTPUT_PERIOD_ODV ),
61  m_qseqDataOutputFileName (UQ_MOC_SG_QSEQ_DATA_OUTPUT_FILE_NAME_ODV),
62  m_qseqDataOutputFileType (UQ_MOC_SG_QSEQ_DATA_OUTPUT_FILE_TYPE_ODV),
63  //m_qseqDataOutputAllowedSet (),
64 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
65  m_qseqComputeStats (UQ_MOC_SG_QSEQ_COMPUTE_STATS_ODV ),
66  m_alternativePSsOptionsValues(),
67  m_alternativeQSsOptionsValues(),
68 #endif
69  m_parser(NULL),
70  m_option_help (m_prefix + "help" ),
71  m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ),
72  m_option_dataOutputAllowedSet (m_prefix + "dataOutputAllowedSet" ),
73  m_option_pseq_dataOutputPeriod (m_prefix + "pseq_dataOutputPeriod" ),
74  m_option_pseq_dataOutputFileName (m_prefix + "pseq_dataOutputFileName" ),
75  m_option_pseq_dataOutputFileType (m_prefix + "pseq_dataOutputFileType" ),
76  m_option_pseq_dataOutputAllowedSet(m_prefix + "pseq_dataOutputAllowedSet" ),
77 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
78  m_option_pseq_computeStats (m_prefix + "pseq_computeStats" ),
79 #endif
80  m_option_qseq_dataInputFileName (m_prefix + "qseq_dataInputFileName" ),
81  m_option_qseq_dataInputFileType (m_prefix + "qseq_dataInputFileType" ),
82  m_option_qseq_size (m_prefix + "qseq_size" ),
83  m_option_qseq_displayPeriod (m_prefix + "qseq_displayPeriod" ),
84  m_option_qseq_measureRunTimes (m_prefix + "qseq_measureRunTimes" ),
85  m_option_qseq_dataOutputPeriod (m_prefix + "qseq_dataOutputPeriod" ),
86  m_option_qseq_dataOutputFileName (m_prefix + "qseq_dataOutputFileName" ),
87  m_option_qseq_dataOutputFileType (m_prefix + "qseq_dataOutputFileType" ),
88  m_option_qseq_dataOutputAllowedSet(m_prefix + "qseq_dataOutputAllowedSet" )
89 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
90  ,
91  m_option_qseq_computeStats (m_prefix + "qseq_computeStats" )
92 #endif
93 {
94 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
95  if (alternativePSsOptionsValues) m_alternativePSsOptionsValues = *alternativePSsOptionsValues;
96  if (alternativeQSsOptionsValues) m_alternativeQSsOptionsValues = *alternativeQSsOptionsValues;
97 #endif
98 }
99 
101 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
102  const SsOptionsValues* alternativePSsOptionsValues,
103  const SsOptionsValues* alternativeQSsOptionsValues,
104 #endif
105  const BaseEnvironment * env, const char * prefix
106  )
107  :
108  m_prefix ((std::string)(prefix) + "mc_"),
109  m_help (UQ_MOC_SG_HELP),
110  m_dataOutputFileName (UQ_MOC_SG_DATA_OUTPUT_FILE_NAME_ODV ),
111  //m_dataOutputAllowedSet (),
112  m_pseqDataOutputPeriod (UQ_MOC_SG_PSEQ_DATA_OUTPUT_PERIOD_ODV ),
113  m_pseqDataOutputFileName (UQ_MOC_SG_PSEQ_DATA_OUTPUT_FILE_NAME_ODV),
114  m_pseqDataOutputFileType (UQ_MOC_SG_PSEQ_DATA_OUTPUT_FILE_TYPE_ODV),
115  //m_pseqDataOutputAllowedSet (),
116 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
117  m_pseqComputeStats (UQ_MOC_SG_PSEQ_COMPUTE_STATS_ODV ),
118 #endif
119  m_qseqDataInputFileName (UQ_MOC_SG_QSEQ_DATA_INPUT_FILE_NAME_ODV ),
120  m_qseqDataInputFileType (UQ_MOC_SG_QSEQ_DATA_INPUT_FILE_TYPE_ODV ),
121  m_qseqSize (UQ_MOC_SG_QSEQ_SIZE_ODV ),
122  m_qseqDisplayPeriod (UQ_MOC_SG_QSEQ_DISPLAY_PERIOD_ODV ),
123  m_qseqMeasureRunTimes (UQ_MOC_SG_QSEQ_MEASURE_RUN_TIMES_ODV ),
124  m_qseqDataOutputPeriod (UQ_MOC_SG_QSEQ_DATA_OUTPUT_PERIOD_ODV ),
125  m_qseqDataOutputFileName (UQ_MOC_SG_QSEQ_DATA_OUTPUT_FILE_NAME_ODV),
126  m_qseqDataOutputFileType (UQ_MOC_SG_QSEQ_DATA_OUTPUT_FILE_TYPE_ODV),
127  //m_qseqDataOutputAllowedSet (),
128 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
129  m_qseqComputeStats (UQ_MOC_SG_QSEQ_COMPUTE_STATS_ODV ),
130  m_alternativePSsOptionsValues(),
131  m_alternativeQSsOptionsValues(),
132 #endif
133  m_parser(new BoostInputOptionsParser(env->optionsInputFileName())),
134  m_option_help (m_prefix + "help" ),
135  m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ),
136  m_option_dataOutputAllowedSet (m_prefix + "dataOutputAllowedSet" ),
137  m_option_pseq_dataOutputPeriod (m_prefix + "pseq_dataOutputPeriod" ),
138  m_option_pseq_dataOutputFileName (m_prefix + "pseq_dataOutputFileName" ),
139  m_option_pseq_dataOutputFileType (m_prefix + "pseq_dataOutputFileType" ),
140  m_option_pseq_dataOutputAllowedSet(m_prefix + "pseq_dataOutputAllowedSet" ),
141 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
142  m_option_pseq_computeStats (m_prefix + "pseq_computeStats" ),
143 #endif
144  m_option_qseq_dataInputFileName (m_prefix + "qseq_dataInputFileName" ),
145  m_option_qseq_dataInputFileType (m_prefix + "qseq_dataInputFileType" ),
146  m_option_qseq_size (m_prefix + "qseq_size" ),
147  m_option_qseq_displayPeriod (m_prefix + "qseq_displayPeriod" ),
148  m_option_qseq_measureRunTimes (m_prefix + "qseq_measureRunTimes" ),
149  m_option_qseq_dataOutputPeriod (m_prefix + "qseq_dataOutputPeriod" ),
150  m_option_qseq_dataOutputFileName (m_prefix + "qseq_dataOutputFileName" ),
151  m_option_qseq_dataOutputFileType (m_prefix + "qseq_dataOutputFileType" ),
152  m_option_qseq_dataOutputAllowedSet(m_prefix + "qseq_dataOutputAllowedSet" )
153 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
154  ,
155  m_option_qseq_computeStats (m_prefix + "qseq_computeStats" )
156 #endif
157 {
158 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
159  if (alternativePSsOptionsValues) m_alternativePSsOptionsValues = *alternativePSsOptionsValues;
160  if (alternativeQSsOptionsValues) m_alternativeQSsOptionsValues = *alternativeQSsOptionsValues;
161 #endif
162 
163  m_parser->registerOption<std::string >(m_option_help, UQ_MOC_SG_HELP , "produce help message for Monte Carlo distribution calculator");
164  m_parser->registerOption<std::string >(m_option_dataOutputFileName, UQ_MOC_SG_DATA_OUTPUT_FILE_NAME_ODV , "name of generic data output file" );
165  m_parser->registerOption<std::string >(m_option_dataOutputAllowedSet, UQ_MOC_SG_DATA_OUTPUT_ALLOWED_SET_ODV , "subEnvs that will write to generic data output file" );
166  m_parser->registerOption<unsigned int>(m_option_pseq_dataOutputPeriod, UQ_MOC_SG_PSEQ_DATA_OUTPUT_PERIOD_ODV , "period of message display during param sequence generation" );
167  m_parser->registerOption<std::string >(m_option_pseq_dataOutputFileName, UQ_MOC_SG_PSEQ_DATA_OUTPUT_FILE_NAME_ODV , "name of data output file for parameters" );
168  m_parser->registerOption<std::string >(m_option_pseq_dataOutputFileType, UQ_MOC_SG_PSEQ_DATA_OUTPUT_FILE_TYPE_ODV , "type of data output file for parameters" );
169  m_parser->registerOption<std::string >(m_option_pseq_dataOutputAllowedSet, UQ_MOC_SG_PSEQ_DATA_OUTPUT_ALLOWED_SET_ODV, "subEnvs that will write to data output file for parameters" );
170 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
171  m_parser->registerOption<bool >(m_option_pseq_computeStats, UQ_MOC_SG_PSEQ_COMPUTE_STATS_ODV , "compute statistics on sequence of parameter" );
172 #endif
173  m_parser->registerOption<std::string >(m_option_qseq_dataInputFileName, UQ_MOC_SG_QSEQ_DATA_INPUT_FILE_NAME_ODV , "name of data input file for qois" );
174  m_parser->registerOption<std::string >(m_option_qseq_dataInputFileType, UQ_MOC_SG_QSEQ_DATA_INPUT_FILE_TYPE_ODV , "type of data input file for qois" );
175  m_parser->registerOption<unsigned int>(m_option_qseq_size, UQ_MOC_SG_QSEQ_SIZE_ODV , "size of qoi sequence" );
176  m_parser->registerOption<unsigned int>(m_option_qseq_displayPeriod, UQ_MOC_SG_QSEQ_DISPLAY_PERIOD_ODV , "period of message display during qoi sequence generation" );
178  m_parser->registerOption<unsigned int>(m_option_qseq_dataOutputPeriod, UQ_MOC_SG_QSEQ_DATA_OUTPUT_PERIOD_ODV , "period of message display during qoi sequence generation" );
179  m_parser->registerOption<std::string >(m_option_qseq_dataOutputFileName, UQ_MOC_SG_QSEQ_DATA_OUTPUT_FILE_NAME_ODV , "name of data output file for qois" );
180  m_parser->registerOption<std::string >(m_option_qseq_dataOutputFileType, UQ_MOC_SG_QSEQ_DATA_OUTPUT_FILE_TYPE_ODV , "type of data output file for qois" );
181  m_parser->registerOption<std::string >(m_option_qseq_dataOutputAllowedSet, UQ_MOC_SG_QSEQ_DATA_OUTPUT_ALLOWED_SET_ODV, "subEnvs that will write to data output file for qois" );
182 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
183  m_parser->registerOption<bool >(m_option_qseq_computeStats, UQ_MOC_SG_QSEQ_COMPUTE_STATS_ODV , "compute statistics on sequence of qoi" );
184 #endif
185 
187 
188  m_parser->getOption<std::string >(m_option_help, m_help);
195 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
196  m_parser->getOption<bool >(m_option_pseq_computeStats, m_pseq_computeStats);
197 #endif
207 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
208  m_parser->getOption<bool >(m_option_qseq_computeStats, m_qseq_computeStats);
209 #endif
210 }
211 
212 // Copy constructor --------------------------------
214 {
215  this->copy(src);
216 }
217 // Destructor ---------------------------------------
219 {
220 }
221 // Set methods --------------------------------------
224 {
225  this->copy(rhs);
226  return *this;
227 }
228 // Private methods-----------------------------------
229 void
231 {
232  // Do nothing
233 }
234 
235 void
237 {
244 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
245  m_pseqComputeStats = src.m_pseqComputeStats;
246 #endif
249  m_qseqSize = src.m_qseqSize;
256 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
257  m_qseqComputeStats = src.m_qseqComputeStats;
258 #endif
259 
260 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
261  m_alternativePSsOptionsValues = src.m_alternativePSsOptionsValues;
262  m_alternativeQSsOptionsValues = src.m_alternativeQSsOptionsValues;
263 #endif
264 
265  return;
266 }
267 
268 std::ostream & operator<<(std::ostream & os, const McOptionsValues & obj)
269 {
270  os << (*(obj.m_parser)) << std::endl;
271 
272  os << obj.m_option_dataOutputFileName << " = " << obj.m_dataOutputFileName
273  << "\n" << obj.m_option_dataOutputAllowedSet << " = ";
274  for (std::set<unsigned int>::iterator setIt = obj.m_dataOutputAllowedSet.begin(); setIt != obj.m_dataOutputAllowedSet.end(); ++setIt) {
275  os << *setIt << " ";
276  }
277  os << "\n" << obj.m_option_pseq_dataOutputPeriod << " = " << obj.m_pseqDataOutputPeriod
278  << "\n" << obj.m_option_pseq_dataOutputFileName << " = " << obj.m_pseqDataOutputFileName
279  << "\n" << obj.m_option_pseq_dataOutputFileType << " = " << obj.m_pseqDataOutputFileType
280  << "\n" << obj.m_option_pseq_dataOutputAllowedSet << " = ";
281  for (std::set<unsigned int>::iterator setIt = obj.m_pseqDataOutputAllowedSet.begin(); setIt != obj.m_pseqDataOutputAllowedSet.end(); ++setIt) {
282  os << *setIt << " ";
283  }
284  os
285 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
286  << "\n" << obj.m_option_pseq_computeStats << " = " << obj.m_pseqComputeStats
287 #endif
288  << "\n" << obj.m_option_qseq_dataInputFileName << " = " << obj.m_qseqDataInputFileName
289  << "\n" << obj.m_option_qseq_dataInputFileType << " = " << obj.m_qseqDataInputFileType
290  << "\n" << obj.m_option_qseq_size << " = " << obj.m_qseqSize
291  << "\n" << obj.m_option_qseq_displayPeriod << " = " << obj.m_qseqDisplayPeriod
292  << "\n" << obj.m_option_qseq_measureRunTimes << " = " << obj.m_qseqMeasureRunTimes
293  << "\n" << obj.m_option_qseq_dataOutputPeriod << " = " << obj.m_qseqDataOutputPeriod
294  << "\n" << obj.m_option_qseq_dataOutputFileName << " = " << obj.m_qseqDataOutputFileName
295  << "\n" << obj.m_option_qseq_dataOutputFileType << " = " << obj.m_qseqDataOutputFileType
296  << "\n" << obj.m_option_qseq_dataOutputAllowedSet << " = ";
297  for (std::set<unsigned int>::iterator setIt = obj.m_qseqDataOutputAllowedSet.begin(); setIt != obj.m_qseqDataOutputAllowedSet.end(); ++setIt) {
298  os << *setIt << " ";
299  }
300 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
301  os << "\n" << obj.m_option_qseq_computeStats << " = " << obj.m_qseqComputeStats;
302 #endif
303 
304  return os;
305 }
306 
307 // --------------------------------------------------
308 //MonteCarloSGOptions ------------------------
309 // --------------------------------------------------
310 
311 // Default constructor -----------------------------
313  const BaseEnvironment& env,
314  const char* prefix)
315  :
316 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
317  m_ov (NULL,NULL),
318  m_pseqStatisticalOptionsObj (NULL),
319  m_qseqStatisticalOptionsObj (NULL),
320 #else
321  m_ov (),
322 #endif
323  m_prefix ((std::string)(prefix) + "mc_"),
324  m_env (env),
325  m_optionsDesc (new boost::program_options::options_description("Monte Carlo options")),
326  m_option_help (m_prefix + "help" ),
327  m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ),
328  m_option_dataOutputAllowedSet (m_prefix + "dataOutputAllowedSet" ),
329  m_option_pseq_dataOutputPeriod (m_prefix + "pseq_dataOutputPeriod" ),
330  m_option_pseq_dataOutputFileName (m_prefix + "pseq_dataOutputFileName" ),
331  m_option_pseq_dataOutputFileType (m_prefix + "pseq_dataOutputFileType" ),
332  m_option_pseq_dataOutputAllowedSet(m_prefix + "pseq_dataOutputAllowedSet" ),
333 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
334  m_option_pseq_computeStats (m_prefix + "pseq_computeStats" ),
335 #endif
336  m_option_qseq_dataInputFileName (m_prefix + "qseq_dataInputFileName" ),
337  m_option_qseq_dataInputFileType (m_prefix + "qseq_dataInputFileType" ),
338  m_option_qseq_size (m_prefix + "qseq_size" ),
339  m_option_qseq_displayPeriod (m_prefix + "qseq_displayPeriod" ),
340  m_option_qseq_measureRunTimes (m_prefix + "qseq_measureRunTimes" ),
341  m_option_qseq_dataOutputPeriod (m_prefix + "qseq_dataOutputPeriod" ),
342  m_option_qseq_dataOutputFileName (m_prefix + "qseq_dataOutputFileName" ),
343  m_option_qseq_dataOutputFileType (m_prefix + "qseq_dataOutputFileType" ),
344  m_option_qseq_dataOutputAllowedSet(m_prefix + "qseq_dataOutputAllowedSet" )
345 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
346  ,
347  m_option_qseq_computeStats (m_prefix + "qseq_computeStats" )
348 #endif
349 {
351  queso_require_not_equal_to_msg(m_env.optionsInputFileName(), "", "this constructor is incompatible with the absence of an options input file");
352 }
353 // Constructor 2 -----------------------------------
355  const BaseEnvironment& env,
356  const char* prefix,
357  const McOptionsValues& alternativeOptionsValues)
358  :
359  m_ov (alternativeOptionsValues),
360 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
361  m_pseqStatisticalOptionsObj (NULL),
362  m_qseqStatisticalOptionsObj (NULL),
363 #endif
364  m_prefix ((std::string)(prefix) + "mc_"),
365  m_env (env),
366  m_optionsDesc (NULL),
367  m_option_help (m_prefix + "help" ),
368  m_option_dataOutputFileName (m_prefix + "dataOutputFileName" ),
369  m_option_dataOutputAllowedSet (m_prefix + "dataOutputAllowedSet" ),
370  m_option_pseq_dataOutputPeriod (m_prefix + "pseq_dataOutputPeriod" ),
371  m_option_pseq_dataOutputFileName (m_prefix + "pseq_dataOutputFileName" ),
372  m_option_pseq_dataOutputFileType (m_prefix + "pseq_dataOutputFileType" ),
373  m_option_pseq_dataOutputAllowedSet(m_prefix + "pseq_dataOutputAllowedSet"),
374 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
375  m_option_pseq_computeStats (m_prefix + "pseq_computeStats" ),
376 #endif
377  m_option_qseq_dataInputFileName (m_prefix + "qseq_dataInputFileName" ),
378  m_option_qseq_dataInputFileType (m_prefix + "qseq_dataInputFileType" ),
379  m_option_qseq_size (m_prefix + "qseq_size" ),
380  m_option_qseq_displayPeriod (m_prefix + "qseq_displayPeriod" ),
381  m_option_qseq_measureRunTimes (m_prefix + "qseq_measureRunTimes" ),
382  m_option_qseq_dataOutputPeriod (m_prefix + "qseq_dataOutputPeriod" ),
383  m_option_qseq_dataOutputFileName (m_prefix + "qseq_dataOutputFileName" ),
384  m_option_qseq_dataOutputFileType (m_prefix + "qseq_dataOutputFileType" ),
385  m_option_qseq_dataOutputAllowedSet(m_prefix + "qseq_dataOutputAllowedSet")
386 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
387  ,
388  m_option_qseq_computeStats (m_prefix + "qseq_computeStats" )
389 #endif
390 {
392  queso_require_equal_to_msg(m_env.optionsInputFileName(), "", "this constructor is incompatible with the existence of an options input file");
393 
394  if (m_env.subDisplayFile() != NULL) {
395  *m_env.subDisplayFile() << "In MonteCarloSGOptions::constructor(2)"
396  << ": after setting values of options with prefix '" << m_prefix
397  << "', state of object is:"
398  << "\n" << *this
399  << std::endl;
400  }
401 
402  // dakota
403 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
404  if (m_ov.m_pseqComputeStats) m_pseqStatisticalOptionsObj =
405  new SequenceStatisticalOptions(m_env,m_prefix + "pseq_",m_ov.m_alternativePSsOptionsValues);
406  if (m_ov.m_qseqComputeStats) m_qseqStatisticalOptionsObj =
407  new SequenceStatisticalOptions(m_env,m_prefix + "qseq_",m_ov.m_alternativeQSsOptionsValues);
408 #endif
409 }
410 // Destructor --------------------------------------
412 {
414 
415 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
416  if (m_pseqStatisticalOptionsObj) delete m_pseqStatisticalOptionsObj; // dakota
417  if (m_qseqStatisticalOptionsObj) delete m_qseqStatisticalOptionsObj; // dakota
418 #endif
419  if (m_optionsDesc ) delete m_optionsDesc;
420 }
421 // I/O methods -------------------------------------
422 void
424 {
426  queso_require_msg(m_optionsDesc, "m_optionsDesc variable is NULL");
427 
431 
432  if (m_env.subDisplayFile() != NULL) {
433  *m_env.subDisplayFile() << "In MonteCarloSGOptions::scanOptionsValues()"
434  << ": after reading values of options with prefix '" << m_prefix
435  << "', state of object is:"
436  << "\n" << *this
437  << std::endl;
438  }
439 
440  // dakota
441 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
442  if (m_ov.m_pseqComputeStats) m_pseqStatisticalOptionsObj =
443  new SequenceStatisticalOptions(m_env,m_prefix + "pseq_");
444  if (m_ov.m_qseqComputeStats) m_qseqStatisticalOptionsObj =
445  new SequenceStatisticalOptions(m_env,m_prefix + "qseq_");
446 #endif
447  return;
448 }
449 // Private methods ---------------------------------
450 void
451 MonteCarloSGOptions::defineMyOptions(boost::program_options::options_description& optionsDesc) const
452 {
454 
455  optionsDesc.add_options()
456  (m_option_help.c_str(), "produce help message for Monte Carlo distribution calculator")
457  (m_option_dataOutputFileName.c_str(), boost::program_options::value<std::string >()->default_value(UQ_MOC_SG_DATA_OUTPUT_FILE_NAME_ODV ), "name of generic data output file" )
458  (m_option_dataOutputAllowedSet.c_str(), boost::program_options::value<std::string >()->default_value(UQ_MOC_SG_DATA_OUTPUT_ALLOWED_SET_ODV ), "subEnvs that will write to generic data output file" )
459  (m_option_pseq_dataOutputPeriod.c_str(), boost::program_options::value<unsigned int>()->default_value(UQ_MOC_SG_PSEQ_DATA_OUTPUT_PERIOD_ODV ), "period of message display during param sequence generation" )
460  (m_option_pseq_dataOutputFileName.c_str(), boost::program_options::value<std::string >()->default_value(UQ_MOC_SG_PSEQ_DATA_OUTPUT_FILE_NAME_ODV ), "name of data output file for parameters" )
461  (m_option_pseq_dataOutputFileType.c_str(), boost::program_options::value<std::string >()->default_value(UQ_MOC_SG_PSEQ_DATA_OUTPUT_FILE_TYPE_ODV ), "type of data output file for parameters" )
462  (m_option_pseq_dataOutputAllowedSet.c_str(), boost::program_options::value<std::string >()->default_value(UQ_MOC_SG_PSEQ_DATA_OUTPUT_ALLOWED_SET_ODV), "subEnvs that will write to data output file for parameters" )
463 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
464  (m_option_pseq_computeStats.c_str(), boost::program_options::value<bool >()->default_value(UQ_MOC_SG_PSEQ_COMPUTE_STATS_ODV ), "compute statistics on sequence of parameter" )
465 #endif
466  (m_option_qseq_dataInputFileName.c_str(), boost::program_options::value<std::string >()->default_value(UQ_MOC_SG_QSEQ_DATA_INPUT_FILE_NAME_ODV ), "name of data input file for qois" )
467  (m_option_qseq_dataInputFileType.c_str(), boost::program_options::value<std::string >()->default_value(UQ_MOC_SG_QSEQ_DATA_INPUT_FILE_TYPE_ODV ), "type of data input file for qois" )
468  (m_option_qseq_size.c_str(), boost::program_options::value<unsigned int>()->default_value(UQ_MOC_SG_QSEQ_SIZE_ODV ), "size of qoi sequence" )
469  (m_option_qseq_displayPeriod.c_str(), boost::program_options::value<unsigned int>()->default_value(UQ_MOC_SG_QSEQ_DISPLAY_PERIOD_ODV ), "period of message display during qoi sequence generation" )
470  (m_option_qseq_measureRunTimes.c_str(), boost::program_options::value<bool >()->default_value(UQ_MOC_SG_QSEQ_MEASURE_RUN_TIMES_ODV ), "measure run times" )
471  (m_option_qseq_dataOutputPeriod.c_str(), boost::program_options::value<unsigned int>()->default_value(UQ_MOC_SG_QSEQ_DATA_OUTPUT_PERIOD_ODV ), "period of message display during qoi sequence generation" )
472  (m_option_qseq_dataOutputFileName.c_str(), boost::program_options::value<std::string >()->default_value(UQ_MOC_SG_QSEQ_DATA_OUTPUT_FILE_NAME_ODV ), "name of data output file for qois" )
473  (m_option_qseq_dataOutputFileType.c_str(), boost::program_options::value<std::string >()->default_value(UQ_MOC_SG_QSEQ_DATA_OUTPUT_FILE_TYPE_ODV ), "type of data output file for qois" )
474  (m_option_qseq_dataOutputAllowedSet.c_str(), boost::program_options::value<std::string >()->default_value(UQ_MOC_SG_QSEQ_DATA_OUTPUT_ALLOWED_SET_ODV), "subEnvs that will write to data output file for qois" )
475 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
476  (m_option_qseq_computeStats.c_str(), boost::program_options::value<bool >()->default_value(UQ_MOC_SG_QSEQ_COMPUTE_STATS_ODV ), "compute statistics on sequence of qoi" )
477 #endif
478  ;
479 
480  return;
481 }
482 
483 void
484 MonteCarloSGOptions::getMyOptionValues(boost::program_options::options_description& optionsDesc)
485 {
487 
488  if (m_env.allOptionsMap().count(m_option_help)) {
489  if (m_env.subDisplayFile()) {
490  *m_env.subDisplayFile() << optionsDesc
491  << std::endl;
492  }
493  }
494 
496  m_ov.m_dataOutputFileName = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_dataOutputFileName]).as<std::string>();
497  }
498 
501  std::vector<double> tmpAllow(0,0.);
502  std::string inputString = m_env.allOptionsMap()[m_option_dataOutputAllowedSet].as<std::string>();
503  MiscReadDoublesFromString(inputString,tmpAllow);
504 
505  if (tmpAllow.size() > 0) {
506  for (unsigned int i = 0; i < tmpAllow.size(); ++i) {
507  m_ov.m_dataOutputAllowedSet.insert((unsigned int) tmpAllow[i]);
508  }
509  }
510  }
511 
513  m_ov.m_pseqDataOutputPeriod = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_pseq_dataOutputPeriod]).as<unsigned int>();
514  }
515 
517  m_ov.m_pseqDataOutputFileName = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_pseq_dataOutputFileName]).as<std::string>();
518  }
519 
521  m_ov.m_pseqDataOutputFileType = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_pseq_dataOutputFileType]).as<std::string>();
522  }
523 
526  std::vector<double> tmpAllow(0,0.);
527  std::string inputString = m_env.allOptionsMap()[m_option_pseq_dataOutputAllowedSet].as<std::string>();
528  MiscReadDoublesFromString(inputString,tmpAllow);
529 
530  if (tmpAllow.size() > 0) {
531  for (unsigned int i = 0; i < tmpAllow.size(); ++i) {
532  m_ov.m_pseqDataOutputAllowedSet.insert((unsigned int) tmpAllow[i]);
533  }
534  }
535  }
536 
537 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
538  if (m_env.allOptionsMap().count(m_option_pseq_computeStats)) {
539  m_ov.m_pseqComputeStats = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_pseq_computeStats]).as<bool>();
540  }
541 #endif
543  m_ov.m_qseqDataInputFileName = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_qseq_dataInputFileName]).as<std::string>();
544  }
545 
547  m_ov.m_qseqDataInputFileType = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_qseq_dataInputFileType]).as<std::string>();
548  }
549 
550  if (m_env.allOptionsMap().count(m_option_qseq_size)) {
551  m_ov.m_qseqSize = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_qseq_size]).as<unsigned int>();
552  }
553 
555  m_ov.m_qseqDisplayPeriod = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_qseq_displayPeriod]).as<unsigned int>();
556  }
557 
559  m_ov.m_qseqMeasureRunTimes = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_qseq_measureRunTimes]).as<bool>();
560  }
561 
563  m_ov.m_qseqDataOutputPeriod = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_qseq_dataOutputPeriod]).as<unsigned int>();
564  }
565 
567  m_ov.m_qseqDataOutputFileName = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_qseq_dataOutputFileName]).as<std::string>();
568  }
569 
571  m_ov.m_qseqDataOutputFileType = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_qseq_dataOutputFileType]).as<std::string>();
572  }
573 
576  std::vector<double> tmpAllow(0,0.);
577  std::string inputString = m_env.allOptionsMap()[m_option_qseq_dataOutputAllowedSet].as<std::string>();
578  MiscReadDoublesFromString(inputString,tmpAllow);
579 
580  if (tmpAllow.size() > 0) {
581  for (unsigned int i = 0; i < tmpAllow.size(); ++i) {
582  m_ov.m_qseqDataOutputAllowedSet.insert((unsigned int) tmpAllow[i]);
583  }
584  }
585  }
586 
587 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
588  if (m_env.allOptionsMap().count(m_option_qseq_computeStats)) {
589  m_ov.m_qseqComputeStats = ((const boost::program_options::variable_value&) m_env.allOptionsMap()[m_option_qseq_computeStats]).as<bool>();
590  }
591 #endif
592  return;
593 }
594 
595 void
596 MonteCarloSGOptions::print(std::ostream& os) const
597 {
599 
601  << "\n" << m_option_dataOutputAllowedSet << " = ";
602  for (std::set<unsigned int>::iterator setIt = m_ov.m_dataOutputAllowedSet.begin(); setIt != m_ov.m_dataOutputAllowedSet.end(); ++setIt) {
603  os << *setIt << " ";
604  }
608  << "\n" << m_option_pseq_dataOutputAllowedSet << " = ";
609  for (std::set<unsigned int>::iterator setIt = m_ov.m_pseqDataOutputAllowedSet.begin(); setIt != m_ov.m_pseqDataOutputAllowedSet.end(); ++setIt) {
610  os << *setIt << " ";
611  }
612  os
613 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
614  << "\n" << m_option_pseq_computeStats << " = " << m_ov.m_pseqComputeStats
615 #endif
618  << "\n" << m_option_qseq_size << " = " << m_ov.m_qseqSize
624  << "\n" << m_option_qseq_dataOutputAllowedSet << " = ";
625  for (std::set<unsigned int>::iterator setIt = m_ov.m_qseqDataOutputAllowedSet.begin(); setIt != m_ov.m_qseqDataOutputAllowedSet.end(); ++setIt) {
626  os << *setIt << " ";
627  }
628 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
629  os << "\n" << m_option_qseq_computeStats << " = " << m_ov.m_qseqComputeStats;
630 #endif
631 
632  return;
633 }
634 
635 std::ostream& operator<<(std::ostream& os, const MonteCarloSGOptions& obj)
636 {
638 
639  obj.print(os);
640 
641  return os;
642 }
643 
644 } // End namespace QUESO
std::string m_option_qseq_dataOutputFileType
std::string m_option_qseq_dataOutputAllowedSet
void scanOptionsValues()
It scans the option values from the options input file.
void scanInputFileForMyOptions(const boost::program_options::options_description &optionsDesc) const
This method scans the input file provided by the user to QUESO.
Definition: Environment.C:345
#define UQ_MOC_SG_QSEQ_COMPUTE_STATS_ODV
std::string m_option_pseq_dataOutputFileType
BoostInputOptionsParser * m_parser
#define UQ_MOC_SG_QSEQ_DATA_INPUT_FILE_TYPE_ODV
#define queso_require_not_equal_to_msg(expr1, expr2, msg)
Definition: asserts.h:86
#define UQ_MOC_SG_DATA_OUTPUT_FILE_NAME_ODV
std::string m_option_qseq_dataOutputFileName
std::string m_option_qseq_displayPeriod
#define UQ_MOC_SG_PSEQ_COMPUTE_STATS_ODV
std::ostream & operator<<(std::ostream &os, const BaseEnvironment &obj)
boost::program_options::variables_map & allOptionsMap() const
Definition: Environment.C:336
#define UQ_MOC_SG_PSEQ_DATA_OUTPUT_PERIOD_ODV
#define UQ_MOC_SG_PSEQ_DATA_OUTPUT_FILE_TYPE_ODV
std::set< unsigned int > m_pseqDataOutputAllowedSet
std::string m_option_dataOutputAllowedSet
#define UQ_MOC_SG_QSEQ_DATA_OUTPUT_ALLOWED_SET_ODV
std::string m_option_dataOutputFileName
This class provides options for the Monte Carlo sequence generator if no input file is available...
#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
void scanInputFile()
This is the method that parses the input file.
void print(std::ostream &os) const
It prints the option values.
#define queso_require_msg(asserted, msg)
Definition: asserts.h:69
#define UQ_MOC_SG_QSEQ_DATA_OUTPUT_PERIOD_ODV
#define UQ_MOC_SG_QSEQ_DISPLAY_PERIOD_ODV
std::string m_option_qseq_dataOutputPeriod
void copy(const McOptionsValues &src)
Copies the option values from src to this.
McOptionsValues()
Default constructor.
std::ofstream * subDisplayFile() const
Access function for m_subDisplayFile (displays file on stream).
Definition: Environment.C:274
#define UQ_MOC_SG_QSEQ_MEASURE_RUN_TIMES_ODV
std::string m_option_pseq_dataOutputFileName
#define UQ_MOC_SG_HELP
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:193
boost::program_options::options_description * m_optionsDesc
#define UQ_MOC_SG_QSEQ_SIZE_ODV
#define UQ_MOC_SG_PSEQ_DATA_OUTPUT_ALLOWED_SET_ODV
void registerOption(std::string name, T defaultValue, std::string description)
Call this to register an option with the parser.
McOptionsValues & operator=(const McOptionsValues &rhs)
Assignment operator; it copies rhs to this.
const BaseEnvironment & m_env
#define UQ_MOC_SG_QSEQ_DATA_OUTPUT_FILE_TYPE_ODV
#define UQ_MOC_SG_QSEQ_DATA_OUTPUT_FILE_NAME_ODV
#define UQ_MOC_SG_PSEQ_DATA_OUTPUT_FILE_NAME_ODV
void MiscReadDoublesFromString(const std::string &inputString, std::vector< double > &outputDoubles)
Definition: Miscellaneous.C:40
#define queso_deprecated()
Definition: Defines.h:120
std::string m_help
If non-empty string, print options and values to output file.
This class reads the options for the Monte Carlo sequence generator from an input file...
#define UQ_MOC_SG_QSEQ_DATA_INPUT_FILE_NAME_ODV
std::string m_option_qseq_dataInputFileType
std::string m_option_qseq_dataOutputAllowedSet
virtual ~McOptionsValues()
Destructor.
std::set< unsigned int > m_dataOutputAllowedSet
std::string m_option_pseq_dataOutputPeriod
std::string m_option_pseq_dataOutputAllowedSet
std::set< unsigned int > m_qseqDataOutputAllowedSet
#define UQ_MOC_SG_DATA_OUTPUT_ALLOWED_SET_ODV
std::string m_option_qseq_measureRunTimes
void defineMyOptions(boost::program_options::options_description &optionsDesc) const
Defines the options for the Monte Carlo sequence generator as the default options.
void getMyOptionValues(boost::program_options::options_description &optionsDesc)
Gets the sequence options.
MonteCarloSGOptions(const BaseEnvironment &env, const char *prefix)
Constructor: reads options from the input file.
void getOption(std::string &name, T &value)
Get option name from the parser and set value to the parsed value.
std::string m_option_qseq_dataInputFileName
std::string m_option_pseq_dataOutputAllowedSet

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