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.3 KiB

  1. import stormpy
  2. import stormpy.logic
  3. from helpers.helper import get_example_path
  4. class TestModelChecking:
  5. def test_model_checking_dtmc(self):
  6. program = stormpy.parse_prism_program(get_example_path("dtmc", "die.pm"))
  7. formulas = stormpy.parse_formulas_for_prism_program("P=? [ F \"one\" ]", program)
  8. model = stormpy.build_model(program, formulas[0])
  9. assert model.nr_states == 13
  10. assert model.nr_transitions == 20
  11. result = stormpy.model_checking(model, formulas[0])
  12. assert result == 0.16666666666666663
  13. def test_model_checking_all_dtmc(self):
  14. program = stormpy.parse_prism_program(get_example_path("dtmc", "die.pm"))
  15. formulas = stormpy.parse_formulas_for_prism_program("P=? [ F \"one\" ]", program)
  16. model = stormpy.build_model(program, formulas[0])
  17. assert model.nr_states == 13
  18. assert model.nr_transitions == 20
  19. results = stormpy.model_checking_all(model, formulas[0])
  20. results_orig = [0.16666666666666663, 0.3333333333333333, 0, 0.6666666666666666, 0, 0, 0, 1, 0, 0, 0, 0, 0]
  21. assert results == results_orig
  22. def test_parametric_state_elimination(self):
  23. import pycarl
  24. import pycarl.formula
  25. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  26. prop = "P=? [F s=5]"
  27. formulas = stormpy.parse_formulas_for_prism_program(prop, program)
  28. model = stormpy.build_parametric_model_from_prism_program(program, formulas)
  29. assert model.nr_states == 613
  30. assert model.nr_transitions == 803
  31. assert model.model_type == stormpy.ModelType.DTMC
  32. assert model.has_parameters
  33. result = stormpy.model_checking(model, formulas[0])
  34. func = result.result_function
  35. one = pycarl.FactorizedPolynomial(pycarl.Rational(1))
  36. assert func.denominator == one
  37. constraints_well_formed = result.constraints_well_formed
  38. for constraint in constraints_well_formed:
  39. assert constraint.rel() == pycarl.formula.Relation.GEQ or constraint.rel() == pycarl.formula.Relation.LEQ
  40. constraints_graph_preserving = result.constraints_graph_preserving
  41. for constraint in constraints_graph_preserving:
  42. assert constraint.rel() == pycarl.formula.Relation.GREATER