MUQ  0.4.3
MIMCMCBox.h
Go to the documentation of this file.
1 #ifndef MIMCMCBOX_H
2 #define MIMCMCBOX_H
3 
10 
11 #include <boost/property_tree/ptree.hpp>
12 
13 #include <iostream>
14 #include <fstream>
15 
16 namespace pt = boost::property_tree;
17 using namespace muq::Utilities;
18 
19 namespace muq {
20  namespace SamplingAlgorithms {
21 
29  class MIMCMCBox {
30  public:
31 
32  MIMCMCBox(std::shared_ptr<MIComponentFactory> componentFactory,
33  std::shared_ptr<MultiIndex> boxHighestIndex);
34 
35  void Sample();
36 
37  Eigen::VectorXd MeanParam();
38 
39  Eigen::VectorXd MeanQOI();
40 
41  void DrawChain(std::shared_ptr<SingleChainMCMC> chain, std::string chainid, std::ofstream& graphfile) const;
42 
43  void Draw(std::ofstream& graphfile, bool drawSamples = true) const;
44 
45  std::shared_ptr<SingleChainMCMC> FinestChain();
46 
47  std::shared_ptr<SingleChainMCMC> GetChain(std::shared_ptr<MultiIndex> index);
48 
49  std::shared_ptr<MultiIndexSet> GetBoxIndices();
50 
51  std::shared_ptr<AbstractSamplingProblem> GetFinestProblem();
52 
53  std::shared_ptr<MultiIndex> GetHighestIndex();
54  std::shared_ptr<MultiIndex> GetLowestIndex();
55 
56  std::shared_ptr<SampleCollection> GetQOIDiff();
57 
58  void WriteToFile(std::string filename);
59 
60  private:
61 
62  // Creates a path of multiindices back to zero, preferring a route along the diagonal
63  std::shared_ptr<MultiIndexSet> CreateRootPath(std::shared_ptr<MultiIndex> index);
64 
65  std::shared_ptr<SampleCollection> QOIDiff;
66 
67  std::shared_ptr<MIComponentFactory> componentFactory;
68  std::shared_ptr<MultiIndex> boxHighestIndex;
69  std::shared_ptr<MultiIndex> boxLowestIndex;
70  std::shared_ptr<MultiIndexSet> boxIndices;
71  std::vector<std::shared_ptr<SingleChainMCMC>> boxChains;
72  std::vector<std::shared_ptr<SingleChainMCMC>> tailChains;
73  std::shared_ptr<AbstractSamplingProblem> finestProblem;
74  };
75 
76  }
77 }
78 
79 #endif
Representation of a Multiindex MCMC telescoping sum component.
Definition: MIMCMCBox.h:29
std::shared_ptr< SampleCollection > QOIDiff
Definition: MIMCMCBox.h:65
std::shared_ptr< AbstractSamplingProblem > finestProblem
Definition: MIMCMCBox.h:73
std::shared_ptr< MultiIndexSet > boxIndices
Definition: MIMCMCBox.h:70
std::shared_ptr< MultiIndex > boxHighestIndex
Definition: MIMCMCBox.h:68
std::shared_ptr< MIComponentFactory > componentFactory
Definition: MIMCMCBox.h:67
std::vector< std::shared_ptr< SingleChainMCMC > > tailChains
Definition: MIMCMCBox.h:72
std::vector< std::shared_ptr< SingleChainMCMC > > boxChains
Definition: MIMCMCBox.h:71
std::shared_ptr< MultiIndex > boxLowestIndex
Definition: MIMCMCBox.h:69