public IterativeDivider(Array array, Array heftArray, Transformator transformator, int spaceDimension,
     int histogramResolution, int serverNO, double delta, int pointNO, int kNN, int maxRange,
     Shell[] shellsForKNN, Shell[] shellsForRange, double kNNMeasCoeff, double lbMeasCoeff)
     : base(array, heftArray, transformator, spaceDimension, histogramResolution, serverNO, delta, 
         pointNO, kNN, maxRange, shellsForKNN, shellsForRange, kNNMeasCoeff, lbMeasCoeff)
 {
 }
 public RecursiveDivider(Array array, Array heftArray, Transformator transformator, int spaceDimension,
     int histogramResolution, int serverNO, double delta, int pointNO, int kNN, int maxRange,
     Shell[] shellsForKNN, Shell[] shellsForRange, double kNNMeasCoeff, double lbMeasCoeff)
     : base(array, heftArray, transformator, spaceDimension, histogramResolution, serverNO, delta, 
         pointNO, kNN, maxRange, shellsForKNN, shellsForRange, kNNMeasCoeff, lbMeasCoeff)
 {
     this.initializationValue = -1.0;
     transformator.initializeObjectiveValueArray(this.initializationValue, this.objectiveValueArray);
 }
 public BaseDivider(Array array, Array heftArray, Transformator transformator, int spaceDimension, 
     int histogramResolution, int serverNO, double delta, int pointNO, int kNN, int maxRange, 
     Shell[] shellsForKNN, Shell[] shellsForRange, double kNNMeasCoeff, double lbMeasCoeff)
 {
     this.heftArray = heftArray;
     this.transformator = transformator;
     this.spaceDimension = spaceDimension;
     this.histogramResolution = histogramResolution;
     this.serverNO = serverNO;
     this.delta = delta;
     this.kNNMeasCoeff = kNNMeasCoeff;
     this.lbMeasCoeff = lbMeasCoeff;
     int[] lengthsObjectiveValueArray = new int[2 * spaceDimension + 1];
     lengthsObjectiveValueArray[0] = serverNO;
     for (int idx = 1; idx <= 2 * spaceDimension; idx++)
     {
         lengthsObjectiveValueArray[idx] = histogramResolution;
     }
     this.objectiveValueArray = Array.CreateInstance(typeof(double), lengthsObjectiveValueArray);
     this.partitionArray = Array.CreateInstance(typeof(Coords[]), lengthsObjectiveValueArray);
     this.hasEnoughBinsArray = Array.CreateInstance(typeof(bool), lengthsObjectiveValueArray);
     setMeasureInstances(array, pointNO, kNN, maxRange, shellsForKNN, shellsForRange);
 }
Example #4
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 InputParser(Transformator transformator)
 {
     this.transformator = transformator;
 }
 public HeftArrayCreator(Transformator transformator)
 {
     this.transformator = transformator;
 }