Skip to content

Commit

Permalink
fix not using optional coloring
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Andriushchenko committed Dec 8, 2023
1 parent ecb6fb8 commit 1021d24
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
12 changes: 11 additions & 1 deletion paynt/quotient/coloring.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(self, mdp, holes, action_to_hole_options):
@property
def num_choices(self):
return len(self.action_to_hole_options)

def select_actions(self, family):
'''
Select non-default actions relevant in the provided design space.
Expand Down Expand Up @@ -112,3 +112,13 @@ def select_actions(self, family):
selected_actions_bv = stormpy.synthesis.construct_selection(self.default_actions, selected_actions)

return hole_selected_actions,selected_actions,selected_actions_bv


def choices_to_hole_selection(self, choices):
hole_selection = [set() for hole_index in self.holes.hole_indices]
for choice in choices:
choice_options = self.action_to_hole_options[choice]
for hole_index,option in choice_options.items():
hole_selection[hole_index].add(option)
hole_selection = [list(options) for options in hole_selection]
return hole_selection
18 changes: 4 additions & 14 deletions paynt/quotient/quotient.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,25 +185,15 @@ def state_to_choice_to_choices(self, state_to_choice):
choices.set(choice,True)
return choices


def choices_to_hole_selection(self, choices, coloring=None):
if coloring is None:
coloring = self.coloring
hole_selection = [set() for hole_index in self.design_space.hole_indices]
for choice in choices:
choice_options = self.coloring.action_to_hole_options[choice]
for hole_index,option in choice_options.items():
hole_selection[hole_index].add(option)
hole_selection = [list(options) for options in hole_selection]
return hole_selection


def scheduler_selection(self, mdp, scheduler, coloring=None):
''' Get hole options involved in the scheduler selection. '''
assert scheduler.memoryless and scheduler.deterministic
state_to_choice = self.scheduler_to_state_to_choice(mdp, scheduler, keep_reachable=True)
state_to_choice = self.scheduler_to_state_to_choice(mdp, scheduler)
choices = self.state_to_choice_to_choices(state_to_choice)
hole_selection = self.choices_to_hole_selection(choices,coloring)
if coloring is None:
coloring = self.coloring
hole_selection = coloring.choices_to_hole_selection(choices)
return hole_selection


Expand Down

0 comments on commit 1021d24

Please sign in to comment.