Changeset 10224


Ignore:
Timestamp:
12/12/13 01:06:00 (6 years ago)
Author:
ascheibe
Message:

#1886

  • added more performance tests
  • tried to mute qhull
Location:
branches/HeuristicLab.Analysis.AlgorithmBehavior
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/AlgorithmBehaviorUnitTests/LPConvexHullTest.cs

    r10222 r10224  
    2121
    2222using System;
    23 using System.Collections.Generic;
    2423using System.Diagnostics;
    2524using System.Linq;
     
    3635      int sampleSize = 2;
    3736      double[][] inputs = ConvexHullTest.CreateRandomData(nrOfSamples, sampleSize);
    38       var convAlgData = ConvertPermutationToVertex(inputs);
    3937
    4038      Stopwatch watch = new Stopwatch();
     
    4442      Console.WriteLine("LPHull: " + watch.ElapsedMilliseconds);
    4543      watch.Restart();
    46       var result1 = ConvexHull.Create(convAlgData).Points.Select(x => x.Position).ToList();
     44      var result1 = ConvexHull.Create(inputs).Points.Select(x => x.Position).ToList();
    4745      watch.Stop();
    4846      Console.WriteLine("MIConvexHull: " + watch.ElapsedMilliseconds);
     
    140138      return result;
    141139    }
    142 
    143     private List<DefaultVertex> ConvertPermutationToVertex(double[][] data) {
    144       List<DefaultVertex> result = new List<DefaultVertex>();
    145       for (int i = 0; i < data.Count(); i++) {
    146         double[] d = data[i];
    147         DefaultVertex vertex = new DefaultVertex();
    148         vertex.Position = d;
    149         result.Add(vertex);
    150       }
    151       return result;
    152     }
    153140  }
    154141}
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.Views/3.3/PermutationConvexHullView.cs

    r10109 r10224  
    5656        double[][] popPoints = DistanceMatrixToPoints.ConvertDistanceMatrixToPoints(DistanceMatrixToPoints.TransformToDistances(dm));
    5757
    58         var convexHull = HyperHull.CalculateUsingSMO(popPoints);
     58        var convexHull = HyperHull.Calculate(popPoints);
    5959        resultsTextBox.Text += "Nr. of Points in Generation " + i + ": " + convexHull.Count + Environment.NewLine;
    6060        resultsTextBox.Text += "Volume of Convex Hull in Generation " + i + " is: " +
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/HyperHull.cs

    r9945 r10224  
    3030  /// </summary>
    3131  public class HyperHull {
    32     public static List<double[]> CalculateUsingSMO(double[][] inputs) {
     32    public static List<double[]> Calculate(double[][] inputs) {
    3333      int[] labels = new int[inputs.Count()];
    3434      List<double[]> result = new List<double[]>();
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/PerformanceTests/PerformanceTests.csproj

    r10223 r10224  
    5050      <Name>HeuristicLab.Analysis.AlgorithmBehavior.Analyzers-3.3</Name>
    5151    </ProjectReference>
     52    <ProjectReference Include="..\MIConvexHull\MIConvexHull.csproj">
     53      <Project>{2337776d-7d0c-40aa-a439-c26c3ce24fab}</Project>
     54      <Name>MIConvexHull</Name>
     55    </ProjectReference>
    5256  </ItemGroup>
    5357  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/PerformanceTests/Program.cs

    r10223 r10224  
    2525using System.Linq;
    2626using HeuristicLab.Analysis.AlgorithmBehavior.Analyzers;
     27using MIConvexHull;
    2728
    2829namespace PerformanceTests {
    2930  class Program {
     31
     32    static int nrOfPoints = 1000;
     33    static int dimension = 10;
     34
    3035    static void Main(string[] args) {
    31       // TestSimpleVolumeCalculation();
    32       // TestVolCalc();
    33       //TestQHullVolumeCalculation();
    34       TestQhull();
     36      //TestConvexHullPerformance();
     37      //TestVolumeCalculationPerformance();
     38
     39      TestMDSPerformance();
    3540    }
    3641
    37     public static void TestQhull() {
    38       var points = new List<double[]>();
    39       points.Add(new double[] { -0.72045174, 1.44667601, -1.75159125 });
    40       points.Add(new double[] { -0.67521503, 0.61127293, -0.33962646 });
    41       points.Add(new double[] { 2.02392510, -0.41962562, -1.12211942 });
    42       points.Add(new double[] { 0.02647963, -0.24983950, -0.47038916 });
    43       points.Add(new double[] { 0.61548803, -0.25039511, 0.97745744 });
    44       points.Add(new double[] { -1.65142294, -0.09537136, 1.93154268 });
    45       points.Add(new double[] { 1.12618422, 0.49384888, 0.05286691 });
    46       points.Add(new double[] { -0.12506782, -2.29161965, -0.09710301 });
     42    public static void TestMDSPerformance() {
     43      double[][] orgPoints = new double[nrOfPoints][];
     44      double[][] orgDm = new double[nrOfPoints][];
     45      double[][] newPoints = null;
     46      Stopwatch watch = new Stopwatch();
    4747
    48       double volume = QhullWrapper.CalculateVolume(points);
    49       volume = Math.Round(volume, 6);
    50       Console.WriteLine("Volume is: " + volume);
     48      AllocArray(orgPoints, dimension);
     49      AllocArray(orgDm, nrOfPoints);
     50      SamplePoints(orgPoints);
     51      CalculateDistanceMatrix(orgDm, orgPoints);
    5152
    52       var result = QhullWrapper.Calculate(points);
     53      watch.Start();
     54      newPoints = DistanceMatrixToPoints.MetricMDS(orgDm, dimension);
     55      watch.Stop();
     56      Console.WriteLine("Runtime of MetricMDS (in sec): " + watch.Elapsed.TotalSeconds);
     57
     58      Console.ReadLine();
    5359    }
    5460
     61    public static void TestConvexHullPerformance() {
     62      List<double[]> result = null;
     63      Stopwatch watch = new Stopwatch();
    5564
    56     public static void TestVolCalc() {
    57       int dim = 3;
    58       int size = 8;
    59       var data = CreateRandomData(size, dim);
     65      var data = CreateRandomData(nrOfPoints, dimension);
    6066      var dataList = data.ToList();
     67
     68      //calculate convex hull with LP
     69      watch.Start();
     70      result = LPHull.Calculate(data);
     71      watch.Stop();
     72      Console.WriteLine("Runtime of LPHull (in sec): " + watch.Elapsed.TotalSeconds);
     73
     74      //calculate convex hull with SMO
     75      watch.Restart();
     76      result = HyperHull.Calculate(data);
     77      watch.Stop();
     78      Console.WriteLine("Runtime of HyperHull (in sec): " + watch.Elapsed.TotalSeconds);
     79
     80      //calculate convex hull with MIConvexHull
     81      watch.Restart();
     82      result = ConvexHull.Create(data).Points.Select(x => x.Position).ToList();
     83      watch.Stop();
     84      Console.WriteLine("Runtime of MIConvexHull (in sec): " + watch.Elapsed.TotalSeconds);
     85
     86      //calculate convex hull with QHull
     87      watch.Restart();
     88      result = QhullWrapper.Calculate(dataList);
     89      watch.Stop();
     90      Console.WriteLine("Runtime of QHull (in sec): " + watch.Elapsed.TotalSeconds);
     91
     92      Console.ReadLine();
     93    }
     94
     95    public static void TestVolumeCalculationPerformance() {
     96      var data = CreateRandomData(nrOfPoints, dimension);
     97      var dataList = data.ToList();
     98      List<double[]> convexHull = null;
     99      double volume = 0.0;
    61100      Stopwatch watch = new Stopwatch();
    62101
    63102
    64       //calculate convex hull
     103      //calculate volume with LP and then use QHull
    65104      watch.Start();
    66       var convexHull = LPHull.Calculate(data);
     105      convexHull = LPHull.Calculate(data);
     106      volume = QhullWrapper.CalculateVolume(convexHull);
    67107      watch.Stop();
    68       Console.WriteLine("Convex hull calculation took : " + watch.Elapsed.TotalSeconds + " seconds.");
     108      Console.WriteLine(Environment.NewLine + "## Runtime of LPHull/QHull (sec): " + watch.Elapsed.TotalSeconds);
     109      //Console.WriteLine("Volume of convex hull is: " + volume);
    69110
     111      //calculate volume with QHull
     112      watch.Restart();
     113      volume = QhullWrapper.CalculateVolume(dataList);
     114      watch.Stop();
     115      Console.WriteLine(Environment.NewLine + "## Runtime of QHull (sec): " + watch.Elapsed.TotalSeconds);
     116      //Console.WriteLine("Volume of convex hull is: " + volume);
    70117
    71       //calculate volume of convex hull
    72       watch.Start();
    73       double volume = ConvexHullMeasures.CalculateVolume(convexHull);
    74       watch.Stop();
    75       Console.WriteLine("Volume calculation of convex hull took : " + watch.Elapsed.TotalSeconds + " seconds.");
    76       Console.WriteLine("Volume of convex hull is: " + volume);
    77 
    78 
    79       //do volume calculation from the whole data set
    80       watch.Start();
     118      //calculate volume of data with delauny triangulation
     119      watch.Restart();
    81120      volume = ConvexHullMeasures.CalculateVolume(dataList);
    82121      watch.Stop();
    83       Console.WriteLine("Volume calculation of whole data set took : " + watch.Elapsed.TotalSeconds + " seconds.");
    84       Console.WriteLine("Volume of whole data is: " + volume);
    85     }
     122      Console.WriteLine(Environment.NewLine + "## Runtime using all data with delauny (sec): " + watch.Elapsed.TotalSeconds);
     123      //Console.WriteLine("Volume of convex hull is: " + volume);
    86124
    87     private static void TestQHullVolumeCalculation() {
    88       const int numPoints = 8;
    89       const int dimension = 3;
     125      //calculate volume with convex hull (LPHull) and delauny triangulation
     126      watch.Restart();
     127      convexHull = LPHull.Calculate(data);
     128      volume = ConvexHullMeasures.CalculateVolume(convexHull);
     129      watch.Stop();
     130      Console.WriteLine(Environment.NewLine + "## Runtime using convex hull and delauny (sec): " + watch.Elapsed.TotalSeconds);
     131      //Console.WriteLine("Volume of convex hull is: " + volume);
    90132
    91       var points = new List<double[]>();
    92 
    93       points.Add(new double[] { -0.72045174, 1.44667601, -1.75159125 });
    94       points.Add(new double[] { -0.67521503, 0.61127293, -0.33962646 });
    95       points.Add(new double[] { 2.02392510, -0.41962562, -1.12211942 });
    96       points.Add(new double[] { 0.02647963, -0.24983950, -0.47038916 });
    97       points.Add(new double[] { 0.61548803, -0.25039511, 0.97745744 });
    98       points.Add(new double[] { -1.65142294, -0.09537136, 1.93154268 });
    99       points.Add(new double[] { 1.12618422, 0.49384888, 0.05286691 });
    100       points.Add(new double[] { -0.12506782, -2.29161965, -0.09710301 });
    101 
    102       Stopwatch watch = new Stopwatch();
    103       //calculate convex hull
    104       watch.Start();
    105       var convexHull = LPHull.Calculate(points.ToArray());
    106       watch.Stop();
    107       Console.WriteLine("Convex hull calculation took : " + watch.Elapsed.TotalSeconds + " seconds.");
    108 
    109 
    110       //calculate volume of convex hull
    111       watch.Start();
    112       double volume = ConvexHullMeasures.CalculateVolume(convexHull);
    113       watch.Stop();
    114       Console.WriteLine("Volume calculation of convex hull took : " + watch.Elapsed.TotalSeconds + " seconds.");
    115       Console.WriteLine("Volume of convex hull is: " + volume);  //7.960698
    116 
    117 
    118       //do volume calculation from the whole data set
    119       watch.Start();
    120       volume = ConvexHullMeasures.CalculateVolume(points);
    121       watch.Stop();
    122       Console.WriteLine("Volume calculation of whole data set took : " + watch.Elapsed.TotalSeconds + " seconds.");
    123       Console.WriteLine("Volume of whole data is: " + volume);
    124     }
    125 
    126     private static void TestSimpleVolumeCalculation() {
    127       const int numPoints = 4;
    128       const int dimension = 3;
    129 
    130       double[] num1 = new double[dimension];
    131       double[] num2 = new double[dimension];
    132       double[] num3 = new double[dimension];
    133       double[] num4 = new double[dimension];
    134 
    135       num1[0] = 1;
    136       num1[1] = 2;
    137       num1[2] = 2;
    138 
    139       num2[0] = 3;
    140       num2[1] = 4;
    141       num2[2] = 3;
    142 
    143       num3[0] = 3;
    144       num3[1] = 6;
    145       num3[2] = 3;
    146 
    147       num4[0] = 7;
    148       num4[1] = 8;
    149       num4[2] = 3;
    150 
    151       var points = new List<double[]>();
    152       points.Add(num1);
    153       points.Add(num2);
    154       points.Add(num3);
    155       points.Add(num4);
    156 
    157 
    158       double volume = ConvexHullMeasures.CalculateSimplexVolume(points);
    159 
     133      Console.ReadLine();
    160134    }
    161135
     
    172146      return result;
    173147    }
     148
     149    private static void CalculateDistanceMatrix(double[][] dm, double[][] points) {
     150      for (int i = 0; i < points.Length; i++) {
     151        for (int j = 0; j < points.Length; j++) {
     152          dm[i][j] = points[i].EuclideanDistance(points[j]);
     153        }
     154      }
     155    }
     156
     157    private static void AllocArray(double[][] arr, int size) {
     158      for (int i = 0; i < arr.Length; i++) {
     159        arr[i] = new double[size];
     160      }
     161    }
     162
     163    private static void SamplePoints(double[][] points) {
     164      Random rand = new Random();
     165
     166      for (int i = 0; i < points.Length; i++) {
     167        for (int j = 0; j < points[i].Length; j++) {
     168          points[i][j] = rand.NextDouble() * 100;
     169        }
     170      }
     171    }
    174172  }
    175173}
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/Visualization/Program.cs

    r10198 r10224  
    2121
    2222using System;
    23 using System.Collections.Generic;
    2423using System.Diagnostics;
    2524using System.Linq;
     
    4241      double[][] inputs = CreateRandomData(nrOfSamples, sampleSize);
    4342
    44       var convAlgData = ConvertPermutationToVertex(inputs);
    45 
    46 
    4743      Stopwatch watch = new Stopwatch();
    4844      watch.Start();
    49       var result2 = HyperHull.CalculateUsingSMO(inputs);
     45      var result2 = HyperHull.Calculate(inputs);
    5046      watch.Stop();
    5147      Console.WriteLine("HyperHull: " + watch.ElapsedMilliseconds);
    5248      watch.Restart();
    53       var result1 = ConvexHull.Create(convAlgData).Points.Select(x => x.Position).ToList();
     49      var result1 = ConvexHull.Create(inputs).Points.Select(x => x.Position).ToList();
    5450      watch.Stop();
    5551      Console.WriteLine("MIConvexHull: " + watch.ElapsedMilliseconds);
     
    8177    }
    8278
    83     private static List<DefaultVertex> ConvertPermutationToVertex(double[][] data) {
    84       List<DefaultVertex> result = new List<DefaultVertex>();
    85       for (int i = 0; i < data.Count(); i++) {
    86         double[] d = data[i];
    87         DefaultVertex vertex = new DefaultVertex();
    88         vertex.Position = d;
    89         result.Add(vertex);
    90 
    91       }
    92       return result;
    93     }
    94 
    9579    private static double[][] CreateRandomData(int n, int m) {
    9680      double[][] result = new double[n][];
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/qhull-2012.1/src/HeuristicLab.qhull/HeuristicLab_qhull.c

    r10222 r10224  
    5353  boolT ismalloc= False;   
    5454  char flags[250];       
    55   FILE *outfile= stdout;   
    56   FILE *errfile= stdout;   
     55  FILE *outfile= NULL;   
     56  FILE *errfile= stderr;   
    5757  facetT *facet;           
    5858  int curlong, totlong;   
     
    7171  sprintf (flags, "qhull s Tv Qt FA");
    7272
    73   exitcode= qh_new_qhull (dim, numpoints, data, ismalloc, flags, outfile, errfile);
     73  exitcode = qh_new_qhull (dim, numpoints, data, ismalloc, flags, outfile, errfile);
    7474  if (!exitcode) {                     
    75     print_summary(); 
     75   // print_summary(); 
    7676    qh_vertexneighbors();
    7777    volume = qh totvol;
     
    9191  boolT ismalloc= False;   
    9292  char flags[250];       
    93   FILE *outfile= stdout;   
    94   FILE *errfile= stdout;   
     93  FILE *outfile= NULL;   
     94  FILE *errfile= stderr;   
    9595  facetT *facet;           
    9696  int curlong, totlong;   
     
    117117    *nrOfFacets = n;
    118118
    119     print_summary();
     119    //print_summary();
    120120    qh_vertexneighbors();
    121121
Note: See TracChangeset for help on using the changeset viewer.