whitemech / pythomata

A Python package for automata theory.
https://whitemech.github.io/pythomata/
GNU Lesser General Public License v3.0
54 stars 6 forks source link

Generate a random DFA of size N #106

Open odats opened 4 years ago

odats commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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.