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.

50 lines
1.7 KiB

  1. import stormpy
  2. from stormpy.logic import logic
  3. class TestFormulas:
  4. def test_probability_formula(self):
  5. prop = "P=? [F \"one\"]"
  6. formulas = stormpy.parse_formulas(prop)
  7. formula = formulas[0]
  8. assert type(formula) == logic.ProbabilityOperator
  9. assert len(formulas) == 1
  10. assert str(formula) == prop
  11. def test_reward_formula(self):
  12. prop = "R=? [F \"one\"]"
  13. formulas = stormpy.parse_formulas(prop)
  14. formula = formulas[0]
  15. assert type(formula) == logic.RewardOperator
  16. assert len(formulas) == 1
  17. assert str(formula) == "R[exp]=? [F \"one\"]"
  18. def test_formula_list(self):
  19. formulas = []
  20. prop = "=? [F \"one\"]"
  21. forms = stormpy.parse_formulas("P" + prop)
  22. formulas.append(forms[0])
  23. forms = stormpy.parse_formulas("R" + prop)
  24. formulas.append(forms[0])
  25. assert len(formulas) == 2
  26. assert str(formulas[0]) == "P" + prop
  27. assert str(formulas[1]) == "R[exp]" + prop
  28. def test_bounds(self):
  29. prop = "P=? [F \"one\"]"
  30. formula = stormpy.parse_formulas(prop)[0]
  31. assert not formula.has_bound()
  32. prop = "P<0.4 [F \"one\"]"
  33. formula = stormpy.parse_formulas(prop)[0]
  34. assert formula.has_bound()
  35. assert formula.threshold == 0.4
  36. assert formula.comparison_type == logic.ComparisonType.LESS
  37. def test_set_bounds(self):
  38. prop = "P<0.4 [F \"one\"]"
  39. formula = stormpy.parse_formulas(prop)[0]
  40. formula.threshold = 0.2
  41. formula.comparison_type = logic.ComparisonType.GEQ
  42. assert formula.threshold == 0.2
  43. assert formula.comparison_type == logic.ComparisonType.GEQ
  44. assert str(formula) == "P>=0.2 [F \"one\"]"