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.

42 lines
1.9 KiB

  1. import stormpy
  2. import stormpy.info
  3. import stormpy.logic
  4. from helpers.helper import get_example_path
  5. class TestParametric:
  6. def test_constraints_collector(self):
  7. from pycarl.formula import FormulaType, Relation
  8. if stormpy.info.storm_ratfunc_use_cln():
  9. import pycarl.cln.formula
  10. else:
  11. import pycarl.gmp.formula
  12. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  13. prop = "P=? [F s=5]"
  14. formulas = stormpy.parse_properties_for_prism_program(prop, program)
  15. model = stormpy.build_parametric_model(program, formulas)
  16. collector = stormpy.ConstraintCollector(model)
  17. constraints_well_formed = collector.wellformed_constraints
  18. for formula in constraints_well_formed:
  19. assert formula.type == FormulaType.CONSTRAINT
  20. constraint = formula.get_constraint()
  21. assert constraint.relation == Relation.LEQ
  22. constraints_graph_preserving = collector.graph_preserving_constraints
  23. for formula in constraints_graph_preserving:
  24. assert formula.type == FormulaType.CONSTRAINT
  25. constraint = formula.get_constraint()
  26. assert constraint.relation == Relation.NEQ
  27. def test_derivatives(self):
  28. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  29. prop = "P<=0.84 [F s=5 ]"
  30. formulas = stormpy.parse_properties_for_prism_program(prop, program)
  31. model = stormpy.build_parametric_model(program, formulas)
  32. assert model.nr_states == 613
  33. assert model.nr_transitions == 803
  34. assert model.model_type == stormpy.ModelType.DTMC
  35. assert model.has_parameters
  36. parameters = model.collect_probability_parameters()
  37. assert len(parameters) == 2
  38. derivatives = stormpy.pars.gather_derivatives(model, list(parameters)[0])
  39. assert len(derivatives) == 0