コード例 #1
0
ファイル: Program.cs プロジェクト: szalaigj/TilingApplication
 private static void writeOutTiles(int serverNO, int spaceDimension, Coords[] partition)
 {
     StringBuilder strBldr = new StringBuilder();
     StringBuilder strBldrForServers = new StringBuilder();
     for (int idx = 0; idx < serverNO; idx++)
     {
         strBldrForServers.Append(partition[idx].HeftOfRegion);
         strBldrForServers.Append(" ").Append(idx);
         strBldrForServers.AppendLine();
         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());
     string serversOutput = @"c:\temp\data\servers.dat";
     System.IO.File.WriteAllText(serversOutput, strBldrForServers.ToString());
 }
コード例 #2
0
ファイル: Divider.cs プロジェクト: szalaigj/TilingApplication
 public Coords[] determinePartition()
 {
     int[] indicesArray = new int[2 * spaceDimension];
     for (int idx = 0; idx < spaceDimension; idx++)
     {
         indicesArray[2 * idx] = 0;
         indicesArray[2 * idx + 1] = histogramResolution - 1;
     }
     Coords coords = new Coords
     {
         IndicesArray = indicesArray,
         HeftOfRegion = (int)heftArray.GetValue(indicesArray),
         MaxDiv = 0.0
     };
     innerDetermineMaxDivAndChildren(coords);
     innerDeterminePartition(coords.FirstChild, coords.SecondChild);
     return listOfLeaves.ToArray();
 }
コード例 #3
0
ファイル: Divider.cs プロジェクト: szalaigj/TilingApplication
 private void innerDeterminePartition(Coords coords1, Coords coords2)
 {
     innerDetermineMaxDivAndChildren(coords1);
     innerDetermineMaxDivAndChildren(coords2);
     listOfLeaves.Add(coords1);
     listOfLeaves.Add(coords2);
     if (listOfLeaves.Count < serverNO)
     {
         listOfLeaves.Sort(new Comparison<Coords>((c1, c2) => c2.MaxDiv.CompareTo(c1.MaxDiv)));
         Coords leafWithMaxDiv = listOfLeaves[0];
         Coords firstChildOfLeafWithMaxDiv = leafWithMaxDiv.FirstChild;
         Coords secondChildOfLeafWithMaxDiv = leafWithMaxDiv.SecondChild;
         listOfLeaves.Remove(leafWithMaxDiv);
         innerDeterminePartition(firstChildOfLeafWithMaxDiv, secondChildOfLeafWithMaxDiv);
     }
 }
コード例 #4
0
ファイル: Divider.cs プロジェクト: szalaigj/TilingApplication
 private void innerDetermineMaxDivAndChildren(Coords coords)
 {
     int[] maxFirstChildIndicesArray, maxSecondChildIndicesArray;
     // The following is only for initialization:
     maxFirstChildIndicesArray = maxSecondChildIndicesArray = coords.IndicesArray;
     int cellNO = (int)Math.Pow(histogramResolution, spaceDimension);
     int[] movingIndicesArray = new int[spaceDimension];
     for (int movingIdx = 0; movingIdx < cellNO; movingIdx++)
     {
         transformator.transformCellIdxToIndicesArray(histogramResolution, movingIndicesArray, movingIdx);
         for (int splitDimIdx = 0; splitDimIdx < spaceDimension; splitDimIdx++)
         {
             bool validMovingIndicesArray = transformator.validateIndicesArrays(spaceDimension, splitDimIdx,
                 coords.IndicesArray, movingIndicesArray);
             if (validMovingIndicesArray)
             {
                 int[] firstPartIndicesArray, secondPartIndicesArray;
                 int[] firstWindow, secondWindow;
                 transformator.splitIndicesArrays(spaceDimension, splitDimIdx, coords.IndicesArray,
                     movingIndicesArray, out firstPartIndicesArray, out secondPartIndicesArray);
                 transformator.determineWindowsOfSplitSides(spaceDimension, splitDimIdx, coords.IndicesArray,
                     movingIndicesArray, slidingWindowSize, histogramResolution,
                     out firstWindow, out secondWindow);
                 double currentDiv = determineCurrentDiv(firstWindow, secondWindow, firstPartIndicesArray, secondPartIndicesArray);
                 if (coords.MaxDiv < currentDiv)
                 {
                     coords.MaxDiv = currentDiv;
                     maxFirstChildIndicesArray = firstPartIndicesArray;
                     maxSecondChildIndicesArray = secondPartIndicesArray;
                 }
             }
         }
     }
     Coords firstChild = new Coords
     {
         IndicesArray = maxFirstChildIndicesArray,
         HeftOfRegion = (int)heftArray.GetValue(maxFirstChildIndicesArray),
         MaxDiv = 0.0,
     };
     coords.FirstChild = firstChild;
     Coords secondChild = new Coords
     {
         IndicesArray = maxSecondChildIndicesArray,
         HeftOfRegion = (int)heftArray.GetValue(maxSecondChildIndicesArray),
         MaxDiv = 0.0,
     };
     coords.SecondChild = secondChild;
 }