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
1.9 KiB

  1. import stormpy
  2. import stormpy.info
  3. import stormpy.logic
  4. from helpers.helper import get_example_path
  5. from configurations import pars
  6. @pars
  7. class TestParametric:
  8. def test_constraints_collector(self):
  9. from pycarl.formula import FormulaType, Relation
  10. if stormpy.info.storm_ratfunc_use_cln():
  11. import pycarl.cln.formula
  12. else:
  13. import pycarl.gmp.formula
  14. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  15. prop = "P=? [F s=5]"
  16. formulas = stormpy.parse_properties_for_prism_program(prop, program)
  17. model = stormpy.build_parametric_model(program, formulas)
  18. collector = stormpy.ConstraintCollector(model)
  19. constraints_well_formed = collector.wellformed_constraints
  20. for formula in constraints_well_formed:
  21. assert formula.type == FormulaType.CONSTRAINT
  22. constraint = formula.get_constraint()
  23. assert constraint.relation == Relation.LEQ
  24. constraints_graph_preserving = collector.graph_preserving_constraints
  25. for formula in constraints_graph_preserving:
  26. assert formula.type == FormulaType.CONSTRAINT
  27. constraint = formula.get_constraint()
  28. assert constraint.relation == Relation.NEQ
  29. def test_derivatives(self):
  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