The source code and dockerfile for the GSW2024 AI Lab.
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

50 lines
2.0 KiB

2 months ago
  1. import stormpy
  2. import stormpy.logic
  3. from helpers.helper import get_example_path
  4. class TestLabeling:
  5. def test_set_labeling(self):
  6. program = stormpy.parse_prism_program(get_example_path("dtmc", "die.pm"))
  7. model = stormpy.build_model(program)
  8. labeling = model.labeling
  9. assert "tmp" not in labeling.get_labels()
  10. assert not labeling.contains_label("tmp")
  11. labeling.add_label("tmp")
  12. assert labeling.contains_label("tmp")
  13. labeling.add_label_to_state("tmp", 0)
  14. assert labeling.has_state_label("tmp", 0)
  15. states = labeling.get_states("tmp")
  16. assert states.get(0)
  17. states.set(3)
  18. labeling.set_states("tmp", states)
  19. assert labeling.has_state_label("tmp", 3)
  20. def test_label(self):
  21. program = stormpy.parse_prism_program(get_example_path("dtmc", "die.pm"))
  22. formulas = stormpy.parse_properties_for_prism_program("P=? [ F \"one\" ]", program)
  23. model = stormpy.build_model(program, formulas)
  24. labeling = model.labeling
  25. labels = labeling.get_labels()
  26. assert len(labels) == 3
  27. assert "init" in labels
  28. assert "one" in labels
  29. assert "init" in model.labels_state(0)
  30. assert "init" in labeling.get_labels_of_state(0)
  31. assert "one" in model.labels_state(7)
  32. assert "one" in labeling.get_labels_of_state(7)
  33. def test_label_parametric(self):
  34. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  35. formulas = stormpy.parse_properties_for_prism_program("P=? [ F s=5 ]", program)
  36. model = stormpy.build_parametric_model(program, formulas)
  37. labels = model.labeling.get_labels()
  38. assert len(labels) == 3
  39. assert "init" in labels
  40. assert "(s = 5)" in labels
  41. assert "init" in model.labels_state(0)
  42. assert "(s = 5)" in model.labels_state(28)
  43. assert "(s = 5)" in model.labels_state(611)
  44. initial_states = model.initial_states
  45. assert len(initial_states) == 1
  46. assert 0 in initial_states