Browse Source

ModelInstantiator for CTMC and MA as well

refactoring
Matthias Volk 8 years ago
parent
commit
0b290d782f
  1. 6
      lib/stormpy/storage/__init__.py
  2. 8
      src/storage/model.cpp

6
lib/stormpy/storage/__init__.py

@ -8,8 +8,12 @@ class ModelInstantiator:
self._instantiator = PmdpInstantiator(model) self._instantiator = PmdpInstantiator(model)
elif model.model_type == ModelType.DTMC: elif model.model_type == ModelType.DTMC:
self._instantiator = PdtmcInstantiator(model) 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: else:
raise ValueError("Only DTMCs and MDPs supported")
raise ValueError("Model type {} not supported".format(model.model_type))
def instantiate(self, point): def instantiate(self, point):
return self._instantiator.instantiate(point) return self._instantiator.instantiate(point)

8
src/storage/model.cpp

@ -109,4 +109,12 @@ void define_model_instantiator(py::module& m) {
py::class_<storm::utility::ModelInstantiator<storm::models::sparse::Mdp<storm::RationalFunction>,storm::models::sparse::Mdp<double>>>(m, "PmdpInstantiator", "Instantiate PMDPs to MDPs") py::class_<storm::utility::ModelInstantiator<storm::models::sparse::Mdp<storm::RationalFunction>,storm::models::sparse::Mdp<double>>>(m, "PmdpInstantiator", "Instantiate PMDPs to MDPs")
.def(py::init<storm::models::sparse::Mdp<storm::RationalFunction>>(), "parametric model"_a) .def(py::init<storm::models::sparse::Mdp<storm::RationalFunction>>(), "parametric model"_a)
.def("instantiate", &storm::utility::ModelInstantiator<storm::models::sparse::Mdp<storm::RationalFunction>, storm::models::sparse::Mdp<double>>::instantiate, "Instantiate model with given parameter values"); .def("instantiate", &storm::utility::ModelInstantiator<storm::models::sparse::Mdp<storm::RationalFunction>, storm::models::sparse::Mdp<double>>::instantiate, "Instantiate model with given parameter values");
py::class_<storm::utility::ModelInstantiator<storm::models::sparse::Ctmc<storm::RationalFunction>,storm::models::sparse::Ctmc<double>>>(m, "PctmcInstantiator", "Instantiate PCTMCs to CTMCs")
.def(py::init<storm::models::sparse::Ctmc<storm::RationalFunction>>(), "parametric model"_a)
.def("instantiate", &storm::utility::ModelInstantiator<storm::models::sparse::Ctmc<storm::RationalFunction>, storm::models::sparse::Ctmc<double>>::instantiate, "Instantiate model with given parameter values");
py::class_<storm::utility::ModelInstantiator<storm::models::sparse::MarkovAutomaton<storm::RationalFunction>,storm::models::sparse::MarkovAutomaton<double>>>(m, "PmaInstantiator", "Instantiate PMAs to MAs")
.def(py::init<storm::models::sparse::MarkovAutomaton<storm::RationalFunction>>(), "parametric model"_a)
.def("instantiate", &storm::utility::ModelInstantiator<storm::models::sparse::MarkovAutomaton<storm::RationalFunction>, storm::models::sparse::MarkovAutomaton<double>>::instantiate, "Instantiate model with given parameter values");
} }
Loading…
Cancel
Save