Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10279


Ignore:
Timestamp:
01/05/14 01:30:28 (9 years ago)
Author:
ascheibe
Message:

#1886 added calculation of the ratio between the convex hull volume and the max. hypercube volume

Location:
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/ConvexHullMeasures.cs

    r10275 r10279  
    161161      return maxDist;
    162162    }
     163
     164    private static List<double[]> GenerateHyperCube(double[] bounds, int dim) {
     165      if (bounds.Length != 2)
     166        throw new ArgumentException("Only bounds of length 2 are supported!", "bounds");
     167
     168      int numPoints = (int)Math.Pow(2, dim);
     169
     170      var hyperCube = new List<double[]>(numPoints);
     171      var binaryVectors = new List<string>(numPoints);
     172      for (int i = 0; i < numPoints; i++) {
     173        string binary = Convert.ToString(i, 2);
     174        binaryVectors.Add(binary);
     175      }
     176
     177      for (int i = 0; i < numPoints; i++) {
     178        for (int j = 0; j < dim - binaryVectors[i].Length; j++) {
     179          //TODO: do this properly
     180          binaryVectors[i] = "0" + binaryVectors[i];
     181        }
     182      }
     183
     184      foreach (var binaryVector in binaryVectors) {
     185        double[] point = new double[dim];
     186        for (int i = 0; i < binaryVector.Length; i++) {
     187          if (binaryVector[i] == '0') {
     188            point[i] = bounds[0];
     189          } else {
     190            point[i] = bounds[1];
     191          }
     192        }
     193        hyperCube.Add(point);
     194      }
     195      return hyperCube;
     196    }
     197
     198    public static double CalculateHypercubeVolume(double[] bounds, int dim) {
     199      return CalculateVolume(GenerateHyperCube(bounds, dim));
     200    }
    163201  }
    164202}
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/RunCollectionModifiers/RealVectorConvexHullModifier.cs

    r10275 r10279  
    7373        DataTable centroidMotionTable = new DataTable(CentroidMotionName);
    7474        DoubleValue overallVolume = new DoubleValue();
     75        DoubleValue overallVolumeRatio = new DoubleValue();
    7576
    7677        DataRow dtVolumeRow = new DataRow("Volume");
     
    112113        if (completeHull != null && completeHull.Any() && completeHull.First().Length < completeHull.Count) {
    113114          overallVolume.Value = ConvexHullMeasures.CalculateVolume(completeHull);
     115          var boundsMatrix = run.Parameters["Bounds"] as DoubleMatrix;
     116          var bounds = new double[] { boundsMatrix[0, 0], boundsMatrix[0, 1] };
     117          double hyperHullVolume = ConvexHullMeasures.CalculateHypercubeVolume(bounds, BestSolutionParameter.Value.Length);
     118          overallVolumeRatio.Value = overallVolume.Value / hyperHullVolume;
    114119        } else {
    115120          overallVolume.Value = double.NaN;
     121          overallVolumeRatio.Value = double.NaN;
    116122        }
    117123
     
    121127
    122128        run.Results["Overall volume"] = overallVolume;
     129        run.Results["Overall volume ratio"] = overallVolumeRatio;
    123130        run.Results["Overall diameter"] = new DoubleValue(ConvexHullMeasures.CalculateMaxDiameter(completeHull));
    124131        run.Results["Convex hull volume"] = volDataTable;
Note: See TracChangeset for help on using the changeset viewer.