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.

33 lines
1.0 KiB

  1. import stormpy.shields
  2. from . import shields
  3. from .shields import *
  4. def create_action_lookup(model, scheduler):
  5. ret = {}
  6. for state_id in model.states:
  7. choice = scheduler.get_choice(state_id)
  8. action = choice.get_deterministic_choice()
  9. state_valuation = model.state_valuations.get_string(state_id)
  10. action_to_be_executed = model.choice_labeling.get_labels_of_choice(model.get_choice_index(state_id, action))
  11. ret[state_valuation] = action_to_be_executed
  12. return ret
  13. def create_shield_action_lookup(model, shield):
  14. ret = {}
  15. for state_id in model.states:
  16. choices = shield.construct().get_choice(state_id)
  17. state_valuation = model.state_valuations.get_string(state_id)
  18. l = []
  19. for choice in choices.choice_map:
  20. action = choice[1]
  21. action_to_be_executed = model.choice_labeling.get_labels_of_choice(model.get_choice_index(state_id, action))
  22. l.append(action_to_be_executed)
  23. ret[state_valuation] = l
  24. return ret