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.

55 lines
1.6 KiB

  1. import stormpy
  2. import numpy as np
  3. def example_building_mas_01():
  4. # Building the transition matrix using numpy
  5. transitions = np.array([
  6. [0, 1, 0, 0, 0],
  7. [0.8, 0, 0.2, 0, 0],
  8. [0.9, 0, 0, 0.1, 0],
  9. [0, 0, 0, 0, 1],
  10. [0, 0, 0, 1, 0],
  11. [0, 0, 0, 0, 1]
  12. ], dtype='float64')
  13. # Build matrix and define indices of row groups (ascending order)
  14. transition_matrix = stormpy.build_sparse_matrix(transitions, [0, 2, 3, 4, 5])
  15. print(transition_matrix)
  16. # StateLabeling
  17. state_labeling = stormpy.storage.StateLabeling(5)
  18. # Add labels
  19. state_labels = {'init', 'deadlock'}
  20. # Set labeling of states
  21. for label in state_labels:
  22. state_labeling.add_label(label)
  23. state_labeling.add_label_to_state('init', 0)
  24. # Choice labeling
  25. choice_labeling = stormpy.storage.ChoiceLabeling(6)
  26. # Add labels
  27. choice_labels = {'alpha', 'beta'}
  28. # Set labeling of choices
  29. for label in choice_labels:
  30. choice_labeling.add_label(label)
  31. choice_labeling.add_label_to_choice('alpha', 0)
  32. choice_labeling.add_label_to_choice('beta', 1)
  33. exit_rates = [0.0, 10.0, 12.0, 1.0, 1.0]
  34. markovian_states = stormpy.BitVector(5, [1, 2, 3, 4])
  35. # Collect components
  36. components = stormpy.SparseModelComponents(transition_matrix=transition_matrix, state_labeling=state_labeling,
  37. markovian_states=markovian_states)
  38. components.choice_labeling = choice_labeling
  39. components.exit_rates = exit_rates
  40. # Build the model
  41. ma = stormpy.storage.SparseMA(components)
  42. print(ma)
  43. if __name__ == '__main__':
  44. example_building_mas_01()