Changeset 10224
- Timestamp:
- 12/12/13 01:06:00 (11 years ago)
- Location:
- branches/HeuristicLab.Analysis.AlgorithmBehavior
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Analysis.AlgorithmBehavior/AlgorithmBehaviorUnitTests/LPConvexHullTest.cs
r10222 r10224 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using System.Diagnostics; 25 24 using System.Linq; … … 36 35 int sampleSize = 2; 37 36 double[][] inputs = ConvexHullTest.CreateRandomData(nrOfSamples, sampleSize); 38 var convAlgData = ConvertPermutationToVertex(inputs);39 37 40 38 Stopwatch watch = new Stopwatch(); … … 44 42 Console.WriteLine("LPHull: " + watch.ElapsedMilliseconds); 45 43 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(); 47 45 watch.Stop(); 48 46 Console.WriteLine("MIConvexHull: " + watch.ElapsedMilliseconds); … … 140 138 return result; 141 139 } 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 }153 140 } 154 141 } -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers.Views/3.3/PermutationConvexHullView.cs
r10109 r10224 56 56 double[][] popPoints = DistanceMatrixToPoints.ConvertDistanceMatrixToPoints(DistanceMatrixToPoints.TransformToDistances(dm)); 57 57 58 var convexHull = HyperHull.Calculate UsingSMO(popPoints);58 var convexHull = HyperHull.Calculate(popPoints); 59 59 resultsTextBox.Text += "Nr. of Points in Generation " + i + ": " + convexHull.Count + Environment.NewLine; 60 60 resultsTextBox.Text += "Volume of Convex Hull in Generation " + i + " is: " + -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/HyperHull.cs
r9945 r10224 30 30 /// </summary> 31 31 public class HyperHull { 32 public static List<double[]> Calculate UsingSMO(double[][] inputs) {32 public static List<double[]> Calculate(double[][] inputs) { 33 33 int[] labels = new int[inputs.Count()]; 34 34 List<double[]> result = new List<double[]>(); -
branches/HeuristicLab.Analysis.AlgorithmBehavior/PerformanceTests/PerformanceTests.csproj
r10223 r10224 50 50 <Name>HeuristicLab.Analysis.AlgorithmBehavior.Analyzers-3.3</Name> 51 51 </ProjectReference> 52 <ProjectReference Include="..\MIConvexHull\MIConvexHull.csproj"> 53 <Project>{2337776d-7d0c-40aa-a439-c26c3ce24fab}</Project> 54 <Name>MIConvexHull</Name> 55 </ProjectReference> 52 56 </ItemGroup> 53 57 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> -
branches/HeuristicLab.Analysis.AlgorithmBehavior/PerformanceTests/Program.cs
r10223 r10224 25 25 using System.Linq; 26 26 using HeuristicLab.Analysis.AlgorithmBehavior.Analyzers; 27 using MIConvexHull; 27 28 28 29 namespace PerformanceTests { 29 30 class Program { 31 32 static int nrOfPoints = 1000; 33 static int dimension = 10; 34 30 35 static void Main(string[] args) { 31 // TestSimpleVolumeCalculation();32 // TestVolCalc();33 //TestQHullVolumeCalculation(); 34 Test Qhull();36 //TestConvexHullPerformance(); 37 //TestVolumeCalculationPerformance(); 38 39 TestMDSPerformance(); 35 40 } 36 41 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(); 47 47 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); 51 52 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(); 53 59 } 54 60 61 public static void TestConvexHullPerformance() { 62 List<double[]> result = null; 63 Stopwatch watch = new Stopwatch(); 55 64 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); 60 66 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; 61 100 Stopwatch watch = new Stopwatch(); 62 101 63 102 64 //calculate convex hull103 //calculate volume with LP and then use QHull 65 104 watch.Start(); 66 var convexHull = LPHull.Calculate(data); 105 convexHull = LPHull.Calculate(data); 106 volume = QhullWrapper.CalculateVolume(convexHull); 67 107 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); 69 110 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); 70 117 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(); 81 120 volume = ConvexHullMeasures.CalculateVolume(dataList); 82 121 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); 86 124 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); 90 132 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(); 160 134 } 161 135 … … 172 146 return result; 173 147 } 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 } 174 172 } 175 173 } -
branches/HeuristicLab.Analysis.AlgorithmBehavior/Visualization/Program.cs
r10198 r10224 21 21 22 22 using System; 23 using System.Collections.Generic;24 23 using System.Diagnostics; 25 24 using System.Linq; … … 42 41 double[][] inputs = CreateRandomData(nrOfSamples, sampleSize); 43 42 44 var convAlgData = ConvertPermutationToVertex(inputs);45 46 47 43 Stopwatch watch = new Stopwatch(); 48 44 watch.Start(); 49 var result2 = HyperHull.Calculate UsingSMO(inputs);45 var result2 = HyperHull.Calculate(inputs); 50 46 watch.Stop(); 51 47 Console.WriteLine("HyperHull: " + watch.ElapsedMilliseconds); 52 48 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(); 54 50 watch.Stop(); 55 51 Console.WriteLine("MIConvexHull: " + watch.ElapsedMilliseconds); … … 81 77 } 82 78 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 95 79 private static double[][] CreateRandomData(int n, int m) { 96 80 double[][] result = new double[n][]; -
branches/HeuristicLab.Analysis.AlgorithmBehavior/qhull-2012.1/src/HeuristicLab.qhull/HeuristicLab_qhull.c
r10222 r10224 53 53 boolT ismalloc= False; 54 54 char flags[250]; 55 FILE *outfile= stdout;56 FILE *errfile= std out;55 FILE *outfile= NULL; 56 FILE *errfile= stderr; 57 57 facetT *facet; 58 58 int curlong, totlong; … … 71 71 sprintf (flags, "qhull s Tv Qt FA"); 72 72 73 exitcode = qh_new_qhull (dim, numpoints, data, ismalloc, flags, outfile, errfile);73 exitcode = qh_new_qhull (dim, numpoints, data, ismalloc, flags, outfile, errfile); 74 74 if (!exitcode) { 75 print_summary();75 // print_summary(); 76 76 qh_vertexneighbors(); 77 77 volume = qh totvol; … … 91 91 boolT ismalloc= False; 92 92 char flags[250]; 93 FILE *outfile= stdout;94 FILE *errfile= std out;93 FILE *outfile= NULL; 94 FILE *errfile= stderr; 95 95 facetT *facet; 96 96 int curlong, totlong; … … 117 117 *nrOfFacets = n; 118 118 119 print_summary();119 //print_summary(); 120 120 qh_vertexneighbors(); 121 121
Note: See TracChangeset
for help on using the changeset viewer.