-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* short: - new AdaptiveQuery abstract class with adt and default query extensions - new adaptiveADTOracle classes with parallel interfaces and static implementation - adaptive membership oracle for preset adaptive queries - sleepySUL - changes in ADTLearner class for new Adaptive classes verbose: - added abstract class Adaptive Query in "de.learnlib.query" - added Adaptive_ADT_Query class in "de.learnlib.algorithm.adt.Adaptive" - (added ADTNode<S, I, O> getSuccessor() in ADTResetNode ( in "de.learnlib.algorithm.adt.adt" ) for Adaptive_ADT_Query to work ) - added AdaptiveMembershipOracle interface in "de.learnlib.oracle" - added package Adaptive in "de/learnlib/algorithm/adt/Adaptive" - added Sul_Adaptive_Oracle class in "de.learnlib.algorithm.adt.Adaptive" - added Adaptive_DEF_Query class in "de.learnlib.algorithm.adt.Adaptive" - added A2M_Oracle class in "de.learnlib.algorithm.adt.Adaptive" - added ParallelAdaptiveOracle interface in "de.learnlib.oracle" - added StaticParallelAdaptiveOracle in "de.learnlib.oracle.parallelism" - added SleepySUL class in "de.learnlib.algorithm.adt.Adaptive" - modified ADTLearner class: - added constructor for adaptive membership oracle - added AdaptiveMembershipOracle attribute. - modified startLearning() to choose between oracles - added closeTransitionsLeon() method to use appropriate oracles * added contact info to the parent pom.xml * initial refacotring ideas known issues: * adaptive parallel oracle testing still missing * AQOOTBridge non-functional * A2S_Oracle non-functional * add parallelism tests * some experimentation with adaptive caches * may replace SQOOTBridge * testing of counter currently broken * some progress * some progress * tests now pass * fix code-analysis remarks * remove old SymbolQuery code * some cleanups * share some functionality * add documentation + small cleanups * update CHANGELOG * remove obsolete method --------- Co-authored-by: vito <vito@vito> Co-authored-by: Markus Frohme <[email protected]> Co-authored-by: Markus Frohme <[email protected]>
- Loading branch information
1 parent
3e5c33d
commit bd602cb
Showing
56 changed files
with
2,642 additions
and
995 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
algorithms/active/adt/src/main/java/de/learnlib/algorithm/adt/learner/ADSAmbiguityQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* Copyright (C) 2013-2024 TU Dortmund University | ||
* This file is part of LearnLib, http://www.learnlib.de/. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package de.learnlib.algorithm.adt.learner; | ||
|
||
import java.util.ArrayDeque; | ||
import java.util.Deque; | ||
|
||
import de.learnlib.algorithm.adt.adt.ADTNode; | ||
import de.learnlib.algorithm.adt.automaton.ADTState; | ||
import net.automatalib.word.Word; | ||
|
||
/** | ||
* Utility class to resolve ADS ambiguities. This query simply tracks the current ADT node for the given inputs. | ||
* | ||
* @param <I> | ||
* input symbol type | ||
* @param <O> | ||
* output symbol type | ||
*/ | ||
class ADSAmbiguityQuery<I, O> extends AbstractAdaptiveQuery<I, O> { | ||
|
||
private final Word<I> accessSequence; | ||
private final Deque<I> oneShotPrefix; | ||
|
||
private int asIndex; | ||
private boolean inOneShot; | ||
|
||
ADSAmbiguityQuery(Word<I> accessSequence, Word<I> oneShotPrefix, ADTNode<ADTState<I, O>, I, O> root) { | ||
super(root); | ||
this.accessSequence = accessSequence; | ||
this.oneShotPrefix = new ArrayDeque<>(oneShotPrefix.asList()); | ||
this.asIndex = 0; | ||
this.inOneShot = false; | ||
} | ||
|
||
@Override | ||
public I getInput() { | ||
if (this.asIndex < this.accessSequence.length()) { | ||
return this.accessSequence.getSymbol(this.asIndex); | ||
} else { | ||
this.inOneShot = !this.oneShotPrefix.isEmpty(); | ||
if (this.inOneShot) { | ||
return oneShotPrefix.poll(); | ||
} else { | ||
return this.currentADTNode.getSymbol(); | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public Response processOutput(O out) { | ||
if (this.asIndex < this.accessSequence.length()) { | ||
asIndex++; | ||
return Response.SYMBOL; | ||
} else if (this.inOneShot) { | ||
return Response.SYMBOL; | ||
} else { | ||
return super.processOutput(out); | ||
} | ||
} | ||
|
||
@Override | ||
protected void resetProgress() { | ||
this.asIndex = 0; | ||
} | ||
} | ||
|
||
|
107 changes: 107 additions & 0 deletions
107
...thms/active/adt/src/main/java/de/learnlib/algorithm/adt/learner/ADSVerificationQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* Copyright (C) 2013-2024 TU Dortmund University | ||
* This file is part of LearnLib, http://www.learnlib.de/. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package de.learnlib.algorithm.adt.learner; | ||
|
||
import java.util.Objects; | ||
|
||
import de.learnlib.algorithm.adt.automaton.ADTState; | ||
import de.learnlib.query.AdaptiveQuery; | ||
import de.learnlib.query.DefaultQuery; | ||
import net.automatalib.word.Word; | ||
import net.automatalib.word.WordBuilder; | ||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
|
||
/** | ||
* Utility class to verify ADSs. This query tracks the current ADT node for the given inputs and compares it with an | ||
* expected output, potentially constructing a counterexample from the observed data. | ||
* | ||
* @param <I> | ||
* input symbol type | ||
* @param <O> | ||
* output symbol type | ||
*/ | ||
class ADSVerificationQuery<I, O> implements AdaptiveQuery<I, O> { | ||
|
||
private final Word<I> prefix; | ||
private final Word<I> suffix; | ||
private final Word<O> expectedOutput; | ||
private final WordBuilder<O> outputBuilder; | ||
private final ADTState<I, O> state; | ||
|
||
private final int prefixLength; | ||
private final int suffixLength; | ||
private int idx; | ||
private @Nullable DefaultQuery<I, Word<O>> counterexample; | ||
|
||
ADSVerificationQuery(Word<I> prefix, Word<I> suffix, Word<O> expectedSuffixOutput, ADTState<I, O> state) { | ||
this.prefix = prefix; | ||
this.suffix = suffix; | ||
this.expectedOutput = expectedSuffixOutput; | ||
this.outputBuilder = new WordBuilder<>(suffix.size()); | ||
this.state = state; | ||
|
||
this.prefixLength = prefix.length(); | ||
this.suffixLength = suffix.length(); | ||
this.idx = 0; | ||
} | ||
|
||
@Override | ||
public I getInput() { | ||
if (idx < prefixLength) { | ||
return prefix.getSymbol(idx); | ||
} else { | ||
return suffix.getSymbol(idx - prefixLength); | ||
} | ||
} | ||
|
||
@Override | ||
public Response processOutput(O out) { | ||
if (idx < prefixLength) { | ||
idx++; | ||
return Response.SYMBOL; | ||
} else { | ||
outputBuilder.append(out); | ||
|
||
if (!Objects.equals(out, expectedOutput.getSymbol(idx - prefixLength))) { | ||
counterexample = | ||
new DefaultQuery<>(prefix, suffix.prefix(outputBuilder.size()), outputBuilder.toWord()); | ||
return Response.FINISHED; | ||
} else if (outputBuilder.size() < suffixLength) { | ||
idx++; | ||
return Response.SYMBOL; | ||
} else { | ||
return Response.FINISHED; | ||
} | ||
} | ||
} | ||
|
||
@Nullable | ||
DefaultQuery<I, Word<O>> getCounterexample() { | ||
return counterexample; | ||
} | ||
|
||
ADTState<I, O> getState() { | ||
return state; | ||
} | ||
|
||
Word<I> getSuffix() { | ||
return suffix; | ||
} | ||
|
||
Word<O> getExpectedOutput() { | ||
return expectedOutput; | ||
} | ||
} |
Oops, something went wrong.