Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10287


Ignore:
Timestamp:
01/06/14 14:40:45 (9 years ago)
Author:
ascheibe
Message:

#1886 adapted convex hull modifier to use fractions for big volumes

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  
    248248    public static double CalculateHypercubeVolume(double[] bounds, int dim) {
    249249      //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;
    251258    }
    252259
  • branches/HeuristicLab.Analysis.AlgorithmBehavior/HeuristicLab.Analysis.AlgorithmBehavior.Analyzers/3.3/FractionClass.cs

    r10286 r10287  
    249249    }
    250250
     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
    251273    /// <summary>
    252274    /// 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  
    3232using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    3333using HeuristicLab.Problems.TestFunctions;
     34using Mehroz;
    3435
    3536namespace HeuristicLab.Analysis.AlgorithmBehavior.Analyzers {
     
    9394        var boundsMatrix = run.Parameters["Bounds"] as DoubleMatrix;
    9495        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        }
    96102
    97103        List<double[]> completeHull = null;
     
    118124
    119125          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            }
    124137          }
    125138
     
    128141
    129142        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          }
    132151        } else {
    133152          overallVolume.Value = double.NaN;
Note: See TracChangeset for help on using the changeset viewer.