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
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_initial_states(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. initial_states = model.initial_states
  68. assert len(initial_states) == 1
  69. assert 0 in initial_states