Changeset 10287 for branches/HeuristicLab.Analysis.AlgorithmBehavior
- Timestamp:
- 01/06/14 14:40:45 (11 years ago)
- Location:
- branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/ConvexHullMeasures.cs
r10286 r10287 248 248 public static double CalculateHypercubeVolume(double[] bounds, int dim) { 249 249 //this is not very smart... 250 return CalculateVolume(GenerateHyperCube(bounds, dim)); 250 //return CalculateVolume(GenerateHyperCube(bounds, dim)); 251 double diff = bounds[1] - bounds[0]; 252 253 double volume = diff; 254 for (int i = 0; i < dim; i++) { 255 volume *= diff; 256 } 257 return volume; 251 258 } 252 259 -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/FractionClass.cs
r10286 r10287 249 249 } 250 250 251 public double ToDouble(int digits) { 252 if (this.m_Denominator == 1) 253 return (double)this.m_Numerator; 254 else if (this.m_Denominator == 0) { 255 switch (NormalizeIndeterminate(this.m_Numerator)) { 256 case Indeterminates.NegativeInfinity: 257 return double.NegativeInfinity; 258 259 case Indeterminates.PositiveInfinity: 260 return double.PositiveInfinity; 261 262 case Indeterminates.NaN: 263 default: // this can't happen 264 return double.NaN; 265 } 266 } else { 267 ReduceFraction(ref this); 268 int factor = (int)Math.Pow(10, digits); 269 return ((double)((this.m_Numerator * factor) / this.m_Denominator)) / factor; 270 } 271 } 272 251 273 /// <summary> 252 274 /// Get the value of the Fraction as a string, with proper representation for NaNs and infinites -
branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/RunCollectionModifiers/RealVectorConvexHullModifier.cs
r10283 r10287 32 32 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 33 33 using HeuristicLab.Problems.TestFunctions; 34 using Mehroz; 34 35 35 36 namespace HeuristicLab.Analysis.AlgorithmBehavior.Analyzers { … … 93 94 var boundsMatrix = run.Parameters["Bounds"] as DoubleMatrix; 94 95 var bounds = new double[] { boundsMatrix[0, 0], boundsMatrix[0, 1] }; 95 double hyperCubeVolume = ConvexHullMeasures.CalculateHypercubeVolume(bounds, BestSolutionParameter.Value.Length); 96 Fraction hyperCubeVolumeBig = ConvexHullMeasures.CalculateHypercubeVolumeBig(bounds, BestSolutionParameter.Value.Length); 97 double hyperCubeVolume = double.NaN; 98 99 if (hyperCubeVolumeBig < 10000000) { 100 hyperCubeVolume = ConvexHullMeasures.CalculateHypercubeVolume(bounds, BestSolutionParameter.Value.Length); 101 } 96 102 97 103 List<double[]> completeHull = null; … … 118 124 119 125 if (completeHull != null && completeHull.Any() && completeHull.First().Length < completeHull.Count) { 120 double completeHullVolume = ConvexHullMeasures.CalculateVolume(completeHull); 121 double ratio = completeHullVolume / hyperCubeVolume; 122 dtIncrementalHullVolume.Values.Add(completeHullVolume); 123 dtIncrementalHullVolumeRatio.Values.Add(ratio); 126 if (double.IsNaN(hyperCubeVolume)) { 127 Fraction completeHullVolume = ConvexHullMeasures.CalculateVolumeBig(completeHull); 128 Fraction ratio = completeHullVolume / hyperCubeVolumeBig; 129 dtIncrementalHullVolume.Values.Add(completeHullVolume.ToDouble()); 130 dtIncrementalHullVolumeRatio.Values.Add(ratio.ToDouble()); 131 } else { 132 double completeHullVolume = ConvexHullMeasures.CalculateVolume(completeHull); 133 double ratio = completeHullVolume / hyperCubeVolume; 134 dtIncrementalHullVolume.Values.Add(completeHullVolume); 135 dtIncrementalHullVolumeRatio.Values.Add(ratio); 136 } 124 137 } 125 138 … … 128 141 129 142 if (completeHull != null && completeHull.Any() && completeHull.First().Length < completeHull.Count) { 130 overallVolume.Value = ConvexHullMeasures.CalculateVolume(completeHull); 131 overallVolumeRatio.Value = overallVolume.Value / hyperCubeVolume; 143 if (!double.IsNaN(hyperCubeVolume)) { 144 overallVolume.Value = ConvexHullMeasures.CalculateVolume(completeHull); 145 overallVolumeRatio.Value = overallVolume.Value / hyperCubeVolume; 146 } else { 147 Fraction v = ConvexHullMeasures.CalculateVolumeBig(completeHull); 148 overallVolume.Value = v.ToDouble(); 149 overallVolumeRatio.Value = (double)(v / hyperCubeVolumeBig); 150 } 132 151 } else { 133 152 overallVolume.Value = double.NaN;
Note: See TracChangeset
for help on using the changeset viewer.