Changeset 3318


Ignore:
Timestamp:
04/13/10 09:47:06 (11 years ago)
Author:
abeham
Message:

Updated test functions, added reference for Zakharov
Did not find a reference for SumSquares, just described it
Added wiring for rastrigin and sphere
#934

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  
    3636  public class GriewankEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
    3737    /// <summary>
    38     /// Returns false as the Griewangk function is a minimization problem.
     38    /// Returns false as the Griewank function is a minimization problem.
    3939    /// </summary>
    4040    public override bool Maximization {
     
    7575    /// </summary>
    7676    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
    77     /// <returns>The result value of the Griewangk function at the given point.</returns>
     77    /// <returns>The result value of the Griewank function at the given point.</returns>
    7878    public static double Apply(RealVector point) {
    7979      double result = 0;
     
    9797    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
    9898    /// <param name="sqrts">The precomputed array of square roots.</param>
    99     /// <returns>The result value of the Griewangk function at the given point.</returns>
     99    /// <returns>The result value of the Griewank function at the given point.</returns>
    100100    private static double Apply(RealVector point, double[] sqrts) {
    101101      double result = 0;
     
    119119    /// <remarks>Calls <see cref="Apply"/>.</remarks>
    120120    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
    121     /// <returns>The result value of the Griewangk function at the given point.</returns>
     121    /// <returns>The result value of the Griewank function at the given point.</returns>
    122122    protected override double EvaluateFunction(RealVector point) {
    123123      if (point.Length > 100)
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/MatyasEvaluator.cs

    r3315 r3318  
    3434  public class MatyasEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
    3535    /// <summary>
    36     /// Returns false as the Beale function is a minimization problem.
     36    /// Returns false as the Matyas function is a minimization problem.
    3737    /// </summary>
    3838    public override bool Maximization {
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/RosenbrockEvaluator.cs

    r3315 r3318  
    3232  /// </summary>
    3333  [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.
     34For 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).
    3535It 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.")]
     36It 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.")]
    3737  [StorableClass]
    3838  public class RosenbrockEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/SchwefelEvaluator.cs

    r3315 r3318  
    3434  public class SchwefelEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
    3535    /// <summary>
    36     /// Returns false as the Rosenbrock function is a minimization problem.
     36    /// Returns false as the Schwefel (sine root) function is a minimization problem.
    3737    /// </summary>
    3838    public override bool Maximization {
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/SumSquaresEvaluator.cs

    r3187 r3318  
    2828namespace HeuristicLab.Problems.TestFunctions {
    2929  /// <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
    3331  /// </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.")]
    3533  [StorableClass]
    3634  public class SumSquaresEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
    3735    /// <summary>
    38     /// Returns false as the Rosenbrock function is a minimization problem.
     36    /// Returns false as the Sum Squares function is a minimization problem.
    3937    /// </summary>
    4038    public override bool Maximization {
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/ZakharovEvaluator.cs

    r3170 r3318  
    2828namespace HeuristicLab.Problems.TestFunctions {
    2929  /// <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.
    3331  /// </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.")]
    3533  [StorableClass]
    3634  public class ZakharovEvaluator : SingleObjectiveTestFunctionProblemEvaluator {
    3735    /// <summary>
    38     /// Returns false as the Ackley function is a minimization problem.
     36    /// Returns false as the Zakharov function is a minimization problem.
    3937    /// </summary>
    4038    public override bool Maximization {
     
    7775
    7876      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];
    8179      }
    82       return s1 + s2 * s2 + s2 * s2 * s2 * s2;
     80      return s1 + (s2 * s2) + (s2 * s2 * s2 * s2);
    8381    }
    8482
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/MoveEvaluators/RastriginAdditiveMoveEvaluator.cs

    r3315 r3318  
    2121
    2222using HeuristicLab.Core;
     23using HeuristicLab.Data;
     24using HeuristicLab.Encodings.RealVectorEncoding;
     25using HeuristicLab.Parameters;
    2326using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    24 using HeuristicLab.Encodings.RealVectorEncoding;
    2527
    2628namespace HeuristicLab.Problems.TestFunctions {
    2729  [Item("RastriginAdditiveMoveEvaluator", "Class for evaluating an additive move on the Rastrigin function.")]
    2830  [StorableClass]
    29   public class RastriginAdditiveMoveEvaluator : AdditiveMoveEvaluator {
     31  public class RastriginAdditiveMoveEvaluator : AdditiveMoveEvaluator, IRastriginMoveEvaluator {
    3032    public override System.Type EvaluatorType {
    3133      get { return typeof(RastriginEvaluator); }
    3234    }
     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
    3349    protected override double Evaluate(double quality, RealVector point, AdditiveMove move) {
    3450      RealVectorAdditiveMoveWrapper wrapper = new RealVectorAdditiveMoveWrapper(move, point);
    35       return RastriginEvaluator.Apply(wrapper, 10); // FIXME: the parameters have to be wired
     51      return RastriginEvaluator.Apply(wrapper, A.Value);
    3652    }
    3753  }
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/MoveEvaluators/SphereAdditiveMoveEvaluator.cs

    r3315 r3318  
    2121
    2222using HeuristicLab.Core;
     23using HeuristicLab.Data;
     24using HeuristicLab.Encodings.RealVectorEncoding;
     25using HeuristicLab.Parameters;
    2326using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    24 using HeuristicLab.Encodings.RealVectorEncoding;
    2527
    2628namespace HeuristicLab.Problems.TestFunctions {
    2729  [Item("SphereAdditiveMoveEvaluator", "Class for evaluating an additive move on the Sphere function.")]
    2830  [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
    3059    public override System.Type EvaluatorType {
    3160      get { return typeof(SphereEvaluator); }
     
    3362    protected override double Evaluate(double quality, RealVector point, AdditiveMove move) {
    3463      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);
    3665    }
    3766  }
  • trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/SingleObjectiveTestFunctionProblem.cs

    r3303 r3318  
    233233      }
    234234    }
     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    }
    235252    #endregion
    236253
     
    270287        if (op.EvaluatorType == Evaluator.GetType()) {
    271288          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
    272304        }
    273305      ParameterizeOperators();
Note: See TracChangeset for help on using the changeset viewer.