• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

LearnLib / learnlib / 6433387082

06 Oct 2023 03:10PM UTC coverage: 92.296% (-0.007%) from 92.303%
6433387082

push

github

mtf90
update Falk's developer id

11573 of 12539 relevant lines covered (92.3%)

1.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.45
/algorithms/active/adt/src/main/java/de/learnlib/algorithms/adt/adt/ADTNode.java
1
/* Copyright (C) 2013-2023 TU Dortmund
2
 * This file is part of LearnLib, http://www.learnlib.de/.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package de.learnlib.algorithms.adt.adt;
17

18
import java.util.Collection;
19
import java.util.Map;
20

21
import de.learnlib.algorithms.adt.util.ADTUtil;
22
import de.learnlib.api.oracle.SymbolQueryOracle;
23
import net.automatalib.graphs.ads.RecursiveADSNode;
24
import net.automatalib.visualization.VisualizationHelper;
25
import net.automatalib.words.Word;
26

27
/**
28
 * The ADT equivalent of {@link net.automatalib.graphs.ads.ADSNode}. In contrast to regular adaptive distinguishing
29
 * sequences, an ADT node may also represent a reset node that semantically separates multiple ADSs.
30
 *
31
 * @param <S>
32
 *         (hypothesis) state type
33
 * @param <I>
34
 *         input alphabet type
35
 * @param <O>
36
 *         output alphabet type
37
 */
38
public interface ADTNode<S, I, O> extends RecursiveADSNode<S, I, O, ADTNode<S, I, O>> {
39

40
    /**
41
     * Utility method, that sifts a given word through {@code this} ADTNode. If {@code this} node is a <ul> <li>symbol
42
     * node, the symbol is applied to the system under learning and the corresponding child node (based on the observed
43
     * output) is returned. If no matching child node is found, a new leaf node is returned instead </li> <li> reset
44
     * node, the system under learning is reset and the provided prefix is reapplied to the system </li> <li> leaf node,
45
     * an exception is thrown </li> </ul>
46
     *
47
     * @param oracle
48
     *         the oracle used to query the system under learning
49
     * @param prefix
50
     *         the prefix to be re-applied after encountering a reset node
51
     *
52
     * @return the corresponding child node
53
     *
54
     * @throws UnsupportedOperationException
55
     *         when invoked on a leaf node (see {@link #getNodeType()}).
56
     */
57
    ADTNode<S, I, O> sift(SymbolQueryOracle<I, O> oracle, Word<I> prefix);
58

59
    // default methods for graph interface
60
    @Override
61
    default Collection<ADTNode<S, I, O>> getNodes() {
62
        return getNodesForRoot(this);
2✔
63
    }
64

65
    @Override
66
    default VisualizationHelper<ADTNode<S, I, O>, ADTNode<S, I, O>> getVisualizationHelper() {
67
        return new VisualizationHelper<ADTNode<S, I, O>, ADTNode<S, I, O>>() {
2✔
68

69
            @Override
70
            public boolean getNodeProperties(ADTNode<S, I, O> node, Map<String, String> properties) {
71
                if (ADTUtil.isResetNode(node)) {
2✔
72
                    properties.put(NodeAttrs.SHAPE, NodeShapes.OCTAGON);
2✔
73
                    properties.put(NodeAttrs.LABEL, "reset");
2✔
74
                } else if (ADTUtil.isLeafNode(node)) {
2✔
75
                    properties.put(NodeAttrs.SHAPE, NodeShapes.BOX);
2✔
76
                    properties.put(NodeAttrs.LABEL, String.valueOf(node.getHypothesisState()));
2✔
77
                } else {
78
                    properties.put(NodeAttrs.LABEL, node.toString());
2✔
79
                    properties.put(NodeAttrs.SHAPE, NodeShapes.OVAL);
2✔
80
                }
81

82
                return true;
2✔
83
            }
84

85
            @Override
86
            public boolean getEdgeProperties(ADTNode<S, I, O> src,
87
                                             ADTNode<S, I, O> edge,
88
                                             ADTNode<S, I, O> tgt,
89
                                             Map<String, String> properties) {
90

91
                for (Map.Entry<O, ADTNode<S, I, O>> e : src.getChildren().entrySet()) {
2✔
92
                    if (e.getValue().equals(tgt) && !ADTUtil.isResetNode(src)) {
2✔
93
                        properties.put(EdgeAttrs.LABEL, e.getKey().toString());
2✔
94
                        return true;
2✔
95
                    }
96
                }
2✔
97
                return true;
2✔
98
            }
99
        };
100
    }
101

102
    @Override
103
    default boolean isLeaf() {
104
        return NodeType.LEAF_NODE == this.getNodeType();
×
105
    }
106

107
    /**
108
     * Returns the node type of the current node.
109
     *
110
     * @return the node type
111
     */
112
    NodeType getNodeType();
113

114
    /**
115
     * Utility enum to distinguish the 3 possible types of ADT nodes.
116
     */
117
    enum NodeType {
2✔
118
        SYMBOL_NODE,
2✔
119
        RESET_NODE,
2✔
120
        LEAF_NODE
2✔
121
    }
122
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc