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.

35 lines
1.7 KiB

  1. import stormpy
  2. import stormpy.logic
  3. class TestModelChecking:
  4. def test_state_elimination(self):
  5. program = stormpy.parse_program("../examples/dtmc/die/die.pm")
  6. formulas = stormpy.parse_formulas_for_program("P=? [ F \"one\" ]", program)
  7. model = stormpy.build_model(program, formulas[0])
  8. assert model.nr_states() == 13
  9. assert model.nr_transitions() == 20
  10. result = stormpy.model_checking(model, formulas[0])
  11. assert result == 0.16666666666666663
  12. def test_parametric_state_elimination(self):
  13. import pycarl
  14. import pycarl.formula
  15. program = stormpy.parse_program("../examples/pdtmc/brp/brp_16_2.pm")
  16. prop = "P=? [F \"target\"]"
  17. formulas = stormpy.parse_formulas_for_program(prop, program)
  18. pair = stormpy.build_parametric_model_from_prism_program(program, formulas)
  19. model = pair.model
  20. assert model.nr_states() == 613
  21. assert model.nr_transitions() == 803
  22. assert model.model_type() == stormpy.ModelType.DTMC
  23. assert model.has_parameters()
  24. result = stormpy.model_checking(model, formulas[0])
  25. func = result.result_function
  26. one = pycarl.FactorizedPolynomial(pycarl.Rational(1))
  27. assert func.denominator == one
  28. constraints_well_formed = result.constraints_well_formed
  29. for constraint in constraints_well_formed:
  30. assert constraint.rel() == pycarl.formula.Relation.GEQ or constraint.rel() == pycarl.formula.Relation.LEQ
  31. constraints_graph_preserving = result.constraints_graph_preserving
  32. for constraint in constraints_graph_preserving:
  33. assert constraint.rel() == pycarl.formula.Relation.GREATER