Package owl.automaton
Class HashMapAutomaton<S,A extends OmegaAcceptance>
- java.lang.Object
-
- owl.automaton.HashMapAutomaton<S,A>
-
- All Implemented Interfaces:
Automaton<S,A>
,EdgeMapAutomatonMixin<S,A>
,MutableAutomaton<S,A>
public final class HashMapAutomaton<S,A extends OmegaAcceptance> extends Object implements EdgeMapAutomatonMixin<S,A>, MutableAutomaton<S,A>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface owl.automaton.Automaton
Automaton.EdgeMapVisitor<S>, Automaton.EdgeTreeVisitor<S>, Automaton.EdgeVisitor<S>, Automaton.PreferredEdgeAccess, Automaton.Property, Automaton.Visitor<S>
-
-
Field Summary
-
Fields inherited from interface owl.automaton.EdgeMapAutomatonMixin
ACCESS_MODES
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(Automaton.EdgeMapVisitor<S> visitor)
void
accept(Automaton.EdgeTreeVisitor<S> visitor)
void
accept(Automaton.EdgeVisitor<S> visitor)
A
acceptance()
Returns the acceptance condition of this automaton.void
acceptance(A acceptance)
void
addEdge(S source, ValuationSet valuations, Edge<? extends S> edge)
Adds transitions from thesource
state undervaluations
.void
addInitialState(S initialState)
Add an initial state to the automaton.void
addState(S state)
Adds astate
without outgoing edges to the set of states.static <S,A extends OmegaAcceptance>
HashMapAutomaton<S,A>copyOf(Automaton<S,A> source)
Edge<S>
edge(S state, BitSet valuation)
Returns the successor edge of the specifiedstate
under the givenvaluation
.Map<Edge<S>,ValuationSet>
edgeMap(S state)
Returns a mapping from all outgoing edges to their valuations of the specifiedstate
.Set<Edge<S>>
edges(S state)
Returns all successor edges of the specifiedstate
under any valuation.ValuationTree<Edge<S>>
edgeTree(S state)
Returns a decision-tree with nodes labelled by literals and sets of edges as leaves.ValuationSetFactory
factory()
Returns the backing engine for the symbolic representation of edges.Set<S>
initialStates()
Returns the set of initial states, which can potentially be empty.void
initialStates(Collection<? extends S> initialStates)
Sets the set of initial states of the automaton.String
name()
void
name(String name)
Sets the name of the automaton.static <S,A extends OmegaAcceptance>
HashMapAutomaton<S,A>of(A acceptance, ValuationSetFactory vsFactory)
Creates an empty automaton with given acceptance condition.static <S,A extends OmegaAcceptance>
HashMapAutomaton<S,A>of(A acceptance, ValuationSetFactory vsFactory, Collection<S> initialStates, BiFunction<S,BitSet,Edge<S>> successors, Function<S,BitSet> alphabet)
void
removeEdge(S source, ValuationSet valuations, S destination)
Removes all transition fromsource
undervaluations
todestination
.void
removeInitialState(S initialState)
void
removeStateIf(Predicate<? super S> stateFilter)
Removes the specifiedstates
and all transitions involving them from the automaton.Set<S>
states()
The set of all from the initial states reachable states in this automaton.Set<S>
successors(S state)
Returns all successors of the specifiedstate
.String
toString()
void
trim()
Removes unreachable states and adjust internal data structures after mutation.void
updateEdges(BiFunction<S,Edge<S>,Edge<S>> updater)
Remaps each edge of the automaton according toupdater
.void
updateEdges(Set<? extends S> states, BiFunction<? super S,Edge<S>,Edge<S>> f)
Remaps each outgoing edge of the specifiedstates
according toupdater
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface owl.automaton.Automaton
accept, is, onlyInitialState, predecessors, size, successor, successors
-
Methods inherited from interface owl.automaton.EdgeMapAutomatonMixin
edges, preferredEdgeAccess
-
Methods inherited from interface owl.automaton.MutableAutomaton
addEdge, removeEdge, removeState, updateAcceptance
-
-
-
-
Method Detail
-
acceptance
public A acceptance()
Description copied from interface:Automaton
Returns the acceptance condition of this automaton.- Specified by:
acceptance
in interfaceAutomaton<S,A extends OmegaAcceptance>
- Returns:
- The acceptance.
-
acceptance
public void acceptance(A acceptance)
- Specified by:
acceptance
in interfaceMutableAutomaton<S,A extends OmegaAcceptance>
-
initialStates
public Set<S> initialStates()
Description copied from interface:Automaton
Returns the set of initial states, which can potentially be empty.- Specified by:
initialStates
in interfaceAutomaton<S,A extends OmegaAcceptance>
- Returns:
- The set of initial states.
-
initialStates
public void initialStates(Collection<? extends S> initialStates)
Description copied from interface:MutableAutomaton
Sets the set of initial states of the automaton.- Specified by:
initialStates
in interfaceMutableAutomaton<S,A extends OmegaAcceptance>
- Parameters:
initialStates
- The new set of initial states (potentially empty)
-
addInitialState
public void addInitialState(S initialState)
Description copied from interface:MutableAutomaton
Add an initial state to the automaton.- Specified by:
addInitialState
in interfaceMutableAutomaton<S,A extends OmegaAcceptance>
- Parameters:
initialState
- The added initial state.
-
removeInitialState
public void removeInitialState(S initialState)
- Specified by:
removeInitialState
in interfaceMutableAutomaton<S,A extends OmegaAcceptance>
-
states
public Set<S> states()
Description copied from interface:Automaton
The set of all from the initial states reachable states in this automaton.- Specified by:
states
in interfaceAutomaton<S,A extends OmegaAcceptance>
- Returns:
- All reachable states
-
addState
public void addState(S state)
Description copied from interface:MutableAutomaton
Adds astate
without outgoing edges to the set of states. If the state is already present, nothing is changed.- Specified by:
addState
in interfaceMutableAutomaton<S,A extends OmegaAcceptance>
- Parameters:
state
- The state to be added.
-
removeStateIf
public void removeStateIf(Predicate<? super S> stateFilter)
Description copied from interface:MutableAutomaton
Removes the specifiedstates
and all transitions involving them from the automaton.- Specified by:
removeStateIf
in interfaceMutableAutomaton<S,A extends OmegaAcceptance>
- Parameters:
stateFilter
- The states to be removed.
-
edge
@Nullable public Edge<S> edge(S state, BitSet valuation)
Description copied from interface:Automaton
Returns the successor edge of the specifiedstate
under the givenvaluation
. Returns some edge if there is a non-deterministic choice in this state for the specified valuation.If you want to check if this is the unique edge use the
Automaton.edges(Object, BitSet)
method.- Specified by:
edge
in interfaceAutomaton<S,A extends OmegaAcceptance>
- Parameters:
state
- The starting state of the transition.valuation
- The valuation.- Returns:
- A successor edge or
null
if none. - See Also:
Automaton.edgeMap(Object)
-
edges
public Set<Edge<S>> edges(S state)
Description copied from interface:Automaton
Returns all successor edges of the specifiedstate
under any valuation.- Specified by:
edges
in interfaceAutomaton<S,A extends OmegaAcceptance>
- Specified by:
edges
in interfaceEdgeMapAutomatonMixin<S,A extends OmegaAcceptance>
- Parameters:
state
- The starting state of the edges.- Returns:
- The set of edges originating from
state
-
edgeMap
public Map<Edge<S>,ValuationSet> edgeMap(S state)
Description copied from interface:Automaton
Returns a mapping from all outgoing edges to their valuations of the specifiedstate
.- Specified by:
edgeMap
in interfaceAutomaton<S,A extends OmegaAcceptance>
- Parameters:
state
- The state.- Returns:
- All labelled edges of the state.
-
edgeTree
public ValuationTree<Edge<S>> edgeTree(S state)
Description copied from interface:Automaton
Returns a decision-tree with nodes labelled by literals and sets of edges as leaves.- Specified by:
edgeTree
in interfaceAutomaton<S,A extends OmegaAcceptance>
- Specified by:
edgeTree
in interfaceEdgeMapAutomatonMixin<S,A extends OmegaAcceptance>
- Parameters:
state
- The state.- Returns:
- A tree.
-
successors
public Set<S> successors(S state)
Description copied from interface:Automaton
Returns all successors of the specifiedstate
.- Specified by:
successors
in interfaceAutomaton<S,A extends OmegaAcceptance>
- Parameters:
state
- The starting state of the transition.- Returns:
- The successor set.
-
addEdge
public void addEdge(S source, ValuationSet valuations, Edge<? extends S> edge)
Description copied from interface:MutableAutomaton
Adds transitions from thesource
state undervaluations
.- Specified by:
addEdge
in interfaceMutableAutomaton<S,A extends OmegaAcceptance>
- Parameters:
source
- The source state.valuations
- The valuations under which this transition is possible.edge
- The respective edge, containing destination and acceptance information.
-
removeEdge
public void removeEdge(S source, ValuationSet valuations, S destination)
Description copied from interface:MutableAutomaton
Removes all transition fromsource
undervaluations
todestination
. Requires both states to be present in the automaton.- Specified by:
removeEdge
in interfaceMutableAutomaton<S,A extends OmegaAcceptance>
- Parameters:
source
- The source state.valuations
- The valuations.destination
- The destination state.
-
updateEdges
public void updateEdges(Set<? extends S> states, BiFunction<? super S,Edge<S>,Edge<S>> f)
Description copied from interface:MutableAutomaton
Remaps each outgoing edge of the specifiedstates
according toupdater
.The function is allowed to return
null
which indicates that the edge should be removed. Requires allstates
to be present in the automaton.- Specified by:
updateEdges
in interfaceMutableAutomaton<S,A extends OmegaAcceptance>
- Parameters:
states
- The states whose outgoing edges are to be remapped.f
- The remapping function. The updater needs to be stateless, since it might be called with unreachable states.
-
updateEdges
public void updateEdges(BiFunction<S,Edge<S>,Edge<S>> updater)
Description copied from interface:MutableAutomaton
Remaps each edge of the automaton according toupdater
.The function is allowed to return
null
which indicates that the edge should be removed.- Specified by:
updateEdges
in interfaceMutableAutomaton<S,A extends OmegaAcceptance>
- Parameters:
updater
- The remapping function. The updater needs to be stateless, since it might be called with unreachable states.- See Also:
MutableAutomaton.updateEdges(Set, BiFunction)
-
accept
public void accept(Automaton.EdgeVisitor<S> visitor)
- Specified by:
accept
in interfaceAutomaton<S,A extends OmegaAcceptance>
-
accept
public void accept(Automaton.EdgeMapVisitor<S> visitor)
- Specified by:
accept
in interfaceAutomaton<S,A extends OmegaAcceptance>
-
accept
public void accept(Automaton.EdgeTreeVisitor<S> visitor)
- Specified by:
accept
in interfaceAutomaton<S,A extends OmegaAcceptance>
-
factory
public ValuationSetFactory factory()
Description copied from interface:Automaton
Returns the backing engine for the symbolic representation of edges. Only this engine might be used for the access to edges.- Specified by:
factory
in interfaceAutomaton<S,A extends OmegaAcceptance>
- Returns:
- The symbolic engine used to generate ValuationSets.
-
name
public void name(String name)
Description copied from interface:MutableAutomaton
Sets the name of the automaton.- Specified by:
name
in interfaceMutableAutomaton<S,A extends OmegaAcceptance>
- Parameters:
name
- The new name of the automaton.
-
trim
public void trim()
Description copied from interface:MutableAutomaton
Removes unreachable states and adjust internal data structures after mutation.- Specified by:
trim
in interfaceMutableAutomaton<S,A extends OmegaAcceptance>
-
of
public static <S,A extends OmegaAcceptance> HashMapAutomaton<S,A> of(A acceptance, ValuationSetFactory vsFactory)
Creates an empty automaton with given acceptance condition. ThevaluationSetFactory
is used as transition backend.- Type Parameters:
S
- The states of the automaton.A
- The acceptance condition of the automaton.- Parameters:
acceptance
- The acceptance of the new automaton.vsFactory
- The alphabet.- Returns:
- Empty automaton with the specified parameters.
-
of
public static <S,A extends OmegaAcceptance> HashMapAutomaton<S,A> of(A acceptance, ValuationSetFactory vsFactory, Collection<S> initialStates, BiFunction<S,BitSet,Edge<S>> successors, Function<S,BitSet> alphabet)
-
copyOf
public static <S,A extends OmegaAcceptance> HashMapAutomaton<S,A> copyOf(Automaton<S,A> source)
-
-