The source code and dockerfile for the GSW2024 AI Lab.
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

37 lines
1.1 KiB

4 weeks ago
  1. import stormpy
  2. import stormpy.core
  3. import stormpy.examples
  4. import stormpy.examples.files
  5. def example_schedulers_02():
  6. path = stormpy.examples.files.prism_ma_simple
  7. formula_str = "Tmin=? [ F s=4 ]"
  8. program = stormpy.parse_prism_program(path, False, True)
  9. formulas = stormpy.parse_properties_for_prism_program(formula_str, program)
  10. ma = stormpy.build_model(program, formulas)
  11. assert ma.model_type == stormpy.ModelType.MA
  12. # Convert MA to MDP
  13. mdp, mdp_formulas = stormpy.transform_to_discrete_time_model(ma, formulas)
  14. assert mdp.model_type == stormpy.ModelType.MDP
  15. initial_state = mdp.initial_states[0]
  16. assert initial_state == 0
  17. result = stormpy.model_checking(mdp, mdp_formulas[0], extract_scheduler=True)
  18. assert result.has_scheduler
  19. scheduler = result.scheduler
  20. print(scheduler)
  21. assert scheduler.memoryless
  22. assert scheduler.deterministic
  23. for state in mdp.states:
  24. choice = scheduler.get_choice(state)
  25. action = choice.get_deterministic_choice()
  26. print("In state {} choose action {}".format(state, action))
  27. if __name__ == '__main__':
  28. example_schedulers_02()