• 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

73.53
/algorithms/active/ttt-vpa/src/main/java/de/learnlib/algorithms/ttt/vpa/Splitter.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.ttt.vpa;
17

18
import de.learnlib.algorithms.discriminationtree.hypothesis.vpa.ContextPair;
19
import de.learnlib.algorithms.discriminationtree.hypothesis.vpa.DTNode;
20
import de.learnlib.algorithms.discriminationtree.hypothesis.vpa.HypLoc;
21
import net.automatalib.words.Word;
22

23
/**
24
 * Data structure for representing a splitter.
25
 * <p>
26
 * A splitter is represented by an input symbol, and a DT node that separates the successors (wrt. the input symbol) of
27
 * the original states. From this, a discriminator can be obtained by prepending the input symbol to the discriminator
28
 * that labels the separating successor.
29
 * <p>
30
 * <b>Note:</b> as the discriminator finalization is applied to the root of a block and affects all nodes, there is no
31
 * need to store references to the source states from which this splitter was obtained.
32
 *
33
 * @param <I>
34
 *         input symbol type
35
 */
36
public final class Splitter<I> {
37

38
    public final I symbol;
39
    public final HypLoc<I> location;
40
    public final I otherSymbol;
41
    public final SplitType type;
42
    public final DTNode<I> succSeparator;
43

44
    public Splitter(I symbol, DTNode<I> succSeparator) {
2✔
45
        this.symbol = symbol;
2✔
46
        this.location = null;
2✔
47
        this.otherSymbol = null;
2✔
48
        this.type = SplitType.INTERNAL;
2✔
49
        this.succSeparator = succSeparator;
2✔
50
    }
2✔
51

52
    public Splitter(I symbol, HypLoc<I> location, I otherSymbol, boolean call, DTNode<I> succSeparator) {
2✔
53
        this.symbol = symbol;
2✔
54
        this.location = location;
2✔
55
        this.otherSymbol = otherSymbol;
2✔
56
        this.type = call ? SplitType.CALL : SplitType.RETURN;
2✔
57
        this.succSeparator = succSeparator;
2✔
58
    }
2✔
59

60
    public ContextPair<I> getDiscriminator() {
61
        return succSeparator.getDiscriminator();
×
62
    }
63

64
    public ContextPair<I> getNewDiscriminator() {
65
        Word<I> prefix = succSeparator.getDiscriminator().getPrefix();
2✔
66
        Word<I> suffix = succSeparator.getDiscriminator().getSuffix();
2✔
67

68
        switch (type) {
2✔
69
            case INTERNAL:
70
                return new ContextPair<>(prefix, suffix.prepend(symbol));
2✔
71
            case RETURN:
72
                return new ContextPair<>(prefix.concat(location.getAccessSequence()).append(otherSymbol),
×
73
                                         suffix.prepend(symbol));
×
74
            case CALL:
75
                return new ContextPair<>(prefix,
×
76
                                         location.getAccessSequence()
×
77
                                                 .prepend(symbol)
×
78
                                                 .append(otherSymbol)
×
79
                                                 .concat(suffix));
×
80
            default:
81
                throw new IllegalStateException("Unhandled type " + type);
×
82
        }
83
    }
84

85
    public int getNewDiscriminatorLength() {
86
        if (type == SplitType.INTERNAL) {
2✔
87
            return succSeparator.getDiscriminator().getLength() + 1;
2✔
88
        }
89
        return succSeparator.getDiscriminator().getLength() + location.getAccessSequence().length() + 2;
2✔
90
    }
91

92
    public enum SplitType {
2✔
93
        INTERNAL,
2✔
94
        CALL,
2✔
95
        RETURN
2✔
96
    }
97
}
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

© 2026 Coveralls, Inc