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.2 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 = "<<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. shield_specification = stormpy.logic.ShieldExpression(stormpy.logic.ShieldingType.OPTIMAL)
  22. result = stormpy.model_checking(model, formulas[0], extract_scheduler=True, shield_expression=shield_specification)
  23. assert result.has_scheduler
  24. assert result.has_shield
  25. shield = result.shield
  26. stormpy.shields.export_shield(model, shield, "optimal.shield")
  27. if __name__ == '__main__':
  28. optimal_shield_export()