1  #region License Information


2  /* HeuristicLab


3  * Copyright (C) 20022010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)


4  *


5  * This file is part of HeuristicLab.


6  *


7  * HeuristicLab is free software: you can redistribute it and/or modify


8  * it under the terms of the GNU General Public License as published by


9  * the Free Software Foundation, either version 3 of the License, or


10  * (at your option) any later version.


11  *


12  * HeuristicLab is distributed in the hope that it will be useful,


13  * but WITHOUT ANY WARRANTY; without even the implied warranty of


14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the


15  * GNU General Public License for more details.


16  *


17  * You should have received a copy of the GNU General Public License


18  * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.


19  */


20  #endregion


21 


22  using System;


23  using HeuristicLab.Core;


24  using HeuristicLab.Data;


25  using HeuristicLab.Encodings.RealVectorEncoding;


26  using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;


27 


28  namespace HeuristicLab.Problems.TestFunctions {


29  /// <summary>


30  /// The Rosenbrock function features a flat valley in which the global optimum is located.


31  /// 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. 119126, MIT Press.


32  /// </summary>


33  [Item("RosenbrockEvaluator", @"The Rosenbrock function features a flat valley in which the global optimum is located.


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  It is unknown how many local minima there are for dimensions greater than 30.


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. 119126, MIT Press.")]


37  [StorableClass]


38  public class RosenbrockEvaluator : SingleObjectiveTestFunctionProblemEvaluator {


39  /// <summary>


40  /// Returns false as the Rosenbrock function is a minimization problem.


41  /// </summary>


42  public override bool Maximization {


43  get { return false; }


44  }


45  /// <summary>


46  /// Gets the optimum function value (0).


47  /// </summary>


48  public override double BestKnownQuality {


49  get { return 0; }


50  }


51  /// <summary>


52  /// Gets the lower and upper bound of the function.


53  /// </summary>


54  public override DoubleMatrix Bounds {


55  get { return new DoubleMatrix(new double[,] { { 2.048, 2.048 } }); }


56  }


57  /// <summary>


58  /// Gets the minimum problem size (2).


59  /// </summary>


60  public override int MinimumProblemSize {


61  get { return 2; }


62  }


63  /// <summary>


64  /// Gets the (theoretical) maximum problem size (2^31  1).


65  /// </summary>


66  public override int MaximumProblemSize {


67  get { return int.MaxValue; }


68  }


69 


70  /// <summary>


71  /// Evaluates the test function for a specific <paramref name="point"/>.


72  /// </summary>


73  /// <param name="point">Ndimensional point for which the test function should be evaluated.</param>


74  /// <returns>The result value of the Rosenbrock function at the given point.</returns>


75  public static double Apply(RealVector point) {


76  double result = 0;


77  for (int i = 0; i < point.Length  1; i++) {


78  result += 100 * (point[i] * point[i]  point[i + 1]) * (point[i] * point[i]  point[i + 1]);


79  result += (point[i]  1) * (point[i]  1);


80  }


81  return result;


82  }


83 


84  /// <summary>


85  /// Evaluates the test function for a specific <paramref name="point"/>.


86  /// </summary>


87  /// <remarks>Calls <see cref="Apply"/>.</remarks>


88  /// <param name="point">Ndimensional point for which the test function should be evaluated.</param>


89  /// <returns>The result value of the Rosenbrock function at the given point.</returns>


90  protected override double EvaluateFunction(RealVector point) {


91  return Apply(point);


92  }


93  }


94  }

