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
  1. import stormpy
  2. import stormpy.logic
  3. from helpers.helper import get_example_path
  4. class TestModelChecking:
  5. def test_pla(self):
  6. import pycarl
  7. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  8. prop = "P<=0.84 [F s=5 ]"
  9. formulas = stormpy.parse_properties_for_prism_program(prop, program)
  10. model = stormpy.build_parametric_model(program, formulas)
  11. assert model.nr_states == 613
  12. assert model.nr_transitions == 803
  13. assert model.model_type == stormpy.ModelType.DTMC
  14. assert model.has_parameters
  15. checker = stormpy.SparseDtmcRegionChecker(model)
  16. checker.specify_formula(formulas[0].raw_formula)
  17. parameters = model.collect_probability_parameters()
  18. assert len(parameters) == 2
  19. region = stormpy.ParameterRegion("0.7<=pL<=0.9,0.75<=pK<=0.95", parameters)
  20. result = checker.check_region(region)
  21. assert result == stormpy.RegionCheckResult.ALLSAT
  22. region = stormpy.ParameterRegion("0.4<=pL<=0.65,0.75<=pK<=0.95", parameters)
  23. result = checker.check_region(region, stormpy.RegionCheckResult.UNKNOWN, True)
  24. assert result == stormpy.RegionCheckResult.EXISTSBOTH
  25. region = stormpy.ParameterRegion("0.1<=pL<=0.73,0.2<=pK<=0.715", parameters)
  26. result = checker.check_region(region)
  27. assert result == stormpy.RegionCheckResult.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.gather_derivatives(model, list(parameters)[0])
  41. assert len(derivatives) == 0