if (filteredPairs.isEmpty())
stateToLabelRed = pairs.get(0).getQ();// if mandatory merge rules out all mergers, return any of the states to be marked red
else
if (classifierToChooseWhereNoMergeIsAppropriate)
{
PairScore worstPair = getPairToBeLabelledRed(filteredPairs,coregraph);
if (worstPair != null)
{
stateToLabelRed = worstPair.getQ();
/*
long highestScore=-1;
for(PairScore p:pairs)
if (p.getScore() > highestScore) highestScore = p.getScore();
{
List<PairScore> pairOfInterest = Arrays.asList(new PairScore[]{worstPair});
List<PairScore> correctPairs = new ArrayList<PairScore>(pairOfInterest.size()), wrongPairs = new ArrayList<PairScore>(pairOfInterest.size());
SplitSetOfPairsIntoRightAndWrong(coregraph, referenceGraph, pairOfInterest, correctPairs, wrongPairs);
// this one is checking that wrong pairs because we aim to check that the pair chosen is not the right one to merge
System.out.println("resolvePotentialDeadEnd: pair forced red: "+stateToLabelRed+" pair: "+worstPair+" max score: "+highestScore+(wrongPairs.isEmpty()?" THAT IS INCORRECT":""));
}
*/
}
//System.out.println("resolvePotentialDeadEnd: number of states considered = "+pairs.size()+" number of reds: "+reds.size()+(worstPair != null?(" pair chosen as the worst: "+worstPair):""));
}
return stateToLabelRed;// resolution depends on whether Weka has successfully guessed that all pairs are wrong.
}
@Override
public void initComputation(@SuppressWarnings("unused") LearnerGraph gr) {
// dummy
}
@Override
public long overrideScoreComputation(PairScore p) {
return p.getScore();// dummy
}});
if (!outcome.isEmpty())
{
List<PairScore> filteredPairs = filterPairsBasedOnMandatoryMerge(outcome,graph);
assert !outcome.isEmpty() : "no feasible pairs left for a choice by QSM, this case should have been handled by resolvePotentialDeadEnd";
//System.out.println("classifyPairs: number of states considered = "+filteredPairs.size()+" number of reds: "+graph.getRedStateNumber()+" ( before filtering "+outcome.size()+")");
ArrayList<PairScore> possibleResults = classifyPairs(filteredPairs,graph);
updateStatistics(pairQuality, graph,referenceGraph, filteredPairs);
if (possibleResults.isEmpty())
{
possibleResults.add(pickPairQSMLike(filteredPairs));// no pairs have been provided by the modified algorithm, hence using the default one.
//System.out.println("no suitable pair was found");
}
PairScore result = possibleResults.iterator().next();
outcome.clear();outcome.push(result);
/*
{
List<PairScore> correctPairs = new ArrayList<PairScore>(outcome.size()), wrongPairs = new ArrayList<PairScore>(outcome.size());
SplitSetOfPairsIntoRightAndWrong(graph, referenceGraph, outcome, correctPairs, wrongPairs);