Skip to content

Commit 929b07e

Browse files
tupaulmtf90
authored andcommitted
MMLT-Learner now explicitly takes untimed inputs in constructor.
1 parent fce5471 commit 929b07e

4 files changed

Lines changed: 19 additions & 19 deletions

File tree

algorithms/active/lstar/src/main/java/de/learnlib/algorithm/lstar/mmlt/LStarLocalTimerMealy.java

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
import de.learnlib.symbol_filter.SymbolFilterResponse;
3030
import de.learnlib.util.mealy.MealyUtil;
3131
import net.automatalib.alphabet.Alphabet;
32+
import net.automatalib.alphabet.GrowingAlphabet;
33+
import net.automatalib.alphabet.impl.Alphabets;
34+
import net.automatalib.alphabet.impl.GrowingMapAlphabet;
3235
import net.automatalib.automaton.mmlt.MMLT;
3336
import net.automatalib.automaton.mmlt.MealyTimerInfo;
3437
import net.automatalib.symbol.time.InputSymbol;
@@ -70,13 +73,13 @@ public class LStarLocalTimerMealy<I, O> implements OTLearner<MMLT<Integer, I, ?,
7073
* Uses the close-shortest strategy for closing the observation table and
7174
* binary-backwards search for decomposing counterexamples.
7275
*
73-
* @param alphabet Input alphabet for the semantic automaton
76+
* @param alphabet Alphabet of non-delaying inputs
7477
* @param modelParams LocalTimerMealyModel parameters
7578
* @param initialSuffixes Initial set of suffixes. May be empty.
7679
* @param timeOracle The output query oracle for MMLTs.
7780
* @param symbolFilter The symbol filter. If no filter should be used, use the AcceptAll filter.
7881
*/
79-
public LStarLocalTimerMealy(Alphabet<TimedInput<I>> alphabet,
82+
public LStarLocalTimerMealy(Alphabet<I> alphabet,
8083
LocalTimerMealyModelParams<O> modelParams,
8184
List<Word<TimedInput<I>>> initialSuffixes,
8285
AbstractTimedQueryOracle<I, O> timeOracle,
@@ -87,15 +90,15 @@ public LStarLocalTimerMealy(Alphabet<TimedInput<I>> alphabet,
8790
/**
8891
* Instantiates a new Rivest-Schapire learner for MMLTs.
8992
*
90-
* @param alphabet Input alphabet for the semantic automaton
93+
* @param alphabet Alphabet of non-delaying inputs
9194
* @param modelParams LocalTimerMealyModel parameters
9295
* @param initialSuffixes Initial set of suffixes. May be empty.
9396
* @param closingStrategy Closing strategy for the observation table.
9497
* @param timeOracle The output query oracle for MMLTs.
9598
* @param symbolFilter The symbol filter. If no filter should be used, use the AcceptAll filter.
9699
* @param analyzer The strategy for decomposing counterexamples.
97100
*/
98-
public LStarLocalTimerMealy(Alphabet<TimedInput<I>> alphabet,
101+
public LStarLocalTimerMealy(Alphabet<I> alphabet,
99102
LocalTimerMealyModelParams<O> modelParams,
100103
List<Word<TimedInput<I>>> initialSuffixes,
101104
ClosingStrategy<? super TimedInput<I>, ? super Word<TimedOutput<O>>> closingStrategy,
@@ -108,9 +111,14 @@ public LStarLocalTimerMealy(Alphabet<TimedInput<I>> alphabet,
108111

109112
// Prepare hyp data:
110113

114+
// Internally, the learner also stores TimeStepSequences in its alphabet:
115+
GrowingAlphabet<TimedInput<I>> internalAlphabet = new GrowingMapAlphabet<>();
116+
alphabet.forEach(s -> internalAlphabet.add(TimedInput.input(s)));
117+
111118
// Init hypothesis data:
112-
this.hypData = new LStarLocalTimerMealyHypDataContainer<>(alphabet, modelParams,
113-
new LocalTimerMealyObservationTable<>(alphabet, modelParams.maxTimerQueryWaitingTime(), symbolFilter, modelParams.silentOutput()));
119+
this.hypData = new LStarLocalTimerMealyHypDataContainer<>(internalAlphabet, modelParams,
120+
new LocalTimerMealyObservationTable<>(internalAlphabet,
121+
modelParams.maxTimerQueryWaitingTime(), symbolFilter, modelParams.silentOutput()));
114122

115123
this.cexAnalyzer = new LocalTimerMealyCounterexampleHandler<>(timeOracle, analyzer, symbolFilter);
116124
this.symbolFilter = symbolFilter;

algorithms/active/lstar/src/test/java/de/learnlib/algorithm/lstar/mmlt/LStarLocalTimerMealyBenchmarkTests.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ private static <S, I, T, O> void learnModel(String name, MMLT<S, I, T, O> automa
9494
stats.setCounter("original_inputs", "Untimed alphabet size in original", automaton.getInputAlphabet().size());
9595

9696
// Set up a pipeline:
97-
Alphabet<TimedInput<I>> alphabet = new GrowingMapAlphabet<>(automaton.getInputAlphabet().stream().map(TimedInput::input).toList());
98-
9997
// Query oracle -> TimeoutReducer -> Cache -> Query stats -> SUL
10098
LocalTimerMealySimulatorSUL<?, I, ?, O> sul = new LocalTimerMealySimulatorSUL<>(automaton.getSemantics());
10199
LocalTimerMealyStatsSUL<I, O> statsAfterCache = new LocalTimerMealyStatsSUL<>(sul, stats);
@@ -116,7 +114,7 @@ private static <S, I, T, O> void learnModel(String name, MMLT<S, I, T, O> automa
116114

117115
// Create learner:
118116
List<Word<TimedInput<I>>> suffixes = new ArrayList<>();
119-
alphabet.forEach(s -> suffixes.add(Word.fromLetter(s)));
117+
automaton.getInputAlphabet().forEach(s -> suffixes.add(Word.fromLetter(TimedInput.input(s))));
120118
suffixes.add(Word.fromLetter(new TimeoutSymbol<>()));
121119

122120
// Configure symbol filter:
@@ -130,7 +128,7 @@ private static <S, I, T, O> void learnModel(String name, MMLT<S, I, T, O> automa
130128
filter = new LocalTimerMealyStatisticsSymbolFilter<>(automaton, filter, stats);
131129
filter = new CachedSymbolFilter<>(filter); // need to wrap to enable updates to responses
132130

133-
var learner = new LStarLocalTimerMealy<>(alphabet, params, suffixes, timeOracle, filter);
131+
var learner = new LStarLocalTimerMealy<>(automaton.getInputAlphabet(), params, suffixes, timeOracle, filter);
134132
learner.setStatsContainer(stats);
135133

136134
// Start learning:

algorithms/active/lstar/src/test/java/de/learnlib/algorithm/lstar/mmlt/LStarLocalTimerMealyCounterexampleTests.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,10 @@ public class LStarLocalTimerMealyCounterexampleTests {
2929

3030
private static <S, I, T, O> void learnModel(LocalTimerMealyModel<S, I, T, O> model, List<Word<TimedInput<I>>> counterexamples) {
3131

32-
Alphabet<TimedInput<I>> alphabet =
33-
new GrowingMapAlphabet<>(model.automaton().getInputAlphabet().stream().map(TimedInput::input).toList());
34-
3532
var sul = new LocalTimerMealySimulatorSUL<>(model.automaton().getSemantics());
3633
TimedQueryOracle<I, O> timeOracle = new TimedQueryOracle<>(sul, model.params());
3734

38-
var learner = new LStarLocalTimerMealy<>(alphabet, model.params(), Collections.emptyList(),
35+
var learner = new LStarLocalTimerMealy<>(model.automaton().getInputAlphabet(), model.params(), Collections.emptyList(),
3936
timeOracle, new AcceptAllSymbolFilter<>());
4037

4138
learner.startLearning();

examples/src/main/java/de/learnlib/example/mmlt/Example1.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ public static void main(String[] args) {
5353

5454
// ======================
5555
// Set up the pipeline:
56-
Alphabet<TimedInput<String>> alphabet =
57-
new GrowingMapAlphabet<>(model.automaton().getInputAlphabet().stream().map(TimedInput::input).toList());
58-
5956
// We use a simulator SUL to simulate our automaton:
6057
var sul = new LocalTimerMealySimulatorSUL<>(model.automaton().getSemantics());
6158

@@ -80,7 +77,7 @@ public static void main(String[] args) {
8077

8178
// Set up our L* learner:
8279
List<Word<TimedInput<String>>> suffixes = new ArrayList<>();
83-
alphabet.forEach(s -> suffixes.add(Word.fromLetter(s)));
80+
model.automaton().getInputAlphabet().forEach(s -> suffixes.add(Word.fromLetter(TimedInput.input(s))));
8481
suffixes.add(Word.fromLetter(new TimeoutSymbol<>()));
8582

8683
// A symbol filter allows us to reduce queries by exploiting prior knowledge.
@@ -92,7 +89,7 @@ public static void main(String[] args) {
9289
filter = new LocalTimerMealyStatisticsSymbolFilter<>(model.automaton(), filter, stats);
9390
filter = new CachedSymbolFilter<>(filter); // need to wrap to enable updates to responses
9491

95-
var learner = new LStarLocalTimerMealy<>(alphabet, model.params(), suffixes, timeOracle, filter);
92+
var learner = new LStarLocalTimerMealy<>(model.automaton().getInputAlphabet(), model.params(), suffixes, timeOracle, filter);
9693
learner.setStatsContainer(stats);
9794

9895
// Start learning:

0 commit comments

Comments
 (0)