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.

43 lines
1.3 KiB

  1. import stormpy
  2. import numpy as np
  3. def example_building_ctmcs_01():
  4. # Building the transition matrix using numpy
  5. transitions = np.array([
  6. [0, 1.5, 0, 0],
  7. [3, 0, 1.5, 0],
  8. [0, 3, 0, 1.5],
  9. [0, 0, 3, 0], ], dtype='float64')
  10. # Default row groups: [0,1,2,3]
  11. transition_matrix = stormpy.build_sparse_matrix(transitions)
  12. print(transition_matrix)
  13. # State labeling
  14. state_labeling = stormpy.storage.StateLabeling(4)
  15. state_labels = {'empty', 'init', 'deadlock', 'full'}
  16. for label in state_labels:
  17. state_labeling.add_label(label)
  18. # Adding label to states
  19. state_labeling.add_label_to_state('init', 0)
  20. state_labeling.add_label_to_state('empty', 0)
  21. state_labeling.add_label_to_state('full', 3)
  22. # Exit rate for each state
  23. exit_rates = [1.5, 4.5, 4.5, 3.0]
  24. # Collect components
  25. # rate_transitions = True, because the transition values are interpreted as rates
  26. components = stormpy.SparseModelComponents(transition_matrix=transition_matrix, state_labeling=state_labeling, rate_transitions=True)
  27. components.exit_rates = exit_rates
  28. # Build the model
  29. ctmc = stormpy.storage.SparseCtmc(components)
  30. print(ctmc)
  31. if __name__ == '__main__':
  32. example_building_ctmcs_01()