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 #ifndef UQ_SEQUENCE_STATISTICAL_OPTIONS_H
26 #define UQ_SEQUENCE_STATISTICAL_OPTIONS_H
27 
28 #include <queso/Defines.h>
29 
30 #ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
31 
32 #include <queso/Environment.h>
33 #include <queso/BoostInputOptionsParser.h>
34 
35 #define UQ_SEQUENCE_INITIAL_DISCARDED_PORTIONS_ODV   "0."
36 #ifdef QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
37 #define UQ_SEQUENCE_MEAN_MONITOR_PERIOD_ODV          0
38 #define UQ_SEQUENCE_BMM_RUN_ODV                      0
39 #define UQ_SEQUENCE_BMM_LENGTHS_ODV                  "0"
40 #define UQ_SEQUENCE_BMM_DISPLAY_ODV                  0
41 #define UQ_SEQUENCE_BMM_WRITE_ODV                    0
42 #define UQ_SEQUENCE_FFT_COMPUTE_ODV                  0
43 #define UQ_SEQUENCE_FFT_PARAM_ID_ODV                 0
44 #define UQ_SEQUENCE_FFT_SIZE_ODV                     2048
45 #define UQ_SEQUENCE_FFT_TEST_INVERSION_ODV           0
46 #define UQ_SEQUENCE_FFT_WRITE_ODV                    0
47 #define UQ_SEQUENCE_PSD_COMPUTE_ODV                  0
48 #define UQ_SEQUENCE_PSD_NUM_BLOCKS_ODV               8
49 #define UQ_SEQUENCE_PSD_HOP_SIZE_RATIO_ODV           0.
50 #define UQ_SEQUENCE_PSD_PARAM_ID_ODV                 0
51 #define UQ_SEQUENCE_PSD_WRITE_ODV                    0
52 #define UQ_SEQUENCE_PSD_AT_ZERO_COMPUTE_ODV          0
53 #define UQ_SEQUENCE_PSD_AT_ZERO_NUM_BLOCKS_ODV       "8"
54 #define UQ_SEQUENCE_PSD_AT_ZERO_HOP_SIZE_RATIO_ODV   .5
55 #define UQ_SEQUENCE_PSD_AT_ZERO_DISPLAY_ODV          0
56 #define UQ_SEQUENCE_PSD_AT_ZERO_WRITE_ODV            0
57 #define UQ_SEQUENCE_GEWEKE_COMPUTE_ODV               0
58 #define UQ_SEQUENCE_GEWEKE_NA_RATIO_ODV              .1
59 #define UQ_SEQUENCE_GEWEKE_NB_RATIO_ODV              .5
60 #define UQ_SEQUENCE_GEWEKE_DISPLAY_ODV               0
61 #define UQ_SEQUENCE_GEWEKE_WRITE_ODV                 0
62 #define UQ_SEQUENCE_MEAN_STACC_COMPUTE_ODV           0
63 #define UQ_SEQUENCE_HIST_COMPUTE_ODV                 0
64 #define UQ_SEQUENCE_HIST_NUM_INTERNAL_BINS_ODV       100
65 #define UQ_SEQUENCE_CDF_STACC_COMPUTE_ODV            0
66 #define UQ_SEQUENCE_CDF_STACC_NUM_EVAL_POSITIONS_ODV 50
67 #endif
68 #define UQ_SEQUENCE_AUTO_CORR_COMPUTE_VIA_DEF_ODV    0
69 #define UQ_SEQUENCE_AUTO_CORR_COMPUTE_VIA_FFT_ODV    0
70 #define UQ_SEQUENCE_AUTO_CORR_SECOND_LAG_ODV         0
71 #define UQ_SEQUENCE_AUTO_CORR_LAG_SPACING_ODV        0
72 #define UQ_SEQUENCE_AUTO_CORR_NUM_LAGS_ODV           0
73 #define UQ_SEQUENCE_AUTO_CORR_DISPLAY_ODV            0
74 #define UQ_SEQUENCE_AUTO_CORR_WRITE_ODV              0
75 #define UQ_SEQUENCE_KDE_COMPUTE_ODV                  0
76 #define UQ_SEQUENCE_KDE_NUM_EVAL_POSITIONS_ODV       100
77 #define UQ_SEQUENCE_COV_MATRIX_COMPUTE_ODV           0
78 #define UQ_SEQUENCE_CORR_MATRIX_COMPUTE_ODV          0
79 
80 namespace boost {
81   namespace program_options {
82     class options_description;
83   }
84 }
85 
86 /*!\file SequenceStatisticalOptions.h
87  * \brief A templated class that stores default statistical options
88  *
89  * \class SsOptionsValues
90  * \brief A templated class that stores default statistical options for a sequence of vectors, e.g.
91  *    a Markov chain, a Monte Carlo input sequence, or a Monte Carlo output sequence.
92  */
93 
94 class SsOptionsValues
95 {
96 public:
97   //! @name Constructor/Destructor methods
98   //@{
99   //! Default constructor.
100   /*! It assigns to the variables the pre-defined options for a sequence of data (scalars; vectors).*/
101   SsOptionsValues            ();
102 
103   //! Prefix constructor.
104   /*! Uses the prefix to read options from an input file. */
105   SsOptionsValues(const BaseEnvironment * env, const char * prefix);
106 
107   //! Copy  constructor.
108   /*! It assigns to \c this' variables, the same values of the variable of \c src.*/
109   SsOptionsValues            (const SsOptionsValues& src);
110 
111   //! Destructor.
112   virtual ~SsOptionsValues            ();
113   //@}
114 
115   //! @name Set methods
116   //@{
117   //! Assignment operator; it copies \c rhs to \c this.
118   SsOptionsValues& operator= (const SsOptionsValues& rhs);
119   //@}
120 
121   //! @name Public attributes
122   //@{
123 
124   std::string               m_prefix;
125 
126   //! Stores the initial  discarded portion of the chain.
127   std::vector<double>       m_initialDiscardedPortions;
128 
129   //! Whether or not compute autocorrelation via definition.
130   bool                      m_autoCorrComputeViaDef;
131 
132    //! Whether or not compute autocorrelation via FFT.
133   bool                      m_autoCorrComputeViaFft;
134 
135   //! Second lag of the autocorrelation.
136   unsigned int              m_autoCorrSecondLag;
137 
138   //! Lag spacing of the autocorrelation.
139   unsigned int              m_autoCorrLagSpacing;
140 
141   //! Number of lags of the autocorrelation.
142   unsigned int              m_autoCorrNumLags;
143 
144   //! Whether or not display autocorrelation.
145   bool                      m_autoCorrDisplay;
146 
147   //! Whether or not write autocorrelation to file.
148   bool                      m_autoCorrWrite;
149 
150   //! Whether or not compute kernel density estimate (kde).
151   bool                      m_kdeCompute;
152 
153   //! Number of positions to evaluate kde.
154   unsigned int              m_kdeNumEvalPositions;
155 
156   //! Whether or not compute covariance matrix.
157   bool                      m_covMatrixCompute;
158 
159   //! Whether or not compute correlation matrix.
160   bool                      m_corrMatrixCompute;
161 
162 #ifdef QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
163   unsigned int              m_meanMonitorPeriod;
164 
165   bool                      m_bmmRun;
166   std::vector<unsigned int> m_bmmLengths;
167   bool                      m_bmmDisplay;
168   bool                      m_bmmWrite;
169 
170   bool                      m_fftCompute;
171   unsigned int              m_fftParamId;
172   unsigned int              m_fftSize;
173   bool                      m_fftTestInversion;
174   bool                      m_fftWrite;
175 
176   bool                      m_psdCompute;
177   unsigned int              m_psdNumBlocks;
178   double                    m_psdHopSizeRatio;
179   unsigned int              m_psdParamId;
180   bool                      m_psdWrite;
181 
182   bool                      m_psdAtZeroCompute;
183   std::vector<unsigned int> m_psdAtZeroNumBlocks;
184   double                    m_psdAtZeroHopSizeRatio;
185   bool                      m_psdAtZeroDisplay;
186   bool                      m_psdAtZeroWrite;
187 
188   bool                      m_gewekeCompute;
189   double                    m_gewekeNaRatio;
190   double                    m_gewekeNbRatio;
191   bool                      m_gewekeDisplay;
192   bool                      m_gewekeWrite;
193 
194   bool                      m_meanStaccCompute;
195 
196   bool                      m_histCompute;
197   unsigned int              m_histNumInternalBins;
198 
199   bool                      m_cdfStaccCompute;
200   unsigned int              m_cdfStaccNumEvalPositions;
201 #endif
202   //@}
203   // end public attributes
204 private:
205   BoostInputOptionsParser * m_parser;
206 
207   std::string                   m_option_help;
208   std::string                   m_option_initialDiscardedPortions;
209 
210   std::string                   m_option_autoCorr_computeViaDef;
211   std::string                   m_option_autoCorr_computeViaFft;
212   std::string                   m_option_autoCorr_secondLag;
213   std::string                   m_option_autoCorr_lagSpacing;
214   std::string                   m_option_autoCorr_numLags;
215   std::string                   m_option_autoCorr_display;
216   std::string                   m_option_autoCorr_write;
217   std::string                   m_option_kde_compute;
218   std::string                   m_option_kde_numEvalPositions;
219   std::string                   m_option_covMatrix_compute;
220   std::string                   m_option_corrMatrix_compute;
221 
222 #ifdef QUESO_COMPUTES_EXTRA_POST_PROCESSING_STATISTICS
223   std::string                   m_option_mean_monitorPeriod;
224   std::string                   m_option_bmm_run;
225   std::string                   m_option_bmm_lengths;
226   std::string                   m_option_bmm_display;
227   std::string                   m_option_bmm_write;
228   std::string                   m_option_fft_compute;
229   std::string                   m_option_fft_paramId;
230   std::string                   m_option_fft_size;
231   std::string                   m_option_fft_testInversion;
232   std::string                   m_option_fft_write;
233   std::string                   m_option_psd_compute;
234   std::string                   m_option_psd_numBlocks;
235   std::string                   m_option_psd_hopSizeRatio;
236   std::string                   m_option_psd_paramId;
237   std::string                   m_option_psd_write;
238   std::string                   m_option_psdAtZero_compute;
239   std::string                   m_option_psdAtZero_numBlocks;
240   std::string                   m_option_psdAtZero_hopSizeRatio;
241   std::string                   m_option_psdAtZero_display;
242   std::string                   m_option_psdAtZero_write;
243   std::string                   m_option_geweke_compute;
244   std::string                   m_option_geweke_naRatio;
245   std::string                   m_option_geweke_nbRatio;
246   std::string                   m_option_geweke_display;
247   std::string                   m_option_geweke_write;
248   std::string                   m_option_meanStacc_compute;
249   std::string                   m_option_hist_compute;
250   std::string                   m_option_hist_numInternalBins;
251   std::string                   m_option_cdfStacc_compute;
252   std::string                   m_option_cdfStacc_numEvalPositions;
253 #endif
254 
255   //! Copies the option values from \c src to \c this.
256   void copy(const SsOptionsValues& src);
257 };
258 
259 
260 #endif // ifdef QUESO_USES_SEQUENCE_STATISTICAL_OPTIONS
261 
262 #endif // UQ_SEQUENCE_STATISTICAL_OPTIONS_H
263 
264