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.

105 lines
4.9 KiB

8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. import stormpy
  2. import stormpy.logic
  3. from helpers.helper import get_example_path
  4. class TestModel:
  5. def test_build_dtmc_from_prism_program(self):
  6. program = stormpy.parse_prism_program(get_example_path("dtmc", "die.pm"))
  7. model = stormpy.build_model(program)
  8. assert model.nr_states == 13
  9. assert model.nr_transitions == 20
  10. assert model.model_type == stormpy.ModelType.DTMC
  11. assert not model.supports_parameters
  12. assert type(model) is stormpy.SparseDtmc
  13. def test_build_dtmc_from_prism_program_formulas(self):
  14. program = stormpy.parse_prism_program(get_example_path("dtmc", "die.pm"))
  15. prop = "P=? [F \"one\"]"
  16. properties = stormpy.parse_properties_for_prism_program(prop, program, None)
  17. model = stormpy.build_model(program, properties)
  18. assert model.nr_states == 13
  19. assert model.nr_transitions == 20
  20. assert model.model_type == stormpy.ModelType.DTMC
  21. assert not model.supports_parameters
  22. assert type(model) is stormpy.SparseDtmc
  23. def test_build_parametric_dtmc_from_prism_program(self):
  24. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  25. assert program.nr_modules == 5
  26. assert program.model_type == stormpy.PrismModelType.DTMC
  27. assert program.has_undefined_constants
  28. prop = "P=? [F s=5]"
  29. formulas = stormpy.parse_properties_for_prism_program(prop, program)
  30. model = stormpy.build_parametric_model(program, formulas)
  31. assert model.nr_states == 613
  32. assert model.nr_transitions == 803
  33. assert model.model_type == stormpy.ModelType.DTMC
  34. assert model.supports_parameters
  35. assert model.has_parameters
  36. assert type(model) is stormpy.SparseParametricDtmc
  37. def test_build_dtmc(self):
  38. program = stormpy.parse_prism_program(get_example_path("dtmc", "die.pm"))
  39. formulas = stormpy.parse_properties_for_prism_program("P=? [ F \"one\" ]", program)
  40. model = stormpy.build_model(program, formulas)
  41. assert model.nr_states == 13
  42. assert model.nr_transitions == 20
  43. assert model.model_type == stormpy.ModelType.DTMC
  44. assert not model.supports_parameters
  45. assert type(model) is stormpy.SparseDtmc
  46. def test_build_parametric_dtmc(self):
  47. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  48. formulas = stormpy.parse_properties_for_prism_program("P=? [ F s=5 ]", program)
  49. model = stormpy.build_parametric_model(program, formulas)
  50. assert model.nr_states == 613
  51. assert model.nr_transitions == 803
  52. assert model.model_type == stormpy.ModelType.DTMC
  53. assert model.supports_parameters
  54. assert model.has_parameters
  55. assert type(model) is stormpy.SparseParametricDtmc
  56. def test_build_dtmc_supporting_parameters(self):
  57. program = stormpy.parse_prism_program(get_example_path("dtmc", "die.pm"))
  58. formulas = stormpy.parse_properties_for_prism_program("P=? [ F \"one\" ]", program)
  59. model = stormpy.build_parametric_model(program, formulas)
  60. assert model.nr_states == 13
  61. assert model.nr_transitions == 20
  62. assert model.model_type == stormpy.ModelType.DTMC
  63. assert model.supports_parameters
  64. assert not model.has_parameters
  65. assert type(model) is stormpy.SparseParametricDtmc
  66. def test_label(self):
  67. program = stormpy.parse_prism_program(get_example_path("dtmc", "die.pm"))
  68. formulas = stormpy.parse_properties_for_prism_program("P=? [ F \"one\" ]", program)
  69. model = stormpy.build_model(program, formulas)
  70. labels = model.labels
  71. assert len(labels) == 3
  72. assert "init" in labels
  73. assert "one" in labels
  74. assert "init" in model.labels_state(0)
  75. assert "one" in model.labels_state(7)
  76. def test_initial_states(self):
  77. program = stormpy.parse_prism_program(get_example_path("dtmc", "die.pm"))
  78. formulas = stormpy.parse_properties_for_prism_program("P=? [ F \"one\" ]", program)
  79. model = stormpy.build_model(program, formulas)
  80. initial_states = model.initial_states
  81. assert len(initial_states) == 1
  82. assert 0 in initial_states
  83. def test_label_parametric(self):
  84. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  85. formulas = stormpy.parse_properties_for_prism_program("P=? [ F s=5 ]", program)
  86. model = stormpy.build_parametric_model(program, formulas)
  87. labels = model.labels
  88. assert len(labels) == 3
  89. assert "init" in labels
  90. assert "(s = 5)" in labels
  91. assert "init" in model.labels_state(0)
  92. assert "(s = 5)" in model.labels_state(28)
  93. assert "(s = 5)" in model.labels_state(611)
  94. initial_states = model.initial_states
  95. assert len(initial_states) == 1
  96. assert 0 in initial_states