Skip to content

Commit c47f63b

Browse files
committed
ADT: replace usage of deprecated Triple with own datatype
allows for a more expressive result, rather than a generic 3 tuple
1 parent e1fc8c4 commit c47f63b

2 files changed

Lines changed: 21 additions & 10 deletions

File tree

algorithms/active/adt/src/main/java/de/learnlib/algorithms/adt/adt/ADT.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import de.learnlib.algorithms.adt.config.LeafSplitters;
2727
import de.learnlib.algorithms.adt.util.ADTUtil;
2828
import de.learnlib.api.oracle.SymbolQueryOracle;
29-
import net.automatalib.commons.util.Triple;
3029
import net.automatalib.words.Word;
3130

3231
/**
@@ -215,10 +214,10 @@ public ADTNode<S, I, O> splitLeaf(final ADTNode<S, I, O> nodeToSplit,
215214
* @param s2
216215
* second node
217216
*
218-
* @return A {@link Triple} containing the lowest common {@link ADTNode}, the output determining the subtree of the
219-
* first node and the outuput determining the subtree of the second node
217+
* @return A {@link LCAInfo} containing the lowest common {@link ADTNode}, the output determining the subtree of the
218+
* first node and the output determining the subtree of the second node
220219
*/
221-
public Triple<ADTNode<S, I, O>, O, O> findLCA(final ADTNode<S, I, O> s1, final ADTNode<S, I, O> s2) {
220+
public LCAInfo<S, I, O> findLCA(final ADTNode<S, I, O> s1, final ADTNode<S, I, O> s2) {
222221

223222
final Map<ADTNode<S, I, O>, ADTNode<S, I, O>> s1ParentsToS1 = new HashMap<>();
224223

@@ -243,7 +242,7 @@ public Triple<ADTNode<S, I, O>, O, O> findLCA(final ADTNode<S, I, O> s1, final A
243242
final O s1Out = ADTUtil.getOutputForSuccessor(lca, s1ParentsToS1.get(lca));
244243
final O s2Out = ADTUtil.getOutputForSuccessor(lca, s2Iter);
245244

246-
return new Triple<>(lca, s1Out, s2Out);
245+
return new LCAInfo<>(lca, s1Out, s2Out);
247246
}
248247

249248
s2Iter = s2Iter.getParent();
@@ -255,4 +254,16 @@ public Triple<ADTNode<S, I, O>, O, O> findLCA(final ADTNode<S, I, O> s1, final A
255254
public void setLeafSplitter(final LeafSplitter leafSplitter) {
256255
this.leafSplitter = leafSplitter;
257256
}
257+
258+
public static class LCAInfo<S, I, O> {
259+
public final ADTNode<S, I, O> adtNode;
260+
public final O firstOutput;
261+
public final O secondOutput;
262+
263+
LCAInfo(ADTNode<S, I, O> adtNode, O firstOutput, O secondOutput) {
264+
this.adtNode = adtNode;
265+
this.firstOutput = firstOutput;
266+
this.secondOutput = secondOutput;
267+
}
268+
}
258269
}

algorithms/active/adt/src/main/java/de/learnlib/algorithms/adt/learner/ADTLearner.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
import com.github.misberner.buildergen.annotations.GenerateBuilder;
3535
import de.learnlib.algorithms.adt.adt.ADT;
36+
import de.learnlib.algorithms.adt.adt.ADT.LCAInfo;
3637
import de.learnlib.algorithms.adt.adt.ADTLeafNode;
3738
import de.learnlib.algorithms.adt.adt.ADTNode;
3839
import de.learnlib.algorithms.adt.adt.ADTResetNode;
@@ -60,7 +61,6 @@
6061
import de.learnlib.util.MQUtil;
6162
import net.automatalib.automata.transout.MealyMachine;
6263
import net.automatalib.commons.util.Pair;
63-
import net.automatalib.commons.util.Triple;
6464
import net.automatalib.words.Alphabet;
6565
import net.automatalib.words.Word;
6666
import net.automatalib.words.WordBuilder;
@@ -749,13 +749,13 @@ private void resolveAmbiguities(final ADTNode<ADTState<I, O>, I, O> nodeToReplac
749749
}
750750
}
751751

752-
final Triple<ADTNode<ADTState<I, O>, I, O>, O, O> lcaResult = this.adt.findLCA(oldReference, newReference);
753-
final ADTNode<ADTState<I, O>, I, O> lca = lcaResult.getFirst();
752+
final LCAInfo<ADTState<I, O>, I, O> lcaResult = this.adt.findLCA(oldReference, newReference);
753+
final ADTNode<ADTState<I, O>, I, O> lca = lcaResult.adtNode;
754754
final Pair<Word<I>, Word<O>> lcaTrace = ADTUtil.buildTraceForNode(lca);
755755

756756
final Word<I> sepWord = lcaTrace.getFirst().append(lca.getSymbol());
757-
final Word<O> oldOutputTrace = lcaTrace.getSecond().append(lcaResult.getSecond());
758-
final Word<O> newOutputTrace = lcaTrace.getSecond().append(lcaResult.getThird());
757+
final Word<O> oldOutputTrace = lcaTrace.getSecond().append(lcaResult.firstOutput);
758+
final Word<O> newOutputTrace = lcaTrace.getSecond().append(lcaResult.secondOutput);
759759

760760
final ADTNode<ADTState<I, O>, I, O> oldTrace =
761761
ADTUtil.buildADSFromObservation(sepWord, oldOutputTrace, iter.getHypothesisState());

0 commit comments

Comments
 (0)