Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Generate a random DFA of size N #106

Open
odats opened this issue Aug 11, 2020 · 2 comments
Open

Generate a random DFA of size N #106

odats opened this issue Aug 11, 2020 · 2 comments

Comments

@odats
Copy link

odats commented Aug 11, 2020

I train Neural Network to recognize DFA given accept / not accept strings. It would be nice to have a method that samples random DFA with maximum size N and K strings that are accepted and K strings that are not accepted by this automaton.

@odats
Copy link
Author

odats commented Aug 12, 2020

Something like this:

def from_table_to_transition_function(table):
  transition_function = {i : {0:s[0], 1:s[1]} for i, s in enumerate(table)}
  return transition_function


def get_random_dfa(number_of_states = 6, alphabet_size = 2):
  dfa_table = np.random.randint(number_of_states, size=(number_of_states, alphabet_size))

  transition_function = from_table_to_transition_function(dfa_table)
  dfa = SimpleDFA.from_transitions(0, {number_of_states-1}, transition_function)

  return dfa

@marcofavorito
Copy link
Member

Hi @odats , thank you for the feature request, and thank you very much for your interest in the library. We will surely keep in mind this request, although in the short term the focus of the library will be more on better APIs, other concrete implementations of the main interfaces, and implementation of transducers.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants