MUQ  0.4.3
GMHKernel.h
Go to the documentation of this file.
1 #ifndef GMHKERNEL_H_
2 #define GMHKERNEL_H_
3 
4 #include "MUQ/config.h"
5 
6 #if MUQ_HAS_PARCER
7 #include <parcer/Queue.h>
8 #endif
9 
12 
13 namespace muq {
14  namespace SamplingAlgorithms {
16 
19  class GMHKernel : public MHKernel {
20  public:
21 
26  GMHKernel(boost::property_tree::ptree const& pt, std::shared_ptr<AbstractSamplingProblem> problem);
27 
33  GMHKernel(boost::property_tree::ptree const& pt, std::shared_ptr<AbstractSamplingProblem> problem, std::shared_ptr<MCMCProposal> proposalIn);
34 
35  virtual ~GMHKernel();
36 
42  virtual void PreStep(unsigned int const t, std::shared_ptr<SamplingState> state) override;
43 
44 
51  virtual std::vector<std::shared_ptr<SamplingState> > Step(unsigned int const t, std::shared_ptr<SamplingState> state) override;
52 
54 
57  std::vector<std::shared_ptr<SamplingState> > SampleStationary() const;
58 
60 
64  Eigen::VectorXd StationaryAcceptance() const;
65 
66 #if MUQ_HAS_PARCER
67  std::shared_ptr<parcer::Communicator> GetCommunicator() const;
68 #endif
69 
70  private:
71 
73 
77  void SerialProposal(unsigned int const t, std::shared_ptr<SamplingState> state);
78 
79 #if MUQ_HAS_PARCER
81 
85  void ParallelProposal(unsigned int const t, std::shared_ptr<SamplingState> state);
86 #endif
87 
89 
92  void AcceptanceDensity(Eigen::VectorXd& R);
93 
94  Eigen::MatrixXd AcceptanceMatrix(Eigen::VectorXd const& R) const;
95 
97 
100  void ComputeStationaryAcceptance(Eigen::VectorXd const& R);
101 
103  const unsigned int N;
104 
106 
109  const unsigned int Np1;
110 
112  const unsigned int M;
113 
115  Eigen::VectorXd stationaryAcceptance;
116 
118  std::vector<std::shared_ptr<SamplingState> > proposedStates;
119  };
120  } // namespace SamplingAlgorithms
121 } // namespace muq
122 
123 #endif
A kernel for the generalized Metropolis-Hastings kernel.
Definition: GMHKernel.h:19
void SerialProposal(unsigned int const t, std::shared_ptr< SamplingState > state)
Propose points in serial and evaluate the log target.
Definition: GMHKernel.cpp:58
Eigen::MatrixXd AcceptanceMatrix(Eigen::VectorXd const &R) const
Definition: GMHKernel.cpp:154
const unsigned int N
Number of proposals.
Definition: GMHKernel.h:103
const unsigned int Np1
Number of proposals plus one.
Definition: GMHKernel.h:109
void ParallelProposal(unsigned int const t, std::shared_ptr< SamplingState > state)
Propose points in parallel and evaluate the log target.
Definition: GMHKernel.cpp:84
Eigen::VectorXd stationaryAcceptance
The cumulative stationary accepatnce probability.
Definition: GMHKernel.h:115
std::shared_ptr< parcer::Communicator > GetCommunicator() const
Definition: GMHKernel.cpp:228
std::vector< std::shared_ptr< SamplingState > > SampleStationary() const
Sample the stationary distribution.
Definition: GMHKernel.cpp:197
GMHKernel(boost::property_tree::ptree const &pt, std::shared_ptr< AbstractSamplingProblem > problem, std::shared_ptr< MCMCProposal > proposalIn)
Eigen::VectorXd StationaryAcceptance() const
Get the cumulative stationary acceptance probability.
Definition: GMHKernel.cpp:220
void ComputeStationaryAcceptance(Eigen::VectorXd const &R)
Compute the cumulative acceptance density.
Definition: GMHKernel.cpp:168
virtual std::vector< std::shared_ptr< SamplingState > > Step(unsigned int const t, std::shared_ptr< SamplingState > state) override
Definition: GMHKernel.cpp:210
std::vector< std::shared_ptr< SamplingState > > proposedStates
Proposed states.
Definition: GMHKernel.h:118
void AcceptanceDensity(Eigen::VectorXd &R)
Compute the stationary transition density.
Definition: GMHKernel.cpp:140
virtual void PreStep(unsigned int const t, std::shared_ptr< SamplingState > state) override
Definition: GMHKernel.cpp:183
const unsigned int M
Number of accepted points (number of points added to the chain)
Definition: GMHKernel.h:112
GMHKernel(boost::property_tree::ptree const &pt, std::shared_ptr< AbstractSamplingProblem > problem)
An implementation of the standard Metropolis-Hastings transition kernel.
Definition: MHKernel.h:22
std::shared_ptr< AbstractSamplingProblem > problem
The sampling problem that evaluates/samples the target distribution.