Пример #1
0
        static void Main(string[] args)
        {
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();

            IntTupleEqualityComparer comparer = new IntTupleEqualityComparer();
            CornacchiaMethod cornacchiaMethod = new CornacchiaMethod(comparer);
            BacktrackingMethod backtrackingMethod = new BacktrackingMethod(cornacchiaMethod);
            ShellBuilder shellBuilder = new ShellBuilder(backtrackingMethod);
            Transformator transformator = new Transformator(shellBuilder);
            InputParser inputParser = new InputParser(transformator);
            HeftArrayCreator heftArrayCreator = new HeftArrayCreator(transformator);
            //int kNN = 274;
            double kNNMeasCoeff = 1.0;//0.1;
            double lbMeasCoeff = 0.0;//0.9;

            int serverNO;
            int pointNO;
            double delta;
            int spaceDimension;
            int histogramResolution;
            Array array;
            bool together = inputParser.determineTogetherOrSeparately();
            if (together)
            {
                array = inputParser.parseInputFile(out spaceDimension, out histogramResolution,
                    out serverNO, out pointNO, out delta);
            }
            else
            {
                parseInputSeparately(inputParser, out serverNO, out pointNO, out delta, out spaceDimension,
                    out histogramResolution, out array);
            }
            int kNN = (int)Math.Ceiling(delta);
            int maxShellNO = transformator.determineMaxRange(spaceDimension, histogramResolution);
            Shell[] shellsForKNN = shellBuilder.createShells(maxShellNO, spaceDimension);
            int maxRange = transformator.determineMaxRange(spaceDimension, histogramResolution / 2);
            Shell[] shellsForRange = shellBuilder.createShells(maxRange, spaceDimension);
            Console.WriteLine("Point no.: {0}", pointNO);
            Console.WriteLine("Delta: {0}", delta);
            Console.WriteLine("kNN measurement coefficient: {0}", kNNMeasCoeff);
            Console.WriteLine("Load balancing measurement coefficient: {0}", lbMeasCoeff);

            Array heftArray = heftArrayCreator.createHeftArray(spaceDimension, histogramResolution, array);

            IterativeDivider divider = new IterativeDivider(array, heftArray, transformator, spaceDimension,
                histogramResolution, serverNO, delta, pointNO, kNN, maxRange, shellsForKNN, shellsForRange,
                kNNMeasCoeff, lbMeasCoeff);
            Coords[] partition;
            double objectiveValue = divider.determineObjectiveValue(out partition);
            Console.WriteLine("Objective value: {0}", objectiveValue);
            Console.WriteLine("Sum of differences between tile hefts and delta: {0}", divider.getDiffSum());
            writeOutTiles(serverNO, spaceDimension, partition);
            writeOutServers(serverNO, partition);
            writeOutCellsToServers(histogramResolution, serverNO, partition);

            stopwatch.Stop();
            // Write hours, minutes and seconds.
            Console.WriteLine("Elapsed time: {0:hh\\:mm\\:ss}", stopwatch.Elapsed);

            Console.WriteLine("Press any key to exit!");
            Console.Read();
        }
 public BacktrackingMethod(CornacchiaMethod cornacchiaMethod)
 {
     this.cornacchiaMethod = cornacchiaMethod;
 }