Changeset 10279 for branches/HeuristicLab.Analysis.AlgorithmBehavior
- Timestamp:
- 01/05/14 01:30:28 (11 years ago)
- Location:
- branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/ConvexHullMeasures.cs
r10275 r10279 161 161 return maxDist; 162 162 } 163 164 private static List<double[]> GenerateHyperCube(double[] bounds, int dim) { 165 if (bounds.Length != 2) 166 throw new ArgumentException("Only bounds of length 2 are supported!", "bounds"); 167 168 int numPoints = (int)Math.Pow(2, dim); 169 170 var hyperCube = new List<double[]>(numPoints); 171 var binaryVectors = new List<string>(numPoints); 172 for (int i = 0; i < numPoints; i++) { 173 string binary = Convert.ToString(i, 2); 174 binaryVectors.Add(binary); 175 } 176 177 for (int i = 0; i < numPoints; i++) { 178 for (int j = 0; j < dim - binaryVectors[i].Length; j++) { 179 //TODO: do this properly 180 binaryVectors[i] = "0" + binaryVectors[i]; 181 } 182 } 183 184 foreach (var binaryVector in binaryVectors) { 185 double[] point = new double[dim]; 186 for (int i = 0; i < binaryVector.Length; i++) { 187 if (binaryVector[i] == '0') { 188 point[i] = bounds[0]; 189 } else { 190 point[i] = bounds[1]; 191 } 192 } 193 hyperCube.Add(point); 194 } 195 return hyperCube; 196 } 197 198 public static double CalculateHypercubeVolume(double[] bounds, int dim) { 199 return CalculateVolume(GenerateHyperCube(bounds, dim)); 200 } 163 201 } 164 202 } -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/RunCollectionModifiers/RealVectorConvexHullModifier.cs
r10275 r10279 73 73 DataTable centroidMotionTable = new DataTable(CentroidMotionName); 74 74 DoubleValue overallVolume = new DoubleValue(); 75 DoubleValue overallVolumeRatio = new DoubleValue(); 75 76 76 77 DataRow dtVolumeRow = new DataRow("Volume"); … … 112 113 if (completeHull != null && completeHull.Any() && completeHull.First().Length < completeHull.Count) { 113 114 overallVolume.Value = ConvexHullMeasures.CalculateVolume(completeHull); 115 var boundsMatrix = run.Parameters["Bounds"] as DoubleMatrix; 116 var bounds = new double[] { boundsMatrix[0, 0], boundsMatrix[0, 1] }; 117 double hyperHullVolume = ConvexHullMeasures.CalculateHypercubeVolume(bounds, BestSolutionParameter.Value.Length); 118 overallVolumeRatio.Value = overallVolume.Value / hyperHullVolume; 114 119 } else { 115 120 overallVolume.Value = double.NaN; 121 overallVolumeRatio.Value = double.NaN; 116 122 } 117 123 … … 121 127 122 128 run.Results["Overall volume"] = overallVolume; 129 run.Results["Overall volume ratio"] = overallVolumeRatio; 123 130 run.Results["Overall diameter"] = new DoubleValue(ConvexHullMeasures.CalculateMaxDiameter(completeHull)); 124 131 run.Results["Convex hull volume"] = volDataTable;
Note: See TracChangeset
for help on using the changeset viewer.