1 #include "AllClassWrappers.h"
11 #include <pybind11/pybind11.h>
12 #include <pybind11/stl.h>
13 #include <pybind11/eigen.h>
25 py::class_<AbstractSamplingProblem, std::shared_ptr<AbstractSamplingProblem>> absSamp(m,
"AbstractSamplingProblem");
27 .def(
"LogDensity", &AbstractSamplingProblem::LogDensity)
28 .def_readonly(
"numBlocks", &AbstractSamplingProblem::numBlocks)
29 .def_readonly(
"blockSizes", &AbstractSamplingProblem::blockSizes);
31 py::class_<SamplingProblem, AbstractSamplingProblem, std::shared_ptr<SamplingProblem>> sampProb(m,
"SamplingProblem");
33 .def(py::init<std::shared_ptr<muq::Modeling::ModPiece>>())
34 .def(py::init<std::shared_ptr<muq::Modeling::ModPiece>, std::shared_ptr<muq::Modeling::ModPiece>>())
35 .def(
"LogDensity", &SamplingProblem::LogDensity)
36 .def(
"GradLogDensity", &SamplingProblem::GradLogDensity)
37 .def(
"GetDistribution", &SamplingProblem::GetDistribution);
39 py::class_<InferenceProblem, AbstractSamplingProblem, std::shared_ptr<InferenceProblem>>(m,
"InferenceProblem")
40 .def(py::init<std::shared_ptr<muq::Modeling::ModPiece>,std::shared_ptr<muq::Modeling::ModPiece>,
double>(),py::arg(
"logLikely"),py::arg(
"logPrior"), py::arg(
"inverseTemp")=1.0)
41 .def(py::init<std::shared_ptr<muq::Modeling::ModPiece>,std::shared_ptr<muq::Modeling::ModPiece>, std::shared_ptr<muq::Modeling::ModPiece>,
double>(), py::arg(
"logLikely"),py::arg(
"logPrior"), py::arg(
"qoi"), py::arg(
"inverseTemp")=1.0)
42 .def(
"LogDensity", &InferenceProblem::LogDensity)
43 .def(
"GradLogDensity", &InferenceProblem::GradLogDensity)
45 .def(
"Likelihood", &InferenceProblem::Likelihood)
46 .def(
"Prior", &InferenceProblem::Prior)
47 .def(
"SetInverseTemp", &InferenceProblem::SetInverseTemp)
48 .def(
"GetInverseTemp", &InferenceProblem::GetInverseTemp)
49 .def(
"Clone", &InferenceProblem::Clone);
51 py::class_<ExpensiveSamplingProblem, SamplingProblem, std::shared_ptr<ExpensiveSamplingProblem>> expenProb(m,
"ExpensiveSamplingProblem");
55 .def(
"LogDensity", &ExpensiveSamplingProblem::LogDensity)
56 .def(
"CacheSize", &ExpensiveSamplingProblem::CacheSize);
59 expenProb.def(py::init( [] (std::shared_ptr<muq::Modeling::ModPiece> target, Eigen::VectorXd
const& centroid, py::dict d, std::shared_ptr<parcer::Communicator> comm) {
return new ExpensiveSamplingProblem(target, centroid,
ConvertDictToPtree(d), comm); }));
void ProblemWrapper(pybind11::module &m)
boost::property_tree::ptree ConvertDictToPtree(pybind11::dict dict)