@Override
public void initComputation(LearnerGraph graph)
{
coregraph = graph;
cl = new MarkovClassifier(m, coregraph);
extendedGraph = cl.constructMarkovTentative();
}
@Override
public long overrideScoreComputation(PairScore p)
{
long pairScore = p.getScore();
if (pairScore >= 0)
pairScore = MarkovScoreComputation.computenewscore(p, extendedGraph);
return pairScore;
}
/** This one returns a set of transitions in all directions. */
@SuppressWarnings("unused")
@Override
public Collection<Entry<Label, CmpVertex>> getSurroundingTransitions(CmpVertex currentRed)
{
return null;
}
});
actualAutomaton = learnerOfPairs.learnMachine(new LinkedList<List<Label>>(),new LinkedList<List<Label>>());
SampleData dataSample = new SampleData(null,null);
//dataSample.difference = new DifferenceToReferenceDiff(0, 0);
//dataSample.differenceForReferenceLearner = new DifferenceToReferenceDiff(0, 0);
VertID rejectVertexID = null;
for(CmpVertex v:actualAutomaton.transitionMatrix.keySet())
if (!v.isAccept())
{
assert rejectVertexID == null : "multiple reject vertices in learnt automaton, such as "+rejectVertexID+" and "+v;
rejectVertexID = v;break;
}
if (rejectVertexID == null)
rejectVertexID = actualAutomaton.nextID(false);
actualAutomaton.pathroutines.completeGraphPossiblyUsingExistingVertex(rejectVertexID);// we need to complete the graph, otherwise we are not matching it with the original one that has been completed.
dataSample.actualLearner = estimateDifference(referenceGraph,actualAutomaton,testSet);
dataSample.actualLearner.inconsistency = MarkovClassifier.computeInconsistency(actualAutomaton, m, checker,false);
dataSample.referenceLearner = zeroScore;
LearnerGraph outcomeOfReferenceLearner = new LearnerGraph(config);
try
{
outcomeOfReferenceLearner = //new ReferenceLearnerUsingSiccoScoring(learnerEval,ptaCopy,false).learnMachine(new LinkedList<List<Label>>(),new LinkedList<List<Label>>());
new EDSMReferenceLearner(learnerEval,ptaCopy,2).learnMachine(new LinkedList<List<Label>>(),new LinkedList<List<Label>>());
dataSample.referenceLearner = estimateDifference(referenceGraph, outcomeOfReferenceLearner,testSet);
dataSample.referenceLearner.inconsistency = MarkovClassifier.computeInconsistency(outcomeOfReferenceLearner, m, checker,false);
}
catch(LearnerAbortedException ex)
{// the exception is thrown because the learner failed to learn anything completely. Ignore it because the default score is zero assigned via zeroScore.
}
dataSample.fractionOfStatesIdentifiedBySingletons=Math.round(100*MarkovClassifier.calculateFractionOfStatesIdentifiedBySingletons(referenceGraph));
dataSample.stateNumber = referenceGraph.getStateNumber();
dataSample.transitionsSampled = Math.round(100*trimmedReference.pathroutines.countEdges()/referenceGraph.pathroutines.countEdges());
statechum.Pair<Double,Double> correctnessOfMarkov = new MarkovClassifier(m, referenceGraph).evaluateCorrectnessOfMarkov();
dataSample.markovPrecision = Math.round(100*correctnessOfMarkov.firstElem);dataSample.markovRecall = Math.round(100*correctnessOfMarkov.secondElem);
Collection<List<Label>> wset=WMethod.computeWSet_reducedw(referenceGraph);
int wSeqLen=0;
for(List<Label> seq:wset)
{