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.

32 lines
1.2 KiB

2 months ago
  1. import stormpy
  2. import stormpy.core
  3. import stormpy.examples
  4. import stormpy.examples.files
  5. def example_reward_models_01():
  6. program = stormpy.parse_prism_program(stormpy.examples.files.prism_dtmc_die)
  7. prop = "R=? [F \"done\"]"
  8. properties = stormpy.parse_properties_for_prism_program(prop, program, None)
  9. model = stormpy.build_model(program, properties)
  10. assert len(model.reward_models) == 1
  11. initial_state = model.initial_states[0]
  12. result = stormpy.model_checking(model, properties[0])
  13. print("Result: {}".format(round(result.at(initial_state), 6)))
  14. reward_model_name = list(model.reward_models.keys())[0]
  15. print(reward_model_name)
  16. assert reward_model_name == "coin_flips"
  17. assert not model.reward_models[reward_model_name].has_state_rewards
  18. assert model.reward_models[reward_model_name].has_state_action_rewards
  19. for reward in model.reward_models[reward_model_name].state_action_rewards:
  20. print(reward)
  21. assert not model.reward_models[reward_model_name].has_transition_rewards
  22. model = stormpy.build_parametric_model_from_drn(stormpy.examples.files.drn_pdtmc_die)
  23. assert len(model.reward_models) == 1
  24. assert reward_model_name == "coin_flips"
  25. if __name__ == '__main__':
  26. example_reward_models_01()