hannah
4 years ago
committed by
Matthias Volk
No known key found for this signature in database
GPG Key ID: 83A57678F739FCD3
8 changed files with 262 additions and 68 deletions
-
2doc/source/advanced_topics.rst
-
7doc/source/doc/building_ctmcs.rst
-
17doc/source/doc/building_dtmcs.rst
-
82doc/source/doc/building_mas.rst
-
111doc/source/doc/building_mdps.rst
-
5examples/building_dtmcs/01-building-dtmcs.py
-
49examples/building_mas/01-building-mas.py
-
35examples/building_mdps/01-building-mdps.py
@ -1,9 +1,54 @@ |
|||||
import stormpy |
import stormpy |
||||
|
import numpy as np |
||||
|
|
||||
|
|
||||
# hybrid_states example |
|
||||
def example_building_mas_01(): |
def example_building_mas_01(): |
||||
print('todo') |
|
||||
|
# Building the transition matrix using numpy |
||||
|
transitions = np.array([ |
||||
|
[0, 1, 0, 0, 0], |
||||
|
[0.8, 0, 0.2, 0, 0], |
||||
|
[0.9, 0, 0, 0.1, 0], |
||||
|
[0, 0, 0, 0, 1], |
||||
|
[0, 0, 0, 1, 0], |
||||
|
[0, 0, 0, 0, 1] |
||||
|
], dtype='float64') |
||||
|
|
||||
|
# Build matrix and define indices of row groups (ascending order) |
||||
|
transition_matrix = stormpy.build_sparse_matrix(transitions, [0, 2, 3, 4, 5]) |
||||
|
print(transition_matrix) |
||||
|
|
||||
|
# StateLabeling |
||||
|
state_labeling = stormpy.storage.StateLabeling(5) |
||||
|
# Add labels |
||||
|
state_labels = {'init', 'deadlock'} |
||||
|
# Set labeling of states |
||||
|
for label in state_labels: |
||||
|
state_labeling.add_label(label) |
||||
|
state_labeling.add_label_to_state('init', 0) |
||||
|
|
||||
|
# Choice labeling |
||||
|
choice_labeling = stormpy.storage.ChoiceLabeling(6) |
||||
|
# Add labels |
||||
|
choice_labels = {'alpha', 'beta'} |
||||
|
# Set labeling of choices |
||||
|
for label in choice_labels: |
||||
|
choice_labeling.add_label(label) |
||||
|
choice_labeling.add_label_to_choice('alpha', 0) |
||||
|
choice_labeling.add_label_to_choice('beta', 1) |
||||
|
|
||||
|
exit_rates = [0.0, 10.0, 12.0, 1.0, 1.0] |
||||
|
|
||||
|
markovian_states = stormpy.BitVector(5, [1, 2, 3, 4]) |
||||
|
|
||||
|
# Collect components |
||||
|
components = stormpy.SparseModelComponents(transition_matrix=transition_matrix, state_labeling=state_labeling, |
||||
|
markovian_states=markovian_states) |
||||
|
components.choice_labeling = choice_labeling |
||||
|
components.exit_rates = exit_rates |
||||
|
|
||||
|
# Build the model |
||||
|
ma = stormpy.storage.SparseMA(components) |
||||
|
print(ma) |
||||
|
|
||||
|
|
||||
if __name__ == '__main__': |
if __name__ == '__main__': |
||||
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue