Interactive version: Binder badge.

Working with Schedulers

In non-deterministic models the notion of a scheduler (or policy) is important. The scheduler determines which action to take at each state.

For a given reachability property, Storm can return the scheduler realizing the resulting probability.

Examining Schedulers for MDPs

01-schedulers.py

As in Getting Started, we import some required modules and build a model from the example files:

[1]:
import stormpy
import stormpy.examples
import stormpy.examples.files

path = stormpy.examples.files.prism_mdp_coin_2_2
formula_str = 'Pmin=? [F "finished" & "all_coins_equal_1"]'
program = stormpy.parse_prism_program(path)
formulas = stormpy.parse_properties(formula_str, program)
options = stormpy.BuilderOptions(True, True)
options.set_build_state_valuations()
options.set_build_choice_labels()
options.set_build_with_choice_origins()
model = stormpy.build_sparse_model_with_options(program, options)

Next we check the model and make sure to extract the scheduler:

[2]:
result = stormpy.model_checking(model, formulas[0], extract_scheduler=True)

The result then contains the scheduler we want:

[3]:
assert result.has_scheduler
scheduler = result.scheduler
assert scheduler.memoryless
assert scheduler.deterministic
print(scheduler)
___________________________________________________________________
Fully defined memoryless deterministic scheduler:
model state:    choice(s)
           0    0
           1    0
           2    1
           3    0
           4    0
           5    0
           6    0
           7    0
           8    0
           9    1
          10    0
          11    0
          12    0
          13    0
          14    0
          15    0
          16    0
          17    0
          18    0
          19    0
          20    0
          21    1
          22    1
          23    0
          24    1
          25    0
          26    0
          27    0
          28    0
          29    0
          30    1
          31    0
          32    0
          33    0
          34    0
          35    0
          36    0
          37    1
          38    1
          39    0
          40    0
          41    0
          42    0
          43    0
          44    0
          45    1
          46    0
          47    0
          48    0
          49    0
          50    0
          51    0
          52    0
          53    1
          54    0
          55    1
          56    1
          57    0
          58    0
          59    0
          60    0
          61    1
          62    0
          63    1
          64    0
          65    0
          66    0
          67    0
          68    0
          69    1
          70    1
          71    0
          72    0
          73    0
          74    0
          75    0
          76    0
          77    1
          78    0
          79    0
          80    0
          81    0
          82    0
          83    1
          84    0
          85    0
          86    0
          87    0
          88    0
          89    0
          90    1
          91    1
          92    0
          93    0
          94    0
          95    1
          96    0
          97    1
          98    0
          99    0
         100    0
         101    1
         102    1
         103    0
         104    0
         105    0
         106    0
         107    0
         108    0
         109    1
         110    0
         111    0
         112    0
         113    0
         114    0
         115    0
         116    1
         117    1
         118    0
         119    0
         120    0
         121    0
         122    0
         123    0
         124    0
         125    0
         126    1
         127    0
         128    0
         129    0
         130    0
         131    1
         132    0
         133    0
         134    0
         135    0
         136    0
         137    0
         138    0
         139    0
         140    0
         141    0
         142    0
         143    0
         144    0
         145    0
         146    0
         147    0
         148    0
         149    0
         150    0
         151    0
         152    0
         153    0
         154    0
         155    0
         156    0
         157    0
         158    0
         159    0
         160    0
         161    0
         162    0
         163    0
         164    0
         165    0
         166    0
         167    0
         168    0
         169    0
         170    0
         171    0
         172    0
         173    0
         174    0
         175    0
         176    0
         177    0
         178    0
         179    0
         180    0
         181    0
         182    0
         183    0
         184    0
         185    0
         186    0
         187    0
         188    0
         189    0
         190    0
         191    0
         192    0
         193    0
         194    0
         195    0
         196    0
         197    0
         198    0
         199    0
         200    0
         201    0
         202    0
         203    0
         204    0
         205    0
         206    0
         207    0
         208    0
         209    0
         210    0
         211    0
         212    0
         213    0
         214    0
         215    0
         216    0
         217    0
         218    0
         219    0
         220    0
         221    0
         222    0
         223    0
         224    0
         225    0
         226    0
         227    0
         228    0
         229    0
         230    0
         231    0
         232    0
         233    0
         234    0
         235    0
         236    0
         237    0
         238    0
         239    0
         240    0
         241    0
         242    0
         243    0
         244    0
         245    0
         246    0
         247    0
         248    0
         249    0
         250    0
         251    0
         252    0
         253    0
         254    0
         255    0
         256    0
         257    0
         258    0
         259    0
         260    0
         261    0
         262    0
         263    0
         264    0
         265    0
         266    0
         267    0
         268    0
         269    0
         270    0
         271    0
___________________________________________________________________

To get the information which action the scheduler chooses in which state, we can simply iterate over the states:

[4]:
for state in model.states:
    choice = scheduler.get_choice(state)
    action_index = choice.get_deterministic_choice()
    action = state.actions[action_index]
    print("In state {} ({}) choose action {} ({})".format(state, ", ".join(state.labels), action, ", ".join(action.labels)))
    print(state.valuations)
In state 0 (all_coins_equal_0, agree, init) choose action 0 ()
[counter=6      & pc1=0     & coin1=0   & pc2=0     & coin2=0]
In state 1 (all_coins_equal_0, agree) choose action 0 ()
[counter=6      & pc1=1     & coin1=0   & pc2=0     & coin2=0]
In state 2 () choose action 1 ()
[counter=6      & pc1=1     & coin1=1   & pc2=0     & coin2=0]
In state 3 (all_coins_equal_0, agree) choose action 0 ()
[counter=6      & pc1=0     & coin1=0   & pc2=1     & coin2=0]
In state 4 () choose action 0 ()
[counter=6      & pc1=0     & coin1=0   & pc2=1     & coin2=1]
In state 5 (all_coins_equal_0, agree) choose action 0 ()
[counter=5      & pc1=2     & coin1=0   & pc2=0     & coin2=0]
In state 6 (all_coins_equal_0, agree) choose action 0 ()
[counter=6      & pc1=1     & coin1=0   & pc2=1     & coin2=0]
In state 7 () choose action 0 ()
[counter=6      & pc1=1     & coin1=0   & pc2=1     & coin2=1]
In state 8 (all_coins_equal_0, agree) choose action 0 ()
[counter=7      & pc1=2     & coin1=0   & pc2=0     & coin2=0]
In state 9 () choose action 1 ()
[counter=6      & pc1=1     & coin1=1   & pc2=1     & coin2=0]
In state 10 (agree, all_coins_equal_1) choose action 0 ()
[counter=6      & pc1=1     & coin1=1   & pc2=1     & coin2=1]
In state 11 (all_coins_equal_0, agree) choose action 0 ()
[counter=5      & pc1=0     & coin1=0   & pc2=2     & coin2=0]
In state 12 (all_coins_equal_0, agree) choose action 0 ()
[counter=7      & pc1=0     & coin1=0   & pc2=2     & coin2=0]
In state 13 (all_coins_equal_0, agree) choose action 0 ()
[counter=5      & pc1=0     & coin1=0   & pc2=0     & coin2=0]
In state 14 (all_coins_equal_0, agree) choose action 0 ()
[counter=5      & pc1=2     & coin1=0   & pc2=1     & coin2=0]
In state 15 () choose action 0 ()
[counter=5      & pc1=2     & coin1=0   & pc2=1     & coin2=1]
In state 16 (all_coins_equal_0, agree) choose action 0 ()
[counter=5      & pc1=1     & coin1=0   & pc2=2     & coin2=0]
In state 17 (all_coins_equal_0, agree) choose action 0 ()
[counter=7      & pc1=1     & coin1=0   & pc2=2     & coin2=0]
In state 18 (all_coins_equal_0, agree) choose action 0 ()
[counter=7      & pc1=0     & coin1=0   & pc2=0     & coin2=0]
In state 19 (all_coins_equal_0, agree) choose action 0 ()
[counter=7      & pc1=2     & coin1=0   & pc2=1     & coin2=0]
In state 20 () choose action 0 ()
[counter=7      & pc1=2     & coin1=0   & pc2=1     & coin2=1]
In state 21 () choose action 1 ()
[counter=5      & pc1=1     & coin1=1   & pc2=2     & coin2=0]
In state 22 () choose action 1 ()
[counter=7      & pc1=1     & coin1=1   & pc2=2     & coin2=0]
In state 23 (all_coins_equal_0, agree) choose action 0 ()
[counter=5      & pc1=1     & coin1=0   & pc2=0     & coin2=0]
In state 24 () choose action 1 ()
[counter=5      & pc1=1     & coin1=1   & pc2=0     & coin2=0]
In state 25 (all_coins_equal_0, agree) choose action 0 ()
[counter=5      & pc1=0     & coin1=0   & pc2=1     & coin2=0]
In state 26 () choose action 0 ()
[counter=5      & pc1=0     & coin1=0   & pc2=1     & coin2=1]
In state 27 (all_coins_equal_0, agree) choose action 0 ()
[counter=4      & pc1=2     & coin1=0   & pc2=2     & coin2=0]
In state 28 (all_coins_equal_0, agree) choose action 0 ()
[counter=6      & pc1=2     & coin1=0   & pc2=2     & coin2=0]
In state 29 (all_coins_equal_0, agree) choose action 0 ()
[counter=7      & pc1=1     & coin1=0   & pc2=0     & coin2=0]
In state 30 () choose action 1 ()
[counter=7      & pc1=1     & coin1=1   & pc2=0     & coin2=0]
In state 31 (all_coins_equal_0, agree) choose action 0 ()
[counter=7      & pc1=0     & coin1=0   & pc2=1     & coin2=0]
In state 32 () choose action 0 ()
[counter=7      & pc1=0     & coin1=0   & pc2=1     & coin2=1]
In state 33 (all_coins_equal_0, agree) choose action 0 ()
[counter=8      & pc1=2     & coin1=0   & pc2=2     & coin2=0]
In state 34 (all_coins_equal_0, agree) choose action 0 ()
[counter=4      & pc1=2     & coin1=0   & pc2=0     & coin2=0]
In state 35 (all_coins_equal_0, agree) choose action 0 ()
[counter=5      & pc1=1     & coin1=0   & pc2=1     & coin2=0]
In state 36 () choose action 0 ()
[counter=5      & pc1=1     & coin1=0   & pc2=1     & coin2=1]
In state 37 (all_coins_equal_0, agree) choose action 1 ()
[counter=6      & pc1=2     & coin1=0   & pc2=0     & coin2=0]
In state 38 () choose action 1 ()
[counter=5      & pc1=1     & coin1=1   & pc2=1     & coin2=0]
In state 39 (agree, all_coins_equal_1) choose action 0 ()
[counter=5      & pc1=1     & coin1=1   & pc2=1     & coin2=1]
In state 40 (all_coins_equal_0, agree) choose action 0 ()
[counter=4      & pc1=0     & coin1=0   & pc2=2     & coin2=0]
In state 41 (all_coins_equal_0, agree) choose action 0 ()
[counter=6      & pc1=0     & coin1=0   & pc2=2     & coin2=0]
In state 42 (all_coins_equal_0, agree) choose action 0 ()
[counter=7      & pc1=1     & coin1=0   & pc2=1     & coin2=0]
In state 43 () choose action 0 ()
[counter=7      & pc1=1     & coin1=0   & pc2=1     & coin2=1]
In state 44 (all_coins_equal_0, agree) choose action 0 ()
[counter=8      & pc1=2     & coin1=0   & pc2=0     & coin2=0]
In state 45 () choose action 1 ()
[counter=7      & pc1=1     & coin1=1   & pc2=1     & coin2=0]
In state 46 (agree, all_coins_equal_1) choose action 0 ()
[counter=7      & pc1=1     & coin1=1   & pc2=1     & coin2=1]
In state 47 (all_coins_equal_0, agree) choose action 0 ()
[counter=8      & pc1=0     & coin1=0   & pc2=2     & coin2=0]
In state 48 (all_coins_equal_0, agree) choose action 0 ()
[counter=4      & pc1=0     & coin1=0   & pc2=0     & coin2=0]
In state 49 (all_coins_equal_0, agree) choose action 0 ()
[counter=4      & pc1=2     & coin1=0   & pc2=1     & coin2=0]
In state 50 () choose action 0 ()
[counter=4      & pc1=2     & coin1=0   & pc2=1     & coin2=1]
In state 51 (all_coins_equal_0, agree) choose action 0 ()
[counter=4      & pc1=1     & coin1=0   & pc2=2     & coin2=0]
In state 52 (all_coins_equal_0, agree) choose action 0 ()
[counter=6      & pc1=1     & coin1=0   & pc2=2     & coin2=0]
In state 53 (all_coins_equal_0, agree) choose action 1 ()
[counter=6      & pc1=2     & coin1=0   & pc2=1     & coin2=0]
In state 54 () choose action 0 ()
[counter=6      & pc1=2     & coin1=0   & pc2=1     & coin2=1]
In state 55 () choose action 1 ()
[counter=4      & pc1=1     & coin1=1   & pc2=2     & coin2=0]
In state 56 () choose action 1 ()
[counter=6      & pc1=1     & coin1=1   & pc2=2     & coin2=0]
In state 57 (all_coins_equal_0, agree) choose action 0 ()
[counter=8      & pc1=1     & coin1=0   & pc2=2     & coin2=0]
In state 58 (all_coins_equal_0, agree) choose action 0 ()
[counter=8      & pc1=0     & coin1=0   & pc2=0     & coin2=0]
In state 59 (all_coins_equal_0, agree) choose action 0 ()
[counter=8      & pc1=2     & coin1=0   & pc2=1     & coin2=0]
In state 60 () choose action 0 ()
[counter=8      & pc1=2     & coin1=0   & pc2=1     & coin2=1]
In state 61 () choose action 1 ()
[counter=8      & pc1=1     & coin1=1   & pc2=2     & coin2=0]
In state 62 (all_coins_equal_0, agree) choose action 0 ()
[counter=4      & pc1=1     & coin1=0   & pc2=0     & coin2=0]
In state 63 () choose action 1 ()
[counter=4      & pc1=1     & coin1=1   & pc2=0     & coin2=0]
In state 64 (all_coins_equal_0, agree) choose action 0 ()
[counter=4      & pc1=0     & coin1=0   & pc2=1     & coin2=0]
In state 65 () choose action 0 ()
[counter=4      & pc1=0     & coin1=0   & pc2=1     & coin2=1]
In state 66 (all_coins_equal_0, agree) choose action 0 ()
[counter=3      & pc1=2     & coin1=0   & pc2=2     & coin2=0]
In state 67 (all_coins_equal_0, agree) choose action 0 ()
[counter=5      & pc1=2     & coin1=0   & pc2=2     & coin2=0]
In state 68 (all_coins_equal_0, agree) choose action 0 ()
[counter=7      & pc1=2     & coin1=0   & pc2=2     & coin2=0]
In state 69 (all_coins_equal_0, agree) choose action 1 ()
[counter=8      & pc1=1     & coin1=0   & pc2=0     & coin2=0]
In state 70 () choose action 1 ()
[counter=8      & pc1=1     & coin1=1   & pc2=0     & coin2=0]
In state 71 (all_coins_equal_0, agree) choose action 0 ()
[counter=8      & pc1=0     & coin1=0   & pc2=1     & coin2=0]
In state 72 () choose action 0 ()
[counter=8      & pc1=0     & coin1=0   & pc2=1     & coin2=1]
In state 73 (all_coins_equal_0, agree) choose action 0 ()
[counter=9      & pc1=2     & coin1=0   & pc2=2     & coin2=0]
In state 74 (all_coins_equal_0, agree) choose action 0 ()
[counter=3      & pc1=2     & coin1=0   & pc2=0     & coin2=0]
In state 75 (all_coins_equal_0, agree) choose action 0 ()
[counter=4      & pc1=1     & coin1=0   & pc2=1     & coin2=0]
In state 76 () choose action 0 ()
[counter=4      & pc1=1     & coin1=0   & pc2=1     & coin2=1]
In state 77 () choose action 1 ()
[counter=4      & pc1=1     & coin1=1   & pc2=1     & coin2=0]
In state 78 (agree, all_coins_equal_1) choose action 0 ()
[counter=4      & pc1=1     & coin1=1   & pc2=1     & coin2=1]
In state 79 (all_coins_equal_0, agree) choose action 0 ()
[counter=3      & pc1=0     & coin1=0   & pc2=2     & coin2=0]
In state 80 (all_coins_equal_0, agree) choose action 0 ()
[counter=8      & pc1=1     & coin1=0   & pc2=1     & coin2=0]
In state 81 () choose action 0 ()
[counter=8      & pc1=1     & coin1=0   & pc2=1     & coin2=1]
In state 82 (all_coins_equal_0, agree) choose action 0 ()
[counter=9      & pc1=2     & coin1=0   & pc2=0     & coin2=0]
In state 83 () choose action 1 ()
[counter=8      & pc1=1     & coin1=1   & pc2=1     & coin2=0]
In state 84 (agree, all_coins_equal_1) choose action 0 ()
[counter=8      & pc1=1     & coin1=1   & pc2=1     & coin2=1]
In state 85 (all_coins_equal_0, agree) choose action 0 ()
[counter=9      & pc1=0     & coin1=0   & pc2=2     & coin2=0]
In state 86 (all_coins_equal_0, agree) choose action 0 ()
[counter=3      & pc1=0     & coin1=0   & pc2=0     & coin2=0]
In state 87 (all_coins_equal_0, agree) choose action 0 ()
[counter=3      & pc1=2     & coin1=0   & pc2=1     & coin2=0]
In state 88 () choose action 0 ()
[counter=3      & pc1=2     & coin1=0   & pc2=1     & coin2=1]
In state 89 (all_coins_equal_0, agree) choose action 0 ()
[counter=3      & pc1=1     & coin1=0   & pc2=2     & coin2=0]
In state 90 () choose action 1 ()
[counter=3      & pc1=1     & coin1=1   & pc2=2     & coin2=0]
In state 91 (all_coins_equal_0, agree) choose action 1 ()
[counter=9      & pc1=1     & coin1=0   & pc2=2     & coin2=0]
In state 92 (all_coins_equal_0, agree) choose action 0 ()
[counter=9      & pc1=0     & coin1=0   & pc2=0     & coin2=0]
In state 93 (all_coins_equal_0, agree) choose action 0 ()
[counter=9      & pc1=2     & coin1=0   & pc2=1     & coin2=0]
In state 94 () choose action 0 ()
[counter=9      & pc1=2     & coin1=0   & pc2=1     & coin2=1]
In state 95 () choose action 1 ()
[counter=9      & pc1=1     & coin1=1   & pc2=2     & coin2=0]
In state 96 (all_coins_equal_0, agree) choose action 0 ()
[counter=3      & pc1=1     & coin1=0   & pc2=0     & coin2=0]
In state 97 () choose action 1 ()
[counter=3      & pc1=1     & coin1=1   & pc2=0     & coin2=0]
In state 98 (all_coins_equal_0, agree) choose action 0 ()
[counter=3      & pc1=0     & coin1=0   & pc2=1     & coin2=0]
In state 99 () choose action 0 ()
[counter=3      & pc1=0     & coin1=0   & pc2=1     & coin2=1]
In state 100 (all_coins_equal_0, agree) choose action 0 ()
[counter=2      & pc1=2     & coin1=0   & pc2=2     & coin2=0]
In state 101 (all_coins_equal_0, agree) choose action 1 ()
[counter=9      & pc1=1     & coin1=0   & pc2=0     & coin2=0]
In state 102 () choose action 1 ()
[counter=9      & pc1=1     & coin1=1   & pc2=0     & coin2=0]
In state 103 (all_coins_equal_0, agree) choose action 0 ()
[counter=9      & pc1=0     & coin1=0   & pc2=1     & coin2=0]
In state 104 () choose action 0 ()
[counter=9      & pc1=0     & coin1=0   & pc2=1     & coin2=1]
In state 105 (all_coins_equal_0, agree) choose action 0 ()
[counter=10     & pc1=2     & coin1=0   & pc2=2     & coin2=0]
In state 106 (all_coins_equal_0, agree) choose action 0 ()
[counter=2      & pc1=2     & coin1=0   & pc2=0     & coin2=0]
In state 107 (all_coins_equal_0, agree) choose action 0 ()
[counter=3      & pc1=1     & coin1=0   & pc2=1     & coin2=0]
In state 108 () choose action 0 ()
[counter=3      & pc1=1     & coin1=0   & pc2=1     & coin2=1]
In state 109 () choose action 1 ()
[counter=3      & pc1=1     & coin1=1   & pc2=1     & coin2=0]
In state 110 (agree, all_coins_equal_1) choose action 0 ()
[counter=3      & pc1=1     & coin1=1   & pc2=1     & coin2=1]
In state 111 (all_coins_equal_0, agree) choose action 0 ()
[counter=2      & pc1=0     & coin1=0   & pc2=2     & coin2=0]
In state 112 (all_coins_equal_0, agree) choose action 0 ()
[counter=2      & pc1=3     & coin1=0   & pc2=2     & coin2=0]
In state 113 (all_coins_equal_0, agree) choose action 0 ()
[counter=2      & pc1=2     & coin1=0   & pc2=3     & coin2=0]
In state 114 (all_coins_equal_0, agree) choose action 0 ()
[counter=9      & pc1=1     & coin1=0   & pc2=1     & coin2=0]
In state 115 () choose action 0 ()
[counter=9      & pc1=1     & coin1=0   & pc2=1     & coin2=1]
In state 116 (all_coins_equal_0, agree) choose action 1 ()
[counter=10     & pc1=2     & coin1=0   & pc2=0     & coin2=0]
In state 117 () choose action 1 ()
[counter=9      & pc1=1     & coin1=1   & pc2=1     & coin2=0]
In state 118 (agree, all_coins_equal_1) choose action 0 ()
[counter=9      & pc1=1     & coin1=1   & pc2=1     & coin2=1]
In state 119 (all_coins_equal_0, agree) choose action 0 ()
[counter=10     & pc1=0     & coin1=0   & pc2=2     & coin2=0]
In state 120 () choose action 0 ()
[counter=10     & pc1=3     & coin1=1   & pc2=2     & coin2=0]
In state 121 () choose action 0 ()
[counter=10     & pc1=2     & coin1=0   & pc2=3     & coin2=1]
In state 122 (all_coins_equal_0, agree) choose action 0 ()
[counter=2      & pc1=3     & coin1=0   & pc2=0     & coin2=0]
In state 123 (all_coins_equal_0, agree) choose action 0 ()
[counter=2      & pc1=2     & coin1=0   & pc2=1     & coin2=0]
In state 124 () choose action 0 ()
[counter=2      & pc1=2     & coin1=0   & pc2=1     & coin2=1]
In state 125 (all_coins_equal_0, agree) choose action 0 ()
[counter=2      & pc1=1     & coin1=0   & pc2=2     & coin2=0]
In state 126 () choose action 1 ()
[counter=2      & pc1=1     & coin1=1   & pc2=2     & coin2=0]
In state 127 (all_coins_equal_0, agree) choose action 0 ()
[counter=2      & pc1=0     & coin1=0   & pc2=3     & coin2=0]
In state 128 (all_coins_equal_0, agree, finished) choose action 0 (done)
[counter=2      & pc1=3     & coin1=0   & pc2=3     & coin2=0]
In state 129 (all_coins_equal_0, agree) choose action 0 ()
[counter=10     & pc1=1     & coin1=0   & pc2=2     & coin2=0]
In state 130 () choose action 0 ()
[counter=10     & pc1=3     & coin1=1   & pc2=0     & coin2=0]
In state 131 (all_coins_equal_0, agree) choose action 1 ()
[counter=10     & pc1=2     & coin1=0   & pc2=1     & coin2=0]
In state 132 () choose action 0 ()
[counter=10     & pc1=2     & coin1=0   & pc2=1     & coin2=1]
In state 133 () choose action 0 ()
[counter=10     & pc1=1     & coin1=1   & pc2=2     & coin2=0]
In state 134 () choose action 0 ()
[counter=10     & pc1=0     & coin1=0   & pc2=3     & coin2=1]
In state 135 (finished, agree, all_coins_equal_1) choose action 0 (done)
[counter=10     & pc1=3     & coin1=1   & pc2=3     & coin2=1]
In state 136 (all_coins_equal_0, agree) choose action 0 ()
[counter=2      & pc1=3     & coin1=0   & pc2=1     & coin2=0]
In state 137 () choose action 0 ()
[counter=2      & pc1=3     & coin1=0   & pc2=1     & coin2=1]
In state 138 (all_coins_equal_0, agree) choose action 0 ()
[counter=1      & pc1=2     & coin1=0   & pc2=2     & coin2=0]
In state 139 (all_coins_equal_0, agree) choose action 0 ()
[counter=2      & pc1=1     & coin1=0   & pc2=3     & coin2=0]
In state 140 () choose action 0 ()
[counter=2      & pc1=1     & coin1=1   & pc2=3     & coin2=0]
In state 141 () choose action 0 ()
[counter=10     & pc1=1     & coin1=0   & pc2=3     & coin2=1]
In state 142 () choose action 0 ()
[counter=10     & pc1=3     & coin1=1   & pc2=1     & coin2=0]
In state 143 (agree, all_coins_equal_1) choose action 0 ()
[counter=10     & pc1=3     & coin1=1   & pc2=1     & coin2=1]
In state 144 (all_coins_equal_0, agree) choose action 0 ()
[counter=11     & pc1=2     & coin1=0   & pc2=2     & coin2=0]
In state 145 (agree, all_coins_equal_1) choose action 0 ()
[counter=10     & pc1=1     & coin1=1   & pc2=3     & coin2=1]
In state 146 (all_coins_equal_0, agree) choose action 0 ()
[counter=1      & pc1=3     & coin1=0   & pc2=2     & coin2=0]
In state 147 (all_coins_equal_0, agree) choose action 0 ()
[counter=3      & pc1=3     & coin1=0   & pc2=2     & coin2=0]
In state 148 (all_coins_equal_0, agree) choose action 0 ()
[counter=1      & pc1=2     & coin1=0   & pc2=3     & coin2=0]
In state 149 (all_coins_equal_0, agree) choose action 0 ()
[counter=3      & pc1=2     & coin1=0   & pc2=3     & coin2=0]
In state 150 () choose action 0 ()
[counter=9      & pc1=2     & coin1=0   & pc2=3     & coin2=1]
In state 151 () choose action 0 ()
[counter=9      & pc1=3     & coin1=1   & pc2=2     & coin2=0]
In state 152 () choose action 0 ()
[counter=11     & pc1=3     & coin1=1   & pc2=2     & coin2=0]
In state 153 () choose action 0 ()
[counter=11     & pc1=2     & coin1=0   & pc2=3     & coin2=1]
In state 154 (all_coins_equal_0, agree, finished) choose action 0 (done)
[counter=1      & pc1=3     & coin1=0   & pc2=3     & coin2=0]
In state 155 (all_coins_equal_0, agree) choose action 0 ()
[counter=3      & pc1=3     & coin1=0   & pc2=0     & coin2=0]
In state 156 (all_coins_equal_0, agree) choose action 0 ()
[counter=3      & pc1=0     & coin1=0   & pc2=3     & coin2=0]
In state 157 () choose action 0 ()
[counter=9      & pc1=0     & coin1=0   & pc2=3     & coin2=1]
In state 158 () choose action 0 ()
[counter=9      & pc1=3     & coin1=1   & pc2=0     & coin2=0]
In state 159 (finished, agree, all_coins_equal_1) choose action 0 (done)
[counter=11     & pc1=3     & coin1=1   & pc2=3     & coin2=1]
In state 160 (all_coins_equal_0, agree) choose action 0 ()
[counter=3      & pc1=3     & coin1=0   & pc2=1     & coin2=0]
In state 161 () choose action 0 ()
[counter=3      & pc1=3     & coin1=0   & pc2=1     & coin2=1]
In state 162 (all_coins_equal_0, agree) choose action 0 ()
[counter=3      & pc1=1     & coin1=0   & pc2=3     & coin2=0]
In state 163 () choose action 0 ()
[counter=3      & pc1=1     & coin1=1   & pc2=3     & coin2=0]
In state 164 () choose action 0 ()
[counter=9      & pc1=1     & coin1=0   & pc2=3     & coin2=1]
In state 165 (agree, all_coins_equal_1) choose action 0 ()
[counter=9      & pc1=1     & coin1=1   & pc2=3     & coin2=1]
In state 166 () choose action 0 ()
[counter=9      & pc1=3     & coin1=1   & pc2=1     & coin2=0]
In state 167 (agree, all_coins_equal_1) choose action 0 ()
[counter=9      & pc1=3     & coin1=1   & pc2=1     & coin2=1]
In state 168 (all_coins_equal_0, agree) choose action 0 ()
[counter=4      & pc1=3     & coin1=0   & pc2=2     & coin2=0]
In state 169 (all_coins_equal_0, agree) choose action 0 ()
[counter=4      & pc1=2     & coin1=0   & pc2=3     & coin2=0]
In state 170 () choose action 0 ()
[counter=8      & pc1=2     & coin1=0   & pc2=3     & coin2=1]
In state 171 () choose action 0 ()
[counter=8      & pc1=3     & coin1=1   & pc2=2     & coin2=0]
In state 172 (all_coins_equal_0, agree) choose action 0 ()
[counter=4      & pc1=3     & coin1=0   & pc2=0     & coin2=0]
In state 173 (all_coins_equal_0, agree) choose action 0 ()
[counter=4      & pc1=0     & coin1=0   & pc2=3     & coin2=0]
In state 174 () choose action 0 ()
[counter=8      & pc1=0     & coin1=0   & pc2=3     & coin2=1]
In state 175 () choose action 0 ()
[counter=8      & pc1=3     & coin1=1   & pc2=0     & coin2=0]
In state 176 (all_coins_equal_0, agree) choose action 0 ()
[counter=4      & pc1=3     & coin1=0   & pc2=1     & coin2=0]
In state 177 () choose action 0 ()
[counter=4      & pc1=3     & coin1=0   & pc2=1     & coin2=1]
In state 178 (all_coins_equal_0, agree) choose action 0 ()
[counter=4      & pc1=1     & coin1=0   & pc2=3     & coin2=0]
In state 179 () choose action 0 ()
[counter=4      & pc1=1     & coin1=1   & pc2=3     & coin2=0]
In state 180 () choose action 0 ()
[counter=8      & pc1=1     & coin1=0   & pc2=3     & coin2=1]
In state 181 (agree, all_coins_equal_1) choose action 0 ()
[counter=8      & pc1=1     & coin1=1   & pc2=3     & coin2=1]
In state 182 () choose action 0 ()
[counter=8      & pc1=3     & coin1=1   & pc2=1     & coin2=0]
In state 183 (agree, all_coins_equal_1) choose action 0 ()
[counter=8      & pc1=3     & coin1=1   & pc2=1     & coin2=1]
In state 184 (all_coins_equal_0, agree) choose action 0 ()
[counter=5      & pc1=3     & coin1=0   & pc2=2     & coin2=0]
In state 185 (all_coins_equal_0, agree) choose action 0 ()
[counter=5      & pc1=2     & coin1=0   & pc2=3     & coin2=0]
In state 186 () choose action 0 ()
[counter=7      & pc1=2     & coin1=0   & pc2=3     & coin2=1]
In state 187 () choose action 0 ()
[counter=7      & pc1=3     & coin1=1   & pc2=2     & coin2=0]
In state 188 (all_coins_equal_0, agree) choose action 0 ()
[counter=5      & pc1=3     & coin1=0   & pc2=0     & coin2=0]
In state 189 (all_coins_equal_0, agree) choose action 0 ()
[counter=5      & pc1=0     & coin1=0   & pc2=3     & coin2=0]
In state 190 () choose action 0 ()
[counter=7      & pc1=0     & coin1=0   & pc2=3     & coin2=1]
In state 191 () choose action 0 ()
[counter=7      & pc1=3     & coin1=1   & pc2=0     & coin2=0]
In state 192 (all_coins_equal_0, agree) choose action 0 ()
[counter=5      & pc1=3     & coin1=0   & pc2=1     & coin2=0]
In state 193 () choose action 0 ()
[counter=5      & pc1=3     & coin1=0   & pc2=1     & coin2=1]
In state 194 (all_coins_equal_0, agree) choose action 0 ()
[counter=5      & pc1=1     & coin1=0   & pc2=3     & coin2=0]
In state 195 () choose action 0 ()
[counter=5      & pc1=1     & coin1=1   & pc2=3     & coin2=0]
In state 196 () choose action 0 ()
[counter=7      & pc1=1     & coin1=0   & pc2=3     & coin2=1]
In state 197 (agree, all_coins_equal_1) choose action 0 ()
[counter=7      & pc1=1     & coin1=1   & pc2=3     & coin2=1]
In state 198 () choose action 0 ()
[counter=7      & pc1=3     & coin1=1   & pc2=1     & coin2=0]
In state 199 (agree, all_coins_equal_1) choose action 0 ()
[counter=7      & pc1=3     & coin1=1   & pc2=1     & coin2=1]
In state 200 (all_coins_equal_0, agree) choose action 0 ()
[counter=6      & pc1=3     & coin1=0   & pc2=2     & coin2=0]
In state 201 (all_coins_equal_0, agree) choose action 0 ()
[counter=6      & pc1=2     & coin1=0   & pc2=3     & coin2=0]
In state 202 () choose action 0 ()
[counter=6      & pc1=2     & coin1=0   & pc2=3     & coin2=1]
In state 203 () choose action 0 ()
[counter=6      & pc1=3     & coin1=1   & pc2=2     & coin2=0]
In state 204 (all_coins_equal_0, agree) choose action 0 ()
[counter=6      & pc1=3     & coin1=0   & pc2=0     & coin2=0]
In state 205 (all_coins_equal_0, agree) choose action 0 ()
[counter=6      & pc1=0     & coin1=0   & pc2=3     & coin2=0]
In state 206 () choose action 0 ()
[counter=6      & pc1=0     & coin1=0   & pc2=3     & coin2=1]
In state 207 () choose action 0 ()
[counter=6      & pc1=3     & coin1=1   & pc2=0     & coin2=0]
In state 208 (all_coins_equal_0, agree) choose action 0 ()
[counter=6      & pc1=3     & coin1=0   & pc2=1     & coin2=0]
In state 209 () choose action 0 ()
[counter=6      & pc1=3     & coin1=0   & pc2=1     & coin2=1]
In state 210 (all_coins_equal_0, agree) choose action 0 ()
[counter=6      & pc1=1     & coin1=0   & pc2=3     & coin2=0]
In state 211 () choose action 0 ()
[counter=6      & pc1=1     & coin1=1   & pc2=3     & coin2=0]
In state 212 () choose action 0 ()
[counter=6      & pc1=1     & coin1=0   & pc2=3     & coin2=1]
In state 213 (agree, all_coins_equal_1) choose action 0 ()
[counter=6      & pc1=1     & coin1=1   & pc2=3     & coin2=1]
In state 214 () choose action 0 ()
[counter=6      & pc1=3     & coin1=1   & pc2=1     & coin2=0]
In state 215 (agree, all_coins_equal_1) choose action 0 ()
[counter=6      & pc1=3     & coin1=1   & pc2=1     & coin2=1]
In state 216 (all_coins_equal_0, agree) choose action 0 ()
[counter=7      & pc1=3     & coin1=0   & pc2=2     & coin2=0]
In state 217 (all_coins_equal_0, agree) choose action 0 ()
[counter=7      & pc1=2     & coin1=0   & pc2=3     & coin2=0]
In state 218 () choose action 0 ()
[counter=5      & pc1=2     & coin1=0   & pc2=3     & coin2=1]
In state 219 () choose action 0 ()
[counter=5      & pc1=3     & coin1=1   & pc2=2     & coin2=0]
In state 220 (all_coins_equal_0, agree) choose action 0 ()
[counter=7      & pc1=3     & coin1=0   & pc2=0     & coin2=0]
In state 221 (all_coins_equal_0, agree) choose action 0 ()
[counter=7      & pc1=0     & coin1=0   & pc2=3     & coin2=0]
In state 222 () choose action 0 ()
[counter=5      & pc1=0     & coin1=0   & pc2=3     & coin2=1]
In state 223 () choose action 0 ()
[counter=5      & pc1=3     & coin1=1   & pc2=0     & coin2=0]
In state 224 (all_coins_equal_0, agree) choose action 0 ()
[counter=7      & pc1=3     & coin1=0   & pc2=1     & coin2=0]
In state 225 () choose action 0 ()
[counter=7      & pc1=3     & coin1=0   & pc2=1     & coin2=1]
In state 226 (all_coins_equal_0, agree) choose action 0 ()
[counter=7      & pc1=1     & coin1=0   & pc2=3     & coin2=0]
In state 227 () choose action 0 ()
[counter=7      & pc1=1     & coin1=1   & pc2=3     & coin2=0]
In state 228 () choose action 0 ()
[counter=5      & pc1=1     & coin1=0   & pc2=3     & coin2=1]
In state 229 (agree, all_coins_equal_1) choose action 0 ()
[counter=5      & pc1=1     & coin1=1   & pc2=3     & coin2=1]
In state 230 () choose action 0 ()
[counter=5      & pc1=3     & coin1=1   & pc2=1     & coin2=0]
In state 231 (agree, all_coins_equal_1) choose action 0 ()
[counter=5      & pc1=3     & coin1=1   & pc2=1     & coin2=1]
In state 232 (all_coins_equal_0, agree) choose action 0 ()
[counter=8      & pc1=3     & coin1=0   & pc2=2     & coin2=0]
In state 233 (all_coins_equal_0, agree) choose action 0 ()
[counter=8      & pc1=2     & coin1=0   & pc2=3     & coin2=0]
In state 234 () choose action 0 ()
[counter=4      & pc1=2     & coin1=0   & pc2=3     & coin2=1]
In state 235 () choose action 0 ()
[counter=4      & pc1=3     & coin1=1   & pc2=2     & coin2=0]
In state 236 (all_coins_equal_0, agree) choose action 0 ()
[counter=8      & pc1=3     & coin1=0   & pc2=0     & coin2=0]
In state 237 (all_coins_equal_0, agree) choose action 0 ()
[counter=8      & pc1=0     & coin1=0   & pc2=3     & coin2=0]
In state 238 () choose action 0 ()
[counter=4      & pc1=0     & coin1=0   & pc2=3     & coin2=1]
In state 239 () choose action 0 ()
[counter=4      & pc1=3     & coin1=1   & pc2=0     & coin2=0]
In state 240 (all_coins_equal_0, agree) choose action 0 ()
[counter=8      & pc1=3     & coin1=0   & pc2=1     & coin2=0]
In state 241 () choose action 0 ()
[counter=8      & pc1=3     & coin1=0   & pc2=1     & coin2=1]
In state 242 (all_coins_equal_0, agree) choose action 0 ()
[counter=8      & pc1=1     & coin1=0   & pc2=3     & coin2=0]
In state 243 () choose action 0 ()
[counter=8      & pc1=1     & coin1=1   & pc2=3     & coin2=0]
In state 244 () choose action 0 ()
[counter=4      & pc1=1     & coin1=0   & pc2=3     & coin2=1]
In state 245 (agree, all_coins_equal_1) choose action 0 ()
[counter=4      & pc1=1     & coin1=1   & pc2=3     & coin2=1]
In state 246 () choose action 0 ()
[counter=4      & pc1=3     & coin1=1   & pc2=1     & coin2=0]
In state 247 (agree, all_coins_equal_1) choose action 0 ()
[counter=4      & pc1=3     & coin1=1   & pc2=1     & coin2=1]
In state 248 (all_coins_equal_0, agree) choose action 0 ()
[counter=9      & pc1=3     & coin1=0   & pc2=2     & coin2=0]
In state 249 (all_coins_equal_0, agree) choose action 0 ()
[counter=9      & pc1=2     & coin1=0   & pc2=3     & coin2=0]
In state 250 () choose action 0 ()
[counter=3      & pc1=2     & coin1=0   & pc2=3     & coin2=1]
In state 251 () choose action 0 ()
[counter=3      & pc1=3     & coin1=1   & pc2=2     & coin2=0]
In state 252 (all_coins_equal_0, agree) choose action 0 ()
[counter=9      & pc1=3     & coin1=0   & pc2=0     & coin2=0]
In state 253 (all_coins_equal_0, agree) choose action 0 ()
[counter=9      & pc1=0     & coin1=0   & pc2=3     & coin2=0]
In state 254 () choose action 0 ()
[counter=3      & pc1=0     & coin1=0   & pc2=3     & coin2=1]
In state 255 () choose action 0 ()
[counter=3      & pc1=3     & coin1=1   & pc2=0     & coin2=0]
In state 256 (all_coins_equal_0, agree) choose action 0 ()
[counter=9      & pc1=3     & coin1=0   & pc2=1     & coin2=0]
In state 257 () choose action 0 ()
[counter=9      & pc1=3     & coin1=0   & pc2=1     & coin2=1]
In state 258 (all_coins_equal_0, agree) choose action 0 ()
[counter=9      & pc1=1     & coin1=0   & pc2=3     & coin2=0]
In state 259 () choose action 0 ()
[counter=9      & pc1=1     & coin1=1   & pc2=3     & coin2=0]
In state 260 () choose action 0 ()
[counter=3      & pc1=1     & coin1=0   & pc2=3     & coin2=1]
In state 261 (agree, all_coins_equal_1) choose action 0 ()
[counter=3      & pc1=1     & coin1=1   & pc2=3     & coin2=1]
In state 262 () choose action 0 ()
[counter=3      & pc1=3     & coin1=1   & pc2=1     & coin2=0]
In state 263 (agree, all_coins_equal_1) choose action 0 ()
[counter=3      & pc1=3     & coin1=1   & pc2=1     & coin2=1]
In state 264 (all_coins_equal_0, agree) choose action 0 ()
[counter=10     & pc1=3     & coin1=0   & pc2=2     & coin2=0]
In state 265 (all_coins_equal_0, agree) choose action 0 ()
[counter=10     & pc1=2     & coin1=0   & pc2=3     & coin2=0]
In state 266 () choose action 0 ()
[counter=2      & pc1=2     & coin1=0   & pc2=3     & coin2=1]
In state 267 () choose action 0 ()
[counter=2      & pc1=3     & coin1=1   & pc2=2     & coin2=0]
In state 268 (finished) choose action 0 (done)
[counter=10     & pc1=3     & coin1=0   & pc2=3     & coin2=1]
In state 269 (finished) choose action 0 (done)
[counter=10     & pc1=3     & coin1=1   & pc2=3     & coin2=0]
In state 270 (finished) choose action 0 (done)
[counter=2      & pc1=3     & coin1=0   & pc2=3     & coin2=1]
In state 271 (finished) choose action 0 (done)
[counter=2      & pc1=3     & coin1=1   & pc2=3     & coin2=0]

Examining Schedulers for Markov automata

02-schedulers.py

Currently there is no support yet for scheduler extraction on MAs. However, if the timing information is not relevant for the property, we can circumvent this lack by first transforming the MA to an MDP.

We build the model as before:

[5]:
path = stormpy.examples.files.prism_ma_simple
formula_str = "Tmin=? [ F s=4 ]"

program = stormpy.parse_prism_program(path, False, True)
formulas = stormpy.parse_properties_for_prism_program(formula_str, program)
ma = stormpy.build_model(program, formulas)

Next we transform the continuous-time model into a discrete-time model. Note that all timing information is lost at this point:

[6]:
mdp, mdp_formulas = stormpy.transform_to_discrete_time_model(ma, formulas)
assert mdp.model_type == stormpy.ModelType.MDP

After the transformation we have obtained an MDP where we can extract the scheduler as shown before:

[7]:
result = stormpy.model_checking(mdp, mdp_formulas[0], extract_scheduler=True)
scheduler = result.scheduler
print(scheduler)
___________________________________________________________________
Fully defined memoryless deterministic scheduler:
model state:    choice(s)
           0    1
           1    0
           2    0
           3    0
           4    0
___________________________________________________________________