Changeset 3315 for trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/SphereEvaluator.cs
- Timestamp:
- 04/12/10 23:39:40 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/SphereEvaluator.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 /// 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. 33 33 /// </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.")] 35 35 [StorableClass] 36 36 public class SphereEvaluator : SingleObjectiveTestFunctionProblemEvaluator { 37 37 /// <summary> 38 /// Returns false as the Rosenbrockfunction is a minimization problem.38 /// Returns false as the Sphere function is a minimization problem. 39 39 /// </summary> 40 40 public override bool Maximization { … … 65 65 get { return int.MaxValue; } 66 66 } 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 } 67 93 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 } 68 102 /// <summary> 69 103 /// Evaluates the test function for a specific <paramref name="point"/>. … … 71 105 /// <param name="point">N-dimensional point for which the test function should be evaluated.</param> 72 106 /// <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) { 74 108 double result = 0; 75 109 for (int i = 0; i < point.Length; i++) 76 110 result += point[i] * point[i]; 77 return result; 111 if (alpha != 2) result = Math.Pow(Math.Sqrt(result), alpha); 112 return c * result; 78 113 } 79 114 … … 85 120 /// <returns>The result value of the Sphere function at the given point.</returns> 86 121 protected override double EvaluateFunction(RealVector point) { 87 return Apply(point );122 return Apply(point, C.Value, Alpha.Value); 88 123 } 89 124 }
Note: See TracChangeset
for help on using the changeset viewer.