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.

45 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.PLAChecker(model)
  16. checker.specify_formula(formulas[0].raw_formula)
  17. parameters = model.collect_probability_parameters()
  18. assert len(parameters) == 2
  19. #if str(parameters[0]) == "pL":
  20. # pL = parameters[0]
  21. # pK = parameters[1]
  22. #else:
  23. # pK = parameters[0]
  24. # pL = parameters[1]
  25. #assert str(pL) == "pL"
  26. #assert str(pK) == "pK"
  27. #lowerBounds = {pL: 0.7, pK: 0.75}
  28. #upperBounds = {pL: 0.9, pK: 0.95}
  29. #region = stormpy.ParameterRegion(lowerBounds, upperBounds)
  30. region = stormpy.ParameterRegion("0.7<=pL<=0.9,0.75<=pK<=0.95", parameters)
  31. result = checker.check_region(region)
  32. assert result == stormpy.RegionCheckResult.ALLSAT
  33. #lowerBounds = {pL: 0.4, pK: 0.75}
  34. #upperBounds = {pL: 0.65, pK: 0.95}
  35. #region = stormpy.ParameterRegion(lowerBounds, upperBounds)
  36. region = stormpy.ParameterRegion("0.4<=pL<=0.65,0.75<=pK<=0.95", parameters)
  37. result = checker.check_region(region, stormpy.RegionCheckResult.UNKNOWN, True)
  38. assert result == stormpy.RegionCheckResult.EXISTSBOTH
  39. #lowerBounds = {pL: 0.1, pK: 0.2}
  40. #upperBounds = {pL: 0.73, pK: 0.715}
  41. #region = stormpy.ParameterRegion(lowerBounds, upperBounds)
  42. region = stormpy.ParameterRegion("0.1<=pL<=0.73,0.2<=pK<=0.715", parameters)
  43. result = checker.check_region(region)
  44. assert result == stormpy.RegionCheckResult.ALLVIOLATED