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.5 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. from stormpy.decision_tree import create_decision_tree
  8. def export_shield_as_dot():
  9. path = stormpy.examples.files.prism_mdp_lava_simple
  10. formula_str = "Pmax=? [G !\"AgentIsInLavaAndNotDone\"]"
  11. program = stormpy.parse_prism_program(path)
  12. formulas = stormpy.parse_properties_for_prism_program(formula_str, program)
  13. options = stormpy.BuilderOptions([p.raw_formula for p in formulas])
  14. options.set_build_state_valuations(True)
  15. options.set_build_choice_labels(True)
  16. options.set_build_all_labels()
  17. options.set_build_with_choice_origins(True)
  18. model = stormpy.build_sparse_model_with_options(program, options)
  19. shield_specification = stormpy.logic.ShieldExpression(stormpy.logic.ShieldingType.POST_SAFETY, stormpy.logic.ShieldComparison.RELATIVE, 0.9)
  20. result = stormpy.model_checking(model, formulas[0], extract_scheduler=True, shield_expression=shield_specification)
  21. assert result.has_shield
  22. shield = result.shield
  23. filename = "postshield.storm.json"
  24. filename2 = "postshield.shield"
  25. stormpy.shields.export_shield(model, shield, filename)
  26. stormpy.shields.export_shield(model, shield, filename2)
  27. output_folder = "post_trees"
  28. name = 'post_my_output'
  29. suite = create_decision_tree(filename, name=name , output_folder=output_folder, export_pdf=True)
  30. suite.display_html()
  31. if __name__ == '__main__':
  32. export_shield_as_dot()