• 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

83.33
/commons/util/src/main/java/de/learnlib/util/AbstractBFOracle.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.util;
17

18
import java.util.LinkedList;
19
import java.util.Queue;
20

21
import de.learnlib.api.oracle.AutomatonOracle;
22
import de.learnlib.api.oracle.MembershipOracle;
23
import de.learnlib.api.query.DefaultQuery;
24
import net.automatalib.automata.DeterministicAutomaton;
25
import net.automatalib.words.Word;
26
import org.checkerframework.checker.nullness.qual.Nullable;
27

28
/**
29
 * An {@link AutomatonOracle} that processes words in a breadth-first manner.
30
 *
31
 * @param <A> the automaton type
32
 * @param <I> the input type
33
 * @param <D> the output type
34
 */
35
public abstract class AbstractBFOracle<A extends DeterministicAutomaton<?, I, ?>, I, D>
36
        implements AutomatonOracle<A, I, D> {
37

38
    /**
39
     * The queue containing the words to find a counterexample with.
40
     */
41
    private final Queue<Word<I>> queue = new LinkedList<>();
1✔
42

43
    /**
44
     * The {@link MembershipOracle} used to answer {@link DefaultQuery}s.
45
     */
46
    private final MembershipOracle<I, D> membershipOracle;
47

48
    private double multiplier;
49

50
    protected AbstractBFOracle(MembershipOracle<I, D> membershipOracle, double multiplier) {
1✔
51
        this.membershipOracle = membershipOracle;
1✔
52
        this.multiplier = multiplier;
1✔
53
    }
1✔
54

55
    @Override
56
    public DefaultQuery<I, D> processInput(A hypothesis, Word<I> input) {
57
        final DefaultQuery<I, D> query = new DefaultQuery<>(input);
1✔
58
        membershipOracle.processQuery(query);
1✔
59

60
        return query;
1✔
61
    }
62

63
    @Override
64
    public double getMultiplier() {
65
        return multiplier;
1✔
66
    }
67

68
    @Override
69
    public void setMultiplier(double multiplier) {
70
        this.multiplier = multiplier;
×
71
    }
×
72

73
    public MembershipOracle<I, D> getMembershipOracle() {
74
        return membershipOracle;
×
75
    }
76

77
    /**
78
     * Returns the next input word, by popping from a queue.
79
     *
80
     * @see AutomatonOracle#nextInput()
81
     */
82
    @Override
83
    public @Nullable Word<I> nextInput() {
84
        return queue.poll();
1✔
85
    }
86

87
    /**
88
     * Adds a new input word to the queue.
89
     *
90
     * @see AutomatonOracle#addWord(Word)
91
     */
92
    @Override
93
    public void addWord(Word<I> input) {
94
        queue.add(input);
1✔
95
    }
1✔
96

97
    /**
98
     * Clears the queue.
99
     */
100
    @Override
101
    public void pre() {
102
        queue.clear();
1✔
103
        addWord(Word.epsilon());
1✔
104
    }
1✔
105
}
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