queso-0.57.0
InfiniteDimensionalMCMCSampler.h
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/Defines.h>
26 
27 #ifdef QUESO_HAVE_HDF5
28 
29 #ifndef QUESO_INFINITE_SAMPLER_H
30 #define QUESO_INFINITE_SAMPLER_H
31 
32 // Queso includes
33 #include <queso/SharedPtr.h>
34 #include <queso/Environment.h>
35 #include <queso/InfiniteDimensionalMeasureBase.h>
36 #include <queso/InfiniteDimensionalLikelihoodBase.h>
37 #include <queso/InfiniteDimensionalMCMCSamplerOptions.h>
38 
39 // HDF5 includes
40 #include <hdf5.h>
41 
42 namespace QUESO {
43 
52 {
53 public:
56  const BaseEnvironment& env,
60 
63 
65  void step();
66 
68  double llhd_val() const;
69 
71  double acc_prob();
72 
74  double avg_acc_prob();
75 
77  unsigned int iteration() const;
78 
81 
82 private:
83  // Current iteration
84  unsigned int _iteration;
85 
86  // The current value of the negative log-likelihood functional
87  double _llhd_val;
88 
89  // The current acceptance probability
90  double _acc_prob;
91 
92  // The current running mean of the acceptance probability
93  double _avg_acc_prob;
94 
95  // The prior measure from which to draw
97 
98  // The negative log-likelihood functional. Operates on functions.
99  // Should be const?
101 
102  // Aggregate options object
104 
105  // The QUESO environment
107 
108  // Pointer to the current physical state
110 
111  // Pointer to the current proposed state
113 
114  // Pointer to the current physical mean
116 
117  // Pointer to the current physical variance
119 
120  // Stores the differences from the mean
122 
123  // Stores a running sum-of-squares (kinda)
125 
126  // HDF5 file identifier
127  hid_t _outfile;
128 
129  // HDF5 datasets
130  hid_t _acc_dset;
136 
140  void _propose();
141 
142  // Do a metropolis random walk step
143  void _metropolis_hastings();
144 
145  // Increments the current iteration and updates the running mean and variance.
146  void _update_moments();
147 
148  // Write the current state of the chain to disk
149  void _write_state();
150 
151  // Creates a scalar dataset called \c name in \c _outfile file and returns it
152  hid_t _create_scalar_dataset(const std::string & name);
153 
154  // Appends to a scalar dataset in the hdf5 file
155  void _append_scalar_dataset(hid_t dset, double data);
156 };
157 
158 } // End namespace QUESO
159 
160 #endif // QUESO_INFINITE_SAMPLER_H
161 
162 #endif // QUESO_HAVE_HDF5
Class representing the infinite dimensional Markov chain Monte Carlo sampler.
SharedPtr< FunctionBase >::Type current_physical_state
double avg_acc_prob()
Returns current average acceptance probability.
SharedPtr< FunctionBase >::Type current_physical_var
Abstract class representing the likelihood. Users must subclass this.
SharedPtr< FunctionBase >::Type proposed_physical_state
SharedPtr< FunctionBase >::Type current_physical_mean
Abstract base class for infinite dimensional measures.
InfiniteDimensionalMCMCSamplerOptions * m_ov
double llhd_val() const
Get the current value of the llhd.
unsigned int iteration() const
Returns the current iteration number.
This class defines the options that specify the behaviour of the MCMC sampler.
double acc_prob()
Returns current acceptance probability.
std::shared_ptr< T > Type
Definition: SharedPtr.h:69
InfiniteDimensionalMCMCSampler(const BaseEnvironment &env, InfiniteDimensionalMeasureBase &prior, InfiniteDimensionalLikelihoodBase &llhd, InfiniteDimensionalMCMCSamplerOptions *ov)
Construct an infinite dimensional MCMC chain with given prior, likelihood llhd, and options ov...
void step()
Do one iteration of the Markov chain.
SharedPtr< InfiniteDimensionalMCMCSampler >::Type clone_and_reset() const
Returns a pointer to new sampler, with all the moments reset.
This (virtual) class sets up the environment underlying the use of the QUESO library by an executable...
Definition: Environment.h:198
hid_t _create_scalar_dataset(const std::string &name)

Generated on Sat Apr 22 2017 14:04:35 for queso-0.57.0 by  doxygen 1.8.5