From b844d02cd987efea693a6fe26887a512152cde13 Mon Sep 17 00:00:00 2001 From: Sebastian Junges Date: Tue, 21 Apr 2020 21:23:51 -0700 Subject: [PATCH] make canonic for pomdps --- lib/stormpy/pomdp/__init__.py | 2 ++ src/mod_pomdp.cpp | 12 ++++++++++++ src/pomdp/common.h | 1 + src/pomdp/transformations.cpp | 15 +++++++++++++++ src/pomdp/transformations.h | 6 ++++++ 5 files changed, 36 insertions(+) create mode 100644 src/pomdp/common.h create mode 100644 src/pomdp/transformations.cpp create mode 100644 src/pomdp/transformations.h diff --git a/lib/stormpy/pomdp/__init__.py b/lib/stormpy/pomdp/__init__.py index a3d0e4a..c27a6d0 100644 --- a/lib/stormpy/pomdp/__init__.py +++ b/lib/stormpy/pomdp/__init__.py @@ -1,3 +1,5 @@ from . import pomdp from .pomdp import * +def make_canonic(model): + return pomdp._make_canonic_Double(model) \ No newline at end of file diff --git a/src/mod_pomdp.cpp b/src/mod_pomdp.cpp index 8b13789..fb48fa7 100644 --- a/src/mod_pomdp.cpp +++ b/src/mod_pomdp.cpp @@ -1 +1,13 @@ +#include "common.h" +#include "pomdp/transformations.h" + +PYBIND11_MODULE(pomdp, m) { + m.doc() = "Functionality for POMDP analysis"; + +#ifdef STORMPY_DISABLE_SIGNATURE_DOC + py::options options; + options.disable_function_signatures(); +#endif + define_transformations(m, "Double"); +} diff --git a/src/pomdp/common.h b/src/pomdp/common.h new file mode 100644 index 0000000..c9b9b0c --- /dev/null +++ b/src/pomdp/common.h @@ -0,0 +1 @@ +#include "src/common.h" diff --git a/src/pomdp/transformations.cpp b/src/pomdp/transformations.cpp new file mode 100644 index 0000000..db0e77a --- /dev/null +++ b/src/pomdp/transformations.cpp @@ -0,0 +1,15 @@ +#include "transformations.h" +#include + +template +std::shared_ptr> make_canonic(storm::models::sparse::Pomdp const& pomdp) { + storm::transformer::MakePOMDPCanonic makeCanonic(pomdp); + return makeCanonic.transform(); +} + +template +void define_transformations(py::module& m, std::string const& vtSuffix) { + m.def(("_make_canonic_" + vtSuffix).c_str(), &make_canonic, "Return a canonicly-ordered POMDP", py::arg("pomdp")); +} + +template void define_transformations(py::module& m, std::string const& vtSuffix); diff --git a/src/pomdp/transformations.h b/src/pomdp/transformations.h new file mode 100644 index 0000000..b261e6d --- /dev/null +++ b/src/pomdp/transformations.h @@ -0,0 +1,6 @@ +#pragma once + +#include "common.h" + +template +void define_transformations(py::module& m, std::string const& vtSuffix);