1 #ifndef SINGLECHAINMCMC_H
2 #define SINGLECHAINMCMC_H
11 #include <boost/property_tree/ptree.hpp>
14 namespace SamplingAlgorithms{
35 std::shared_ptr<parcer::Communicator>
const&
comm,
36 std::vector<std::shared_ptr<TransitionKernel> >
const& kernelsIn);
39 std::shared_ptr<AbstractSamplingProblem>
const& problem,
40 std::shared_ptr<parcer::Communicator>
const&
comm);
44 std::shared_ptr<AbstractSamplingProblem>
const& problem);
47 std::vector<std::shared_ptr<TransitionKernel> >
const&
kernels);
59 virtual void SetState(std::shared_ptr<SamplingState>
const& x0);
60 virtual void SetState(std::vector<Eigen::VectorXd>
const& x0);
62 template<
typename... Args>
64 std::vector<Eigen::VectorXd> vec;
68 virtual std::vector<std::shared_ptr<TransitionKernel>>&
Kernels(){
return kernels;};
70 template<
typename... Args>
71 inline std::shared_ptr<MarkovChain>
Run(Args
const&... args) {
72 std::vector<Eigen::VectorXd> vec;
76 virtual std::shared_ptr<MarkovChain>
Run(std::vector<Eigen::VectorXd>
const& x0);
115 virtual std::shared_ptr<MarkovChain>
GetSamples()
const;
118 std::shared_ptr<MarkovChain>
GetQOIs()
const;
128 std::shared_ptr<SamplingState>
SaveSamples(std::vector<std::shared_ptr<SamplingState> >
const& newStates,
135 void PrintStatus(std::string prefix,
unsigned int currInd)
const;
139 std::shared_ptr<MarkovChain>
QOIs;
149 std::vector<std::shared_ptr<TransitionKernel>>
kernels;
154 std::shared_ptr<parcer::Communicator>
comm =
nullptr;
157 template<
typename... Args>
158 inline std::shared_ptr<MarkovChain>
RunRecurse(std::vector<Eigen::VectorXd>& vec, Eigen::VectorXd
const& ith, Args
const&... args) {
163 inline std::shared_ptr<MarkovChain>
RunRecurse(std::vector<Eigen::VectorXd>& vec, Eigen::VectorXd
const&
last) {
168 inline std::shared_ptr<MarkovChain>
RunRecurse(std::vector<Eigen::VectorXd>& vec) {
172 template<
typename... Args>
173 inline void SetStateRecurse(std::vector<Eigen::VectorXd>& vec, Eigen::VectorXd
const& it, Args
const&... args) {
188 void Setup(boost::property_tree::ptree pt,
189 std::vector<std::shared_ptr<TransitionKernel>>
const& kernelsIn);
191 void Setup(boost::property_tree::ptree pt, std::shared_ptr<AbstractSamplingProblem>
const& problem);
Defines an MCMC sampler with a single chain.
bool ShouldSave(unsigned int const sampNum) const
SingleChainMCMC(boost::property_tree::ptree pt, std::shared_ptr< AbstractSamplingProblem > const &problem)
void SetState(Args const &... args)
virtual std::shared_ptr< MarkovChain > GetSamples() const
void SetStateRecurse(std::vector< Eigen::VectorXd > &vec, Eigen::VectorXd const &last)
std::shared_ptr< SamplingState > SaveSamples(std::vector< std::shared_ptr< SamplingState > > const &newStates, std::shared_ptr< SamplingState > &lastSavedState, unsigned int &sampNum) const
void Setup(boost::property_tree::ptree pt, std::shared_ptr< AbstractSamplingProblem > const &problem)
SingleChainMCMC(boost::property_tree::ptree pt, std::shared_ptr< parcer::Communicator > const &comm, std::vector< std::shared_ptr< TransitionKernel > > const &kernelsIn)
std::shared_ptr< parcer::Communicator > comm
std::shared_ptr< SamplingState > prevState
std::shared_ptr< SaveSchedulerBase > schedulerQOI
std::shared_ptr< MarkovChain > samples
void PrintStatus(unsigned int currInd) const
std::shared_ptr< MarkovChain > RunRecurse(std::vector< Eigen::VectorXd > &vec, Eigen::VectorXd const &last)
void Setup(boost::property_tree::ptree pt, std::vector< std::shared_ptr< TransitionKernel >> const &kernelsIn)
std::vector< std::shared_ptr< TransitionKernel > > kernels
virtual double TotalTime()
virtual unsigned int NumSamps() const
std::shared_ptr< MarkovChain > Run(Args const &... args)
virtual void SetState(std::shared_ptr< SamplingState > const &x0)
Set the state of the MCMC chain.
std::shared_ptr< SaveSchedulerBase > scheduler
std::shared_ptr< parcer::Communicator > GetCommunicator() const
virtual std::vector< std::shared_ptr< TransitionKernel > > & Kernels()
SingleChainMCMC(boost::property_tree::ptree pt, std::shared_ptr< TransitionKernel > const &kernel)
std::shared_ptr< MarkovChain > QOIs
void PrintStatus(std::string prefix) const
virtual void AddNumSamps(unsigned int numNewSamps)
std::shared_ptr< MarkovChain > GetQOIs() const
virtual ~SingleChainMCMC()=default
SingleChainMCMC(boost::property_tree::ptree pt, std::shared_ptr< AbstractSamplingProblem > const &problem, std::shared_ptr< parcer::Communicator > const &comm)
std::shared_ptr< MarkovChain > RunRecurse(std::vector< Eigen::VectorXd > &vec, Eigen::VectorXd const &ith, Args const &... args)
std::shared_ptr< MarkovChain > RunRecurse(std::vector< Eigen::VectorXd > &vec)
std::shared_ptr< SamplingState > lastSavedState
void SetStateRecurse(std::vector< Eigen::VectorXd > &vec, Eigen::VectorXd const &it, Args const &... args)
Defines the transition kernel used by an MCMC algorithm.