public static bool TestGraphPaths(TransducerGraph sourceGraph, TransducerGraph testGraph, int numPaths) { for (int i = 0; i < numPaths; i++) { IList path = sourceGraph.SampleUniformPathFromGraph(); double score = sourceGraph.GetOutputOfPathInGraph(path); double newScore = testGraph.GetOutputOfPathInGraph(path); if ((score - newScore) / (score + newScore) > 1e-10) { System.Console.Out.WriteLine("Problem: " + score + " vs. " + newScore + " on " + path); return(false); } } return(true); }
/// <summary>For testing only.</summary> private static void PrintPathOutputs(IList <IList> pathList, TransducerGraph graph, bool printPaths) { int i = 0; foreach (IList path in pathList) { if (printPaths) { foreach (object aPath in path) { System.Console.Out.Write(aPath + " "); } } else { System.Console.Out.Write(i++ + " "); } System.Console.Out.Write("output: " + graph.GetOutputOfPathInGraph(path)); System.Console.Out.WriteLine(); } }