- Timestamp:
- 12/09/13 16:56:03 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Analysis.AlgorithmBehavior/PerformanceTests/Program.cs
r10200 r10208 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System; 23 using System.Collections.Generic; 2 24 using System.Diagnostics; 3 25 using System.Linq; … … 7 29 class Program { 8 30 static void Main(string[] args) { 9 TestVolCalc(); 31 // TestSimpleVolumeCalculation(); 32 // TestVolCalc(); 33 //TestQHullVolumeCalculation(); 34 TestQhull(); 10 35 } 11 36 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 }); 47 48 double volume = QhullWrapper.CalculateVolume(points); 49 volume = Math.Round(volume, 6); 50 Console.WriteLine("Volume is: " + volume); 51 } 52 53 12 54 public static void TestVolCalc() { 13 int dim = 4;14 int size = 20;55 int dim = 3; 56 int size = 8; 15 57 var data = CreateRandomData(size, dim); 16 58 var dataList = data.ToList(); … … 27 69 //calculate volume of convex hull 28 70 watch.Start(); 29 double volume = ConvexHullMeasures.CalculateVolume New(convexHull);71 double volume = ConvexHullMeasures.CalculateVolume(convexHull); 30 72 watch.Stop(); 31 73 Console.WriteLine("Volume calculation of convex hull took : " + watch.Elapsed.TotalSeconds + " seconds."); … … 35 77 //do volume calculation from the whole data set 36 78 watch.Start(); 37 volume = ConvexHullMeasures.CalculateVolume New(dataList);79 volume = ConvexHullMeasures.CalculateVolume(dataList); 38 80 watch.Stop(); 39 81 Console.WriteLine("Volume calculation of whole data set took : " + watch.Elapsed.TotalSeconds + " seconds."); … … 47 89 Console.WriteLine("Volume calculation of whole data set with lrs took : " + watch.Elapsed.TotalSeconds + " seconds."); 48 90 Console.WriteLine("Volume of whole data with lrs is: " + volume); 91 } 92 93 private static void TestQHullVolumeCalculation() { 94 const int numPoints = 8; 95 const int dimension = 3; 96 97 var points = new List<double[]>(); 98 99 points.Add(new double[] { -0.72045174, 1.44667601, -1.75159125 }); 100 points.Add(new double[] { -0.67521503, 0.61127293, -0.33962646 }); 101 points.Add(new double[] { 2.02392510, -0.41962562, -1.12211942 }); 102 points.Add(new double[] { 0.02647963, -0.24983950, -0.47038916 }); 103 points.Add(new double[] { 0.61548803, -0.25039511, 0.97745744 }); 104 points.Add(new double[] { -1.65142294, -0.09537136, 1.93154268 }); 105 points.Add(new double[] { 1.12618422, 0.49384888, 0.05286691 }); 106 points.Add(new double[] { -0.12506782, -2.29161965, -0.09710301 }); 107 108 Stopwatch watch = new Stopwatch(); 109 //calculate convex hull 110 watch.Start(); 111 var convexHull = LPHull.Calculate(points.ToArray()); 112 watch.Stop(); 113 Console.WriteLine("Convex hull calculation took : " + watch.Elapsed.TotalSeconds + " seconds."); 114 115 116 //calculate volume of convex hull 117 watch.Start(); 118 double volume = ConvexHullMeasures.CalculateVolume(convexHull); 119 watch.Stop(); 120 Console.WriteLine("Volume calculation of convex hull took : " + watch.Elapsed.TotalSeconds + " seconds."); 121 Console.WriteLine("Volume of convex hull is: " + volume); //7.960698 122 123 124 //do volume calculation from the whole data set 125 watch.Start(); 126 volume = ConvexHullMeasures.CalculateVolume(points); 127 watch.Stop(); 128 Console.WriteLine("Volume calculation of whole data set took : " + watch.Elapsed.TotalSeconds + " seconds."); 129 Console.WriteLine("Volume of whole data is: " + volume); 130 131 132 //do volume calculation with lrs 133 watch = new Stopwatch(); 134 watch.Start(); 135 volume = LiblrsWrapper.CalculateVolume(points); 136 watch.Stop(); 137 Console.WriteLine("Volume calculation of whole data set with lrs took : " + watch.Elapsed.TotalSeconds + " seconds."); 138 Console.WriteLine("Volume of whole data with lrs is: " + volume); 139 } 140 141 private static void TestSimpleVolumeCalculation() { 142 const int numPoints = 4; 143 const int dimension = 3; 144 145 double[] num1 = new double[dimension]; 146 double[] num2 = new double[dimension]; 147 double[] num3 = new double[dimension]; 148 double[] num4 = new double[dimension]; 149 150 num1[0] = 1; 151 num1[1] = 2; 152 num1[2] = 2; 153 154 num2[0] = 3; 155 num2[1] = 4; 156 num2[2] = 3; 157 158 num3[0] = 3; 159 num3[1] = 6; 160 num3[2] = 3; 161 162 num4[0] = 7; 163 num4[1] = 8; 164 num4[2] = 3; 165 166 var points = new List<double[]>(); 167 points.Add(num1); 168 points.Add(num2); 169 points.Add(num3); 170 points.Add(num4); 171 172 173 double volume = ConvexHullMeasures.CalculateSimplexVolume(points); 174 49 175 } 50 176
Note: See TracChangeset
for help on using the changeset viewer.