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.

77 lines
3.6 KiB

8 years ago
8 years ago
  1. import stormpy
  2. import stormpy.logic
  3. from helpers.helper import get_example_path
  4. import math
  5. class TestBisimulation:
  6. def test_bisimulation(self):
  7. program = stormpy.parse_prism_program(get_example_path("dtmc", "crowds5_5.pm"))
  8. assert program.nr_modules == 1
  9. assert program.model_type == stormpy.PrismModelType.DTMC
  10. prop = "P=? [F \"observe0Greater1\"]"
  11. properties = stormpy.parse_properties_for_prism_program(prop, program)
  12. model = stormpy.build_model(program, properties)
  13. assert model.nr_states == 7403
  14. assert model.nr_transitions == 13041
  15. assert model.model_type == stormpy.ModelType.DTMC
  16. assert not model.supports_parameters
  17. initial_state = model.initial_states[0]
  18. assert initial_state == 0
  19. result = stormpy.model_checking(model, properties[0])
  20. model_bisim = stormpy.perform_bisimulation(model, properties, stormpy.BisimulationType.STRONG)
  21. assert model_bisim.nr_states == 64
  22. assert model_bisim.nr_transitions == 104
  23. assert model_bisim.model_type == stormpy.ModelType.DTMC
  24. assert not model_bisim.supports_parameters
  25. result_bisim = stormpy.model_checking(model_bisim, properties[0])
  26. initial_state_bisim = model_bisim.initial_states[0]
  27. assert initial_state_bisim == 34
  28. assert math.isclose(result.at(initial_state), result_bisim.at(initial_state_bisim), rel_tol=1e-4)
  29. def test_symbolic_bisimulation(self):
  30. program = stormpy.parse_prism_program(get_example_path("dtmc", "crowds5_5.pm"))
  31. prop = "P=? [F \"observe0Greater1\"]"
  32. properties = stormpy.parse_properties_for_prism_program(prop, program)
  33. model = stormpy.build_symbolic_model(program, properties)
  34. assert model.nr_states == 7403
  35. assert model.nr_transitions == 13041
  36. assert model.model_type == stormpy.ModelType.DTMC
  37. assert not model.supports_parameters
  38. model_bisim = stormpy.perform_symbolic_bisimulation(model, properties)
  39. assert model_bisim.nr_states == 65
  40. assert model_bisim.nr_transitions == 105
  41. assert model_bisim.model_type == stormpy.ModelType.DTMC
  42. assert not model_bisim.supports_parameters
  43. def test_parametric_bisimulation(self):
  44. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  45. assert program.nr_modules == 5
  46. assert program.model_type == stormpy.PrismModelType.DTMC
  47. assert program.has_undefined_constants
  48. assert program.undefined_constants_are_graph_preserving
  49. prop = "P=? [F s=5]"
  50. properties = stormpy.parse_properties_for_prism_program(prop, program)
  51. model = stormpy.build_parametric_model(program, properties)
  52. assert model.nr_states == 613
  53. assert model.nr_transitions == 803
  54. assert model.model_type == stormpy.ModelType.DTMC
  55. assert model.has_parameters
  56. initial_state = model.initial_states[0]
  57. assert initial_state == 0
  58. result = stormpy.model_checking(model, properties[0])
  59. ratFunc = result.at(initial_state)
  60. model_bisim = stormpy.perform_bisimulation(model, properties, stormpy.BisimulationType.STRONG)
  61. assert model_bisim.nr_states == 324
  62. assert model_bisim.nr_transitions == 452
  63. assert model_bisim.model_type == stormpy.ModelType.DTMC
  64. assert model_bisim.has_parameters
  65. result_bisim = stormpy.model_checking(model_bisim, properties[0])
  66. initial_state_bisim = model_bisim.initial_states[0]
  67. assert initial_state_bisim == 316
  68. ratFunc_bisim = result_bisim.at(initial_state_bisim)
  69. assert ratFunc == ratFunc_bisim