From ac9a233aaffb73b20b3c88dc4a21a426b4b154df Mon Sep 17 00:00:00 2001 From: sjunges Date: Wed, 18 Jan 2017 23:13:50 +0100 Subject: [PATCH] ModelInstantiator for MDP & DTMC --- lib/stormpy/storage/__init__.py | 12 ++++++++++++ tests/storage/test_model_instantiator.py | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/stormpy/storage/__init__.py b/lib/stormpy/storage/__init__.py index c68800f..2eda405 100644 --- a/lib/stormpy/storage/__init__.py +++ b/lib/stormpy/storage/__init__.py @@ -1,3 +1,15 @@ from . import storage from .storage import * from . import state,action + +class ModelInstantiator: + def __init__(self, model): + if model.model_type == ModelType.MDP: + self._instantiator = PmdpInstantiator(model) + elif model.model_type == ModelType.DTMC: + self._instantiator = PdtmcInstantiator(model) + else: + raise ValueError("Only DTMCs and MDPs supported") + + def instantiate(self, point): + return self._instantiator.instantiate(point) \ No newline at end of file diff --git a/tests/storage/test_model_instantiator.py b/tests/storage/test_model_instantiator.py index 5e7a489..fd2c4fc 100644 --- a/tests/storage/test_model_instantiator.py +++ b/tests/storage/test_model_instantiator.py @@ -9,7 +9,7 @@ class TestModel: formulas = stormpy.parse_properties_for_prism_program("P=? [ F s=5 ]", program) model = stormpy.build_parametric_model(program, formulas) parameters = model.collect_probability_parameters() - instantiator = stormpy.storage.PdtmcInstantiator(model) + instantiator = stormpy.ModelInstantiator(model) point = dict() for p in parameters: point[p] = 0.4