-
Notifications
You must be signed in to change notification settings - Fork 3
Fundamental Refactoring of SL Lambda Learning Algorithm #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
FredrikTaquist
wants to merge
29
commits into
main
Choose a base branch
from
sllambda-refactor
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
2d5e626
classification tree and slct implementation
FredrikTaquist 4b3ff4e
update out-of-date code and fix errors
FredrikTaquist 7f37b3d
add sllambda algorithm and replace ralambda with sllambda
FredrikTaquist c3fc70a
bugfixing
FredrikTaquist 510acdb
remove method call introduced in java 21
FredrikTaquist 37a794b
fix query counting in caching oracle and update query numbers
FredrikTaquist a700572
fix to caching oracle query counting
FredrikTaquist 5398c1d
remove unused files
FredrikTaquist bf76607
apply spotless
FredrikTaquist decd5ea
remove one additional unused file
FredrikTaquist a424449
change variable name to keep codespell happy
FredrikTaquist 5574133
remove some prints
FredrikTaquist 4b8e253
remove unused dependency
FredrikTaquist 0041267
remove unused and commented out code
FredrikTaquist acf70bd
improve readability with code reorganization and documentation/comments
FredrikTaquist 943222e
apply spotless
FredrikTaquist 0d7dbcc
fix mistake in ClassificationTree::suffixRevealsNewGuard
FredrikTaquist 9e4a661
add test case for issue #78
FredrikTaquist 422a5a6
rename test so it runs automatically
FredrikTaquist 392c6a2
attempt number 2 at renaming test
FredrikTaquist 1b5d55b
fix ineq theory guard merging bug
FredrikTaquist 63a02bd
add test case revealing bug
FredrikTaquist 0519bc8
fix bug with comparing sdts using inequality theory
FredrikTaquist dd2105c
add test revealing non-determinacy bug
FredrikTaquist c65f8f1
include ra transitions in ra run
FredrikTaquist 64cc631
remove unused methods
FredrikTaquist 1d1c92c
update login test query count
FredrikTaquist 1f918d4
fix error in RARun::getGuard
FredrikTaquist fea8076
small fixes, tidying up, and removing unused code
FredrikTaquist File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,158 @@ | ||
| package de.learnlib.ralib.automata; | ||
|
|
||
|
|
||
| import java.util.ArrayList; | ||
| import java.util.Collections; | ||
| import java.util.LinkedHashSet; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| import de.learnlib.ralib.automata.output.OutputMapping; | ||
| import de.learnlib.ralib.automata.output.OutputTransition; | ||
| import de.learnlib.ralib.data.Constants; | ||
| import de.learnlib.ralib.data.DataValue; | ||
| import de.learnlib.ralib.data.Mapping; | ||
| import de.learnlib.ralib.data.RegisterValuation; | ||
| import de.learnlib.ralib.data.SymbolicDataValue; | ||
| import de.learnlib.ralib.data.SymbolicDataValue.Parameter; | ||
| import de.learnlib.ralib.smt.VarsValuationVisitor; | ||
| import de.learnlib.ralib.words.PSymbolInstance; | ||
| import gov.nasa.jpf.constraints.api.Expression; | ||
| import gov.nasa.jpf.constraints.expressions.NumericBooleanExpression; | ||
| import gov.nasa.jpf.constraints.expressions.NumericComparator; | ||
| import gov.nasa.jpf.constraints.util.ExpressionUtil; | ||
|
|
||
| /** | ||
| * Data structure containing the locations, register valuations, symbol instances | ||
| * and transitions at each step of a run of a hypothesis over a data word. | ||
| * | ||
| * @author fredrik | ||
| */ | ||
| public class RARun { | ||
|
|
||
| private final RALocation[] locations; | ||
| private final RegisterValuation[] valuations; | ||
| private final PSymbolInstance[] symbols; | ||
| private final Transition[] transitions; | ||
|
|
||
| public RARun(RALocation[] locations, RegisterValuation[] valuations, PSymbolInstance[] symbols, Transition[] transitions) { | ||
| this.locations = locations; | ||
| this.valuations = valuations; | ||
| this.symbols = symbols; | ||
| this.transitions = transitions; | ||
| } | ||
|
|
||
| public RALocation getLocation(int i) { | ||
| return locations[i]; | ||
| } | ||
|
|
||
| public RegisterValuation getValuation(int i) { | ||
| return valuations[i]; | ||
| } | ||
|
|
||
| public PSymbolInstance getTransitionSymbol(int i) { | ||
| return symbols[i-1]; | ||
| } | ||
|
|
||
| public Transition getRATransition(int i) { | ||
| return transitions[i-1]; | ||
| } | ||
|
|
||
| /** | ||
| * Get the guard of the {@code Transition} at index {@code i}. If the {@code Transition} | ||
| * is an {@code OutputTransition}, the guard is computed from the transition's | ||
| * {@code OutputMapping}. | ||
| * | ||
| * @param i | ||
| * @return | ||
| */ | ||
| public Expression<Boolean> getGuard(int i) { | ||
| Transition transition = getRATransition(i); | ||
| if (transition == null) { | ||
| return null; | ||
| } | ||
| return transition instanceof OutputTransition ? | ||
| outputGuard((OutputTransition) transition) : | ||
| transition.getGuard(); | ||
| } | ||
|
|
||
| /** | ||
| * Get the guard of the {@code Transition} at index {@code i}. If the {@code Transition} | ||
| * is an {@code OutputTransition}, the guard is computed from the transition's | ||
| * {@code OutputMapping}. Registers of the guard will be evaluated according to the | ||
| * data values from the register valuation at index {@code i}, and constants will be | ||
| * evaluated according to {@code consts}. | ||
| * | ||
| * @param i | ||
| * @return | ||
| */ | ||
| public Expression<Boolean> getGuard(int i, Constants consts) { | ||
| Expression<Boolean> guard = getGuard(i); | ||
| VarsValuationVisitor vvv = new VarsValuationVisitor(); | ||
| Mapping<SymbolicDataValue, DataValue> vals = new Mapping<>(); | ||
| vals.putAll(getValuation(i)); | ||
| vals.putAll(consts); | ||
| return vvv.apply(guard, vals); | ||
| } | ||
|
|
||
| private Expression<Boolean> outputGuard(OutputTransition t) { | ||
| OutputMapping out = t.getOutput(); | ||
|
|
||
| Set<Parameter> params = new LinkedHashSet<>(); | ||
| params.addAll(out.getFreshParameters()); | ||
| params.addAll(out.getOutput().keySet()); | ||
| Set<SymbolicDataValue> regs = new LinkedHashSet<>(); | ||
| regs.addAll(out.getOutput().values()); | ||
|
|
||
| Expression[] expressions = new Expression[params.size()]; | ||
| int index = 0; | ||
|
|
||
| // fresh parameters | ||
| List<Parameter> prior = new ArrayList<>(); | ||
| List<Parameter> fresh = new ArrayList<>(out.getFreshParameters()); | ||
| Collections.sort(fresh, (a,b) -> Integer.compare(a.getId(), b.getId())); | ||
| for (Parameter p : fresh) { | ||
| Expression[] diseq = new Expression[prior.size() + regs.size()]; | ||
| int i = 0; | ||
| for (Parameter prev : prior) { | ||
| diseq[i++] = new NumericBooleanExpression(p, NumericComparator.NE, prev); | ||
| } | ||
| for (SymbolicDataValue s : regs) { | ||
| diseq[i++] = new NumericBooleanExpression(p, NumericComparator.NE, s); | ||
| } | ||
| expressions[index++] = ExpressionUtil.and(diseq); | ||
| prior.add(p); | ||
| } | ||
|
|
||
| // mapped parameters | ||
| for (Map.Entry<Parameter, SymbolicDataValue> e : out.getOutput().entrySet()) { | ||
| Parameter p = e.getKey(); | ||
| SymbolicDataValue s = e.getValue(); | ||
| expressions[index++] = new NumericBooleanExpression(p, NumericComparator.EQ, s); | ||
| } | ||
|
|
||
| return ExpressionUtil.and(expressions); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| if (locations.length == 0) { | ||
| return "ε"; | ||
| } | ||
|
|
||
| String str = "<" + locations[0] + ", " + valuations[0] + ">"; | ||
| for (int i = 1; i < locations.length; i++) { | ||
| str = str + | ||
| " -- " + | ||
| symbols[i-1] + | ||
| " -- <" + | ||
| locations[i] + | ||
| ", " + | ||
| valuations[i] + | ||
| ">"; | ||
| } | ||
|
|
||
| return str; | ||
| } | ||
| } |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we remove the deprecated method? |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to remove the deprecated method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for removal. Esp. given the comment above it that it is unsafe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why these methods are deprecated is that the XML automata models make use of the unsafe functionality, in that they are coded to only assign a parameter to a register. They do not reassign old values for registers that will be reused. Because of this, removing the deprecated methods will require refactoring of the XML models. I am not opposed to refactoring the models, but I feel like this is beyond the scope of this PR and should perhaps be done in a separate PR.