- Timestamp:
- 01/06/14 02:36:31 (11 years ago)
- Location:
- branches/HeuristicLab.Analysis.AlgorithmBehavior
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Analysis.AlgorithmBehavior/AlgorithmBehaviorUnitTests/AlgorithmBehaviorUnitTests.csproj
r10222 r10286 98 98 </Choose> 99 99 <ItemGroup> 100 <Compile Include="BigVolumeTest.cs" /> 100 101 <Compile Include="LPConvexHullSortingTest.cs" /> 101 102 <Compile Include="LPConvexHullTest.cs" /> -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/ConvexHullMeasures.cs
r10279 r10286 23 23 using System.Collections.Generic; 24 24 using System.Linq; 25 using Mehroz; 25 26 using MIConvexHull; 26 27 … … 44 45 } 45 46 47 public static Fraction CalculateSimplexVolumeBig(List<double[]> simplex) { 48 int dim = simplex.First().Length; 49 double[,] diffs = new double[dim, dim]; 50 51 for (int i = 1; i < simplex.Count; i++) { 52 for (int j = 0; j < dim; j++) { 53 diffs[j, i - 1] = simplex[i][j] - simplex[0][j]; 54 } 55 } 56 57 //calculate determinante from lu decomposition 58 int[] pivots = null; 59 alglib.rmatrixlu(ref diffs, dim, dim, out pivots); 60 61 Fraction det = 1; 62 for (int i = 0; i < dim; i++) { 63 det = det * diffs[i, i]; 64 } 65 66 if (det < 0) 67 det = -1 * det; 68 69 Fraction result = det / dim.Fact(); 70 return result; 71 } 72 46 73 //calculates the volume of a convex d-polytope 47 74 //decomposition based on delaunay triangulation … … 64 91 foreach (var simplex in simplices) { 65 92 volume += CalculateSimplexVolume(simplex.ToList()); 93 } 94 95 return volume; 96 } 97 98 public static Fraction CalculateVolumeBig(List<double[]> convexHull) { 99 Fraction volume = new Fraction(0.0); 100 101 int dim = convexHull.First().Length; 102 if (dim > convexHull.Count) 103 throw new ArgumentException("Nr. of points for volume calculation must be greater than dimension", "convexHull"); 104 105 ITriangulation<DefaultVertex, DefaultTriangulationCell<DefaultVertex>> triangulation = null; 106 try { 107 //Under certain circumstances MIConvexHull is not able to calculate the triangulation 108 triangulation = Triangulation.CreateDelaunay(ConvertToVertex(convexHull)); 109 } 110 catch { 111 return Fraction.NaN; 112 } 113 var simplices = ConvertFromTriangulation(triangulation); 114 foreach (var simplex in simplices) { 115 volume += CalculateSimplexVolumeBig(simplex.ToList()); 66 116 } 67 117 … … 197 247 198 248 public static double CalculateHypercubeVolume(double[] bounds, int dim) { 249 //this is not very smart... 199 250 return CalculateVolume(GenerateHyperCube(bounds, dim)); 251 } 252 253 public static Fraction CalculateHypercubeVolumeBig(double[] bounds, int dim) { 254 double diff = bounds[1] - bounds[0]; 255 256 Fraction volume = diff; 257 for (int i = 0; i < dim; i++) { 258 volume *= diff; 259 } 260 return volume; 200 261 } 201 262 } -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers-3.3.csproj
r10275 r10286 106 106 <Reference Include="System.Core" /> 107 107 <Reference Include="System.Drawing" /> 108 <Reference Include="System.Numerics" /> 108 109 <Reference Include="System.Xml.Linq" /> 109 110 <Reference Include="System.Data.DataSetExtensions" /> … … 113 114 </ItemGroup> 114 115 <ItemGroup> 116 <Compile Include="FractionClass.cs" /> 115 117 <Compile Include="QhullWrapper.cs" /> 116 118 <Compile Include="DoubleArrayExtensions.cs" />
Note: See TracChangeset
for help on using the changeset viewer.