Skip to content

Commit f446e09

Browse files
committed
add utility constructors
1 parent 83bdeba commit f446e09

12 files changed

Lines changed: 89 additions & 14 deletions

File tree

algorithms/active/aaar/src/test/java/de/learnlib/algorithm/aaar/AbstractAAARTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void testAbstractHypothesisEquivalence() {
5252
final WpMethodTestsIterator<I> iter = new WpMethodTestsIterator<>(automaton, alphabet);
5353
final List<Word<I>> testCases = IteratorUtil.list(iter);
5454

55-
final SampleSetEQOracle<I, D> eqo = new SampleSetEQOracle<>(false);
55+
final SampleSetEQOracle<I, D> eqo = new SampleSetEQOracle<>();
5656
eqo.addAll(new SimulatorOracle<>(automaton), testCases);
5757

5858
final LearningAlgorithm<A, I, D> learner =

algorithms/active/lambda/src/test/java/de/learnlib/algorithm/lambda/AbstractCounterexampleQueueTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public void testPop() {
7575
final DFAMembershipOracle<Character> mqOracle = new DFASimulatorOracle<>(DFA);
7676
final DFALearner<Character> learner = getLearner(alphabet, mqOracle);
7777

78-
final SampleSetEQOracle<Character, Boolean> eqOracle = new SampleSetEQOracle<>(false);
78+
final SampleSetEQOracle<Character, Boolean> eqOracle = new SampleSetEQOracle<>();
7979
final Word<Character> a = Word.fromLetter('a');
8080
final Word<Character> b = new WordBuilder<>('b', 9).toWord();
8181
eqOracle.addAll(mqOracle, Word.fromWords(b, a, b, a, b, a, b, a));

algorithms/active/nlstar/src/test/java/de/learnlib/algorithm/nlstar/NLStarTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void testIssue70() {
5353

5454
final DFAMembershipOracle<Character> mqOracle = new NFASimulatorOracle<>(nfa);
5555

56-
final SampleSetEQOracle<Character, Boolean> eqOracle = new SampleSetEQOracle<>(false);
56+
final SampleSetEQOracle<Character, Boolean> eqOracle = new SampleSetEQOracle<>();
5757
eqOracle.addAll(mqOracle,
5858
Word.fromLetter('a'),
5959
Word.fromString("ab"),

algorithms/active/procedural/src/test/java/de/learnlib/algorithm/procedural/sba/OptimizationsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void testOptimizations() {
5050

5151
final SimulatorOracle<Character, Boolean> mqo = new SimulatorOracle<>(sba);
5252

53-
final SampleSetEQOracle<Character, Boolean> eqo1 = new SampleSetEQOracle<>(false);
53+
final SampleSetEQOracle<Character, Boolean> eqo1 = new SampleSetEQOracle<>();
5454
eqo1.addAll(mqo, Word.fromString("STcTSaSaRaRRcRR"));
5555
final SimulatorEQOracle<Character> eqo2 = new SimulatorEQOracle<>(sba);
5656
final EQOracleChain<SBA<?, Character>, Character, Boolean> eqo = new EQOracleChain<>(Arrays.asList(eqo1, eqo2));

algorithms/active/procedural/src/test/java/de/learnlib/algorithm/procedural/spmm/OptimizationsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public void testOptimizations() {
5050

5151
final SimulatorOracle<Character, Word<Character>> mqo = new SimulatorOracle<>(spmm);
5252

53-
final SampleSetEQOracle<Character, Word<Character>> eqo1 = new SampleSetEQOracle<>(false);
53+
final SampleSetEQOracle<Character, Word<Character>> eqo1 = new SampleSetEQOracle<>();
5454
eqo1.addAll(mqo, Word.fromString("STcTSaSaRaRRcRR"));
5555
final SimulatorEQOracle<Character, Character> eqo2 = new SimulatorEQOracle<>(spmm);
5656
final EQOracleChain<SPMM<?, Character, ?, Character>, Character, Word<Character>> eqo =

oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/SampleSetEQOracle.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ public class SampleSetEQOracle<I, D> implements EquivalenceOracle<SuffixOutput<I
5353
private final boolean removeUnsuccessful;
5454
private final List<DefaultQuery<I, D>> testQueries;
5555

56+
/**
57+
* Constructor. Convenience method for {@link #SampleSetEQOracle(boolean)} that does not remove unsuccessful
58+
* samples.
59+
*/
60+
public SampleSetEQOracle() {
61+
this(false);
62+
}
63+
5664
/**
5765
* Constructor. Initializes the oracle with an empty sample set.
5866
*
@@ -180,8 +188,8 @@ public SampleSetEQOracle<I, D> addAll(Collection<? extends DefaultQuery<I, D>> n
180188
* @param inputs
181189
* the set of allowed inputs
182190
*
183-
* @return {@code true} if the input word of {@code query} consists entirely of symbols in {@code inputs}, {@code
184-
* false} otherwise
191+
* @return {@code true} if the input word of {@code query} consists entirely of symbols in {@code inputs},
192+
* {@code false} otherwise
185193
*/
186194
private static <I> boolean checkInputs(Query<I, ?> query, Collection<? extends I> inputs) {
187195
for (I sym : query.getPrefix()) {
@@ -205,8 +213,8 @@ private static <I> boolean checkInputs(Query<I, ?> query, Collection<? extends I
205213
* @param hypOutput
206214
* the suffix output portion of the hypothesis
207215
*
208-
* @return {@code true} if the suffix output by {@code hypOutput} matches the expected output stored in {@code
209-
* query}, {@code false} otherwise.
216+
* @return {@code true} if the suffix output by {@code hypOutput} matches the expected output stored in
217+
* {@code query}, {@code false} otherwise.
210218
*/
211219
private static <I, D> boolean test(DefaultQuery<I, D> query, SuffixOutput<I, D> hypOutput) {
212220
D hypOut = hypOutput.computeSuffixOutput(query.getPrefix(), query.getSuffix());

oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/WMethodEQOracle.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,17 @@ public class WMethodEQOracle<A extends UniversalDeterministicAutomaton<?, I, ?,
8787
private final int lookahead;
8888
private final int expectedSize;
8989

90+
/**
91+
* Constructor. Convenience method for {@link #WMethodEQOracle(MembershipOracle, int)} that sets {@code lookahead}
92+
* to 1.
93+
*
94+
* @param sulOracle
95+
* interface to the system under learning
96+
*/
97+
public WMethodEQOracle(MembershipOracle<I, D> sulOracle) {
98+
this(sulOracle, 1);
99+
}
100+
90101
/**
91102
* Constructor. Convenience method for {@link #WMethodEQOracle(MembershipOracle, int, int)} that sets
92103
* {@code expectedSize} to 0.

oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/WpMethodEQOracle.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,19 @@ public class WpMethodEQOracle<A extends UniversalDeterministicAutomaton<?, I, ?,
8787
private final int expectedSize;
8888

8989
/**
90-
* Constructor. Convenience method for {@link #WpMethodEQOracle(MembershipOracle, int, int)} that sets {@code
91-
* expectedSize} to 0.
90+
* Constructor. Convenience method for {@link #WpMethodEQOracle(MembershipOracle, int)} that sets {@code lookahead}
91+
* to 1.
92+
*
93+
* @param sulOracle
94+
* interface to the system under learning
95+
*/
96+
public WpMethodEQOracle(MembershipOracle<I, D> sulOracle) {
97+
this(sulOracle, 1);
98+
}
99+
100+
/**
101+
* Constructor. Convenience method for {@link #WpMethodEQOracle(MembershipOracle, int, int)} that sets
102+
* {@code expectedSize} to 0.
92103
*
93104
* @param sulOracle
94105
* interface to the system under learning
@@ -100,8 +111,8 @@ public WpMethodEQOracle(MembershipOracle<I, D> sulOracle, int lookahead) {
100111
}
101112

102113
/**
103-
* Constructor. Convenience method for {@link #WpMethodEQOracle(MembershipOracle, int, int, int)} that sets {@code
104-
* batchSize} to 1.
114+
* Constructor. Convenience method for {@link #WpMethodEQOracle(MembershipOracle, int, int, int)} that sets
115+
* {@code batchSize} to 1.
105116
*
106117
* @param sulOracle
107118
* interface to the system under learning
@@ -115,7 +126,8 @@ public WpMethodEQOracle(MembershipOracle<I, D> sulOracle, int lookahead, int exp
115126
}
116127

117128
/**
118-
* Constructor. Uses {@link Math#max(int, int) Math.max}{@code (lookahead, expectedSize - }{@link
129+
* Constructor. Uses
130+
* {@link Math#max(int, int) Math.max}{@code (lookahead, expectedSize - }{@link
119131
* UniversalDeterministicAutomaton#size() hypothesis.size()}{@code )} to determine the maximum length of sequences,
120132
* that should be appended to the state-cover (first phase) and remaining transition-cover (second phase) part of
121133
* the test sequence to account for the fact that the system under learning may have more states than the current

oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/sba/WMethodEQOracle.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ public class WMethodEQOracle<I> extends AbstractTestWordEQOracle<SBA<?, I>, I, B
4040
private final int lookahead;
4141
private final int expectedSize;
4242

43+
/**
44+
* Constructor. Convenience method for {@link #WMethodEQOracle(MembershipOracle, int)} that sets {@code lookahead}
45+
* to 1.
46+
*
47+
* @param sulOracle
48+
* interface to the system under learning
49+
*/
50+
public WMethodEQOracle(MembershipOracle<I, Boolean> sulOracle) {
51+
this(sulOracle, 1);
52+
}
53+
4354
/**
4455
* Constructor. Convenience method for {@link #WMethodEQOracle(MembershipOracle, int, int)} that sets
4556
* {@code expectedSize} to 0.

oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/spa/WMethodEQOracle.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,17 @@ public class WMethodEQOracle<I> extends AbstractTestWordEQOracle<SPA<?, I>, I, B
4040
private final int lookahead;
4141
private final int expectedSize;
4242

43+
/**
44+
* Constructor. Convenience method for {@link #WMethodEQOracle(MembershipOracle, int)} that sets {@code lookahead}
45+
* to 1.
46+
*
47+
* @param sulOracle
48+
* interface to the system under learning
49+
*/
50+
public WMethodEQOracle(MembershipOracle<I, Boolean> sulOracle) {
51+
this(sulOracle, 1);
52+
}
53+
4354
/**
4455
* Constructor. Convenience method for {@link #WMethodEQOracle(MembershipOracle, int, int)} that sets
4556
* {@code expectedSize} to 0.

0 commit comments

Comments
 (0)