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.

40 lines
1.1 KiB

  1. import stormpy
  2. import stormpy.core
  3. import stormpy.simulator
  4. import stormpy.shields
  5. import stormpy.examples
  6. import stormpy.examples.files
  7. def optimal_shield_extraction():
  8. path = stormpy.examples.files.prism_smg_robot
  9. formula_str = "<path_correction, Optimal> <<sh>> R{\"travel_costs\"}min=? [ LRA ]"
  10. program = stormpy.parse_prism_program(path)
  11. formulas = stormpy.parse_properties_for_prism_program(formula_str, program)
  12. options = stormpy.BuilderOptions([p.raw_formula for p in formulas])
  13. options.set_build_state_valuations(True)
  14. options.set_build_choice_labels(True)
  15. options.set_build_all_labels()
  16. model = stormpy.build_sparse_model_with_options(program, options)
  17. result = stormpy.model_checking(model, formulas[0], extract_scheduler=True)
  18. assert result.has_scheduler
  19. assert result.has_shield
  20. shield = result.shield
  21. state_ids = [x for x in model.states]
  22. for state_id in state_ids[0:50]:
  23. choices = shield.construct().get_choice(state_id)
  24. print(F"Corrections in state {state_id}, are {choices.choice_map} ")
  25. if __name__ == '__main__':
  26. optimal_shield_extraction()