Changeset 3315 for trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/RastriginEvaluator.cs
- Timestamp:
- 04/12/10 23:39:40 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/RastriginEvaluator.cs
r3170 r3315 25 25 using HeuristicLab.Encodings.RealVectorEncoding; 26 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 using HeuristicLab.Parameters; 27 28 28 29 namespace HeuristicLab.Problems.TestFunctions { 29 30 /// <summary> 30 /// Rastrigin Function<br/> 31 /// Domain: [-5.12 , 5.12]^n <br/> 32 /// Optimum: 0.0 at (0, 0, ..., 0) 31 /// The generalized Rastrigin function y = Sum((x_i)^2 + A * (1 - Cos(2pi*x_i))) is a highly multimodal function that has its optimal value 0 at the origin. 32 /// It is implemented as described in Eiben, A.E. and Smith, J.E. 2003. Introduction to Evolutionary Computation. Natural Computing Series, Springer-Verlag Berlin Heidelberg. 33 33 /// </summary 34 [Item("RastriginEvaluator", "Evaluates the Rastrigin function on a given point. The optimum of this function is 0 at the origin.")]34 [Item("RastriginEvaluator", "Evaluates the generalized Rastrigin function y = Sum((x_i)^2 + A * (1 - Cos(2pi*x_i))) on a given point. The optimum of this function is 0 at the origin. It is implemented as described in Eiben, A.E. and Smith, J.E. 2003. Introduction to Evolutionary Computation. Natural Computing Series, Springer-Verlag Berlin Heidelberg.")] 35 35 [StorableClass] 36 36 public class RastriginEvaluator : SingleObjectiveTestFunctionProblemEvaluator { … … 65 65 get { return int.MaxValue; } 66 66 } 67 /// <summary> 68 /// The parameter A is a parameter of the objective function y = Sum((x_i)^2 + A * (1 - Cos(2pi*x_i))). Default is A = 10. 69 /// </summary> 70 public ValueParameter<DoubleValue> AParameter { 71 get { return (ValueParameter<DoubleValue>)Parameters["A"]; } 72 } 73 /// <summary> 74 /// The parameter A is a parameter of the objective function y = Sum((x_i)^2 + A * (1 - Cos(2pi*x_i))). Default is A = 10. 75 /// </summary> 76 public DoubleValue A { 77 get { return AParameter.Value; } 78 set { if (value != null) AParameter.Value = value; } 79 } 80 81 /// <summary> 82 /// Initializes a new instance of the RastriginEvaluator with one parameter (<c>A</c>). 83 /// </summary> 84 public RastriginEvaluator() 85 : base() { 86 Parameters.Add(new ValueParameter<DoubleValue>("A", "The parameter A is a parameter of the objective function y = Sum((x_i)^2 + A * (1 - Cos(2pi*x_i))). Default is A = 10.", new DoubleValue(10))); 87 } 67 88 68 89 /// <summary> … … 71 92 /// <param name="point">N-dimensional point for which the test function should be evaluated.</param> 72 93 /// <returns>The result value of the Rastrigin function at the given point.</returns> 73 public static double Apply(RealVector point ) {74 double result = 10* point.Length;94 public static double Apply(RealVector point, double a) { 95 double result = a * point.Length; 75 96 for (int i = 0; i < point.Length; i++) { 76 97 result += point[i] * point[i]; 77 result -= 10* Math.Cos(2 * Math.PI * point[i]);98 result -= a * Math.Cos(2 * Math.PI * point[i]); 78 99 } 79 100 return (result); … … 87 108 /// <returns>The result value of the Rastrigin function at the given point.</returns> 88 109 protected override double EvaluateFunction(RealVector point) { 89 return Apply(point );110 return Apply(point, A.Value); 90 111 } 91 112 }
Note: See TracChangeset
for help on using the changeset viewer.