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.

42 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. assert len(parameters) == 2
  12. instantiator = stormpy.pars.PDtmcInstantiator(model)
  13. point = {p: stormpy.RationalRF("0.4") for p in parameters}
  14. instantiated_model = instantiator.instantiate(point)
  15. assert instantiated_model.nr_states == model.nr_states
  16. assert not instantiated_model.has_parameters
  17. assert "0.4" in str(instantiated_model.transition_matrix[1])
  18. point = {p: stormpy.RationalRF("0.5") for p in parameters}
  19. instantiated_model2 = instantiator.instantiate(point)
  20. assert "0.5" in str(instantiated_model2.transition_matrix[1])
  21. def test_sample_pdtmc(self):
  22. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  23. formulas = stormpy.parse_properties_for_prism_program("P=? [F \"error\"]", program)
  24. model = stormpy.build_parametric_model(program, formulas)
  25. parameters = model.collect_probability_parameters()
  26. instantiator = stormpy.pars.PDtmcInstantiator(model)
  27. point = {p: stormpy.RationalRF("0.4") for p in parameters}
  28. instantiated_model = instantiator.instantiate(point)
  29. assert instantiated_model.nr_states == model.nr_states
  30. assert not instantiated_model.has_parameters
  31. assert "0.4" in str(instantiated_model.transition_matrix[1])
  32. point = {p: stormpy.RationalRF("0.5") for p in parameters}
  33. instantiated_model2 = instantiator.instantiate(point)
  34. assert "0.5" in str(instantiated_model2.transition_matrix[1])