Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10198


Ignore:
Timestamp:
12/05/13 15:23:48 (11 years ago)
Author:
ascheibe
Message:

#1886

  • added liblrs and c# wrapper for vertex enumeration/volume calculation
  • use MIConvexHull for triangulation and volume calculation
  • fixed vertex conversion code for MIConvexHull lib
  • added a unit test for measuring performance of convex hull/volume calculation
Location:
branches/HeuristicLab.Analysis.AlgorithmBehavior
Files:
22 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/AlgorithmBehaviorUnitTests/AlgorithmBehaviorUnitTests.csproj

    r10109 r10198  
    104104    <Compile Include="ConvexHullTest.cs" />
    105105    <Compile Include="RealVectorSolutionCacheTest.cs" />
     106    <Compile Include="TestVolumeCalculation.cs" />
    106107  </ItemGroup>
    107108  <ItemGroup>
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/AlgorithmBehaviorUnitTests/ConvexHullTest.cs

    r10081 r10198  
    7474      for (int i = 0; i < data.Count(); i++) {
    7575        double[] d = data[i];
    76         for (int j = 0; j < d.Length; j++) {
    77           DefaultVertex vertex = new DefaultVertex();
    78           vertex.Position = d.Select(x => x).ToArray();
    79           result.Add(vertex);
    80         }
     76
     77        DefaultVertex vertex = new DefaultVertex();
     78        vertex.Position = d;
     79        result.Add(vertex);
     80
    8181      }
    8282      return result;
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/AlgorithmBehaviorUnitTests/LPConvexHullTest.cs

    r10081 r10198  
    145145      for (int i = 0; i < data.Count(); i++) {
    146146        double[] d = data[i];
    147         for (int j = 0; j < d.Length; j++) {
    148           DefaultVertex vertex = new DefaultVertex();
    149           vertex.Position = d.Select(x => x).ToArray();
    150           result.Add(vertex);
    151         }
     147        DefaultVertex vertex = new DefaultVertex();
     148        vertex.Position = d;
     149        result.Add(vertex);
    152150      }
    153151      return result;
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/ConvexHullMeasures.cs

    r10097 r10198  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
     25using MIConvexHull;
    2426
    2527namespace HeuristicLab.Analysis.AlgorithmBehavior.Analyzers {
     
    6769      return volume;
    6870    }
     71
     72    public static double CalculateVolumeNew(List<double[]> convexHull) {
     73      double volume = 0.0;
     74
     75      int dim = convexHull.First().Length;
     76      if (dim > convexHull.Count)
     77        throw new ArgumentException("Nr. of points for volume calculation must be greater than dimension", "convexHull");
     78
     79      var triangulation = Triangulation.CreateDelaunay(ConvertToVertex(convexHull));
     80      var simplices = ConvertFromTriangulation(triangulation);
     81      foreach (var simplex in simplices) {
     82        volume += CalculateSimplexVolume(simplex.ToList());
     83      }
     84
     85      return volume;
     86    }
     87
     88    private static List<double[][]> ConvertFromTriangulation(ITriangulation<DefaultVertex, DefaultTriangulationCell<DefaultVertex>> triangulation) {
     89      List<double[][]> results = new List<double[][]>();
     90
     91      foreach (var cell in triangulation.Cells) {
     92        results.Add(cell.Vertices.Select(x => x.Position).ToArray());
     93      }
     94
     95      return results;
     96    }
     97
     98    private static List<DefaultVertex> ConvertToVertex(List<double[]> data) {
     99      List<DefaultVertex> result = new List<DefaultVertex>();
     100      for (int i = 0; i < data.Count(); i++) {
     101        double[] d = data[i];
     102        DefaultVertex vertex = new DefaultVertex();
     103        vertex.Position = d;
     104        result.Add(vertex);
     105      }
     106      return result;
     107    }
    69108  }
    70109}
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers-3.3.csproj

    r10116 r10198  
    159159      <Private>False</Private>
    160160    </ProjectReference>
     161    <ProjectReference Include="..\..\MIConvexHull\MIConvexHull.csproj">
     162      <Project>{2337776d-7d0c-40aa-a439-c26c3ce24fab}</Project>
     163      <Name>MIConvexHull</Name>
     164    </ProjectReference>
    161165  </ItemGroup>
    162166  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/Visualization/Program.cs

    r9945 r10198  
    8585      for (int i = 0; i < data.Count(); i++) {
    8686        double[] d = data[i];
    87         for (int j = 0; j < d.Length; j++) {
    88           DefaultVertex vertex = new DefaultVertex();
    89           vertex.Position = d.Select(x => x).ToArray();
    90           result.Add(vertex);
    91         }
     87        DefaultVertex vertex = new DefaultVertex();
     88        vertex.Position = d;
     89        result.Add(vertex);
     90
    9291      }
    9392      return result;
Note: See TracChangeset for help on using the changeset viewer.