Class ReuseTree<S,I,O>
- java.lang.Object
-
- de.learnlib.filter.reuse.tree.ReuseTree<S,I,O>
-
- Type Parameters:
S
- system state classI
- input symbol classO
- output symbol class
- All Implemented Interfaces:
Iterable<@Nullable ReuseNode<S,I,O>>
,FiniteRepresentation
,Graph<@Nullable ReuseNode<S,I,O>,@Nullable ReuseEdge<S,I,O>>
,IndefiniteGraph<@Nullable ReuseNode<S,I,O>,@Nullable ReuseEdge<S,I,O>>
,IndefiniteSimpleGraph<@Nullable ReuseNode<S,I,O>>
,SimpleGraph<@Nullable ReuseNode<S,I,O>>
public final class ReuseTree<S,I,O> extends Object implements Graph<@Nullable ReuseNode<S,I,O>,@Nullable 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 ifReuseTree.ReuseTreeBuilder.withFailureOutputs(Set)
orReuseTree.ReuseTreeBuilder.withInvariantInputs(Set)
is set).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ReuseTree.ReuseTreeBuilder<S,I,O>
-
Nested classes/interfaces inherited from interface net.automatalib.graph.Graph
Graph.IntAbstraction<E extends Object>
-
-
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(Word<I> query)
Returns a reuseableReuseNode.NodeResult
with system state ornull
if none such exists.Collection<ReuseNode<S,I,O>>
getNodes()
Collection<@Nullable ReuseEdge<S,I,O>>
getOutgoingEdges(@Nullable ReuseNode<S,I,O> node)
@Nullable Word<O>
getOutput(Word<I> query)
Returns the known output for the given query ornull
if not known.Word<O>
getPartialOutput(Word<I> query)
Returns the known output for "reflexive" edges in the tree for the given query.ReuseNode<S,I,O>
getRoot()
@Nullable ReuseNode<S,I,O>
getTarget(@Nullable ReuseEdge<S,I,O> edge)
VisualizationHelper<@Nullable ReuseNode<S,I,O>,@Nullable ReuseEdge<S,I,O>>
getVisualizationHelper()
void
insert(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(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 net.automatalib.graph.IndefiniteSimpleGraph
createDynamicNodeMapping, createStaticNodeMapping, isConnected
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Methods inherited from interface net.automatalib.graph.SimpleGraph
iterator, nodeIDs, size
-
-
-
-
Method Detail
-
getOutput
public @Nullable Word<O> getOutput(Word<I> query)
Returns the known output for the given query ornull
if not known.- Parameters:
query
- Not allowed to benull
.- Returns:
- The output for
query
if already known from theReuseTree
ornull
if unknown.
-
getPartialOutput
public Word<O> getPartialOutput(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
- Not allowed to benull
.- 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(Word<I> query)
Returns a reuseableReuseNode.NodeResult
with system state ornull
if none such exists. If ''oldInvalidated'' was set totrue
(in theReuseOracle
) the system state is already removed from the tree whenever one was available.- Parameters:
query
- Not allowed to benull
.
-
insert
public void insert(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).- Throws:
ReuseException
- if non-deterministic behavior is detected
-
insert
public void insert(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).- Throws:
ReuseException
- if non-deterministic behavior is detected
-
getNodes
public Collection<ReuseNode<S,I,O>> getNodes()
- Specified by:
getNodes
in interfaceSimpleGraph<S>
-
getOutgoingEdges
public Collection<@Nullable ReuseEdge<S,I,O>> getOutgoingEdges(@Nullable ReuseNode<S,I,O> node)
- Specified by:
getOutgoingEdges
in interfaceGraph<S,I>
-
getTarget
public @Nullable ReuseNode<S,I,O> getTarget(@Nullable ReuseEdge<S,I,O> edge)
- Specified by:
getTarget
in interfaceIndefiniteGraph<S,I>
-
getVisualizationHelper
public VisualizationHelper<@Nullable ReuseNode<S,I,O>,@Nullable ReuseEdge<S,I,O>> getVisualizationHelper()
- Specified by:
getVisualizationHelper
in interfaceGraph<S,I>
- Specified by:
getVisualizationHelper
in interfaceSimpleGraph<S>
-
-