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.

35 lines
1.0 KiB

4 weeks ago
  1. import stormpy
  2. import stormpy.core
  3. import stormpy.examples
  4. import stormpy.examples.files
  5. def example_schedulers_01():
  6. path = stormpy.examples.files.prism_mdp_coin_2_2
  7. formula_str = "Pmin=? [F \"finished\" & \"all_coins_equal_1\"]"
  8. program = stormpy.parse_prism_program(path)
  9. formulas = stormpy.parse_properties_for_prism_program(formula_str, program)
  10. model = stormpy.build_model(program, formulas)
  11. initial_state = model.initial_states[0]
  12. assert initial_state == 0
  13. result = stormpy.model_checking(model, formulas[0], extract_scheduler=True)
  14. assert result.has_scheduler
  15. scheduler = result.scheduler
  16. print(scheduler)
  17. assert scheduler.memoryless
  18. assert scheduler.deterministic
  19. for state in model.states:
  20. choice = scheduler.get_choice(state)
  21. action = choice.get_deterministic_choice()
  22. print("In state {} choose action {}".format(state, action))
  23. dtmc = model.apply_scheduler(scheduler)
  24. print(dtmc)
  25. if __name__ == '__main__':
  26. example_schedulers_01()