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.

56 lines
2.0 KiB

  1. import stormpy
  2. import stormpy.gspn
  3. import stormpy.examples
  4. import stormpy.examples.files
  5. def example_gspns_01():
  6. # construct gspn with gspn builder
  7. builder = stormpy.gspn.GSPNBuilder()
  8. builder.set_name("gspn")
  9. it_0 = builder.add_immediate_transition(1, 0.0, "it_0")
  10. it_layout = stormpy.gspn.LayoutInfo(1.5, 1.5)
  11. builder.set_transition_layout_info(it_0, it_layout)
  12. tt_0 = builder.add_timed_transition(0, 0.4, "tt_0")
  13. tt_layout = stormpy.gspn.LayoutInfo(12.5, 1.5)
  14. builder.set_transition_layout_info(tt_0, tt_layout)
  15. place_0 = builder.add_place(1, 1, "place_0")
  16. p0_layout = stormpy.gspn.LayoutInfo(6.5, 1.5)
  17. builder.set_place_layout_info(place_0, p0_layout)
  18. place_1 = builder.add_place(1, 0, "place_1")
  19. p1_layout = stormpy.gspn.LayoutInfo(18.5, 1.5)
  20. builder.set_place_layout_info(place_1, p1_layout)
  21. # arcs
  22. builder.add_output_arc(it_0, place_0)
  23. builder.add_inhibition_arc(place_0, it_0)
  24. builder.add_input_arc(place_0, tt_0)
  25. builder.add_output_arc(tt_0, place_1)
  26. # build gspn
  27. gspn = builder.build_gspn()
  28. print("GSPN with {} places, {} immediate transitions and {} timed transitions.".format(gspn.get_number_of_places(),
  29. gspn.get_number_of_immediate_transitions(),
  30. gspn.get_number_of_timed_transitions()))
  31. path = stormpy.examples.files.gspn_pnpro_simple
  32. # export gspn to pnpro format
  33. gspn.export_gspn_pnpro_file(path)
  34. # import gspn
  35. gspn_parser = stormpy.gspn.GSPNParser()
  36. gspn_import = gspn_parser.parse(path)
  37. print("GSPN with {} places, {} immediate transitions and {} timed transitions.".format(
  38. gspn_import.get_number_of_places(), gspn.get_number_of_immediate_transitions(),
  39. gspn.get_number_of_timed_transitions()))
  40. if __name__ == '__main__':
  41. example_gspns_01()