Class AbstractCompact<I,T,SP,TP>
- java.lang.Object
-
- net.automatalib.automaton.base.AbstractCompact<I,T,SP,TP>
-
- Type Parameters:
I- input symbol typeT- transition typeSP- state property typeTP- transition property type
- All Implemented Interfaces:
Iterable<Integer>,SupportsGrowingAlphabet<I>,Automaton<Integer,I,T>,FiniteRepresentation,InputAlphabetHolder<I>,StateIDs<Integer>,StateLocalInput<Integer,I>,FiniteAlphabetAutomaton<Integer,I,T>,MutableAutomaton<Integer,I,T,SP,TP>,SimpleAutomaton<Integer,I>,UniversalAutomaton<Integer,I,T,SP,TP>,UniversalFiniteAlphabetAutomaton<Integer,I,T,SP,TP>,GraphViewable,SimpleTS<Integer,I>,TransitionSystem<Integer,I,T>,UniversalTransitionSystem<Integer,I,T,SP,TP>
- Direct Known Subclasses:
AbstractCompactDeterministic,AbstractCompactMTS,AbstractCompactSimpleNondet
public abstract class AbstractCompact<I,T,SP,TP> extends Object implements MutableAutomaton<Integer,I,T,SP,TP>, StateIDs<Integer>, UniversalFiniteAlphabetAutomaton<Integer,I,T,SP,TP>, SupportsGrowingAlphabet<I>, StateLocalInput<Integer,I>
Abstract super class for compact automata representations. Compactness is achieved by representing states as integers, such that each state can be conveniently used to address a memory location. As a result most of the relevant automata data (such as successors, state- or transition properties) can be stored in compact arrays.This class provides basic implementations (as far as possible on this abstract level) for several of the implemented concepts and offers utility methods to subclasses, for updating their array-based automata data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractCompact.PayloadA utility class that encapsulates necessary information for performing an update of the stored automata data.
-
Field Summary
Fields Modifier and Type Field Description protected static intDEFAULT_INIT_CAPACITYprotected static floatDEFAULT_RESIZE_FACTORprotected static intINVALID_STATE
-
Constructor Summary
Constructors Constructor Description AbstractCompact(Alphabet<I> alphabet, int stateCapacity, float resizeFactor)AbstractCompact(Alphabet<I> alphabet, AbstractCompact<?,?,?,?> other)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddAlphabetSymbol(I symbol)intaddIntState(@Nullable SP property)IntegeraddState(@Nullable SP property)voidclear()Alphabet<I>getInputAlphabet()Collection<I>getLocalInputs(Integer state)IntegergetState(int id)intgetStateId(Integer state)Collection<Integer>getStates()protected intgetSymbolIndex(I input)intnumInputs()abstract voidsetStateProperty(int state, @Nullable SP property)intsize()StateIDs<Integer>stateIDs()protected static inttoId(@Nullable Integer id)protected inttoMemoryIndex(int stateId, int inputId)Returns for a given state id and input symbol index, the memory location for its associated data.protected static @Nullable IntegertoState(int id)protected Object[]updateStateStorage(@Nullable Object[] oldStorage, @Nullable Object defaultValue, AbstractCompact.Payload payload)Return a copy of the provided array with updated memory layout.protected voidupdateStateStorage(AbstractCompact.Payload payload)Implementing classes should override this method in order to react to changes to the layout of their array-based state data, e.g. due to calls toMutableAutomaton.addState().protected int[]updateTransitionStorage(int[] oldStorage, int defaultValue, AbstractCompact.Payload payload)Return a copy of the provided array with updated memory layout.protected @Nullable Object[]updateTransitionStorage(@Nullable Object[] oldStorage, @Nullable Object defaultValue, AbstractCompact.Payload payload)Return a copy of the provided array with updated memory layout.protected <S> @Nullable S[]updateTransitionStorage(@Nullable S[] oldStorage, IntFunction<@Nullable S[]> arrayConstructor, @Nullable S defaultValue, AbstractCompact.Payload payload)Return a copy of the provided array with updated memory layout.protected voidupdateTransitionStorage(AbstractCompact.Payload payload)Implementing classes should override this method in order to react to changes to the layout of their array-based transition data, e.g. due to calls toMutableAutomaton.addState()oraddAlphabetSymbol(Object).-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.automatalib.automaton.FiniteAlphabetAutomaton
getTransitions, graphView
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface net.automatalib.automaton.MutableAutomaton
addInitialState, addInitialState, addState, addTransition, addTransition, addTransitions, copyTransition, createTransition, removeAllTransitions, removeAllTransitions, removeTransition, setInitial, setStateProperty, setTransitionProperty, setTransitions
-
Methods inherited from interface net.automatalib.automaton.simple.SimpleAutomaton
createDynamicStateMapping, createStaticStateMapping, iterator
-
Methods inherited from interface net.automatalib.ts.simple.SimpleTS
getInitialStates, getStates, getSuccessors, getSuccessors
-
Methods inherited from interface net.automatalib.ts.TransitionSystem
getSuccessor, getSuccessors, getTransitions, powersetView
-
Methods inherited from interface net.automatalib.automaton.UniversalAutomaton
transitionGraphView
-
Methods inherited from interface net.automatalib.automaton.UniversalFiniteAlphabetAutomaton
transitionGraphView
-
Methods inherited from interface net.automatalib.ts.UniversalTransitionSystem
getStateProperty, getTransitionProperty
-
-
-
-
Field Detail
-
DEFAULT_RESIZE_FACTOR
protected static final float DEFAULT_RESIZE_FACTOR
- See Also:
- Constant Field Values
-
DEFAULT_INIT_CAPACITY
protected static final int DEFAULT_INIT_CAPACITY
- See Also:
- Constant Field Values
-
INVALID_STATE
protected static final int INVALID_STATE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractCompact
public AbstractCompact(Alphabet<I> alphabet, AbstractCompact<?,?,?,?> other)
-
-
Method Detail
-
getStates
public Collection<Integer> getStates()
- Specified by:
getStatesin interfaceSimpleAutomaton<I,T>
-
stateIDs
public StateIDs<Integer> stateIDs()
- Specified by:
stateIDsin interfaceSimpleAutomaton<I,T>
-
size
public int size()
- Specified by:
sizein interfaceFiniteRepresentation- Specified by:
sizein interfaceSimpleAutomaton<I,T>
-
getStateId
public int getStateId(Integer state)
- Specified by:
getStateIdin interfaceStateIDs<I>
-
getInputAlphabet
public Alphabet<I> getInputAlphabet()
- Specified by:
getInputAlphabetin interfaceInputAlphabetHolder<I>
-
addAlphabetSymbol
public final void addAlphabetSymbol(I symbol)
- Specified by:
addAlphabetSymbolin interfaceSupportsGrowingAlphabet<I>
-
getLocalInputs
public Collection<I> getLocalInputs(Integer state)
- Specified by:
getLocalInputsin interfaceStateLocalInput<I,T>
-
updateStateStorage
protected void updateStateStorage(AbstractCompact.Payload payload)
Implementing classes should override this method in order to react to changes to the layout of their array-based state data, e.g. due to calls toMutableAutomaton.addState().Subclasses may use one of the
updateStateStorage(Object[], Object, Payload)... methods to conveniently delegate this task to this base class. This leaves subclasses only with the task to invoke the provided update methods for each of their local array storages.- Parameters:
payload- the payload containing the necessary information for the update operation. This object must be passed as-is to theupdateStateStorage(Object[], Object, Payload)... methods.
-
updateStateStorage
protected final Object[] updateStateStorage(@Nullable Object[] oldStorage, @Nullable Object defaultValue, AbstractCompact.Payload payload)
Return a copy of the provided array with updated memory layout.- Parameters:
oldStorage- the current arraydefaultValue- default value for newly allocated array positionspayload- the payload object- Returns:
- a copy of the provided array with updated memory layout.
-
updateTransitionStorage
protected void updateTransitionStorage(AbstractCompact.Payload payload)
Implementing classes should override this method in order to react to changes to the layout of their array-based transition data, e.g. due to calls toMutableAutomaton.addState()oraddAlphabetSymbol(Object).Subclasses may use one of the
updateTransitionStorage(Object[], IntFunction, Object, Payload)... methods to conveniently delegate this task to this base class. This leaves subclasses only with the task to invoke the provided update methods for each of their local array storages.- Parameters:
payload- the payload containing the necessary information for the update operation. This object must be passed as-is to theupdateTransitionStorage(Object[], IntFunction, Object, Payload)... methods.
-
updateTransitionStorage
protected final int[] updateTransitionStorage(int[] oldStorage, int defaultValue, AbstractCompact.Payload payload)Return a copy of the provided array with updated memory layout.- Parameters:
oldStorage- the current arraydefaultValue- default value for newly allocated array positionspayload- the payload object- Returns:
- a copy of the provided array with updated memory layout.
- See Also:
updateTransitionStorage(Object[], Object, Payload),updateTransitionStorage(Object[], IntFunction, Object, Payload)
-
updateTransitionStorage
protected final @Nullable Object[] updateTransitionStorage(@Nullable Object[] oldStorage, @Nullable Object defaultValue, AbstractCompact.Payload payload)
Return a copy of the provided array with updated memory layout.- Parameters:
oldStorage- the current arraydefaultValue- default value for newly allocated array positionspayload- the payload object- Returns:
- a copy of the provided array with updated memory layout.
- See Also:
updateTransitionStorage(int[], int, Payload),updateTransitionStorage(Object[], IntFunction, Object, Payload)
-
updateTransitionStorage
protected final <S> @Nullable S[] updateTransitionStorage(@Nullable S[] oldStorage, IntFunction<@Nullable S[]> arrayConstructor, @Nullable S defaultValue, AbstractCompact.Payload payload)
Return a copy of the provided array with updated memory layout.- Type Parameters:
S- the storage type- Parameters:
oldStorage- the current arraydefaultValue- default value for newly allocated array positionspayload- the payload object- Returns:
- a copy of the provided array with updated memory layout.
- See Also:
updateTransitionStorage(int[], int, Payload),updateTransitionStorage(Object[], Object, Payload)
-
toMemoryIndex
protected final int toMemoryIndex(int stateId, int inputId)Returns for a given state id and input symbol index, the memory location for its associated data.- Parameters:
stateId- the state idinputId- the index of input symbol- Returns:
- the memory location for the given state id and input symbol index
- See Also:
getSymbolIndex(Object)
-
getSymbolIndex
protected final int getSymbolIndex(I input)
-
numInputs
public final int numInputs(@UnknownInitialization(AbstractCompact.class) AbstractCompact<I,T,SP,TP> this)
-
-