Browse Source

ModelInstantiator for MDP & DTMC

refactoring
sjunges 8 years ago
parent
commit
ac9a233aaf
  1. 12
      lib/stormpy/storage/__init__.py
  2. 2
      tests/storage/test_model_instantiator.py

12
lib/stormpy/storage/__init__.py

@ -1,3 +1,15 @@
from . import storage from . import storage
from .storage import * from .storage import *
from . import state,action 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)

2
tests/storage/test_model_instantiator.py

@ -9,7 +9,7 @@ class TestModel:
formulas = stormpy.parse_properties_for_prism_program("P=? [ F s=5 ]", program) formulas = stormpy.parse_properties_for_prism_program("P=? [ F s=5 ]", program)
model = stormpy.build_parametric_model(program, formulas) model = stormpy.build_parametric_model(program, formulas)
parameters = model.collect_probability_parameters() parameters = model.collect_probability_parameters()
instantiator = stormpy.storage.PdtmcInstantiator(model)
instantiator = stormpy.ModelInstantiator(model)
point = dict() point = dict()
for p in parameters: for p in parameters:
point[p] = 0.4 point[p] = 0.4

Loading…
Cancel
Save