Пример #1
0
 private static double buildHistograms(InputParser inputParser, HistogramComputer histogramComputer, 
     KnuthPosteriorComputer knuthPosteriorComputer, string filename, int spaceDimension, int pointNO, 
     double[] minElems, double[] maxElems, int serverNO, int upperBoundOfPostVals, 
     double[] posteriorValues, double[] centralDiffs, int initialHistRes, List<DataRow> data)
 {
     double posteriorSum = 0.0;
     for (int histogramResolution = initialHistRes; histogramResolution <= upperBoundOfPostVals;
         histogramResolution++)
     {
         int[] binHefts = histogramComputer.buildHistogram(histogramResolution, data, spaceDimension,
             minElems, maxElems);
         posteriorSum = innerBuildHistograms(inputParser, knuthPosteriorComputer, filename, spaceDimension,
             pointNO, serverNO, upperBoundOfPostVals, posteriorValues, centralDiffs, initialHistRes, posteriorSum,
             histogramResolution, binHefts);
     }
     return posteriorSum;
 }
Пример #2
0
 private static double buildHistogramsStreamMode(InputParser inputParser, HistogramComputer histogramComputer,
     KnuthPosteriorComputer knuthPosteriorComputer, string filename, int spaceDimension, int pointNO,
     double[] minElems, double[] maxElems, int serverNO, int upperBoundOfPostVals,
     double[] posteriorValues, double[] centralDiffs, int initialHistRes)
 {
     double posteriorSum = 0.0;
     for (int histogramResolution = initialHistRes; histogramResolution <= upperBoundOfPostVals;
         histogramResolution++)
     {
         int[] binHefts = new int[(int)Math.Pow(histogramResolution, spaceDimension)];
         var lines = File.ReadLines(filename);
         int lineIdx = 0;
         foreach (var line in lines)
         {
             string[] lineParts = line.Split(InputParser.delimiter);
             if (lineParts.Length < spaceDimension)
                 throw new ArgumentException("The line " + lineIdx + " has invalid dimension!");
             else if (lineParts.Length > spaceDimension)
             {
                 string[] tempLineParts = new string[spaceDimension];
                 for (int idx = 0; idx < spaceDimension; idx++)
                 {
                     tempLineParts[idx] = lineParts[idx];
                 }
                 lineParts = tempLineParts;
             }
             double[] coords = new double[spaceDimension];
             for (int coordIdx = 0; coordIdx < lineParts.Length; coordIdx++)
             {
                 coords[coordIdx] = Double.Parse(lineParts[coordIdx], NumberStyles.Float,
                     CultureInfo.InvariantCulture);
             }
             histogramComputer.buildHistogramForDataRowTuple(histogramResolution, spaceDimension, minElems,
                 maxElems, binHefts, coords);
             lineIdx++;
         }
         posteriorSum = innerBuildHistograms(inputParser, knuthPosteriorComputer, filename, spaceDimension,
             pointNO, serverNO, upperBoundOfPostVals, posteriorValues, centralDiffs, initialHistRes, posteriorSum,
             histogramResolution, binHefts);
     }
     return posteriorSum;
 }
Пример #3
0
 static void Main(string[] args)
 {
     InputParser inputParser = new InputParser();
     HistogramComputer histogramComputer = new HistogramComputer();
     KnuthPosteriorComputer knuthPosteriorComputer = new KnuthPosteriorComputer();
     LMethod lMethod = new LMethod();
     FurthestPointFromLineMethod furthestPointFromLineMethod = new FurthestPointFromLineMethod();
     string filename;
     int spaceDimension, pointNO, serverNO, upperBoundOfPostVals, initialHistRes;
     double[] minElems, maxElems, posteriorValues, centralDiffs;
     double posteriorSum;
     Console.WriteLine("How would you like to execute histogram building? " +
         "Would you like to apply stream mode?");
     Console.WriteLine("(Please choose this mode only if you have prior information about " +
         "object number and bounding box)");
     bool streamMode = bool.Parse(Console.ReadLine());
     if (streamMode)
     {
         handleStreamMode(inputParser, histogramComputer, knuthPosteriorComputer, out filename, out spaceDimension,
             out pointNO, out serverNO, out upperBoundOfPostVals, out initialHistRes, out minElems, out maxElems,
             out posteriorValues, out centralDiffs, out posteriorSum);
     }
     else
     {
         handleNormalMode(inputParser, histogramComputer, knuthPosteriorComputer, out filename, out spaceDimension,
             out pointNO, out serverNO, out upperBoundOfPostVals, out initialHistRes, out minElems, out maxElems,
             out posteriorValues, out centralDiffs, out posteriorSum);
     }
     writeOutStats(lMethod, furthestPointFromLineMethod, upperBoundOfPostVals, initialHistRes,
         posteriorValues, centralDiffs, posteriorSum);
     Console.WriteLine("Press any key to continue...");
     Console.Read();
 }
Пример #4
0
 private static void handleStreamMode(InputParser inputParser, HistogramComputer histogramComputer, 
     KnuthPosteriorComputer knuthPosteriorComputer, out string filename, out int spaceDimension, 
     out int pointNO, out int serverNO, out int upperBoundOfPostVals, out int initialHistRes, 
     out double[] minElems, out double[] maxElems, out double[] posteriorValues, out double[] centralDiffs, 
     out double posteriorSum)
 {
     inputParser.parseInputFileStreamMode(out filename, out spaceDimension, out pointNO,
         out minElems, out maxElems);
     initializeVariables(inputParser, pointNO, out serverNO, out upperBoundOfPostVals, out posteriorValues,
         out centralDiffs, out initialHistRes);
     posteriorSum = buildHistogramsStreamMode(inputParser, histogramComputer, knuthPosteriorComputer,
         filename, spaceDimension, pointNO, minElems, maxElems, serverNO, upperBoundOfPostVals,
         posteriorValues, centralDiffs, initialHistRes);
 }