From 72cb1020137ed813c980156bc1073328c5f4c8e9 Mon Sep 17 00:00:00 2001 From: Matthias Volk Date: Wed, 2 Aug 2017 18:04:22 +0200 Subject: [PATCH] Test for model instantiation --- tests/pars/test_model_instantiator.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/pars/test_model_instantiator.py b/tests/pars/test_model_instantiator.py index 494a3df..d520546 100644 --- a/tests/pars/test_model_instantiator.py +++ b/tests/pars/test_model_instantiator.py @@ -21,3 +21,21 @@ class TestModelInstantiator: point = {p: stormpy.RationalRF("0.5") for p in parameters} instantiated_model2 = instantiator.instantiate(point) assert "0.5" in str(instantiated_model2.transition_matrix[1]) + + def test_sample_pdtmc(self): + program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm")) + formulas = stormpy.parse_properties_for_prism_program("P=? [F \"error\"]", program) + model = stormpy.build_parametric_model(program, formulas) + + parameters = model.collect_probability_parameters() + instantiator = stormpy.pars.PDtmcInstantiator(model) + + point = {p: stormpy.RationalRF("0.4") for p in parameters} + instantiated_model = instantiator.instantiate(point) + assert instantiated_model.nr_states == model.nr_states + assert not instantiated_model.has_parameters + assert "0.4" in str(instantiated_model.transition_matrix[1]) + + point = {p: stormpy.RationalRF("0.5") for p in parameters} + instantiated_model2 = instantiator.instantiate(point) + assert "0.5" in str(instantiated_model2.transition_matrix[1])