MUQ  0.4.3
SubsamplingTestMultilevelGaussianSampling.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(){
27 
28  pt::ptree pt;
29 
30  pt.put("NumSamples", 1e3); // number of samples for single level
31  pt.put("NumInitialSamples", 1e4); // number of initial samples for greedy MLMCMC
32  pt.put("GreedyTargetVariance", 0.05); // estimator variance to be achieved by greedy algorithm
33  pt.put("verbosity", 1); // show some output
34 
35 
36  for (int subsampling : {0, 5, 10, 25, 100, 1000}) {
37  std::cout << "Running with subsampling " << subsampling << std::endl;
38  pt.put("MLMCMC.Subsampling", subsampling);
39 
40 
41  auto componentFactory = std::make_shared<MyMIComponentFactory>(pt);
42 
43  std::cout << std::endl << "*************** greedy multillevel chain" << std::endl << std::endl;
44 
45  GreedyMLMCMC greedymlmcmc (pt, componentFactory);
46  greedymlmcmc.Run();
47  std::cout << "mean QOI: " << greedymlmcmc.GetQOIs()->Mean().transpose() << std::endl;
48  greedymlmcmc.Draw(false);
49 
50  /*std::cout << std::endl << "*************** single chain reference" << std::endl << std::endl;
51 
52  SLMCMC slmcmc (pt, componentFactory);
53  slmcmc.Run();
54  std::cout << "mean QOI: " << slmcmc.MeanQOI().transpose() << std::endl;*/
55 
56  }
57 
58  return 0;
59 }
Greedy Multilevel MCMC method.
Definition: GreedyMLMCMC.h:24
virtual std::shared_ptr< MultiIndexEstimator > GetQOIs() const
virtual std::shared_ptr< MultiIndexEstimator > Run()
void Draw(bool drawSamples=true)