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.

103 lines
4.7 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. prop = "P=? [F s=5]"
  26. formulas = stormpy.parse_properties_for_prism_program(prop, program)
  27. model = stormpy.build_parametric_model(program, formulas)
  28. assert model.nr_states == 613
  29. assert model.nr_transitions == 803
  30. assert model.model_type == stormpy.ModelType.DTMC
  31. assert model.supports_parameters
  32. assert model.has_parameters
  33. assert type(model) is stormpy.SparseParametricDtmc
  34. def test_build_dtmc(self):
  35. program = stormpy.parse_prism_program(get_example_path("dtmc", "die.pm"))
  36. formulas = stormpy.parse_properties_for_prism_program("P=? [ F \"one\" ]", program)
  37. model = stormpy.build_model(program, formulas)
  38. assert model.nr_states == 13
  39. assert model.nr_transitions == 20
  40. assert model.model_type == stormpy.ModelType.DTMC
  41. assert not model.supports_parameters
  42. assert type(model) is stormpy.SparseDtmc
  43. def test_build_parametric_dtmc(self):
  44. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  45. formulas = stormpy.parse_properties_for_prism_program("P=? [ F s=5 ]", program)
  46. model = stormpy.build_parametric_model(program, formulas)
  47. assert model.nr_states == 613
  48. assert model.nr_transitions == 803
  49. assert model.model_type == stormpy.ModelType.DTMC
  50. assert model.supports_parameters
  51. assert model.has_parameters
  52. assert type(model) is stormpy.SparseParametricDtmc
  53. def test_build_dtmc_supporting_parameters(self):
  54. program = stormpy.parse_prism_program(get_example_path("dtmc", "die.pm"))
  55. formulas = stormpy.parse_properties_for_prism_program("P=? [ F \"one\" ]", program)
  56. model = stormpy.build_parametric_model(program, formulas)
  57. assert model.nr_states == 13
  58. assert model.nr_transitions == 20
  59. assert model.model_type == stormpy.ModelType.DTMC
  60. assert model.supports_parameters
  61. assert not model.has_parameters
  62. assert type(model) is stormpy.SparseParametricDtmc
  63. def test_label(self):
  64. program = stormpy.parse_prism_program(get_example_path("dtmc", "die.pm"))
  65. formulas = stormpy.parse_properties_for_prism_program("P=? [ F \"one\" ]", program)
  66. model = stormpy.build_model(program, formulas)
  67. labels = model.labels
  68. assert len(labels) == 3
  69. assert "init" in labels
  70. assert "one" in labels
  71. assert "init" in model.labels_state(0)
  72. assert "one" in model.labels_state(7)
  73. def test_initial_states(self):
  74. program = stormpy.parse_prism_program(get_example_path("dtmc", "die.pm"))
  75. formulas = stormpy.parse_properties_for_prism_program("P=? [ F \"one\" ]", program)
  76. model = stormpy.build_model(program, formulas)
  77. initial_states = model.initial_states
  78. assert len(initial_states) == 1
  79. assert 0 in initial_states
  80. def test_label_parametric(self):
  81. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  82. formulas = stormpy.parse_properties_for_prism_program("P=? [ F s=5 ]", program)
  83. model = stormpy.build_parametric_model(program, formulas)
  84. labels = model.labels
  85. assert len(labels) == 3
  86. assert "init" in labels
  87. assert "(s = 5)" in labels
  88. assert "init" in model.labels_state(0)
  89. assert "(s = 5)" in model.labels_state(28)
  90. assert "(s = 5)" in model.labels_state(611)
  91. initial_states = model.initial_states
  92. assert len(initial_states) == 1
  93. assert 0 in initial_states