Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/27/20 12:59:27 (4 years ago)
Author:
dpiringe
Message:

#3081: merged r17729:r17730 into stable

Location:
stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Optimization.Operators/3.3/GeneralizedExponentialDiscreteDoubleValueModifier.cs

    r17181 r17732  
    5858    }
    5959
     60    protected override double Modify(double value, double startValue, double endValue, int index, int startIndex, int endIndex) {
     61      return Apply(value, startValue, endValue, index, startIndex, endIndex, Base);
     62    }
     63
    6064    /// <summary>
    6165    /// Calculates a new value based on exponential decay or growth.
     
    6973    /// <param name="endIndex">The final index.</param>
    7074    /// <returns>The new value.</returns>
    71     protected override double Modify(double value, double startValue, double endValue, int index, int startIndex, int endIndex) {
    72       if (Base <= 0)
     75    public static double Apply(double value, double startValue, double endValue, int index, int startIndex, int endIndex, double @base) {
     76      if (@base <= 0)
    7377        throw new ArgumentException("Base must be > 0.");
    74       if (Base == 1.0)
    75         return startValue + (endValue - startValue)*(index - startIndex)/(endIndex - startIndex);
    76       return startValue + (endValue - startValue)*(Math.Pow(Base, 1.0*(index-startIndex)/(endIndex-startIndex)) - 1)/(Base - 1);
     78      if (@base == 1.0)
     79        return startValue + (endValue - startValue) * (index - startIndex) / (endIndex - startIndex);
     80      return startValue + (endValue - startValue) * (Math.Pow(@base, 1.0 * (index - startIndex) / (endIndex - startIndex)) - 1) / (@base - 1);
    7781    }
    7882  }
Note: See TracChangeset for help on using the changeset viewer.