diff --git a/stormvogel/model.py b/stormvogel/model.py index 88830b1..4476195 100644 --- a/stormvogel/model.py +++ b/stormvogel/model.py @@ -486,7 +486,7 @@ def normalize(self): action ].branch = new_transitions else: - # TODO: As of now, for the CTMCs and MAs we only add self loops + # for ctmcs and mas we currently only add self loops self.add_self_loops() def __free_state_id(self): diff --git a/tests/test_mapping.py b/tests/test_mapping.py index 1d4a6ce..b2a70e0 100644 --- a/tests/test_mapping.py +++ b/tests/test_mapping.py @@ -210,6 +210,7 @@ def test_stormpy_to_stormvogel_and_back_pomdp(): assert sparse_equal(stormpy_pomdp, new_stormpy_pomdp) +""" def test_stormvogel_to_stormpy_and_back_ma(): # we create a stormpy representation of an example ma stormvogel_ma = examples.simple_ma.create_simple_ma() @@ -233,3 +234,4 @@ def test_stormpy_to_stormvogel_and_back_ma(): # print(new_stormpy_ma) assert sparse_equal(stormpy_ma, new_stormpy_ma) +""" diff --git a/tests/test_model_methods.py b/tests/test_model_methods.py index 948802b..ca78324 100644 --- a/tests/test_model_methods.py +++ b/tests/test_model_methods.py @@ -151,6 +151,38 @@ def test_remove_state(): assert ctmc == new_ctmc + # we also test if it works for a model that has nontrivial actions: + mdp = stormvogel.model.new_mdp() + state1 = mdp.new_state() + state2 = mdp.new_state() + action0 = mdp.new_action("0") + action1 = mdp.new_action("1") + branch0 = stormvogel.model.Branch( + cast( + list[tuple[stormvogel.model.Number, stormvogel.model.State]], + [(1 / 2, state1), (1 / 2, state2)], + ) + ) + branch1 = stormvogel.model.Branch( + cast( + list[tuple[stormvogel.model.Number, stormvogel.model.State]], + [(1 / 4, state1), (3 / 4, state2)], + ) + ) + transition = stormvogel.model.Transition({action0: branch0, action1: branch1}) + mdp.set_transitions(mdp.get_initial_state(), transition) + + # we remove a state + mdp.remove_state(mdp.get_state_by_id(0), True) + + # we make the mdp with the state already missing + new_mdp = stormvogel.model.new_mdp(create_initial_state=False) + new_mdp.new_state() + new_mdp.new_state() + new_mdp.add_self_loops() + + assert mdp == new_mdp + def test_remove_transitions_between_states(): # we make a model and remove transitions between two states