Skip to content

Commit

Permalink
fix kWayStateCoverageEqOracle.py for non strongly connected autoamta
Browse files Browse the repository at this point in the history
  • Loading branch information
emuskardin committed Nov 21, 2024
1 parent 9e9edcd commit 2950234
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions aalpy/oracles/kWayStateCoverageEqOracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class KWayStateCoverageEqOracle(Oracle):
random walk at the end.
"""

def __init__(self, alphabet: list, sul: SUL, k=2, random_walk_len=20, method='combinations'):
def __init__(self, alphabet: list, sul: SUL, k=2, random_walk_len=20, method='permutations'):
"""
Args:
Expand Down Expand Up @@ -61,10 +61,23 @@ def find_cex(self, hypothesis):

index = 0
path = comb[0].prefix

# in case of non-strongly connected automata test case might not be possible as a path between 2 states
# might not exist
possible_test_case = True
while index < len(comb) - 1:
path += hypothesis.get_shortest_path(comb[index], comb[index + 1])
path_between_states = hypothesis.get_shortest_path(comb[index], comb[index + 1])
index += 1

if not path_between_states:
possible_test_case = False
break

path += path_between_states

if possible_test_case is None:
continue

path += tuple(choices(self.alphabet, k=self.random_walk_len))

self.reset_hyp_and_sul(hypothesis)
Expand Down

0 comments on commit 2950234

Please sign in to comment.