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 edited

Legend:

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

    r3170 r3315  
    2525using HeuristicLab.Encodings.RealVectorEncoding;
    2626using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     27using HeuristicLab.Parameters;
    2728
    2829namespace HeuristicLab.Problems.TestFunctions {
    2930  /// <summary>
    30   /// Sphere Function<br/>
    31   /// Domain:  [-5.12 , 5.12]^n<br/>
    32   /// Optimum: 0.0 at (0, 0, ..., 0)
     31  /// The sphere function is a unimodal function that has its optimum at the origin.
     32  /// It is implemented as described in Beyer, H.-G. and Schwefel, H.-P. 2002. Evolution Strategies - A Comprehensive Introduction Natural Computing, 1, pp. 3-52.
    3333  /// </summary>
    34   [Item("SphereEvaluator", "Evaluates the Sphere function on a given point. The optimum of this function is 0 at the origin.")]
     34  [Item("SphereEvaluator", "Evaluates the Sphere function y = C * ||X||^Alpha on a given point. The optimum of this function is 0 at the origin. It is implemented as described in Beyer, H.-G. and Schwefel, H.-P. 2002. Evolution Strategies - A Comprehensive Introduction Natural Computing, 1, pp. 3-52.")]
    3535  [StorableClass]
    3636  public class SphereEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
    3737    /// <summary>
    38     /// Returns false as the Rosenbrock function is a minimization problem.
     38    /// Returns false as the Sphere function is a minimization problem.
    3939    /// </summary>
    4040    public override bool Maximization {
     
    6565      get { return int.MaxValue; }
    6666    }
     67    /// <summary>
     68    /// The parameter C modifies the steepness of the objective function y = C * ||X||^Alpha. Default is C = 1.
     69    /// </summary>
     70    public ValueParameter<DoubleValue> CParameter {
     71      get { return (ValueParameter<DoubleValue>)Parameters["C"]; }
     72    }
     73    /// <summary>
     74    /// The parameter Alpha modifies the steepness of the objective function y = C * ||X||^Alpha. Default is Alpha = 2.
     75    /// </summary>
     76    public ValueParameter<DoubleValue> AlphaParameter {
     77      get { return (ValueParameter<DoubleValue>)Parameters["Alpha"]; }
     78    }
     79    /// <summary>
     80    /// The parameter C modifies the steepness of the objective function y = C * ||X||^Alpha. Default is C = 1.
     81    /// </summary>
     82    public DoubleValue C {
     83      get { return CParameter.Value; }
     84      set { if (value != null) CParameter.Value = value; }
     85    }
     86    /// <summary>
     87    /// The parameter Alpha modifies the steepness of the objective function y = C * ||X||^Alpha. Default is Alpha = 2.
     88    /// </summary>
     89    public DoubleValue Alpha {
     90      get { return AlphaParameter.Value; }
     91      set { if (value != null) AlphaParameter.Value = value; }
     92    }
    6793
     94    /// <summary>
     95    /// Initializes a new instance of the SphereEvaluator with two parameters (<c>C</c> and <c>Alpha</c>).
     96    /// </summary>
     97    public SphereEvaluator()
     98      : base() {
     99      Parameters.Add(new ValueParameter<DoubleValue>("C", "The parameter C modifies the steepness of the objective function y = C * ||X||^Alpha. Default is C = 1.", new DoubleValue(1)));
     100      Parameters.Add(new ValueParameter<DoubleValue>("Alpha", "The parameter Alpha modifies the steepness of the objective function y = C * ||X||^Alpha. Default is Alpha = 2.", new DoubleValue(2)));
     101    }
    68102    /// <summary>
    69103    /// Evaluates the test function for a specific <paramref name="point"/>.
     
    71105    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
    72106    /// <returns>The result value of the Sphere function at the given point.</returns>
    73     public static double Apply(RealVector point) {
     107    public static double Apply(RealVector point, double c, double alpha) {
    74108      double result = 0;
    75109      for (int i = 0; i < point.Length; i++)
    76110        result += point[i] * point[i];
    77       return result;
     111      if (alpha != 2) result = Math.Pow(Math.Sqrt(result), alpha);
     112      return c * result;
    78113    }
    79114
     
    85120    /// <returns>The result value of the Sphere function at the given point.</returns>
    86121    protected override double EvaluateFunction(RealVector point) {
    87       return Apply(point);
     122      return Apply(point, C.Value, Alpha.Value);
    88123    }
    89124  }
Note: See TracChangeset for help on using the changeset viewer.