You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The accept method for accepting a string could be made faster by stopping the iteration over the string symbols when the DFA is in a sink state. Here is my custom solution that should work:
...
current_states = reduce(set.union, map(lambda x: dfa.get_successors(x, temp), current_states),set(),)
sink_state = all(is_sink(dfa, state) for state in current_states)
if sink_state:
break
is_accepted = any(dfa.is_accepting(state) for state in current_states)
where
def is_sink(dfa: SymbolicDFA, current_state: int):
sink = True
for output_state in dfa._transition_function[current_state].keys():
if output_state != current_state:
sink = False
return sink
Hope it will be useful. My 2 cents.
Ivan
The text was updated successfully, but these errors were encountered:
The accept method for accepting a string could be made faster by stopping the iteration over the string symbols when the DFA is in a sink state. Here is my custom solution that should work:
where
Hope it will be useful. My 2 cents.
Ivan
The text was updated successfully, but these errors were encountered: