MUQ  0.4.3
ModelParallelMultilevelGaussianSampling.cpp
Go to the documentation of this file.
4 
7 
13 
15 
16 #include <boost/property_tree/ptree.hpp>
17 
18 namespace pt = boost::property_tree;
19 using namespace muq::Modeling;
20 using namespace muq::SamplingAlgorithms;
21 using namespace muq::Utilities;
22 
23 #include "ParallelProblem.h"
24 
25 
26 int main(int argc, char **argv){
27 
28  MPI_Init(&argc, &argv);
29 
30  pt::ptree pt;
31 
32  pt.put("NumSamples", 1e3); // number of samples for single level
33  pt.put("NumInitialSamples", 1e3); // number of initial samples for greedy MLMCMC
34  pt.put("GreedyTargetVariance", 0.05); // estimator variance to be achieved by greedy algorithm
35  pt.put("verbosity", 1); // show some output
36  pt.put("MLMCMC.Subsampling_0", 8);
37  pt.put("MLMCMC.Subsampling_1", 4);
38  pt.put("MLMCMC.Subsampling_2", 2);
39  pt.put("MLMCMC.Subsampling_3", 0);
40 
41  auto localFactory = std::make_shared<MyMIComponentFactory>(pt);
42 
43  std::cout << std::endl << "*************** greedy multillevel chain" << std::endl << std::endl;
44 
45  auto comm = std::make_shared<parcer::Communicator>();
46  localFactory->SetComm(comm);
47  auto componentFactory = std::make_shared<ParallelMIComponentFactory>(comm, comm, localFactory);
48 
49  if (comm->GetRank() == 0) {
50  GreedyMLMCMC greedymlmcmc (pt, componentFactory);
51  greedymlmcmc.Run();
52  std::cout << "mean QOI: " << greedymlmcmc.GetQOIs()->Mean().transpose() << std::endl;
53  }
54 
55 
56  if (comm->GetRank() == 0) {
57  std::cout << std::endl << "*************** single chain reference" << std::endl << std::endl;
58 
59  SLMCMC slmcmc (pt, componentFactory);
60  slmcmc.Run();
61  componentFactory->finalize();
62  std::cout << "mean QOI: " << slmcmc.GetQOIs()->Mean().transpose() << std::endl;
63  }
64 
65 
66  MPI_Finalize();
67  return 0;
68 }
int main(int argc, char **argv)
Greedy Multilevel MCMC method.
Definition: GreedyMLMCMC.h:24
virtual std::shared_ptr< MultiIndexEstimator > GetQOIs() const
virtual std::shared_ptr< MultiIndexEstimator > Run()
Single-level MCMC for multiindex sampling problems.
Definition: SLMCMC.h:23
virtual std::shared_ptr< MarkovChain > GetQOIs() const
Definition: SLMCMC.cpp:35
virtual std::shared_ptr< MarkovChain > Run()
Definition: SLMCMC.cpp:39