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.

69 lines
2.6 KiB

4 weeks ago
  1. import os
  2. import math
  3. import stormpy
  4. from helpers.helper import get_example_path
  5. from configurations import gspn, xml
  6. @gspn
  7. class TestGSPNJani:
  8. def test_custom_property(self):
  9. gspn_parser = stormpy.gspn.GSPNParser()
  10. gspn = gspn_parser.parse(get_example_path("gspn", "philosophers_4.pnpro"))
  11. assert gspn.get_name() == "Philosophers4"
  12. assert gspn.get_number_of_timed_transitions() == 12
  13. assert gspn.get_number_of_immediate_transitions() == 0
  14. assert gspn.get_number_of_places() == 16
  15. # Build jani program
  16. jani_builder = stormpy.gspn.GSPNToJaniBuilder(gspn)
  17. jani_program = jani_builder.build()
  18. # Set properties
  19. properties = stormpy.parse_properties_for_jani_model('P=? [F<=10 eating1=1]', jani_program)
  20. # Build model
  21. model = stormpy.build_model(jani_program, properties)
  22. # Model checking
  23. initial_state = model.initial_states[0]
  24. assert initial_state == 0
  25. result = stormpy.model_checking(model, properties[0])
  26. assert math.isclose(result.at(initial_state), 0.4372171069840004)
  27. def test_standard_properties(self):
  28. gspn_parser = stormpy.gspn.GSPNParser()
  29. gspn = gspn_parser.parse(get_example_path("gspn", "philosophers_4.pnpro"))
  30. assert gspn.get_name() == "Philosophers4"
  31. assert gspn.get_number_of_timed_transitions() == 12
  32. assert gspn.get_number_of_immediate_transitions() == 0
  33. assert gspn.get_number_of_places() == 16
  34. # Build jani program
  35. jani_builder = stormpy.gspn.GSPNToJaniBuilder(gspn)
  36. jani_program = jani_builder.build()
  37. # Use standard properties
  38. properties = jani_builder.create_deadlock_properties(jani_program)
  39. # Instantiate constants
  40. jani_program, properties = stormpy.preprocess_symbolic_input(jani_program, properties, "TIME_BOUND=1")
  41. jani_program = jani_program.as_jani_model()
  42. # Build model
  43. # Leads to incorrect result
  44. #model = stormpy.build_model(jani_program, properties)
  45. model = stormpy.build_model(jani_program)
  46. # Model checking
  47. initial_state = model.initial_states[0]
  48. assert initial_state == 0
  49. result = stormpy.model_checking(model, properties[0])
  50. assert math.isclose(result.at(initial_state), 1.0)
  51. result = stormpy.model_checking(model, properties[1])
  52. assert math.isclose(result.at(initial_state), 0.09123940783)
  53. result = stormpy.model_checking(model, properties[2])
  54. assert math.isclose(result.at(initial_state), 5.445544554455446)