Uh oh!
There was an error while loading. Please reload this page.
How to print the intermediate observation table (especially when the create the hypothesis) #117
Replies: 3 comments 4 replies
In this case you need to implement the lstar.startLearning();
DFA<?, Character> hyp = lstar.getHypothesisModel();
DefaultQuery<Character, Boolean> ce;
while ((ce = eqo.findCounterExample(hyp, alphabet)) != null) {
while (lstar.refineHypothesis(ce)) {}
hyp = lstar.getHypothesisModel();
}Here, you can insert any code you want between the individual steps (e.g., the logging of intermediate observation tables). |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Please provide that when we run the algorithm we can measure the entire time, but I want to compute the time in that number of equivalence queries and membership queies separately. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
actually I ddin't know much about the implementation from the library. Please can we provide the little bit of idea or sample code so I can do it by myself packagecom.experiment;
importcom.experiment.dfa.DFAOperation;
importcom.google.common.collect.Lists;
importde.learnlib.algorithms.lstar.closing.ClosingStrategies;
importde.learnlib.algorithms.lstar.dfa.ClassicLStarDFA;
importde.learnlib.algorithms.lstar.dfa.ClassicLStarDFABuilder;
importde.learnlib.algorithms.malerpnueli.MalerPnueliDFA;
importde.learnlib.algorithms.rivestschapire.RivestSchapireDFA;
importde.learnlib.algorithms.rivestschapire.RivestSchapireDFABuilder;
importde.learnlib.api.oracle.MembershipOracle;
importde.learnlib.api.query.DefaultQuery;
importde.learnlib.datastructure.observationtable.ObservationTable;
importde.learnlib.datastructure.observationtable.writer.ObservationTableASCIIWriter;
importde.learnlib.filter.statistic.oracle.DFACounterOracle;
importde.learnlib.oracle.equivalence.DFAWMethodEQOracle;
importde.learnlib.oracle.equivalence.SampleSetEQOracle;
importde.learnlib.oracle.membership.SimulatorOracle;
importde.learnlib.util.Experiment;
importdk.brics.automaton.Automaton;
importdk.brics.automaton.RegExp;
importnet.automatalib.automata.fsa.DFA;
importnet.automatalib.brics.BricsDFA;
importnet.automatalib.util.automata.conformance.WMethodTestsIterator;
importnet.automatalib.visualization.Visualization;
importnet.automatalib.words.Alphabet;
importnet.automatalib.words.impl.Alphabets;
publicclassDriver {
privatestaticfinalDFAOperationdfaOperation = newDFAOperation();
privatestaticfinalintEXPLORATION_DEPTH = 5;
publicstaticvoidmain(String[] args) {
Stringregex = "a|b|.{3,}";
finalAutomatonautomaton = newRegExp(regex).toAutomaton();
finalAlphabet<Character> alphabet = Alphabets.characters('a', 'b');
finalBricsDFAdfa = newBricsDFA(automaton, true);
MembershipOracle.DFAMembershipOracle<Character> sul = newSimulatorOracle.DFASimulatorOracle<>(dfa);
rsAlgorithm(dfa, alphabet, sul);
System.out.println("-------------------------------------------------------");
}
privatestaticvoidrsAlgorithm(BricsDFAdfa, Alphabet<Character> alphabet, MembershipOracle.DFAMembershipOracle<Character> sul) {
DFACounterOracle<Character> rsCounter = newDFACounterOracle<>(sul, "Membership Queries");
RivestSchapireDFA<Character> rs = newRivestSchapireDFABuilder<Character>()
.withAlphabet(alphabet)
.withOracle(rsCounter)
.withClosingStrategy(ClosingStrategies.CLOSE_FIRST)
.create();
finalSampleSetEQOracle<Character, Boolean> eqo = newSampleSetEQOracle<>(false);
eqo.addAll(sul, Lists.newArrayList(newWMethodTestsIterator<>(dfa, alphabet, EXPLORATION_DEPTH)));
Experiment.DFAExperiment<Character> rsExperiment = newExperiment.DFAExperiment<>(rs, eqo, alphabet);
rs.startLearning();
DFA<?, Character> hyp = rs.getHypothesisModel();
DefaultQuery<Character, Boolean> ce;
intcount = 1;
while ((ce = eqo.findCounterExample(hyp, alphabet)) != null) {
while (rs.refineHypothesis(ce)) {
System.out.println(ce.toStringWithAnswer(true));
hyp = rs.getHypothesisModel();
// Visualization.visualize(hyp, alphabet);newObservationTableASCIIWriter<>().write(rs.getObservationTable(), System.out);
++count;
}
}
longstartTime = System.currentTimeMillis();
// rsExperiment.run();longendTime = System.currentTimeMillis();
printResults("L_RS", rsExperiment, rsCounter, endTime - startTime);
System.out.println("Final observation table of L_RS:");
newObservationTableASCIIWriter<>().write(rs.getObservationTable(), System.out);
}
privatestaticvoidprintResults(StringalgorithmName, Experiment.DFAExperiment<Character> experiment,
DFACounterOracle<Character> counterOracle, longtimeTaken) {
System.out.println("----------------" + algorithmName + "-------------");
System.out.println("EQ: " + experiment.getRounds().getCount());
System.out.println("MQ: " + counterOracle.getCount());
System.out.println("Time: " + timeTaken);
}
} |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
"I provide the code, I want to print the intermediate observation table when hypothesis created or when the each membership queries ask to the teacher (SUL)"
All reactions