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

LearnLib / learnlib / 13034511199

29 Jan 2025 03:18PM UTC coverage: 94.304% (-0.09%) from 94.389%
13034511199

push

github

mtf90
spmm: improve assertions

2 of 2 new or added lines in 1 file covered. (100.0%)

24 existing lines in 7 files now uncovered.

12417 of 13167 relevant lines covered (94.3%)

1.72 hits per line

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

82.35
/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/spa/WpMethodEQOracle.java
1
/* Copyright (C) 2013-2025 TU Dortmund University
2
 * This file is part of LearnLib <https://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.oracle.equivalence.spa;
17

18
import java.util.Collection;
19
import java.util.stream.Stream;
20

21
import de.learnlib.oracle.MembershipOracle;
22
import de.learnlib.oracle.equivalence.AbstractTestWordEQOracle;
23
import net.automatalib.alphabet.ProceduralInputAlphabet;
24
import net.automatalib.automaton.fsa.DFA;
25
import net.automatalib.automaton.procedural.SPA;
26
import net.automatalib.common.util.collection.IteratorUtil;
27
import net.automatalib.util.automaton.conformance.SPATestsIterator;
28
import net.automatalib.util.automaton.conformance.WMethodTestsIterator;
29
import net.automatalib.util.automaton.conformance.WpMethodTestsIterator;
30
import net.automatalib.word.Word;
31

32
/**
33
 * An {@link SPA} version of {@link de.learnlib.oracle.equivalence.WpMethodEQOracle} which generates test sequences
34
 * based on the partial W-method for each procedure.
35
 *
36
 * @param <I>
37
 *         input symbol type
38
 */
39
public class WpMethodEQOracle<I> extends AbstractTestWordEQOracle<SPA<?, I>, I, Boolean> {
40

41
    private final int lookahead;
42
    private final int expectedSize;
43

44
    /**
45
     * Constructor. Convenience method for {@link #WpMethodEQOracle(MembershipOracle, int)} that sets {@code lookahead}
46
     * to 1.
47
     *
48
     * @param sulOracle
49
     *         interface to the system under learning
50
     */
51
    public WpMethodEQOracle(MembershipOracle<I, Boolean> sulOracle) {
UNCOV
52
        this(sulOracle, 1);
×
UNCOV
53
    }
×
54

55
    /**
56
     * Constructor. Convenience method for {@link #WpMethodEQOracle(MembershipOracle, int, int)} that sets
57
     * {@code expectedSize} to 0.
58
     *
59
     * @param sulOracle
60
     *         interface to the system under learning
61
     * @param lookahead
62
     *         the maximum length of the "middle" part of the test cases
63
     */
64
    public WpMethodEQOracle(MembershipOracle<I, Boolean> sulOracle, int lookahead) {
65
        this(sulOracle, lookahead, 0);
2✔
66
    }
2✔
67

68
    /**
69
     * Constructor. Convenience method for {@link #WpMethodEQOracle(MembershipOracle, int, int, int)} that sets
70
     * {@code batchSize} to 1.
71
     *
72
     * @param sulOracle
73
     *         interface to the system under learning
74
     * @param lookahead
75
     *         the (minimal) maximum length of the "middle" part of the test cases
76
     * @param expectedSize
77
     *         the expected size of the system under learning
78
     */
79
    public WpMethodEQOracle(MembershipOracle<I, Boolean> sulOracle, int lookahead, int expectedSize) {
80
        this(sulOracle, lookahead, expectedSize, 1);
2✔
81
    }
2✔
82

83
    /**
84
     * Constructor. Uses
85
     * {@link Math#max(int, int) Math.max}{@code (lookahead, expectedSize - }{@link DFA#size() hypothesis.size()}{@code
86
     * )} (for each procedural {@code hypothesis}) to determine the maximum length of sequences, that should be appended
87
     * to the transition-cover part of the test sequence to account for the fact that the system under learning may have
88
     * more states than the current hypothesis.
89
     *
90
     * @param sulOracle
91
     *         interface to the system under learning
92
     * @param lookahead
93
     *         the (minimal) maximum length of the "middle" part of the test cases
94
     * @param expectedSize
95
     *         the expected size of the system under learning
96
     * @param batchSize
97
     *         size of the batches sent to the membership oracle
98
     *
99
     * @see WMethodTestsIterator
100
     */
101
    public WpMethodEQOracle(MembershipOracle<I, Boolean> sulOracle, int lookahead, int expectedSize, int batchSize) {
102
        super(sulOracle, batchSize);
2✔
103
        this.lookahead = lookahead;
2✔
104
        this.expectedSize = expectedSize;
2✔
105
    }
2✔
106

107
    @Override
108
    protected Stream<Word<I>> generateTestWords(SPA<?, I> hypothesis, Collection<? extends I> inputs) {
109
        if (!(inputs instanceof ProceduralInputAlphabet)) {
2✔
UNCOV
110
            throw new IllegalArgumentException("Inputs are not a procedural alphabet");
×
111
        }
112

113
        @SuppressWarnings("unchecked")
114
        final ProceduralInputAlphabet<I> alphabet = (ProceduralInputAlphabet<I>) inputs;
2✔
115

116
        return IteratorUtil.stream(new SPATestsIterator<>(hypothesis,
2✔
117
                                                          alphabet,
118
                                                          (dfa, alph) -> new WpMethodTestsIterator<>(dfa,
2✔
119
                                                                                                     alph,
120
                                                                                                     Math.max(lookahead,
2✔
121
                                                                                                              expectedSize -
122
                                                                                                              dfa.size()))));
2✔
123
    }
124
}
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