Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17729


Ignore:
Timestamp:
08/27/20 11:55:02 (4 years ago)
Author:
dpiringe
Message:

#3081

  • added static calculation method in:
    • ExponentialDiscreteDoubleValueModifier
    • GeneralizedExponentialDiscreteDoubleValueModifier
    • LinearDiscreteDoubleValueModifier
    • QuadraticDiscreteDoubleValueModifier
    • SquareRootDiscreteDoubleValueModifier
Location:
trunk/HeuristicLab.Optimization.Operators/3.3
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/HeuristicLab.Optimization.Operators/3.3/ExponentialDiscreteDoubleValueModifier.cs

    r17180 r17729  
    5555    /// <returns>The new value.</returns>
    5656    protected override double Modify(double value, double startValue, double endValue, int index, int startIndex, int endIndex) {
     57      return Calculate(value, startValue, endValue, index, startIndex, endIndex);
     58    }
     59
     60    public static double Calculate(double value, double startValue, double endValue, int index, int startIndex, int endIndex) {
    5761      if (endValue <= 0 || startValue <= 0) throw new ArgumentException("startValue and endValue must be greater than 0.");
    5862      double b = Math.Pow(endValue / startValue, 1.0 / (endIndex - startIndex));
  • trunk/HeuristicLab.Optimization.Operators/3.3/GeneralizedExponentialDiscreteDoubleValueModifier.cs

    r17180 r17729  
    7070    /// <returns>The new value.</returns>
    7171    protected override double Modify(double value, double startValue, double endValue, int index, int startIndex, int endIndex) {
    72       if (Base <= 0)
     72      return Calculate(value, startValue, endValue, index, startIndex, endIndex, Base);
     73    }
     74
     75    public static double Calculate(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  }
  • trunk/HeuristicLab.Optimization.Operators/3.3/LinearDiscreteDoubleValueModifier.cs

    r17180 r17729  
    4141
    4242    protected override double Modify(double value, double startValue, double endValue, int index, int startIndex, int endIndex) {
     43      return Calculate(value, startValue, endValue, index, startIndex, endIndex);
     44    }
     45
     46    public static double Calculate(double value, double startValue, double endValue, int index, int startIndex, int endIndex) {
    4347      double k = (endValue - startValue) / (endIndex - startIndex);
    4448      double x = index - startIndex;
  • trunk/HeuristicLab.Optimization.Operators/3.3/QuadraticDiscreteDoubleValueModifier.cs

    r17180 r17729  
    4141
    4242    protected override double Modify(double value, double startValue, double endValue, int index, int startIndex, int endIndex) {
     43      return Calculate(value, startValue, endValue, index, startIndex, endIndex);
     44    }
     45
     46    public static double Calculate(double value, double startValue, double endValue, int index, int startIndex, int endIndex) {
    4347      double a = (endValue - startValue) / ((endIndex - startIndex) * (endIndex - startIndex));
    4448      return a * (index - startIndex) * (index - startIndex) + startValue;
  • trunk/HeuristicLab.Optimization.Operators/3.3/SquareRootDiscreteDoubleValueModifier.cs

    r17180 r17729  
    4242
    4343    protected override double Modify(double value, double startValue, double endValue, int index, int startIndex, int endIndex) {
     44      return Calculate(value, startValue, endValue, index, startIndex, endIndex);
     45    }
     46
     47    public static double Calculate(double value, double startValue, double endValue, int index, int startIndex, int endIndex) {
    4448      double a = (endValue - startValue) / Math.Sqrt(endIndex - startIndex);
    4549      return a * Math.Sqrt(index - startIndex) + startValue;
Note: See TracChangeset for help on using the changeset viewer.