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.

96 lines
4.5 KiB

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