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.

37 lines
1.2 KiB

  1. import stormpy
  2. import stormpy.core
  3. import stormpy.examples
  4. import stormpy.examples.files
  5. def example_exploration_02():
  6. """
  7. Example to exploration of POMDPs.
  8. :return:
  9. """
  10. program = stormpy.parse_prism_program(stormpy.examples.files.prism_pomdp_maze)
  11. prop = "R=? [F \"goal\"]"
  12. properties = stormpy.parse_properties(prop, program)
  13. model = stormpy.build_model(program, properties)
  14. print(model.model_type)
  15. # Internally, POMDPs are just MDPs with additional observation information.
  16. # Thus, data structure exploration for MDPs can be applied as before.
  17. initial_state = model.initial_states[0]
  18. for state in model.states:
  19. if state.id in model.initial_states:
  20. print(state)
  21. for action in state.actions:
  22. for transition in action.transitions:
  23. print("From state {} by action {}, with probability {}, go to state {}".format(state, action, transition.value(),
  24. transition.column))
  25. print(model.nr_observations)
  26. for state in model.states:
  27. print("State {} has observation id {}".format(state.id, model.observations[state.id]))
  28. if __name__ == '__main__':
  29. example_exploration_02()