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>>
TheReuseTreeis 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.
ReuseTreeis the central data structure that maintains observed behavior from the SUL and maintains also available system states. TheReuseTreeis 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 classReuseTree.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 voidclearTree()Clears the whole tree which means the root will be reinitialized by a newReuseNodeand all existing system states will be disposed.voiddisposeSystemStates()This method removes all system states from the tree.@Nullable ReuseNode.NodeResult<S,I,O>fetchSystemState(Word<I> query)Returns a reuseableReuseNode.NodeResultwith system state ornullif 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 ornullif 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()voidinsert(Word<I> query, ReuseCapableOracle.QueryResult<S,O> queryResult)Inserts the givenWordwithReuseCapableOracle.QueryResultinto the tree starting from the root node of the tree.voidinsert(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 ornullif not known.- Parameters:
query- Not allowed to benull.- Returns:
- The output for
queryif already known from theReuseTreeornullif 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
queryfrom theReuseTreewith outputs for "reflexive" edges filled withnullfor "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
SystemStateHandlerwill be informed about all disposals.
-
clearTree
public void clearTree()
Clears the whole tree which means the root will be reinitialized by a newReuseNodeand all existing system states will be disposed. All invariant input symbols as well as all failure output symbols will remain.The
SystemStateHandlerwill not be informed about any disposings.
-
fetchSystemState
public @Nullable ReuseNode.NodeResult<S,I,O> fetchSystemState(Word<I> query)
Returns a reuseableReuseNode.NodeResultwith system state ornullif 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 givenWordwithReuseCapableOracle.QueryResultinto the tree starting from the root node of the tree. For the longest known prefix of the givenWordthere will be no new nodes or edges created.Will be called from the
ReuseOracleif 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
ReuseOracleunless 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 givenWordthere will be no new nodes or edges created.Will be called from the
ReuseOracleif 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 theReuseOraclewas set totrue.This method should only be invoked internally from the
ReuseOracleunless 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:
getNodesin interfaceSimpleGraph<S>
-
getOutgoingEdges
public Collection<@Nullable ReuseEdge<S,I,O>> getOutgoingEdges(@Nullable ReuseNode<S,I,O> node)
- Specified by:
getOutgoingEdgesin interfaceGraph<S,I>
-
getTarget
public @Nullable ReuseNode<S,I,O> getTarget(@Nullable ReuseEdge<S,I,O> edge)
- Specified by:
getTargetin interfaceIndefiniteGraph<S,I>
-
getVisualizationHelper
public VisualizationHelper<@Nullable ReuseNode<S,I,O>,@Nullable ReuseEdge<S,I,O>> getVisualizationHelper()
- Specified by:
getVisualizationHelperin interfaceGraph<S,I>- Specified by:
getVisualizationHelperin interfaceSimpleGraph<S>
-
-