-
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.
procedural: add OptimalLStar adapters
- Loading branch information
Showing
8 changed files
with
106 additions
and
4 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
47 changes: 47 additions & 0 deletions
47
...al/src/main/java/de/learnlib/algorithm/procedural/adapter/dfa/OptimalLStarAdapterDFA.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,47 @@ | ||
/* 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.procedural.adapter.dfa; | ||
|
||
import java.util.List; | ||
|
||
import de.learnlib.AccessSequenceTransformer; | ||
import de.learnlib.algorithm.oml.lstar.OptimalLStarDFA; | ||
import de.learnlib.oracle.MembershipOracle; | ||
import net.automatalib.alphabet.Alphabet; | ||
import net.automatalib.word.Word; | ||
|
||
/** | ||
* Adapter for using {@link OptimalLStarDFA} as a procedural learner. | ||
* | ||
* @param <I> | ||
* input symbol type | ||
*/ | ||
public class OptimalLStarAdapterDFA<I> extends OptimalLStarDFA<I> implements AccessSequenceTransformer<I> { | ||
|
||
public OptimalLStarAdapterDFA(Alphabet<I> alphabet, MembershipOracle<I, Boolean> oracle) { | ||
super(alphabet, oracle); | ||
} | ||
|
||
@Override | ||
public Word<I> transformAccessSequence(Word<I> word) { | ||
final List<Boolean> row = super.rowForState(word); | ||
final List<Word<I>> shortPrefixes = super.getShortPrefixes(row); | ||
|
||
assert shortPrefixes.size() == 1; | ||
|
||
return shortPrefixes.get(0); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...rc/main/java/de/learnlib/algorithm/procedural/adapter/mealy/OptimalLStarAdapterMealy.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,49 @@ | ||
/* 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.procedural.adapter.mealy; | ||
|
||
import java.util.List; | ||
|
||
import de.learnlib.AccessSequenceTransformer; | ||
import de.learnlib.algorithm.oml.lstar.OptimalLStarMealy; | ||
import de.learnlib.oracle.MembershipOracle; | ||
import net.automatalib.alphabet.Alphabet; | ||
import net.automatalib.word.Word; | ||
|
||
/** | ||
* Adapter for using {@link OptimalLStarMealy} as a procedural learner. | ||
* | ||
* @param <I> | ||
* input symbol type | ||
* @param <O> | ||
* output symbol type | ||
*/ | ||
public class OptimalLStarAdapterMealy<I, O> extends OptimalLStarMealy<I, O> implements AccessSequenceTransformer<I> { | ||
|
||
public OptimalLStarAdapterMealy(Alphabet<I> alphabet, MembershipOracle<I, Word<O>> oracle) { | ||
super(alphabet, oracle); | ||
} | ||
|
||
@Override | ||
public Word<I> transformAccessSequence(Word<I> word) { | ||
final List<Word<O>> row = super.rowForState(word); | ||
final List<Word<I>> shortPrefixes = super.getShortPrefixes(row); | ||
|
||
assert shortPrefixes.size() == 1; | ||
|
||
return shortPrefixes.get(0); | ||
} | ||
} |
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