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.

41 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. import random
  8. def pre_schield_01():
  9. path = stormpy.examples.files.prism_mdp_lava_simple
  10. formula_str = "<ShieldFileName, PreSafety, gamma=0.9> 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. model = stormpy.build_sparse_model_with_options(program, options)
  18. initial_state = model.initial_states[0]
  19. assert initial_state == 0
  20. result = stormpy.model_checking(model, formulas[0], extract_scheduler=True)
  21. assert result.has_scheduler
  22. assert result.has_schield
  23. shield = result.shield
  24. lookup = stormpy.shields.create_shield_action_lookup(model, shield)
  25. query = list(lookup.keys())[0]
  26. print(query)
  27. print(lookup[query])
  28. if __name__ == '__main__':
  29. pre_schield_01()