- java.lang.Object
-
- de.learnlib.filter.reuse.tree.ReuseTree<S,I,O>
-
- Type Parameters:
S
- system state typeI
- input symbol typeO
- output symbol type
- All Implemented Interfaces:
Iterable<ReuseNode<S,I,O>>
,net.automatalib.automaton.concept.FiniteRepresentation
,net.automatalib.graph.Graph<ReuseNode<S,I,O>,ReuseEdge<S,I,O>>
,net.automatalib.graph.IndefiniteGraph<ReuseNode<S,I,O>,ReuseEdge<S,I,O>>
,net.automatalib.graph.IndefiniteSimpleGraph<ReuseNode<S,I,O>>
,net.automatalib.graph.SimpleGraph<ReuseNode<S,I,O>>
public final class ReuseTree<S,I,O> extends Object implements net.automatalib.graph.Graph<ReuseNode<S,I,O>,ReuseEdge<S,I,O>>
TheReuseTree
is a tree like structure consisting of nodes (seeReuseNode
) and edges (seeReuseEdge
) that is used by theReuseOracle
:- Nodes may contain a system state (see
ReuseNode.fetchSystemState(boolean)
) that could be used for executing suffixes of membership queries. Each node consists of a (possible empty) set of outgoing edges. - Edges consists beside source and target node of input and output behavior.
ReuseTree
is the central data structure that maintains observed behavior from the SUL and maintains also available system states. TheReuseTree
is only 'tree like' since it may contain reflexive edges at nodes (only possible ifReuseTreeBuilder.withFailureOutputs(Set)
orReuseTreeBuilder.withInvariantInputs(Set)
is set).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.automatalib.graph.Graph
net.automatalib.graph.Graph.IntAbstraction<E extends Object>
-
-
Constructor Summary
Constructors Constructor Description ReuseTree(net.automatalib.alphabet.Alphabet<I> alphabet, boolean enabledSystemStateInvalidation, SystemStateHandler<S> systemStateHandler, Set<I> invariantInputs, Set<O> failureOutputs, int maxSystemStates, BoundedDeque.AccessPolicy accessPolicy, BoundedDeque.EvictPolicy evictPolicy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearTree()
Clears the whole tree which means the root will be reinitialized by a newReuseNode
and all existing system states will be disposed.void
disposeSystemStates()
This method removes all system states from the tree.@Nullable ReuseNode.NodeResult<S,I,O>
fetchSystemState(net.automatalib.word.Word<I> query)
Returns a reusableReuseNode.NodeResult
with system state accessed by the given access sequence. ornull
if none such exists.Collection<ReuseNode<S,I,O>>
getNodes()
Collection<ReuseEdge<S,I,O>>
getOutgoingEdges(ReuseNode<S,I,O> node)
@Nullable net.automatalib.word.Word<O>
getOutput(net.automatalib.word.Word<I> query)
Returns the known output for the given query ornull
if not known.net.automatalib.word.Word<@Nullable O>
getPartialOutput(net.automatalib.word.Word<I> query)
Returns the known output for "reflexive" edges in the tree for the given query.ReuseNode<S,I,O>
getRoot()
ReuseNode<S,I,O>
getTarget(ReuseEdge<S,I,O> edge)
net.automatalib.visualization.VisualizationHelper<ReuseNode<S,I,O>,ReuseEdge<S,I,O>>
getVisualizationHelper()
void
insert(net.automatalib.word.Word<I> query, ReuseCapableOracle.QueryResult<S,O> queryResult)
Inserts the givenWord
withReuseCapableOracle.QueryResult
into the tree starting from the root node of the tree.void
insert(net.automatalib.word.Word<I> query, ReuseNode<S,I,O> sink, ReuseCapableOracle.QueryResult<S,O> queryResult)
Inserts the givenWord
(suffix of a membership query) withReuseCapableOracle.QueryResult
(suffix output) into the tree starting from theReuseNode
(contains prefix with prefix output) in the tree.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.automatalib.graph.Graph
getAdjacentNodes, getOutgoingEdgesIterator
-
Methods inherited from interface net.automatalib.graph.IndefiniteGraph
getAdjacentNodesIterator, getEdgesBetween
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
ReuseTree
public ReuseTree(net.automatalib.alphabet.Alphabet<I> alphabet, boolean enabledSystemStateInvalidation, SystemStateHandler<S> systemStateHandler, Set<I> invariantInputs, Set<O> failureOutputs, int maxSystemStates, BoundedDeque.AccessPolicy accessPolicy, BoundedDeque.EvictPolicy evictPolicy)
-
-
Method Detail
-
getOutput
public @Nullable net.automatalib.word.Word<O> getOutput(net.automatalib.word.Word<I> query)
Returns the known output for the given query ornull
if not known.- Parameters:
query
- the query- Returns:
- The output for
query
if already known from theReuseTree
ornull
if unknown.
-
getPartialOutput
public net.automatalib.word.Word<@Nullable O> getPartialOutput(net.automatalib.word.Word<I> query)
Returns the known output for "reflexive" edges in the tree for the given query. All other symbols are set tonull
.- Parameters:
query
- the query- Returns:
- The partial output for
query
from theReuseTree
with outputs for "reflexive" edges filled withnull
for "non-reflexive" and not-known parts of the input word.
-
disposeSystemStates
public void disposeSystemStates()
This method removes all system states from the tree. The tree structure remains, but there will be nothing for reuse.The
SystemStateHandler
will be informed about all disposals.
-
clearTree
public void clearTree()
Clears the whole tree which means the root will be reinitialized by a newReuseNode
and all existing system states will be disposed. All invariant input symbols as well as all failure output symbols will remain.The
SystemStateHandler
will not be informed about any disposings.
-
fetchSystemState
public @Nullable ReuseNode.NodeResult<S,I,O> fetchSystemState(net.automatalib.word.Word<I> query)
Returns a reusableReuseNode.NodeResult
with system state accessed by the given access sequence. ornull
if none such exists.- Parameters:
query
- the access sequence to the node- Returns:
- the node accessed by the given query,
null
if no such node exists
-
insert
public void insert(net.automatalib.word.Word<I> query, ReuseCapableOracle.QueryResult<S,O> queryResult)
Inserts the givenWord
withReuseCapableOracle.QueryResult
into the tree starting from the root node of the tree. For the longest known prefix of the givenWord
there will be no new nodes or edges created.Will be called from the
ReuseOracle
if no system state was available for reuse for the query (otherwiseinsert(Word, ReuseNode, ReuseCapableOracle.QueryResult)
would be called). The last node reached by the last symbol of the query will hold the system state from the givenReuseCapableOracle.QueryResult
.This method should only be invoked internally from the
ReuseOracle
unless you know exactly what you are doing (you may want to create a predefined reuse tree before start learning).- Parameters:
query
- the query determining a path in the treequeryResult
- the output that should be associated with the given path- Throws:
ReuseException
- if non-deterministic behavior is detected
-
insert
public void insert(net.automatalib.word.Word<I> query, ReuseNode<S,I,O> sink, ReuseCapableOracle.QueryResult<S,O> queryResult)
Inserts the givenWord
(suffix of a membership query) withReuseCapableOracle.QueryResult
(suffix output) into the tree starting from theReuseNode
(contains prefix with prefix output) in the tree. For the longest known prefix of the suffix from the givenWord
there will be no new nodes or edges created.Will be called from the
ReuseOracle
if an available system state was reused for the query (otherwiseinsert(Word, ReuseCapableOracle.QueryResult)
would be called). The old system state was already removed from theReuseNode
(throughfetchSystemState(Word)
) if the ''invalidateSystemstates'' flag in theReuseOracle
was set totrue
.This method should only be invoked internally from the
ReuseOracle
unless you know exactly what you are doing (you may want to create a predefined reuse tree before start learning).- Parameters:
query
- the query determining a path in the treesink
- the starting node of the pathqueryResult
- the output that should be associated with the given path- Throws:
ReuseException
- if non-deterministic behavior is detected
-
getNodes
public Collection<ReuseNode<S,I,O>> getNodes()
- Specified by:
getNodes
in interfacenet.automatalib.graph.SimpleGraph<S>
-
-