• 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

93.33
/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/spa/WpMethodEQOracle.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.oracle.equivalence.spa;
17

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

21
import com.google.common.collect.Streams;
22
import de.learnlib.api.oracle.MembershipOracle;
23
import de.learnlib.oracle.equivalence.AbstractTestWordEQOracle;
24
import net.automatalib.automata.fsa.DFA;
25
import net.automatalib.automata.procedural.SPA;
26
import net.automatalib.util.automata.conformance.SPATestsIterator;
27
import net.automatalib.util.automata.conformance.WMethodTestsIterator;
28
import net.automatalib.util.automata.conformance.WpMethodTestsIterator;
29
import net.automatalib.words.ProceduralInputAlphabet;
30
import net.automatalib.words.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, int)} that sets
46
     * {@code expectedSize} to 0.
47
     *
48
     * @param sulOracle
49
     *         interface to the system under learning
50
     * @param lookahead
51
     *         the maximum length of the "middle" part of the test cases
52
     */
53
    public WpMethodEQOracle(MembershipOracle<I, Boolean> sulOracle, int lookahead) {
54
        this(sulOracle, lookahead, 0);
2✔
55
    }
2✔
56

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

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

96
    @Override
97
    protected Stream<Word<I>> generateTestWords(SPA<?, I> hypothesis, Collection<? extends I> inputs) {
98
        if (!(inputs instanceof ProceduralInputAlphabet)) {
2✔
99
            throw new IllegalArgumentException("Inputs are not a procedural alphabet");
×
100
        }
101

102
        @SuppressWarnings("unchecked")
103
        final ProceduralInputAlphabet<I> alphabet = (ProceduralInputAlphabet<I>) inputs;
2✔
104

105
        return Streams.stream(new SPATestsIterator<>(hypothesis,
2✔
106
                                                     alphabet,
107
                                                     (dfa, alph) -> new WpMethodTestsIterator<>(dfa,
2✔
108
                                                                                                alph,
109
                                                                                                Math.max(lookahead,
2✔
110
                                                                                                         expectedSize -
111
                                                                                                         dfa.size()))));
2✔
112
    }
113
}
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