Class RandomICAutomatonGenerator<SP,​TP>

  • Type Parameters:
    SP - state property type
    TP - transition property type

    public class RandomICAutomatonGenerator<SP,​TP>
    extends Object
    A random generator for initially connected (IC) deterministic automata.

    The object state of instances of this class only determines how state and transition properties are assigned. These can be set conveniently using the with... methods in a fluent interface-like manner.

    For conveniently generating initially connected deterministic automata of certain types, consider using the static methods defined in class RandomAutomata, such as RandomAutomata.randomICDFA(Random, int, Alphabet, boolean).

    • Constructor Detail

      • RandomICAutomatonGenerator

        public RandomICAutomatonGenerator()
    • Method Detail

      • forDFA

        public static RandomICAutomatonGenerator<Boolean,​Void> forDFA()
        Creates a random IC automaton generator instance for generating DFAs. States in generated automata will be accepting or rejecting with equal probability.
        Returns:
        a random IC automaton generator instance for generating DFAs
      • forDFA

        public static RandomICAutomatonGenerator<Boolean,​Void> forDFA​(double acceptingRatio)
        Creates a random IC automaton generator instance for generating DFAs. The acceptingRatio parameter controls the probability of a state in a generated automaton being an accepting state.
        Parameters:
        acceptingRatio - the (approximate) ratio of accepting states in generated automata
        Returns:
        a random IC automaton generator instance for generating DFAs
      • withStateProperties

        public RandomICAutomatonGenerator<SP,​TP> withStateProperties​(Function<? super Random,​? extends SP> spFunc)
        Sets the function for supplying state properties, and returns this.
        Parameters:
        spFunc - the function that supplies state properties, using a Random object as a source for randomness
        Returns:
        this
      • withStateProperties

        public RandomICAutomatonGenerator<SP,​TP> withStateProperties​(Supplier<? extends SP> spSupplier)
        Sets the supplier for state properties, and returns this.

        Using this function is discouraged, as it ignores the Random instance passed to the generation functions. If possible, use withStateProperties(Function).

        Parameters:
        spSupplier - the supplier for state properties
        Returns:
        this
      • withStateProperties

        public RandomICAutomatonGenerator<SP,​TP> withStateProperties​(Collection<? extends SP> possibleSps)
        Sets the possible state properties, and returns this. The collection is internally converted into a list, from which state properties are selected using RandomUtil.choose(Random, List). If the collection is empty, null will always be chosen as the state property.

        Note that if the collection contains elements several times, the probability of these elements being selected is proportionally higher.

        Parameters:
        possibleSps - the collection of possible state properties
        Returns:
        this
      • withStateProperties

        @SafeVarargs
        public final RandomICAutomatonGenerator<SP,​TP> withStateProperties​(SP... possibleSps)
        Sets the possible state properties, and returns this. State properties are selected from this array using RandomUtil.choose(Random, Object[]). If the array is empty, null will always be chosen as the state property.
        Parameters:
        possibleSps - the possible state properties
        Returns:
        this
      • withTransitionProperties

        public RandomICAutomatonGenerator<SP,​TP> withTransitionProperties​(Supplier<? extends TP> tpSupplier)
        Sets the supplier for transition properties, and returns this.

        Using this function is discouraged, as it ignores the Random instance passed to the generation functions. If possible, use withTransitionProperties(Function).

        Parameters:
        tpSupplier - the supplier for transition properties
        Returns:
        this
      • withTransitionProperties

        public RandomICAutomatonGenerator<SP,​TP> withTransitionProperties​(Function<? super Random,​? extends TP> tpFunc)
        Sets the function for supplying transition properties, and returns this.
        Parameters:
        tpFunc - the function that supplies transition properties, using a Random object as a source for randomness
        Returns:
        this
      • withTransitionProperties

        @SafeVarargs
        public final RandomICAutomatonGenerator<SP,​TP> withTransitionProperties​(TP... possibleTps)
        Sets the possible transition properties, and returns this. Transition properties are selected from this array using RandomUtil.choose(Random, Object[]). If the array is empty, null will always be chosen as the state property.
        Parameters:
        possibleTps - the possible transition properties
        Returns:
        this
      • withTransitionProperties

        public RandomICAutomatonGenerator<SP,​TP> withTransitionProperties​(Collection<? extends TP> possibleTps)
        Sets the possible transition properties, and returns this. The collection is internally converted into a list, from which transition properties are selected using RandomUtil.choose(Random, List). If the collection is empty, null will always be chosen as the transition property.

        Note that if the collection contains elements several times, the probability of these elements being selected is proportionally higher.

        Parameters:
        possibleTps - the collection of possible transition properties
        Returns:
        this
      • generateICDeterministicAutomaton

        public <I,​A extends MutableDeterministic<?,​I,​?,​? super SP,​? super TP>> A generateICDeterministicAutomaton​(int numStates,
                                                                                                                                                Alphabet<I> alphabet,
                                                                                                                                                AutomatonCreator<? extends A,​I> creator,
                                                                                                                                                Random r)
        Generates an initially-connected (IC) deterministic automaton with the given parameters. The resulting automaton is instantiated using the given creator. Note that the resulting automaton will not be minimized.
        Parameters:
        numStates - the number of states of the resulting automaton
        alphabet - the input alphabet of the resulting automaton
        creator - an AutomatonCreator for instantiating the result automaton
        r - the randomness source
        Returns:
        a randomly-generated IC deterministic automaton
      • generateICDeterministicAutomaton

        public <I,​A extends MutableDeterministic<?,​I,​?,​? super SP,​? super TP>> A generateICDeterministicAutomaton​(int numStates,
                                                                                                                                                Collection<? extends I> inputs,
                                                                                                                                                A result,
                                                                                                                                                Random r)
        Generates an initially connected (IC) deterministic automaton with the given parameters. Note that the automaton will not be minized.
        Parameters:
        numStates - the number of states of the resulting automaton
        inputs - the input symbols to consider during generation
        result - the result automaton (should be empty)
        r - the randomness source
        Returns:
        the result automaton