Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.TestFunctions/3.3/Evaluators/SingleObjectiveTestFunctionProblemEvaluator.cs @ 4108

Last change on this file since 4108 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

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