moves-rwth / stormvogel

Storm for almost everyone
2 stars 0 forks source link

Unable to transform model with deleted states into stormpy model #94

Closed lukovdm closed 1 month ago

lukovdm commented 2 months ago

I have created a model and afterwards deleted states from that model. Thus, the ids of my states are no longer continuous. Now when I try to convert this model into a stormpy model I get the following exception:

Exception has occurred: RuntimeError       (note: full exception trace is shown but execution is paused at: <module>)
OutOfRangeException: Item index out of range.
  File "/home/luko/Documents/MDP-product/env/lib/python3.11/site-packages/stormvogel/mapping.py", line 66, in add_labels
    state_labeling.add_label_to_state(label, state[0])
  File "/home/luko/Documents/MDP-product/env/lib/python3.11/site-packages/stormvogel/mapping.py", line 200, in map_pomdp
    state_labeling = add_labels(model)
                     ^^^^^^^^^^^^^^^^^
  File "/home/luko/Documents/MDP-product/env/lib/python3.11/site-packages/stormvogel/mapping.py", line 283, in stormvogel_to_stormpy
    return map_pomdp(model)
           ^^^^^^^^^^^^^^^^
  File "/tmp/ipykernel_142866/3029802077.py", line 1, in <module> (Current frame)
    storm_pomdp = stormvogel_to_stormpy(pomdp)

As far as I can see, the error occurs because the state labelling is initialized with the amount of states:

state_labeling = stormpy.storage.StateLabeling(len(model.states))

But it uses the non-continuous ids to add labels to the states in the state labelling:

for state in model.states:
    for label in state[1]:
        state_labeling.add_label_to_state(label, state[0])