pythomata icon indicating copy to clipboard operation
pythomata copied to clipboard

Generate a random DFA of size N

Open odats opened this issue 5 years ago • 2 comments

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 avatar Aug 11 '20 09:08 odats

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

odats avatar Aug 12 '20 07:08 odats

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.

marcofavorito avatar Aug 12 '20 08:08 marcofavorito