Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.TestFunctions.SingleObjective/3.3/Evaluators/SingleObjectiveTestFunctionEvaluator.cs @ 3150

Last change on this file since 3150 was 3150, checked in by abeham, 14 years ago

Added first version of single objective test functions problem #934

File size: 3.5 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.SingleObjective {
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 SingleObjectiveTestFunctionEvaluator : SingleSuccessorOperator, ISingleObjectiveTestFunctionEvaluator {
36    /// <summary>
37    /// Returns whether the actual function constitutes a maximization or minimization problem.
38    /// </summary>
39    public abstract bool Maximization { get; }
40    /// <summary>
41    /// Gets the lower and upper bound of the function.
42    /// </summary>
43    public abstract DoubleMatrix Bounds { get; }
44    /// <summary>
45    /// Gets the optimum function value.
46    /// </summary>
47    public abstract double BestKnownQuality { get; }
48    /// <summary>
49    /// Gets the minimum problem size.
50    /// </summary>
51    public abstract int MinimumProblemSize { get; }
52    /// <summary>
53    /// Gets the maximum problem size.
54    /// </summary>
55    public abstract int MaximumProblemSize { get; }
56
57    public ILookupParameter<DoubleValue> QualityParameter {
58      get { return (ILookupParameter<DoubleValue>)Parameters["Quality"]; }
59    }
60    public ILookupParameter<RealVector> PointParameter {
61      get { return (ILookupParameter<RealVector>)Parameters["Point"]; }
62    }
63    /// <summary>
64    /// Initializes a new instance of <see cref="SingleObjectiveTestFunctionEvaluator"/> with two parameters
65    /// (<c>Quality</c> and <c>Point</c>).
66    /// </summary>
67    public SingleObjectiveTestFunctionEvaluator() {
68      Parameters.Add(new LookupParameter<DoubleValue>("Quality", "Result of the evaluation of a solution."));
69      Parameters.Add(new LookupParameter<RealVector>("Point", "The point at which the function should be evaluated."));
70    }
71
72    public override IOperation Apply() {
73      RealVector point = PointParameter.ActualValue;
74      double quality = EvaluateFunction(point);
75      QualityParameter.ActualValue = new DoubleValue(quality);
76      return base.Apply();
77    }
78
79    /// <summary>
80    /// Evaluates the test function for a specific <paramref name="point"/>.
81    /// </summary>
82    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
83    /// <returns>The result value of the function at the given point.</returns>
84    protected abstract double EvaluateFunction(RealVector point);
85  }
86}
Note: See TracBrowser for help on using the repository browser.