Skip to content

Commit 903cdf7

Browse files
committed
initial refactorings / cleanups
1 parent 929b07e commit 903cdf7

50 files changed

Lines changed: 964 additions & 1238 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

algorithms/active/lstar/pom.xml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,23 @@ limitations under the License.
155155
<configuration>
156156
<!-- append to existing argLine to nicely work together with jacoco plugin -->
157157
<!-- allow tests access to util and statistics -->
158-
<argLine>@{argLine} --add-reads=de.learnlib.algorithm.lstar=net.automatalib.util --add-reads=de.learnlib.algorithm.lstar=de.learnlib.filter.statistic
158+
<argLine>
159+
@{argLine}
160+
--add-reads=de.learnlib.algorithm.lstar=net.automatalib.util
161+
--add-reads=de.learnlib.algorithm.lstar=de.learnlib.filter.statistic
162+
</argLine>
163+
</configuration>
164+
</plugin>
165+
<plugin>
166+
<groupId>org.apache.maven.plugins</groupId>
167+
<artifactId>maven-failsafe-plugin</artifactId>
168+
<configuration>
169+
<!-- append to existing argLine to nicely work together with jacoco plugin -->
170+
<!-- allow tests access to util and statistics -->
171+
<argLine>
172+
@{argLine}
173+
--add-reads=de.learnlib.algorithm.lstar=net.automatalib.util
174+
--add-reads=de.learnlib.algorithm.lstar=de.learnlib.filter.statistic
159175
</argLine>
160176
</configuration>
161177
</plugin>

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

Lines changed: 145 additions & 41 deletions
Large diffs are not rendered by default.

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

Lines changed: 0 additions & 129 deletions
This file was deleted.

algorithms/active/lstar/src/main/java/de/learnlib/algorithm/lstar/mmlt/LStarLocalTimerMealyHypDataContainer.java renamed to algorithms/active/lstar/src/main/java/de/learnlib/algorithm/lstar/mmlt/MMLTHypDataContainer.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package de.learnlib.algorithm.lstar.mmlt;
22

3-
import de.learnlib.algorithm.LocalTimerMealyModelParams;
3+
import de.learnlib.algorithm.MMLTModelParams;
44
import de.learnlib.datastructure.observationtable.Row;
55
import net.automatalib.alphabet.Alphabet;
66
import net.automatalib.symbol.time.TimedInput;
@@ -20,16 +20,16 @@
2020
* @param <I> Input type for non-delaying inputs
2121
* @param <O> Output symbol type
2222
*/
23-
class LStarLocalTimerMealyHypDataContainer<I, O> {
23+
class MMLTHypDataContainer<I, O> {
2424
private final Alphabet<TimedInput<I>> alphabet;
2525

26-
private final LocalTimerMealyObservationTable<I, O> table;
26+
private final MMLTObservationTable<I, O> table;
2727
private final Map<Word<TimedInput<I>>, TimedOutput<O>> transitionOutputMap;
2828
private final Set<Word<TimedInput<I>>> transitionResetSet; // all transitions that trigger a reset
2929

30-
private final LocalTimerMealyModelParams<O> modelParams;
30+
private final MMLTModelParams<O> modelParams;
3131

32-
public LStarLocalTimerMealyHypDataContainer(Alphabet<TimedInput<I>> alphabet, LocalTimerMealyModelParams<O> modelParams, LocalTimerMealyObservationTable<I, O> table) {
32+
public MMLTHypDataContainer(Alphabet<TimedInput<I>> alphabet, MMLTModelParams<O> modelParams, MMLTObservationTable<I, O> table) {
3333
this.alphabet = alphabet;
3434
this.modelParams = modelParams;
3535
this.table = table;
@@ -49,7 +49,7 @@ protected TimedOutput<O> getTransitionOutput(Row<TimedInput<I>> stateRow, int in
4949
}
5050

5151

52-
public LocalTimerMealyModelParams<O> getModelParams() {
52+
public MMLTModelParams<O> getModelParams() {
5353
return modelParams;
5454
}
5555

@@ -58,7 +58,7 @@ public Alphabet<TimedInput<I>> getAlphabet() {
5858
}
5959

6060

61-
public LocalTimerMealyObservationTable<I, O> getTable() {
61+
public MMLTObservationTable<I, O> getTable() {
6262
return table;
6363
}
6464

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package de.learnlib.algorithm.lstar.mmlt;
2+
3+
import java.util.Map;
4+
5+
import net.automatalib.alphabet.Alphabet;
6+
import net.automatalib.automaton.mmlt.State;
7+
import net.automatalib.automaton.mmlt.SymbolCombiner;
8+
import net.automatalib.automaton.mmlt.impl.CompactMMLT;
9+
import net.automatalib.symbol.time.TimeStepSequence;
10+
import net.automatalib.symbol.time.TimedInput;
11+
import net.automatalib.word.Word;
12+
13+
/**
14+
* An MMLT hypothesis that includes a prefix mapping. This mapping assigns a short prefix to each location.
15+
*
16+
* @param <I>
17+
* Input type for non-delaying inputs
18+
* @param <O>
19+
* Output symbol type
20+
*/
21+
public class MMLTHypothesis<I, O> extends CompactMMLT<I, O> {
22+
23+
private final Map<Integer, Word<TimedInput<I>>> prefixMap; // location -> prefix
24+
25+
MMLTHypothesis(Alphabet<I> alphabet,
26+
int sizeHint,
27+
O silentOuput,
28+
SymbolCombiner<O> outputCombiner,
29+
Map<Integer, Word<TimedInput<I>>> prefixMap) {
30+
super(alphabet, sizeHint, silentOuput, outputCombiner);
31+
this.prefixMap = prefixMap;
32+
}
33+
34+
/**
35+
* Returns the prefix assigned to the provided configuration. The assigned prefix is the concatenation of the prefix
36+
* assigned to the active location and the minimal number of time steps needed to reach the configuration after
37+
* entering its location (= entry distance).
38+
*
39+
* @param configuration
40+
* Considered configuration
41+
*
42+
* @return Assigned prefix
43+
*/
44+
public Word<TimedInput<I>> getPrefix(State<Integer, O> configuration) {
45+
var locPrefix = getLocationPrefix(configuration);
46+
if (configuration.isEntryConfig()) {
47+
return locPrefix; // entry distance = 0
48+
} else {
49+
return locPrefix.append(new TimeStepSequence<>(configuration.getEntryDistance()));
50+
}
51+
}
52+
53+
public Word<TimedInput<I>> getPrefix(Word<TimedInput<I>> prefix) {
54+
var resultingConfig = getSemantics().getState(prefix);
55+
return getPrefix(resultingConfig);
56+
}
57+
58+
/**
59+
* Returns the prefix assigned to the location that is active in the provided configuration.
60+
*
61+
* @param configuration
62+
* Considered configuration
63+
*
64+
* @return Assigned prefix
65+
*/
66+
public Word<TimedInput<I>> getLocationPrefix(State<Integer, O> configuration) {
67+
var locPrefix = this.prefixMap.get(configuration.getLocation());
68+
if (locPrefix == null) {throw new AssertionError();}
69+
return locPrefix;
70+
}
71+
72+
/**
73+
* Returns a prefix for the given location. This prefix is deterministic in the RS learner.
74+
*
75+
* @param location
76+
* Location
77+
*
78+
* @return Location prefix
79+
*/
80+
public Word<TimedInput<I>> getPrefix(Integer location) {
81+
return prefixMap.get(location);
82+
}
83+
}

0 commit comments

Comments
 (0)