de.ls5.jlearn.shared
Class AutomatonImpl

java.lang.Object
  extended by de.ls5.jlearn.shared.AutomatonImpl
All Implemented Interfaces:
Automaton, Serializable
Direct Known Subclasses:
AnnotatedAutomaton, FiniteStateAcceptor

public class AutomatonImpl
extends Object
implements Automaton

Author:
merten
See Also:
Serialized Form

Constructor Summary
AutomatonImpl(Alphabet alphabet)
          Constructor.
AutomatonImpl(Alphabet alphabet, boolean optimizedTraces)
          Constructor.
 
Method Summary
 State addNewState()
          Creates a new State and return it.
 List<State> getAllStates()
          Applies a breadth-first search algorithm to retrieve all states reachable from the starting state.
 Alphabet getAlphabet()
          Return Alphabet of this automaton
 Automaton getCopyWithRestrictedAlphabet(Alphabet alpha)
          Create a copy of the automaton with only input symbols present in the supplied alphabet being present.
 List<State> getIncompleteStates()
          Returns all states of the automaton which not yet have a complete set of transitions.
 boolean getOptimizedTracesEnabled()
           
 State getOtherStateWithSameSignature(State s)
          Find state other than the supplied state producing the very same output for every input symbol of the alphabet.
 Alphabet getOutputAlphabet()
          Return all symbols used as output in this automaton.
 State getStart()
          Return the starting state.
 Word getTraceOutput(Word trace)
          Return a word of output symbols produced by the automaton as reaction to the supplied word of input symbols.
 State getTraceState(Word trace, int steps)
          Return reached state after consuming the specified number of symbols of the input trace.
 Word getTraceToState(State destination)
          Returns an access-sequence to the given state.
 Word getTraceToStateOptimized(StateImpl destination)
           
 boolean isWellDefined()
          Checks if all states of the automaton have a complete set of valid transitions, meaning that every state has a transition for every symbol of the alphabet.
 void reassignStateIds()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AutomatonImpl

public AutomatonImpl(Alphabet alphabet)
Constructor. Takes sigma, initializes StateDB, creates the starting state and adds it to the state database.


AutomatonImpl

public AutomatonImpl(Alphabet alphabet,
                     boolean optimizedTraces)
Constructor. Takes sigma, initializes StateDB, creates the starting state and adds it to the state database. If optimizedTraces is set then every state will keep a reference to its "parent" state to efficiently find a shortest path to the starting state. This only works reliably if construction of the automaton begins at the starting state.

Method Detail

getOptimizedTracesEnabled

public boolean getOptimizedTracesEnabled()

getStart

public State getStart()
Description copied from interface: Automaton
Return the starting state. When instantiating an Automaton the starting state is automatically instantiated, too.

Specified by:
getStart in interface Automaton
Returns:
starting state

getAlphabet

public Alphabet getAlphabet()
Description copied from interface: Automaton
Return Alphabet of this automaton

Specified by:
getAlphabet in interface Automaton
Returns:
alphabet of this automaton

getOutputAlphabet

public Alphabet getOutputAlphabet()
Description copied from interface: Automaton
Return all symbols used as output in this automaton.

Specified by:
getOutputAlphabet in interface Automaton
Returns:
return output symbols

addNewState

public State addNewState()
Description copied from interface: Automaton
Creates a new State and return it.

Specified by:
addNewState in interface Automaton
Returns:
created state

isWellDefined

public boolean isWellDefined()
Description copied from interface: Automaton
Checks if all states of the automaton have a complete set of valid transitions, meaning that every state has a transition for every symbol of the alphabet.

Specified by:
isWellDefined in interface Automaton
Returns:
true if well-defined, false otherwise

getAllStates

public List<State> getAllStates()
Description copied from interface: Automaton
Applies a breadth-first search algorithm to retrieve all states reachable from the starting state.

Specified by:
getAllStates in interface Automaton
Returns:
list of states in automaton

getIncompleteStates

public List<State> getIncompleteStates()
Description copied from interface: Automaton
Returns all states of the automaton which not yet have a complete set of transitions.

Specified by:
getIncompleteStates in interface Automaton
Returns:
list of incomplete states

getOtherStateWithSameSignature

public State getOtherStateWithSameSignature(State s)
Description copied from interface: Automaton
Find state other than the supplied state producing the very same output for every input symbol of the alphabet.

Specified by:
getOtherStateWithSameSignature in interface Automaton
Returns:
state with same signature

getCopyWithRestrictedAlphabet

public Automaton getCopyWithRestrictedAlphabet(Alphabet alpha)
Description copied from interface: Automaton
Create a copy of the automaton with only input symbols present in the supplied alphabet being present.

Specified by:
getCopyWithRestrictedAlphabet in interface Automaton
Parameters:
alpha - Alphabet to resrict the copy to
Returns:
stripped automaton

getTraceToState

public Word getTraceToState(State destination)
Description copied from interface: Automaton
Returns an access-sequence to the given state.

Specified by:
getTraceToState in interface Automaton
Returns:
trace to supplied state

getTraceToStateOptimized

public Word getTraceToStateOptimized(StateImpl destination)

getTraceOutput

public Word getTraceOutput(Word trace)
Description copied from interface: Automaton
Return a word of output symbols produced by the automaton as reaction to the supplied word of input symbols.

Specified by:
getTraceOutput in interface Automaton
Returns:
sequence of outputs

getTraceState

public State getTraceState(Word trace,
                           int steps)
Description copied from interface: Automaton
Return reached state after consuming the specified number of symbols of the input trace.

Specified by:
getTraceState in interface Automaton
Returns:
active state after consumption

reassignStateIds

public void reassignStateIds()


Copyright © 2011. All Rights Reserved.