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.

44 lines
2.0 KiB

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