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.

98 lines
4.5 KiB

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