4 namespace pt = boost::property_tree;
10 std::shared_ptr<AbstractSamplingProblem> problem) :
ParallelAMProposal(pt, problem, std::make_shared<parcer::Communicator>()){}
12 ParallelAMProposal::ParallelAMProposal(pt::ptree pt ,
13 std::shared_ptr<AbstractSamplingProblem> problem,
14 std::shared_ptr<parcer::Communicator>
const& newcomm) :
AMProposal(pt, problem)
16 SetCommunicator(newcomm);
19 void ParallelAMProposal::Adapt(
unsigned int const t, std::vector<std::shared_ptr<SamplingState> >
const& states) {
22 for(
unsigned int i=0; i<
comm->GetSize(); ++i ) {
24 std::vector<std::shared_ptr<SamplingState> > otherStates;
25 if( i==
comm->GetRank() ) { otherStates = states; }
26 comm->Bcast(otherStates, i);
REGISTER_MCMC_PROPOSAL(ParallelAMProposal) ParallelAMProposal
An implemental of the Adaptive Metropolis algorithm.
virtual void Adapt(unsigned int const t, std::vector< std::shared_ptr< SamplingState >> const &states) override
Adapt the proposal after each step.
std::shared_ptr< parcer::Communicator > comm
unsigned int totSamps
The total number of samples used for the adaption.
ParallelAMProposal(boost::property_tree::ptree pt, std::shared_ptr< AbstractSamplingProblem > problem)