Generate a random automaton. The states are guaranteed to be accessible, but some may be non coaccessible.
The number of states wanted in the automata
(>0). All states will be connected, and there will be no dead
state. However, some might not be coaccessible.
density = 0.1:
The density of the automata. This is the probability
(between 0.0 and 1.0), to add a transition between two
states. All states have at least one outgoing transition,
so \a d is considered only when adding the remaining transition.
A density of 1 means all states will be connected to each other.
num_initial = 1:
The number of initial states wanted (0 <= num_initial <= num_states)
num_final = 1:
The number of final states wanted (0 <= num_final <= num_states)
max_labels = generators.size():
The maximum number of labels per transition. Defaults to the
number of generators.
loop_chance = 0:
The probability (between 0.0 and 1.0) for each state to have
loop_change = 0there can be loops.
a, which results in only two labels.
import vcsn import os # Make sure we always get the same sequence of random automata. os.environ["VCSN_SEED"] = "1" b = vcsn.context('lal_char(abc), b')
Pushing the arguments to their limits guarantees the result. For instance, a full density builds a clique.
vcsn.context('lal(abc), b').random_automaton(3, density=1, max_labels=1)
All the states are initial, final, and have a loop.
vcsn.context('lal(abc), b').random_automaton(3, max_labels=1, loop_chance=1, num_initial=3, num_final=3)