8 Eigen::VectorXd
const& startPt,
9 std::vector<std::shared_ptr<muq::Modeling::ModPiece>>
const& models,
10 std::shared_ptr<MultiIndexSet>
const& multis) :
MIMCMC(pt,startPt, CreateProblems(models),multis)
16 Eigen::VectorXd
const& startPt,
17 std::vector<std::shared_ptr<AbstractSamplingProblem>>
const& problems,
18 std::shared_ptr<MultiIndexSet>
const& multis) :
MIMCMC(pt, std::make_shared<
DefaultComponentFactory>(pt,startPt,ProcessMultis(multis,problems.size()),problems))
24 MIMCMC::MIMCMC (pt::ptree pt, std::shared_ptr<MIComponentFactory>
const& componentFactory)
26 componentFactory(componentFactory)
31 std::shared_ptr<MultiIndex> boxHighestIndex = (*gridIndices)[i];
37 std::shared_ptr<MIMCMCBox>
MIMCMC::GetBox(std::shared_ptr<MultiIndex> index) {
38 for (std::shared_ptr<MIMCMCBox> box :
boxes) {
39 if (*(box->GetHighestIndex()) == *index)
46 return std::make_shared<MultiIndexEstimator>(
boxes);
49 return std::make_shared<MultiIndexEstimator>(
boxes,
true);
53 for (
auto box :
boxes) {
56 for (
int samp = 0; samp < numSamples; samp++) {
65 for (
auto box :
boxes) {
66 if (*(box->GetHighestIndex()) == *index)
73 for (
auto box :
boxes) {
74 box->WriteToFile(filename);
85 std::stringstream strs;
86 for (
int i = 0; i < index->GetLength(); i++) {
87 strs <<
"_" << index->GetValue(i);
93 std::ofstream graphfile;
94 graphfile.open (
"graph");
95 graphfile <<
"digraph {" << std::endl;
96 graphfile <<
"nodesep=1.2;" << std::endl;
97 graphfile <<
"splines=false;" << std::endl;
98 for (
auto box :
boxes) {
99 box->Draw(graphfile, drawSamples);
101 graphfile <<
"}" << std::endl;
106 unsigned int numLevels)
111 return MultiIndexFactory::CreateFullTensor(1, numLevels-1);
115 std::vector<std::shared_ptr<AbstractSamplingProblem>>
MIMCMC::CreateProblems(std::vector<std::shared_ptr<muq::Modeling::ModPiece>>
const& models)
117 std::vector<std::shared_ptr<AbstractSamplingProblem>> output(models.size());
118 for(
unsigned int i=0; i<models.size(); ++i)
119 output.at(i) = std::make_shared<SamplingProblem>(models.at(i));
Provides a high level interface for the sampling problems on each MIMCMC level.
std::shared_ptr< MIMCMCBox > GetBox(std::shared_ptr< MultiIndex > index)
Access an MIMCMCBox.
MIMCMC(boost::property_tree::ptree options, std::shared_ptr< MIComponentFactory > const &componentFactory)
void Draw(bool drawSamples=true)
Draw MI structure (mostly debugging purposes)
std::string multiindexToConfigString(std::shared_ptr< MultiIndex > index)
std::shared_ptr< MultiIndexSet > GetIndices()
Get set of indices of boxes set up by the method.
virtual std::shared_ptr< MultiIndexEstimator > GetQOIs() const
std::shared_ptr< MIMCMCBox > GetMIMCMCBox(std::shared_ptr< MultiIndex > index)
std::shared_ptr< MultiIndexSet > gridIndices
static std::shared_ptr< MultiIndexSet > ProcessMultis(std::shared_ptr< MultiIndexSet > const &multis, unsigned int numLevels)
virtual std::shared_ptr< MultiIndexEstimator > Run()
static std::vector< std::shared_ptr< AbstractSamplingProblem > > CreateProblems(std::vector< std::shared_ptr< muq::Modeling::ModPiece >> const &models)
void WriteToFile(std::string filename)
Write HDF5 output for the entire MIMCMC method.
virtual std::shared_ptr< MultiIndexEstimator > GetSamples() const
std::vector< std::shared_ptr< MIMCMCBox > > boxes
std::shared_ptr< MIComponentFactory > componentFactory