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.

60 lines
2.8 KiB

3 months ago
  1. import stormpy
  2. import stormpy.logic
  3. from helpers.helper import get_example_path
  4. import math
  5. from configurations import dft
  6. @dft
  7. class TestAnalysis:
  8. def test_analyze_mttf(self):
  9. dft = stormpy.dft.load_dft_json_file(get_example_path("dft", "and.json"))
  10. formulas = stormpy.parse_properties("T=? [ F \"failed\" ]")
  11. assert dft.nr_elements() == 3
  12. results = stormpy.dft.analyze_dft(dft, [formulas[0].raw_formula])
  13. assert math.isclose(results[0], 3)
  14. def test_relevant_events_property(self):
  15. dft = stormpy.dft.load_dft_json_file(get_example_path("dft", "and.json"))
  16. properties = stormpy.parse_properties("P=? [ F<=1 \"A_failed\" ]")
  17. formulas = [p.raw_formula for p in properties]
  18. relevant_events = stormpy.dft.compute_relevant_events(dft, formulas)
  19. assert relevant_events.is_relevant("A")
  20. assert not relevant_events.is_relevant("B")
  21. assert not relevant_events.is_relevant("C")
  22. results = stormpy.dft.analyze_dft(dft, formulas, relevant_events = relevant_events)
  23. assert math.isclose(results[0], 0.1548181217)
  24. def test_relevant_events_additional(self):
  25. dft = stormpy.dft.load_dft_json_file(get_example_path("dft", "and.json"))
  26. properties = stormpy.parse_properties("P=? [ F<=1 \"failed\" ]")
  27. formulas = [p.raw_formula for p in properties]
  28. relevant_events = stormpy.dft.compute_relevant_events(dft, formulas, ["B", "C"])
  29. assert relevant_events.is_relevant("B")
  30. assert relevant_events.is_relevant("C")
  31. assert not relevant_events.is_relevant("A")
  32. results = stormpy.dft.analyze_dft(dft, formulas, relevant_events = relevant_events)
  33. assert math.isclose(results[0], 0.1548181217)
  34. def test_transformation(self):
  35. dft = stormpy.dft.load_dft_galileo_file(get_example_path("dft", "rc2.dft"))
  36. valid, output = stormpy.dft.is_well_formed(dft)
  37. assert not valid
  38. assert "not binary" in output
  39. dft = stormpy.dft.transform_dft(dft, unique_constant_be=True, binary_fdeps=True)
  40. valid, output = stormpy.dft.is_well_formed(dft)
  41. assert valid
  42. formulas = stormpy.parse_properties("Tmin=? [ F \"failed\" ]")
  43. results = stormpy.dft.analyze_dft(dft, [formulas[0].raw_formula])
  44. assert math.isclose(results[0], 6.380930905)
  45. def test_fdep_conflicts(self):
  46. dft = stormpy.dft.load_dft_galileo_file(get_example_path("dft", "rc2.dft"))
  47. dft = stormpy.dft.transform_dft(dft, unique_constant_be=True, binary_fdeps=True)
  48. has_conflicts = stormpy.dft.compute_dependency_conflicts(dft, use_smt=False, solver_timeout=0)
  49. assert not has_conflicts
  50. formulas = stormpy.parse_properties("T=? [ F \"failed\" ]")
  51. results = stormpy.dft.analyze_dft(dft, [formulas[0].raw_formula])
  52. assert math.isclose(results[0], 6.380930905)