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.

89 lines
4.2 KiB

  1. import stormpy
  2. import stormpy.info
  3. import stormpy.logic
  4. from helpers.helper import get_example_path
  5. from configurations import pars
  6. @pars
  7. class TestSparseParametricModel:
  8. def test_build_parametric_dtmc(self):
  9. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  10. formulas = stormpy.parse_properties_for_prism_program("P=? [ F s=5 ]", program)
  11. model = stormpy.build_parametric_model(program, formulas)
  12. assert model.nr_states == 613
  13. assert model.nr_transitions == 803
  14. assert model.model_type == stormpy.ModelType.DTMC
  15. assert model.supports_parameters
  16. assert model.has_parameters
  17. assert type(model) is stormpy.SparseParametricDtmc
  18. def test_build_dtmc_supporting_parameters(self):
  19. program = stormpy.parse_prism_program(get_example_path("dtmc", "die.pm"))
  20. formulas = stormpy.parse_properties_for_prism_program("P=? [ F \"one\" ]", program)
  21. model = stormpy.build_parametric_model(program, formulas)
  22. assert model.nr_states == 13
  23. assert model.nr_transitions == 20
  24. assert model.model_type == stormpy.ModelType.DTMC
  25. assert model.supports_parameters
  26. assert not model.has_parameters
  27. assert type(model) is stormpy.SparseParametricDtmc
  28. def test_build_parametric_mdp(self):
  29. program = stormpy.parse_prism_program(get_example_path("pmdp", "two_dice.nm"))
  30. formulas = stormpy.parse_properties_for_prism_program("P=? [ F \"two\" ]", program)
  31. model = stormpy.build_parametric_model(program, formulas)
  32. assert model.nr_states == 169
  33. assert model.nr_transitions == 435
  34. assert model.model_type == stormpy.ModelType.MDP
  35. assert model.supports_parameters
  36. assert type(model) is stormpy.SparseParametricMdp
  37. @pars
  38. class TestSymbolicParametricModel:
  39. def test_build_parametric_dtmc(self):
  40. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  41. formulas = stormpy.parse_properties_for_prism_program("P=? [ F s=5 ]", program)
  42. model = stormpy.build_symbolic_parametric_model(program, formulas)
  43. assert model.nr_states == 613
  44. assert model.nr_transitions == 803
  45. assert model.model_type == stormpy.ModelType.DTMC
  46. assert model.supports_parameters
  47. assert model.has_parameters
  48. assert type(model) is stormpy.SymbolicSylvanParametricDtmc
  49. def test_build_parametric_dtmc_preprocess(self):
  50. program = stormpy.parse_prism_program(get_example_path("pdtmc", "herman5.pm"))
  51. formulas = stormpy.parse_properties_for_prism_program("R=? [ F \"stable\" ]", program)
  52. trans_program, trans_formulas = stormpy.preprocess_prism_program(program, formulas, "")
  53. trans_prism = trans_program.as_prism_program()
  54. model = stormpy.build_symbolic_parametric_model(trans_prism, trans_formulas)
  55. assert model.nr_states == 33
  56. assert model.nr_transitions == 276
  57. assert model.model_type == stormpy.ModelType.DTMC
  58. assert model.supports_parameters
  59. assert model.has_parameters
  60. assert type(model) is stormpy.SymbolicSylvanParametricDtmc
  61. def test_build_dtmc_supporting_parameters(self):
  62. program = stormpy.parse_prism_program(get_example_path("dtmc", "die.pm"))
  63. formulas = stormpy.parse_properties_for_prism_program("P=? [ F \"one\" ]", program)
  64. model = stormpy.build_symbolic_parametric_model(program, formulas)
  65. assert model.nr_states == 13
  66. assert model.nr_transitions == 20
  67. assert model.model_type == stormpy.ModelType.DTMC
  68. assert model.supports_parameters
  69. assert not model.has_parameters
  70. assert type(model) is stormpy.SymbolicSylvanParametricDtmc
  71. def test_build_parametric_mdp(self):
  72. program = stormpy.parse_prism_program(get_example_path("pmdp", "two_dice.nm"))
  73. formulas = stormpy.parse_properties_for_prism_program("P=? [ F \"two\" ]", program)
  74. model = stormpy.build_symbolic_parametric_model(program, formulas)
  75. assert model.nr_states == 169
  76. assert model.nr_transitions == 435
  77. assert model.model_type == stormpy.ModelType.MDP
  78. assert model.supports_parameters
  79. assert type(model) is stormpy.SymbolicSylvanParametricMdp