Changeset 3318
- Timestamp:
- 04/13/10 09:47:06 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.TestFunctions/3.3
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/GriewankEvaluator.cs
r3315 r3318 36 36 public class GriewankEvaluator : SingleObjectiveTestFunctionProblemEvaluator { 37 37 /// <summary> 38 /// Returns false as the Griewan gk function is a minimization problem.38 /// Returns false as the Griewank function is a minimization problem. 39 39 /// </summary> 40 40 public override bool Maximization { … … 75 75 /// </summary> 76 76 /// <param name="point">N-dimensional point for which the test function should be evaluated.</param> 77 /// <returns>The result value of the Griewan gk function at the given point.</returns>77 /// <returns>The result value of the Griewank function at the given point.</returns> 78 78 public static double Apply(RealVector point) { 79 79 double result = 0; … … 97 97 /// <param name="point">N-dimensional point for which the test function should be evaluated.</param> 98 98 /// <param name="sqrts">The precomputed array of square roots.</param> 99 /// <returns>The result value of the Griewan gk function at the given point.</returns>99 /// <returns>The result value of the Griewank function at the given point.</returns> 100 100 private static double Apply(RealVector point, double[] sqrts) { 101 101 double result = 0; … … 119 119 /// <remarks>Calls <see cref="Apply"/>.</remarks> 120 120 /// <param name="point">N-dimensional point for which the test function should be evaluated.</param> 121 /// <returns>The result value of the Griewan gk function at the given point.</returns>121 /// <returns>The result value of the Griewank function at the given point.</returns> 122 122 protected override double EvaluateFunction(RealVector point) { 123 123 if (point.Length > 100) -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/MatyasEvaluator.cs
r3315 r3318 34 34 public class MatyasEvaluator : SingleObjectiveTestFunctionProblemEvaluator { 35 35 /// <summary> 36 /// Returns false as the Bealefunction is a minimization problem.36 /// Returns false as the Matyas function is a minimization problem. 37 37 /// </summary> 38 38 public override bool Maximization { -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/RosenbrockEvaluator.cs
r3315 r3318 32 32 /// </summary> 33 33 [Item("RosenbrockEvaluator", @"The Rosenbrock function features a flat valley in which the global optimum is located. 34 For 2 and 3 dimensions the optimum of this function is 0 at (1,1,...,1), for 4 to 30 dimensions there is an additional local minimum.34 For 2 and 3 dimensions the single minimum of this function is 0 at (1,1,...,1), for 4 to 30 dimensions there is an additional local minimum close to (-1,1,...,1). 35 35 It is unknown how many local minima there are for dimensions greater than 30. 36 It is implemented as generalized Rosenbrock function as for example given in Shang, Y.-W. and Qiu, Y.-H. 2006. A Note on the Extended Rosenbrock Function. Evolutionary Computation 14, pp. 119-126, MIT Press.")]36 It is implemented as generalized Rosenbrock function for which the 2 dimensional function is a special case, as for example given in Shang, Y.-W. and Qiu, Y.-H. 2006. A Note on the Extended Rosenbrock Function. Evolutionary Computation 14, pp. 119-126, MIT Press.")] 37 37 [StorableClass] 38 38 public class RosenbrockEvaluator : SingleObjectiveTestFunctionProblemEvaluator { -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/SchwefelEvaluator.cs
r3315 r3318 34 34 public class SchwefelEvaluator : SingleObjectiveTestFunctionProblemEvaluator { 35 35 /// <summary> 36 /// Returns false as the Rosenbrockfunction is a minimization problem.36 /// Returns false as the Schwefel (sine root) function is a minimization problem. 37 37 /// </summary> 38 38 public override bool Maximization { -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/SumSquaresEvaluator.cs
r3187 r3318 28 28 namespace HeuristicLab.Problems.TestFunctions { 29 29 /// <summary> 30 /// Sum Squares Function<br/> 31 /// Domain: [-10.0 , 10.0]^n<br/> 32 /// Optimum: 0.0 at (0.0, 0.0, ..., 0.0) 30 /// The Sum Squares function is defined as sum(i * x_i * x_i) for i = 1..n 33 31 /// </summary> 34 [Item("SumSquaresEvaluator", "Evaluates the sum squares function on a given point. The optimum of this function is 0 at the origin. ")]32 [Item("SumSquaresEvaluator", "Evaluates the sum squares function on a given point. The optimum of this function is 0 at the origin. The Sum Squares function is defined as sum(i * x_i * x_i) for i = 1..n.")] 35 33 [StorableClass] 36 34 public class SumSquaresEvaluator : SingleObjectiveTestFunctionProblemEvaluator { 37 35 /// <summary> 38 /// Returns false as the Rosenbrockfunction is a minimization problem.36 /// Returns false as the Sum Squares function is a minimization problem. 39 37 /// </summary> 40 38 public override bool Maximization { -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/ZakharovEvaluator.cs
r3170 r3318 28 28 namespace HeuristicLab.Problems.TestFunctions { 29 29 /// <summary> 30 /// Zakharov Function<br/> 31 /// Domain: [-5.0 , 10.0]^n<br/> 32 /// Optimum: 0.0 at (0.0, 0.0, ..., 0.0) 30 /// The Zakharov function is implemented as described in Hedar, A. & Fukushima, M. 2004. Heuristic pattern search and its hybridization with simulated annealing for nonlinear global optimization. Optimization Methods and Software 19, pp. 291-308, Taylor & Francis. 33 31 /// </summary> 34 [Item("ZakharovEvaluator", "Evaluates the Zakharov function on a given point. The optimum of this function is 0 at the origin. ")]32 [Item("ZakharovEvaluator", "Evaluates the Zakharov function on a given point. The optimum of this function is 0 at the origin. It is implemented as described in Hedar, A. & Fukushima, M. 2004. Heuristic pattern search and its hybridization with simulated annealing for nonlinear global optimization. Optimization Methods and Software 19, pp. 291-308, Taylor & Francis.")] 35 33 [StorableClass] 36 34 public class ZakharovEvaluator : SingleObjectiveTestFunctionProblemEvaluator { 37 35 /// <summary> 38 /// Returns false as the Ackleyfunction is a minimization problem.36 /// Returns false as the Zakharov function is a minimization problem. 39 37 /// </summary> 40 38 public override bool Maximization { … … 77 75 78 76 for (int i = 0; i < length; i++) { 79 s1 = s1 +point[i] * point[i];80 s2 = s2 +0.5 * i * point[i];77 s1 += point[i] * point[i]; 78 s2 += 0.5 * i * point[i]; 81 79 } 82 return s1 + s2 * s2 + s2 * s2 * s2 * s2;80 return s1 + (s2 * s2) + (s2 * s2 * s2 * s2); 83 81 } 84 82 -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/MoveEvaluators/RastriginAdditiveMoveEvaluator.cs
r3315 r3318 21 21 22 22 using HeuristicLab.Core; 23 using HeuristicLab.Data; 24 using HeuristicLab.Encodings.RealVectorEncoding; 25 using HeuristicLab.Parameters; 23 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 24 using HeuristicLab.Encodings.RealVectorEncoding;25 27 26 28 namespace HeuristicLab.Problems.TestFunctions { 27 29 [Item("RastriginAdditiveMoveEvaluator", "Class for evaluating an additive move on the Rastrigin function.")] 28 30 [StorableClass] 29 public class RastriginAdditiveMoveEvaluator : AdditiveMoveEvaluator {31 public class RastriginAdditiveMoveEvaluator : AdditiveMoveEvaluator, IRastriginMoveEvaluator { 30 32 public override System.Type EvaluatorType { 31 33 get { return typeof(RastriginEvaluator); } 32 34 } 35 /// <summary> 36 /// 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. 37 /// </summary> 38 public ValueParameter<DoubleValue> AParameter { 39 get { return (ValueParameter<DoubleValue>)Parameters["A"]; } 40 } 41 /// <summary> 42 /// 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. 43 /// </summary> 44 public DoubleValue A { 45 get { return AParameter.Value; } 46 set { if (value != null) AParameter.Value = value; } 47 } 48 33 49 protected override double Evaluate(double quality, RealVector point, AdditiveMove move) { 34 50 RealVectorAdditiveMoveWrapper wrapper = new RealVectorAdditiveMoveWrapper(move, point); 35 return RastriginEvaluator.Apply(wrapper, 10); // FIXME: the parameters have to be wired51 return RastriginEvaluator.Apply(wrapper, A.Value); 36 52 } 37 53 } -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/MoveEvaluators/SphereAdditiveMoveEvaluator.cs
r3315 r3318 21 21 22 22 using HeuristicLab.Core; 23 using HeuristicLab.Data; 24 using HeuristicLab.Encodings.RealVectorEncoding; 25 using HeuristicLab.Parameters; 23 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 24 using HeuristicLab.Encodings.RealVectorEncoding;25 27 26 28 namespace HeuristicLab.Problems.TestFunctions { 27 29 [Item("SphereAdditiveMoveEvaluator", "Class for evaluating an additive move on the Sphere function.")] 28 30 [StorableClass] 29 public class SphereAdditiveMoveEvaluator : AdditiveMoveEvaluator { 31 public class SphereAdditiveMoveEvaluator : AdditiveMoveEvaluator, ISphereMoveEvaluator { 32 /// <summary> 33 /// The parameter C modifies the steepness of the objective function y = C * ||X||^Alpha. Default is C = 1. 34 /// </summary> 35 public ValueParameter<DoubleValue> CParameter { 36 get { return (ValueParameter<DoubleValue>)Parameters["C"]; } 37 } 38 /// <summary> 39 /// The parameter Alpha modifies the steepness of the objective function y = C * ||X||^Alpha. Default is Alpha = 2. 40 /// </summary> 41 public ValueParameter<DoubleValue> AlphaParameter { 42 get { return (ValueParameter<DoubleValue>)Parameters["Alpha"]; } 43 } 44 /// <summary> 45 /// The parameter C modifies the steepness of the objective function y = C * ||X||^Alpha. Default is C = 1. 46 /// </summary> 47 public DoubleValue C { 48 get { return CParameter.Value; } 49 set { if (value != null) CParameter.Value = value; } 50 } 51 /// <summary> 52 /// The parameter Alpha modifies the steepness of the objective function y = C * ||X||^Alpha. Default is Alpha = 2. 53 /// </summary> 54 public DoubleValue Alpha { 55 get { return AlphaParameter.Value; } 56 set { if (value != null) AlphaParameter.Value = value; } 57 } 58 30 59 public override System.Type EvaluatorType { 31 60 get { return typeof(SphereEvaluator); } … … 33 62 protected override double Evaluate(double quality, RealVector point, AdditiveMove move) { 34 63 RealVectorAdditiveMoveWrapper wrapper = new RealVectorAdditiveMoveWrapper(move, point); 35 return SphereEvaluator.Apply(wrapper, 1, 2); // FIXME: the parameters have to be wired.64 return SphereEvaluator.Apply(wrapper, C.Value, Alpha.Value); 36 65 } 37 66 } -
trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs
r3303 r3318 233 233 } 234 234 } 235 private void SphereEvaluator_Parameter_ValueChanged(object sender, EventArgs e) { 236 SphereEvaluator eval = (Evaluator as SphereEvaluator); 237 if (eval != null) { 238 foreach (ISphereMoveEvaluator op in Operators.OfType<ISphereMoveEvaluator>()) { 239 op.C = eval.C; 240 op.Alpha = eval.Alpha; 241 } 242 } 243 } 244 private void RastriginEvaluator_Parameter_ValueChanged(object sender, EventArgs e) { 245 RastriginEvaluator eval = (Evaluator as RastriginEvaluator); 246 if (eval != null) { 247 foreach (IRastriginMoveEvaluator op in Operators.OfType<IRastriginMoveEvaluator>()) { 248 op.A = eval.A; 249 } 250 } 251 } 235 252 #endregion 236 253 … … 270 287 if (op.EvaluatorType == Evaluator.GetType()) { 271 288 operators.Add(op); 289 #region Synchronize evaluator specific parameters with the parameters of the corresponding move evaluators 290 if (op is ISphereMoveEvaluator) { 291 SphereEvaluator e = (Evaluator as SphereEvaluator); 292 e.AlphaParameter.ValueChanged += new EventHandler(SphereEvaluator_Parameter_ValueChanged); 293 e.CParameter.ValueChanged += new EventHandler(SphereEvaluator_Parameter_ValueChanged); 294 ISphereMoveEvaluator em = (op as ISphereMoveEvaluator); 295 em.C = e.C; 296 em.Alpha = e.Alpha; 297 } else if (op is IRastriginMoveEvaluator) { 298 RastriginEvaluator e = (Evaluator as RastriginEvaluator); 299 e.AParameter.ValueChanged += new EventHandler(RastriginEvaluator_Parameter_ValueChanged); 300 IRastriginMoveEvaluator em = (op as IRastriginMoveEvaluator); 301 em.A = e.A; 302 } 303 #endregion 272 304 } 273 305 ParameterizeOperators();
Note: See TracChangeset
for help on using the changeset viewer.