The source code and dockerfile for the GSW2024 AI Lab.
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

102 lines
4.9 KiB

2 months ago
  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_parametric_dtmc_preprocess(self):
  19. program = stormpy.parse_prism_program(get_example_path("pdtmc", "herman5.pm"))
  20. formulas = stormpy.parse_properties_for_prism_program("R=? [ F \"stable\" ]", program)
  21. trans_program, trans_formulas = stormpy.preprocess_symbolic_input(program, formulas, "")
  22. trans_prism = trans_program.as_prism_program()
  23. model = stormpy.build_parametric_model(trans_prism, trans_formulas)
  24. assert model.nr_states == 33
  25. assert model.nr_transitions == 266
  26. assert model.model_type == stormpy.ModelType.DTMC
  27. assert model.supports_parameters
  28. assert model.has_parameters
  29. assert type(model) is stormpy.SparseParametricDtmc
  30. def test_build_dtmc_supporting_parameters(self):
  31. program = stormpy.parse_prism_program(get_example_path("dtmc", "die.pm"))
  32. formulas = stormpy.parse_properties_for_prism_program("P=? [ F \"one\" ]", program)
  33. model = stormpy.build_parametric_model(program, formulas)
  34. assert model.nr_states == 13
  35. assert model.nr_transitions == 20
  36. assert model.model_type == stormpy.ModelType.DTMC
  37. assert model.supports_parameters
  38. assert not model.has_parameters
  39. assert type(model) is stormpy.SparseParametricDtmc
  40. def test_build_parametric_mdp(self):
  41. program = stormpy.parse_prism_program(get_example_path("pmdp", "two_dice.nm"))
  42. formulas = stormpy.parse_properties_for_prism_program("P=? [ F \"two\" ]", program)
  43. model = stormpy.build_parametric_model(program, formulas)
  44. assert model.nr_states == 169
  45. assert model.nr_transitions == 435
  46. assert model.model_type == stormpy.ModelType.MDP
  47. assert model.supports_parameters
  48. assert type(model) is stormpy.SparseParametricMdp
  49. @pars
  50. class TestSymbolicParametricModel:
  51. def test_build_parametric_dtmc(self):
  52. program = stormpy.parse_prism_program(get_example_path("pdtmc", "brp16_2.pm"))
  53. formulas = stormpy.parse_properties_for_prism_program("P=? [ F s=5 ]", program)
  54. model = stormpy.build_symbolic_parametric_model(program, formulas)
  55. assert model.nr_states == 613
  56. assert model.nr_transitions == 803
  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_parametric_dtmc_preprocess(self):
  62. program = stormpy.parse_prism_program(get_example_path("pdtmc", "herman5.pm"))
  63. formulas = stormpy.parse_properties_for_prism_program("R=? [ F \"stable\" ]", program)
  64. trans_program, trans_formulas = stormpy.preprocess_symbolic_input(program, formulas, "")
  65. trans_prism = trans_program.as_prism_program()
  66. model = stormpy.build_symbolic_parametric_model(trans_prism, trans_formulas)
  67. assert model.nr_states == 33
  68. assert model.nr_transitions == 266
  69. assert model.model_type == stormpy.ModelType.DTMC
  70. assert model.supports_parameters
  71. assert model.has_parameters
  72. assert type(model) is stormpy.SymbolicSylvanParametricDtmc
  73. def test_build_dtmc_supporting_parameters(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_symbolic_parametric_model(program, formulas)
  77. assert model.nr_states == 13
  78. assert model.nr_transitions == 20
  79. assert model.model_type == stormpy.ModelType.DTMC
  80. assert model.supports_parameters
  81. assert not model.has_parameters
  82. assert type(model) is stormpy.SymbolicSylvanParametricDtmc
  83. def test_build_parametric_mdp(self):
  84. program = stormpy.parse_prism_program(get_example_path("pmdp", "two_dice.nm"))
  85. formulas = stormpy.parse_properties_for_prism_program("P=? [ F \"two\" ]", program)
  86. model = stormpy.build_symbolic_parametric_model(program, formulas)
  87. assert model.nr_states == 169
  88. assert model.nr_transitions == 435
  89. assert model.model_type == stormpy.ModelType.MDP
  90. assert model.supports_parameters
  91. assert type(model) is stormpy.SymbolicSylvanParametricMdp