Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/12/10 23:39:40 (14 years ago)
Author:
abeham
Message:

Documented some of the test functions with literature references.
Renamed Griewangk function as it is actually called Griewank function.
Schwefel is hard to find, used self-citation as Potter and DeJong's description from 1994 seems wrong
Levy is almost impossible to find and defined only for 2 variables, the implementation looks fishy (there was also a bug)
Booth, and Matyas are also just from a single website
Still missing is Zakharov and SumSquares
#934

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/GriewankEvaluator.cs

    r3307 r3315  
    2828namespace HeuristicLab.Problems.TestFunctions {
    2929  /// <summary>
    30   /// Griewangk Function<br/>
    31   /// Domain:  [-600.0 , 600.0]^n<br/>
    32   /// Optimum: 0.0 at (0, 0, ..., 0)
     30  /// The Griewank function is introduced in Griewank, A.O. 1981. Generalized descent for global optimization. Journal of Optimization Theory and Applications 34, pp. 11-39.
     31  /// It is a multimodal fitness function in the range [-600,600]^n.
     32  /// Here it is implemented as described (without the modifications) in Locatelli, M. 2003. A note on the Griewank test function. Journal of Global Optimization 25, pp. 169-174, Springer.
    3333  /// </summary>
    34   [Item("GriewangkEvaluator", "Evaluates the Griewangk function on a given point. The optimum of this function is 0 at the origin.")]
     34  [Item("GriewankEvaluator", "Evaluates the Griewank function on a given point. The optimum of this function is 0 at the origin. It is introduced by Griewank A.O. 1981 and implemented as described (without the modifications) in Locatelli, M. 2003. A note on the Griewank test function. Journal of Global Optimization 25, pp. 169-174, Springer.")]
    3535  [StorableClass]
    36   public class GriewangkEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
     36  public class GriewankEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
    3737    /// <summary>
    3838    /// Returns false as the Griewangk function is a minimization problem.
     
    5454    }
    5555    /// <summary>
    56     /// Gets the minimum problem size (2).
     56    /// Gets the minimum problem size (1).
    5757    /// </summary>
    5858    public override int MinimumProblemSize {
    59       get { return 2; }
     59      get { return 1; }
    6060    }
    6161    /// <summary>
     
    6565      get { return int.MaxValue; }
    6666    }
     67
     68    /// <summary>
     69    /// If dimension of the problem is less or equal than 100 the values of Math.Sqrt(i + 1) are precomputed.
     70    /// </summary>
     71    private double[] sqrts;
    6772
    6873    /// <summary>
     
    8489
    8590      result = result - val + 1;
    86       return (result);
     91      return result;
     92    }
     93
     94    /// <summary>
     95    /// Evaluates the test function for a specific <paramref name="point"/>. It uses an array of precomputed values for Math.Sqrt(i + 1) with i = 0..N
     96    /// </summary>
     97    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
     98    /// <param name="sqrts">The precomputed array of square roots.</param>
     99    /// <returns>The result value of the Griewangk function at the given point.</returns>
     100    private static double Apply(RealVector point, double[] sqrts) {
     101      double result = 0;
     102      double val = 0;
     103
     104      for (int i = 0; i < point.Length; i++)
     105        result += point[i] * point[i];
     106      result = result / 4000;
     107
     108      val = Math.Cos(point[0]);
     109      for (int i = 1; i < point.Length; i++)
     110        val *= Math.Cos(point[i] / sqrts[i]);
     111
     112      result = result - val + 1;
     113      return result;
    87114    }
    88115
     
    94121    /// <returns>The result value of the Griewangk function at the given point.</returns>
    95122    protected override double EvaluateFunction(RealVector point) {
    96       return Apply(point);
     123      if (point.Length > 100)
     124        return Apply(point);
     125      else {
     126        if (sqrts == null || sqrts.Length < point.Length) ComputeSqrts(point.Length);
     127        return Apply(point, sqrts);
     128      }
     129    }
     130
     131    private void ComputeSqrts(int length) {
     132      sqrts = new double[length];
     133      for (int i = 0; i < length; i++) sqrts[i] = Math.Sqrt(i + 1);
    97134    }
    98135  }
Note: See TracChangeset for help on using the changeset viewer.