17 #include <boost/property_tree/ptree.hpp>
19 namespace pt = boost::property_tree;
30 pt.put(
"NumSamples", 1e6);
31 pt.put(
"verbosity", 1);
32 pt.put(
"NumSamples_0", 1e5);
33 pt.put(
"NumSamples_1", 1e4);
34 pt.put(
"NumSamples_2", 1e3);
35 pt.put(
"NumSamples_3", 1e2);
37 auto componentFactory = std::make_shared<MyMIComponentFactory>(pt);
40 std::cout << std::endl <<
"*************** multilevel" << std::endl << std::endl;
42 MIMCMC mimcmc(pt, componentFactory);
45 std::cout <<
"mean QOI: " << mimcmc.
GetQOIs()->Mean().transpose() << std::endl;
49 auto index_zero = std::make_shared<MultiIndex>(1);
50 index_zero->SetValue(0, 0);
51 std::cout <<
"coarsest: " << mimcmc.
GetBox(index_zero)->FinestChain()->GetQOIs()->Mean().transpose() << std::endl;
54 std::cout << std::endl <<
"*************** single level" << std::endl << std::endl;
57 auto index = componentFactory->FinestIndex();
59 auto problem = componentFactory->SamplingProblem(index);
60 auto proposal = componentFactory->Proposal(index, problem);
62 std::vector<std::shared_ptr<TransitionKernel>> kernels(1);
63 kernels[0] = std::make_shared<DummyKernel>(pt,problem,proposal);
65 Eigen::VectorXd startingPoint = componentFactory->StartingPoint(index);
67 auto mcmc = std::make_shared<SingleChainMCMC>(pt,kernels);
68 mcmc->Run(startingPoint);
69 std::cout <<
"mean QOI: " << mcmc->GetQOIs()->Mean().transpose() << std::endl;
std::shared_ptr< MIMCMCBox > GetBox(std::shared_ptr< MultiIndex > index)
Access an MIMCMCBox.
virtual std::shared_ptr< MultiIndexEstimator > GetQOIs() const
virtual std::shared_ptr< MultiIndexEstimator > Run()