Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2521_ProblemRefactoring/HeuristicLab.Problems.TestFunctions/3.3/Functions/SingleObjectiveTestFunction.cs @ 16147

Last change on this file since 16147 was 13403, checked in by abeham, 9 years ago

#2521:

  • Adapted single-objective test function problem to new problem infrastructure
  • Added additional interfaces to RealVectorEncoding
  • Fixed IParticleUpdater interface (must implement IStochasticOperator if it contains a Random parameter)
File size: 3.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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
22using HeuristicLab.Common;
23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.Encodings.RealVectorEncoding;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace HeuristicLab.Problems.TestFunctions {
29  /// <summary>
30  /// Base class for a test function evaluator.
31  /// </summary>
32  [Item("Single-Objective Function", "Base class for single objective functions.")]
33  [StorableClass]
34  public abstract class SingleObjectiveTestFunction : ParameterizedNamedItem, ISingleObjectiveTestFunction {
35    /// <summary>
36    /// These operators should not change their name through the GUI
37    /// </summary>
38    public override bool CanChangeName {
39      get { return false; }
40    }
41    /// <summary>
42    /// Returns whether the actual function constitutes a maximization or minimization problem.
43    /// </summary>
44    public abstract bool Maximization { get; }
45    /// <summary>
46    /// Gets the lower and upper bound of the function.
47    /// </summary>
48    public abstract DoubleMatrix Bounds { get; }
49    /// <summary>
50    /// Gets the optimum function value.
51    /// </summary>
52    public abstract double BestKnownQuality { get; }
53    /// <summary>
54    /// Gets the minimum problem size.
55    /// </summary>
56    public abstract int MinimumProblemSize { get; }
57    /// <summary>
58    /// Gets the maximum problem size.
59    /// </summary>
60    public abstract int MaximumProblemSize { get; }
61
62    [StorableConstructor]
63    protected SingleObjectiveTestFunction(bool deserializing) : base(deserializing) { }
64    protected SingleObjectiveTestFunction(SingleObjectiveTestFunction original, Cloner cloner) : base(original, cloner) { }
65    protected SingleObjectiveTestFunction() : base() { }
66
67    public virtual double Evaluate2D(double x, double y) {
68      return Evaluate(new RealVector(new double[] { x, y }));
69    }
70
71    /// <summary>
72    /// Evaluates the test function for a specific <paramref name="point"/>.
73    /// </summary>
74    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
75    /// <returns>The result value of the function at the given point.</returns>
76    public abstract double Evaluate(RealVector point);
77
78    /// <summary>
79    /// Gets the best known solution for this function.
80    /// </summary>
81    public abstract RealVector GetBestKnownSolution(int dimension);
82  }
83}
Note: See TracBrowser for help on using the repository browser.