1 #ifndef TRANSITIONKERNEL_H_
2 #define TRANSITIONKERNEL_H_
7 #include <boost/function.hpp>
8 #include <boost/property_tree/ptree.hpp>
13 #include <parcer/Communicator.h>
24 namespace SamplingAlgorithms {
43 virtual void SetCommunicator(std::shared_ptr<parcer::Communicator> newcomm);
52 static std::shared_ptr<TransitionKernel>
Construct(boost::property_tree::ptree
const& pt, std::shared_ptr<AbstractSamplingProblem>
problem);
53 typedef boost::function<std::shared_ptr<TransitionKernel>(boost::property_tree::ptree, std::shared_ptr<AbstractSamplingProblem>)>
TransitionKernelConstructor;
63 virtual inline void PreStep(
unsigned int const t, std::shared_ptr<SamplingState> state) {};
71 virtual inline void PostStep(
unsigned int const t, std::vector<std::shared_ptr<SamplingState>>
const& state) {};
77 virtual std::vector<std::shared_ptr<SamplingState>>
Step(
unsigned int const t, std::shared_ptr<SamplingState> prevState) = 0;
88 virtual std::shared_ptr<AbstractSamplingProblem>
const&
Problem()
const{
return problem;};
95 std::shared_ptr<AbstractSamplingProblem>
problem;
98 std::shared_ptr<parcer::Communicator>
comm;
112 #define REGISTER_TRANSITION_KERNEL(NAME) static auto reg ##NAME \
113 = muq::SamplingAlgorithms::TransitionKernel::GetTransitionKernelMap()->insert(std::make_pair(#NAME, muq::Utilities::shared_factory<NAME>()));
Defines the transition kernel used by an MCMC algorithm.
std::map< std::string, TransitionKernelConstructor > TransitionKernelMap
virtual void PrintStatus(std::string prefix) const
virtual void PreStep(unsigned int const t, std::shared_ptr< SamplingState > state)
Allow the kernel to preprocess the current step.
std::shared_ptr< parcer::Communicator > comm
virtual int GetBlockInd() const
static std::shared_ptr< TransitionKernel > Construct(boost::property_tree::ptree const &pt, std::shared_ptr< AbstractSamplingProblem > problem)
Static constructor for the transition kernel.
virtual std::vector< std::shared_ptr< SamplingState > > Step(unsigned int const t, std::shared_ptr< SamplingState > prevState)=0
boost::function< std::shared_ptr< TransitionKernel >boost::property_tree::ptree, std::shared_ptr< AbstractSamplingProblem >)> TransitionKernelConstructor
std::shared_ptr< AbstractSamplingProblem > problem
The sampling problem that evaluates/samples the target distribution.
const bool reeval
true: reevaluate the log density (even if one already exists), false: use stored log density
virtual void SetCommunicator(std::shared_ptr< parcer::Communicator > newcomm)
static std::shared_ptr< TransitionKernelMap > GetTransitionKernelMap()
virtual void SetBlockInd(int newBlockInd)
virtual std::shared_ptr< AbstractSamplingProblem > const & Problem() const
virtual void PostStep(unsigned int const t, std::vector< std::shared_ptr< SamplingState >> const &state)
Allow the kernel to adapt given a new state.
TransitionKernel(boost::property_tree::ptree const &pt, std::shared_ptr< AbstractSamplingProblem > problem)
virtual ~TransitionKernel()=default
virtual void PrintStatus() const