From 0b290d782f283014fb51946e69486244bff7da76 Mon Sep 17 00:00:00 2001 From: Matthias Volk Date: Thu, 2 Mar 2017 23:26:24 +0100 Subject: [PATCH] ModelInstantiator for CTMC and MA as well --- lib/stormpy/storage/__init__.py | 8 ++++++-- src/storage/model.cpp | 16 ++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/stormpy/storage/__init__.py b/lib/stormpy/storage/__init__.py index 2eda405..0d3e560 100644 --- a/lib/stormpy/storage/__init__.py +++ b/lib/stormpy/storage/__init__.py @@ -8,8 +8,12 @@ class ModelInstantiator: self._instantiator = PmdpInstantiator(model) elif model.model_type == ModelType.DTMC: self._instantiator = PdtmcInstantiator(model) + elif model.model_type == ModelType.CTMC: + self._instantiator = PctmcInstantiator(model) + elif model.model_type == ModelType.MA: + self._instantiator = PmaInstantiator(model) else: - raise ValueError("Only DTMCs and MDPs supported") + raise ValueError("Model type {} not supported".format(model.model_type)) def instantiate(self, point): - return self._instantiator.instantiate(point) \ No newline at end of file + return self._instantiator.instantiate(point) diff --git a/src/storage/model.cpp b/src/storage/model.cpp index 290e077..f3bfd31 100644 --- a/src/storage/model.cpp +++ b/src/storage/model.cpp @@ -103,10 +103,18 @@ void define_model(py::module& m) { // Model instantiator void define_model_instantiator(py::module& m) { py::class_,storm::models::sparse::Dtmc>>(m, "PdtmcInstantiator", "Instantiate PDTMCs to DTMCs") - .def(py::init>(), "parametric model"_a) - .def("instantiate", &storm::utility::ModelInstantiator, storm::models::sparse::Dtmc>::instantiate, "Instantiate model with given parameter values"); + .def(py::init>(), "parametric model"_a) + .def("instantiate", &storm::utility::ModelInstantiator, storm::models::sparse::Dtmc>::instantiate, "Instantiate model with given parameter values"); py::class_,storm::models::sparse::Mdp>>(m, "PmdpInstantiator", "Instantiate PMDPs to MDPs") - .def(py::init>(), "parametric model"_a) - .def("instantiate", &storm::utility::ModelInstantiator, storm::models::sparse::Mdp>::instantiate, "Instantiate model with given parameter values"); + .def(py::init>(), "parametric model"_a) + .def("instantiate", &storm::utility::ModelInstantiator, storm::models::sparse::Mdp>::instantiate, "Instantiate model with given parameter values"); + + py::class_,storm::models::sparse::Ctmc>>(m, "PctmcInstantiator", "Instantiate PCTMCs to CTMCs") + .def(py::init>(), "parametric model"_a) + .def("instantiate", &storm::utility::ModelInstantiator, storm::models::sparse::Ctmc>::instantiate, "Instantiate model with given parameter values"); + + py::class_,storm::models::sparse::MarkovAutomaton>>(m, "PmaInstantiator", "Instantiate PMAs to MAs") + .def(py::init>(), "parametric model"_a) + .def("instantiate", &storm::utility::ModelInstantiator, storm::models::sparse::MarkovAutomaton>::instantiate, "Instantiate model with given parameter values"); }