@SuppressWarnings("unused")
@Override
public CmpVertex resolvePotentialDeadEnd(LearnerGraph gr, Collection<CmpVertex> reds, List<PairScore> pairs)
{
PairScore p = LearnerThatCanClassifyPairs.pickPairQSMLike(pairs);
LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>> verticesToMerge = new LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>>();
// constructPairsToMergeBasedOnSetsToMerge(coregraph.transitionMatrix.keySet(),verticesToMergeBasedOnInitialPTA)
int genScore = coregraph.pairscores.computePairCompatibilityScore_general(p, null, verticesToMerge);
assert genScore >= 0;
LearnerGraph merged = MergeStates.mergeCollectionOfVertices(coregraph, null, verticesToMerge);
long value = MarkovClassifier.computeInconsistency(merged, m, checker,false);
inconsistencyFromAnEarlierIteration = value;
return null;
}
long inconsistencyFromAnEarlierIteration = 0;
LearnerGraph coregraph = null;
LearnerGraphND inverseGraph = null;
/** Where I have a set of paths to merge because I have identified specific states, this map is constructed that maps vertices to be merged together to the partition number that corresponds to them. */
Map<CmpVertex,Integer> vertexToPartition = new TreeMap<CmpVertex,Integer>();
@Override
public void initComputation(LearnerGraph graph)
{
coregraph = graph;
//labelStatesAwayFromRoot(coregraph,m.getChunkLen()-1);
inverseGraph = (LearnerGraphND)MarkovClassifier.computeInverseGraph(coregraph,true);
vertexToPartition.clear();
int partitionNumber=0;
for(Set<CmpVertex> set:verticesToMergeBasedOnInitialPTA)
{
for(CmpVertex v:set) vertexToPartition.put(v, partitionNumber);
++partitionNumber;
}
}
@Override
public long overrideScoreComputation(PairScore p)
{
/*
MarkovClassifier cl = new MarkovClassifier(m, coregraph);
long score = 0;
Map<Label, MarkovOutcome> predictedFromRed=cl.predictTransitionsFromState(p.getR(), null, m.getChunkLen(), null);
for(Entry<Label,MarkovOutcome> entry:cl.predictTransitionsFromState(p.getQ(), null, m.getChunkLen(), null).entrySet())
{
MarkovOutcome red = predictedFromRed.get(entry.getKey());
if (red == null || red != entry.getValue())
{
score = -1;break;
}
}
if (score >= 0)
{
LearnerGraph extendedGraph = cl.constructMarkovTentative();
score = extendedGraph.pairscores.computePairCompatibilityScore(p);
}
*/
long score = p.getScore();//computeScoreUsingMarkovFanouts(coregraph,origInverse,m,callbackAlphabet,p);
if (score < 0)
return score;
long currentInconsistency = 0;
Integer a=vertexToPartition.get(p.getR()), b = vertexToPartition.get(p.getQ());
LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>> verticesToMerge = new LinkedList<AMEquivalenceClass<CmpVertex,LearnerGraphCachedData>>();
int genScore = coregraph.pairscores.computePairCompatibilityScore_general(p, null, verticesToMerge);
if (genScore >= 0)
{
LearnerGraph merged = MergeStates.mergeCollectionOfVertices(coregraph, null, verticesToMerge);