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.

88 lines
2.6 KiB

  1. import stormpy
  2. import stormpy.logic
  3. from stormpy.storage import BitVector
  4. from stormpy.utility import ShortestPathsGenerator
  5. from stormpy.utility import MatrixFormat
  6. from helpers.helper import get_example_path
  7. import pytest
  8. @pytest.fixture(scope="module")
  9. def model(program_path=get_example_path("dtmc", "die.pm"), raw_formula="P=? [ F \"one\" ]"):
  10. program = stormpy.parse_prism_program(program_path)
  11. formulas = stormpy.parse_formulas_for_prism_program(raw_formula, program)
  12. return stormpy.build_model(program, formulas[0])
  13. @pytest.fixture
  14. def state(model):
  15. some_state = 7
  16. assert model.nr_states > some_state, "test model too small"
  17. return some_state
  18. @pytest.fixture
  19. def state_list(model):
  20. some_state_list = [4, 5, 7]
  21. assert model.nr_states > max(some_state_list), "test model too small"
  22. return some_state_list
  23. @pytest.fixture
  24. def state_bitvector(model, state_list):
  25. return BitVector(length=model.nr_states, set_entries=state_list)
  26. @pytest.fixture
  27. def label(model):
  28. some_label = "one"
  29. assert some_label in model.labels, "test model does not contain label '" + some_label + "'"
  30. return some_label
  31. @pytest.fixture
  32. def transition_matrix(model):
  33. return model.transition_matrix
  34. @pytest.fixture
  35. def target_prob_map(model, state_list):
  36. return {i: (1.0 if i in state_list else 0.0) for i in range(model.nr_states)}
  37. @pytest.fixture
  38. def target_prob_list(target_prob_map):
  39. return [target_prob_map[i] for i in range(max(target_prob_map.keys()))]
  40. @pytest.fixture
  41. def initial_states(model):
  42. return BitVector(model.nr_states, model.initial_states)
  43. @pytest.fixture
  44. def matrix_format():
  45. return MatrixFormat.Straight
  46. class TestShortestPaths:
  47. def test_spg_ctor_bitvector_target(self, model, state_bitvector):
  48. _ = ShortestPathsGenerator(model, state_bitvector)
  49. def test_spg_ctor_single_state_target(self, model, state):
  50. _ = ShortestPathsGenerator(model, state)
  51. def test_spg_ctor_state_list_target(self, model, state_list):
  52. _ = ShortestPathsGenerator(model, state_list)
  53. def test_spg_ctor_label_target(self, model, label):
  54. _ = ShortestPathsGenerator(model, label)
  55. def test_spg_ctor_matrix_vector(self, transition_matrix, target_prob_list, initial_states, matrix_format):
  56. _ = ShortestPathsGenerator(transition_matrix, target_prob_list, initial_states, matrix_format)
  57. def test_spg_ctor_matrix_map(self, transition_matrix, target_prob_map, initial_states, matrix_format):
  58. _ = ShortestPathsGenerator(transition_matrix, target_prob_map, initial_states, matrix_format)
  59. # TODO: add tests that check actual functionality