Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/SingleObjectiveTestFunctionProblemEvaluator.cs @ 18242

Last change on this file since 18242 was 17180, checked in by swagner, 5 years ago

#2875: Removed years in copyrights

File size: 4.4 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 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.Operators;
27using HeuristicLab.Parameters;
28using HEAL.Attic;
29
30namespace HeuristicLab.Problems.TestFunctions {
31  /// <summary>
32  /// Base class for a test function evaluator.
33  /// </summary>
34  [Item("Evaluator", "Base calls for single objective test function evaluators.")]
35  [StorableType("2775A51F-C97B-4D2E-9B25-9E2591A961CB")]
36  public abstract class SingleObjectiveTestFunctionProblemEvaluator : InstrumentedOperator, ISingleObjectiveTestFunctionProblemEvaluator {
37    /// <summary>
38    /// The name of the function
39    /// </summary>
40    public abstract string FunctionName { get; }
41    /// <summary>
42    /// These operators should not change their name through the GUI
43    /// </summary>
44    public override bool CanChangeName {
45      get { return false; }
46    }
47    /// <summary>
48    /// Returns whether the actual function constitutes a maximization or minimization problem.
49    /// </summary>
50    public abstract bool Maximization { get; }
51    /// <summary>
52    /// Gets the lower and upper bound of the function.
53    /// </summary>
54    public abstract DoubleMatrix Bounds { get; }
55    /// <summary>
56    /// Gets the optimum function value.
57    /// </summary>
58    public abstract double BestKnownQuality { get; }
59    /// <summary>
60    /// Gets the minimum problem size.
61    /// </summary>
62    public abstract int MinimumProblemSize { get; }
63    /// <summary>
64    /// Gets the maximum problem size.
65    /// </summary>
66    public abstract int MaximumProblemSize { get; }
67
68    public ILookupParameter<DoubleValue> QualityParameter {
69      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
70    }
71    public ILookupParameter<RealVector> PointParameter {
72      get { return (ILookupParameter<RealVector>)Parameters["Point"]; }
73    }
74
75    [StorableConstructor]
76    protected SingleObjectiveTestFunctionProblemEvaluator(StorableConstructorFlag _) : base(_) { }
77    protected SingleObjectiveTestFunctionProblemEvaluator(SingleObjectiveTestFunctionProblemEvaluator original, Cloner cloner) : base(original, cloner) { }
78    /// <summary>
79    /// Initializes a new instance of <see cref="SingleObjectiveTestFunctionEvaluator"/> with two parameters
80    /// (<c>Quality</c> and <c>Point</c>).
81    /// </summary>
82    public SingleObjectiveTestFunctionProblemEvaluator()
83      : base() {
84      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "Result of the evaluation of a solution."));
85      Parameters.Add(new LookupParameter<RealVector>("Point", "The point at which the function should be evaluated."));
86    }
87
88    public override IOperation InstrumentedApply() {
89      RealVector point = PointParameter.ActualValue;
90      double quality = Evaluate(point);
91      QualityParameter.ActualValue = new DoubleValue(quality);
92      return base.InstrumentedApply();
93    }
94
95    public virtual double Evaluate2D(double x, double y) {
96      return Evaluate(new RealVector(new double[] { x, y }));
97    }
98
99    /// <summary>
100    /// Evaluates the test function for a specific <paramref name="point"/>.
101    /// </summary>
102    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
103    /// <returns>The result value of the function at the given point.</returns>
104    public abstract double Evaluate(RealVector point);
105
106    /// <summary>
107    /// Gets the best known solution for this function.
108    /// </summary>
109    public abstract RealVector GetBestKnownSolution(int dimension);
110  }
111}
Note: See TracBrowser for help on using the repository browser.