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.

43 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 Pre Safety Shield
  9. to a file
  10. """
  11. def pre_schield():
  12. path = stormpy.examples.files.prism_mdp_lava_simple
  13. formula_str = "<pre, PreSafety, lambda=0.9> Pmax=? [G !\"AgentIsInLavaAndNotDone\"]"
  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. initial_state = model.initial_states[0]
  22. assert initial_state == 0
  23. result = stormpy.model_checking(model, formulas[0], extract_scheduler=True)
  24. assert result.has_scheduler
  25. assert result.has_shield
  26. shield = result.shield
  27. stormpy.shields.export_shieldDouble(model, shield, "pre.shield")
  28. if __name__ == '__main__':
  29. pre_schield()