* @param expectedPairs a set of pairs which has to be returned
* @param graphName the name to give to the constructed graph
*/
public final void testChooseStatePairs(String fsm, String [] initialReds, String [][] expectedReds, List<PairScore> expectedPairs, String graphName)
{
final LearnerGraph fsmAsLearnerGraph = FsmParser.buildLearnerGraph(fsm, graphName,config,getLabelConverter());
final DirectedSparseGraph gB = fsmAsLearnerGraph.pathroutines.getGraph();
for(PairScore pair:expectedPairs)
{
Assert.assertNotNull("vertex "+pair.getQ()+" is missing in the graph",fsmAsLearnerGraph.findVertex(pair.getQ()));
Assert.assertNotNull("vertex "+pair.getR()+" is missing in the graph",fsmAsLearnerGraph.findVertex(pair.getR()));
}
//Visualiser.updateFrame(new LearnerGraph(gB,Configuration.getDefaultConfiguration()), null);Visualiser.waitForKey();
// check how the reference pair selection function performs
Configuration conf = testConfig.copy();conf.setLearnerUseStrings(false);conf.setLearnerCloneGraph(false);
testChooseStatePairsInternal(gB,new LearnerGraph(gB, conf), initialReds, expectedReds, expectedPairs, new InterfaceChooserToTest() {
public @Override Stack<StatePair> choosePairs() {// Here I need to convert the old type of pairs to the new one.
Stack<OrigStatePair> pairs = chooseStatePairs(gB, new HashSet<List<Label>>(), new HashSet<List<Label>>());
Stack<StatePair> result = new Stack<StatePair>();
for(OrigStatePair pair:pairs) result.add(new StatePair((CmpVertex)pair.getQ(),(CmpVertex)pair.getR()));
return result;
}
});
final DirectedSparseGraph gA = FsmParser.buildLearnerGraph(fsm, graphName,config,getLabelConverter()).pathroutines.getGraph();
// check how the revised pair selection function performs
final LearnerGraph s = new LearnerGraph(gA, testConfig);
testChooseStatePairsInternal(gA,s, initialReds, expectedReds, expectedPairs, new InterfaceChooserToTest() {
public @Override Stack<? extends StatePair> choosePairs() {
return s.pairscores.chooseStatePairs(null);
}
});