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.

39 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. """
  8. Example of exporting a Optimal Shield
  9. to a file
  10. """
  11. def optimal_shield_export():
  12. path = stormpy.examples.files.prism_smg_lights
  13. formula_str = "<optimal, Optimal> <<shield>> R{\"differenceWithInterferenceCost\"}min=? [ LRA ]"
  14. program = stormpy.parse_prism_program(path)
  15. formulas = stormpy.parse_properties_for_prism_program(formula_str, program)
  16. options = stormpy.BuilderOptions([p.raw_formula for p in formulas])
  17. options.set_build_state_valuations(True)
  18. options.set_build_choice_labels(True)
  19. options.set_build_all_labels()
  20. model = stormpy.build_sparse_model_with_options(program, options)
  21. result = stormpy.model_checking(model, formulas[0], extract_scheduler=True)
  22. assert result.has_scheduler
  23. assert result.has_shield
  24. shield = result.shield
  25. stormpy.shields.export_shieldDouble(model, shield, "optimal.shield")
  26. if __name__ == '__main__':
  27. optimal_shield_export()