Class RandomICAutomatonGenerator<SP,TP>
- java.lang.Object
-
- net.automatalib.util.automaton.random.RandomICAutomatonGenerator<SP,TP>
-
- Type Parameters:
SP
- state property typeTP
- 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 asRandomAutomata.randomICDFA(Random, int, Alphabet, boolean)
.
-
-
Constructor Summary
Constructors Constructor Description RandomICAutomatonGenerator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static RandomICAutomatonGenerator<Boolean,Void>
forDFA()
Creates a random IC automaton generator instance for generating DFAs.static RandomICAutomatonGenerator<Boolean,Void>
forDFA(double acceptingRatio)
Creates a random IC automaton generator instance for generating DFAs.<I,A extends MutableDeterministic<?,I,?,? super SP,? super TP>>
AgenerateICDeterministicAutomaton(int numStates, Collection<? extends I> inputs, A result, Random r)
Generates an initially connected (IC) deterministic automaton with the given parameters.<I,A extends MutableDeterministic<?,I,?,? super SP,? super TP>>
AgenerateICDeterministicAutomaton(int numStates, Alphabet<I> alphabet, AutomatonCreator<? extends A,I> creator, Random r)
Generates an initially-connected (IC) deterministic automaton with the given parameters.RandomICAutomatonGenerator<SP,TP>
withStateProperties(Collection<? extends SP> possibleSps)
Sets the possible state properties, and returnsthis
.RandomICAutomatonGenerator<SP,TP>
withStateProperties(Function<? super Random,? extends SP> spFunc)
Sets the function for supplying state properties, and returnsthis
.RandomICAutomatonGenerator<SP,TP>
withStateProperties(Supplier<? extends SP> spSupplier)
Sets the supplier for state properties, and returnsthis
.RandomICAutomatonGenerator<SP,TP>
withStateProperties(SP... possibleSps)
Sets the possible state properties, and returnsthis
.RandomICAutomatonGenerator<SP,TP>
withTransitionProperties(Collection<? extends TP> possibleTps)
Sets the possible transition properties, and returnsthis
.RandomICAutomatonGenerator<SP,TP>
withTransitionProperties(Function<? super Random,? extends TP> tpFunc)
Sets the function for supplying transition properties, and returnsthis
.RandomICAutomatonGenerator<SP,TP>
withTransitionProperties(Supplier<? extends TP> tpSupplier)
Sets the supplier for transition properties, and returnsthis
.RandomICAutomatonGenerator<SP,TP>
withTransitionProperties(TP... possibleTps)
Sets the possible transition properties, and returnsthis
.
-
-
-
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. TheacceptingRatio
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 returnsthis
.- Parameters:
spFunc
- the function that supplies state properties, using aRandom
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 returnsthis
.Using this function is discouraged, as it ignores the
Random
instance passed to the generation functions. If possible, usewithStateProperties(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 returnsthis
. The collection is internally converted into a list, from which state properties are selected usingRandomUtil.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 returnsthis
. State properties are selected from this array usingRandomUtil.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 returnsthis
.Using this function is discouraged, as it ignores the
Random
instance passed to the generation functions. If possible, usewithTransitionProperties(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 returnsthis
.- Parameters:
tpFunc
- the function that supplies transition properties, using aRandom
object as a source for randomness- Returns:
this
-
withTransitionProperties
@SafeVarargs public final RandomICAutomatonGenerator<SP,TP> withTransitionProperties(TP... possibleTps)
Sets the possible transition properties, and returnsthis
. Transition properties are selected from this array usingRandomUtil.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 returnsthis
. The collection is internally converted into a list, from which transition properties are selected usingRandomUtil.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 givencreator
. Note that the resulting automaton will not be minimized.- Parameters:
numStates
- the number of states of the resulting automatonalphabet
- the input alphabet of the resulting automatoncreator
- anAutomatonCreator
for instantiating the result automatonr
- 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 automatoninputs
- the input symbols to consider during generationresult
- the result automaton (should be empty)r
- the randomness source- Returns:
- the result automaton
-
-