You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.9 KiB

8 years ago
8 years ago
8 years ago
8 years ago
  1. import stormpy
  2. import stormpy.logic
  3. import stormpy.pars
  4. from helpers.helper import get_example_path
  5. class TestModelInstantiator:
  6. def test_instantiate_dtmc(self):
  7. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  8. formulas = stormpy.parse_properties_for_prism_program("P=? [ F s=5 ]", program)
  9. model = stormpy.build_parametric_model(program, formulas)
  10. parameters = model.collect_probability_parameters()
  11. instantiator = stormpy.pars.PDtmcInstantiator(model)
  12. point = {p: stormpy.RationalRF("0.4") for p in parameters}
  13. instantiated_model = instantiator.instantiate(point)
  14. assert instantiated_model.nr_states == model.nr_states
  15. assert not instantiated_model.has_parameters
  16. assert "0.4" in str(instantiated_model.transition_matrix[1])
  17. point = {p: stormpy.RationalRF("0.5") for p in parameters}
  18. instantiated_model2 = instantiator.instantiate(point)
  19. assert "0.5" in str(instantiated_model2.transition_matrix[1])
  20. def test_sample_pdtmc(self):
  21. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  22. formulas = stormpy.parse_properties_for_prism_program("P=? [F \"error\"]", program)
  23. model = stormpy.build_parametric_model(program, formulas)
  24. parameters = model.collect_probability_parameters()
  25. instantiator = stormpy.pars.PDtmcInstantiator(model)
  26. point = {p: stormpy.RationalRF("0.4") for p in parameters}
  27. instantiated_model = instantiator.instantiate(point)
  28. assert instantiated_model.nr_states == model.nr_states
  29. assert not instantiated_model.has_parameters
  30. assert "0.4" in str(instantiated_model.transition_matrix[1])
  31. point = {p: stormpy.RationalRF("0.5") for p in parameters}
  32. instantiated_model2 = instantiator.instantiate(point)
  33. assert "0.5" in str(instantiated_model2.transition_matrix[1])