public double computeMeasure(Coords[] partition)
 {
     double measure = 0.0;
     foreach (var coords in partition)
     {
         measure += computeMeasureForRegion(coords);
     }
     measure = measure / serverNO;
     return measure;
 }
Example #2
0
 private static void writeOutTiles(int serverNO, int spaceDimension, Coords[] partition)
 {
     StringBuilder strBldr = new StringBuilder();
     for (int idx = 0; idx < serverNO; idx++)
     {
         partition[idx].printCoords(spaceDimension, idx + 1);
         partition[idx].writeToStringBuilder(spaceDimension, strBldr);
     }
     string tilesOutput = @"c:\temp\data\tiles.dat";
     System.IO.File.WriteAllText(tilesOutput, strBldr.ToString());
 }
Example #3
0
 private static void writeOutServers(int serverNO, Coords[] partition)
 {
     StringBuilder strBldr = new StringBuilder();
     for (int tileIdx = 0; tileIdx < serverNO; tileIdx++)
     {
         strBldr.Append(partition[tileIdx].HeftOfRegion).Append(" " + tileIdx);
         strBldr.AppendLine();
     }
     string serversOutput = @"c:\temp\data\servers.dat";
     System.IO.File.WriteAllText(serversOutput, strBldr.ToString());
 }
 private double computeMeasureForRegion(Coords coords)
 {
     return 1 - (coords.differenceFromDelta(delta) / (double)pointNO);
 }
 private Coords[] determinePartitionWhenRemainderServerNOIsZero(int[] indicesArray)
 {
     Coords[] partition;
     int heftOfRegion = (int)heftArray.GetValue(indicesArray);
     Coords coords = new Coords
     {
         IndicesArray = indicesArray,
         HeftOfRegion = heftOfRegion
     };
     partition = new Coords[] { coords };
     return partition;
 }
 private Coords[] determinePartitionWhenRemainderServerNOIsLargerThanZero(int[] indicesArray, 
     int remainderServerNO, int splitLevel)
 {
     // alternate dimension index based on split level
     int splitDimIdx = splitLevel % spaceDimension;
     int minHeftDiffBetweenParts = int.MaxValue;
     int[] minFirstPartIndicesArray = new int[2 * spaceDimension];
     int[] minSecondPartIndicesArray = new int[2 * spaceDimension];
     determineMinHeftDiff(indicesArray, splitDimIdx, ref minHeftDiffBetweenParts, ref minFirstPartIndicesArray,
         ref minSecondPartIndicesArray);
     Coords[] firstPartPartition = innerDecompose(minFirstPartIndicesArray, remainderServerNO / 2,
         splitLevel + 1);
     Coords[] secondPartPartition = innerDecompose(minSecondPartIndicesArray, remainderServerNO / 2,
         splitLevel + 1);
     Coords[] partition = new Coords[remainderServerNO];
     firstPartPartition.CopyTo(partition, 0);
     secondPartPartition.CopyTo(partition, firstPartPartition.Length);
     return partition;
 }