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.

43 lines
2.1 KiB

8 years ago
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 TestModelChecking:
  6. def test_pla(self):
  7. import pycarl
  8. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  9. prop = "P<=0.84 [F s=5 ]"
  10. formulas = stormpy.parse_properties_for_prism_program(prop, program)
  11. model = stormpy.build_parametric_model(program, formulas)
  12. assert model.nr_states == 613
  13. assert model.nr_transitions == 803
  14. assert model.model_type == stormpy.ModelType.DTMC
  15. assert model.has_parameters
  16. checker = stormpy.pars.create_region_checker(model, formulas[0].raw_formula)
  17. parameters = model.collect_probability_parameters()
  18. assert len(parameters) == 2
  19. region = stormpy.pars.ParameterRegion("0.7<=pL<=0.9,0.75<=pK<=0.95", parameters)
  20. result = checker.check_region(region)
  21. assert result == stormpy.pars.RegionResult.ALLSAT
  22. region = stormpy.pars.ParameterRegion("0.4<=pL<=0.65,0.75<=pK<=0.95", parameters)
  23. result = checker.check_region(region, stormpy.pars.RegionResultHypothesis.UNKNOWN, stormpy.pars.RegionResult.UNKNOWN, True)
  24. assert result == stormpy.pars.RegionResult.EXISTSBOTH
  25. region = stormpy.pars.ParameterRegion("0.1<=pL<=0.73,0.2<=pK<=0.715", parameters)
  26. result = checker.check_region(region)
  27. assert result == stormpy.pars.RegionResult.ALLVIOLATED
  28. def test_derivatives(self):
  29. import pycarl
  30. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  31. prop = "P<=0.84 [F s=5 ]"
  32. formulas = stormpy.parse_properties_for_prism_program(prop, program)
  33. model = stormpy.build_parametric_model(program, formulas)
  34. assert model.nr_states == 613
  35. assert model.nr_transitions == 803
  36. assert model.model_type == stormpy.ModelType.DTMC
  37. assert model.has_parameters
  38. parameters = model.collect_probability_parameters()
  39. assert len(parameters) == 2
  40. derivatives = stormpy.pars.gather_derivatives(model, list(parameters)[0])
  41. assert len(derivatives) == 0