Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10008


Ignore:
Timestamp:
09/26/13 23:56:55 (11 years ago)
Author:
ascheibe
Message:

#1886 added volume calculation for convex d-polytopes

File:
1 edited

Legend:

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

    r10007 r10008  
    2525namespace HeuristicLab.Analysis.AlgorithmBehavior.Analyzers {
    2626  public static class ConvexHullMeasures {
    27     //TODO: Calculates only the volumne of a d-simplex
    28     public static double CalculateVolume(List<double[]> hyperHull) {
     27    //Calculates the volumne of a d-simplex
     28    private static double CalculateSimplexVolume(List<double[]> hyperHull) {
    2929      double[,] diffs = new double[hyperHull.Count, hyperHull.Count];
    3030
     
    5050      return result;
    5151    }
     52
     53    //calculate inner point for boundary triangulation (slowwwww.....)
     54    private static double[] CalculateInnerPoint(List<double[]> hyperHull) {
     55      double[] result = new double[hyperHull[0].Count()];
     56
     57      for (int i = 0; i < hyperHull[0].Count(); i++) {
     58        result[i] = hyperHull.Max(x => x[i]) - hyperHull.Min(x => x[i]);
     59      }
     60
     61      return result;
     62    }
     63
     64    //calculates the volume of a convex d-polytope
     65    //decomposition based on boundary triangulation
     66    public static double CalculateVolume(List<double[]> hyperHull) {
     67      double[] innerPoint = CalculateInnerPoint(hyperHull);
     68      double volume = 0.0;
     69
     70      for (int i = 0; i < hyperHull.Count - 1; i += 2) {
     71        List<double[]> simplex = new List<double[]>();
     72        simplex.Add(innerPoint);
     73        simplex.Add(hyperHull[i]);
     74        simplex.Add(hyperHull[i + 1]);
     75        volume += CalculateSimplexVolume(simplex);
     76      }
     77      return volume;
     78    }
    5279  }
    5380}
Note: See TracChangeset for help on using the changeset viewer.