Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/MultiObjectiveTestFunction.cs @ 14067

Last change on this file since 14067 was 14067, checked in by mkommend, 8 years ago

#1087: Refactored multi-objective test functions.

File size: 5.4 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2016 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 System.Collections.Generic;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Data;
26using HeuristicLab.Encodings.RealVectorEncoding;
27using HeuristicLab.Parameters;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29
30namespace HeuristicLab.Problems.MultiObjectiveTestFunctions {
31  /// <summary>
32  /// Base class for a test function evaluator.
33  /// </summary>
34  [Item("Multi-Objective Function", "Base class for multi objective functions.")]
35  [StorableClass]
36  public abstract class MultiObjectiveTestFunction : ParameterizedNamedItem, IMultiObjectiveTestFunction {
37    /// <summary>
38    /// These operators should not change their name through the GUI
39    /// </summary>
40    public override bool CanChangeName {
41      get { return false; }
42    }
43
44    /// <summary>
45    /// Gets the minimum problem size.
46    /// </summary>
47    [Storable]
48    public int MinimumSolutionLength { get; private set; }
49    /// <summary>
50    /// Gets the maximum problem size.
51    /// </summary>
52    [Storable]
53    public int MaximumSolutionLength { get; private set; }
54
55
56    /// <summary>
57    /// Gets the minimum solution size.
58    /// </summary>
59    [Storable]
60    public int MinimumObjectives { get; private set; }
61    /// <summary>
62    /// Gets the maximum solution size.
63    /// </summary>
64    [Storable]
65    public int MaximumObjectives { get; private set; }
66
67
68    /// <summary>
69    /// Returns whether the actual function constitutes a maximization or minimization problem.
70    /// </summary>
71    public abstract bool[] Maximization(int objectives);
72    /// <summary>
73    /// Gets the lower and upper bound of the function.
74    /// </summary>
75    public abstract double[,] Bounds(int objectives);
76
77
78    /// <summary>
79    /// retrieves the optimal pareto front (if known from a file)
80    /// </summary>
81    public abstract IEnumerable<double[]> OptimalParetoFront(int objectives);
82
83    /// <summary>
84    /// returns a Reference Point for Hypervolume calculation (default=(11|11))
85    /// </summary>
86    public abstract double[] ReferencePoint(int objectives);
87
88
89    /// <summary>
90    /// returns the best known Hypervolume for this test function   (default=-1)
91    /// </summary>
92    public virtual double BestKnownHypervolume(int objectives) {
93      return -1;
94    }
95
96    [StorableConstructor]
97    protected MultiObjectiveTestFunction(bool deserializing) : base(deserializing) { }
98
99    protected MultiObjectiveTestFunction(MultiObjectiveTestFunction original, Cloner cloner)
100      : base(original, cloner) {
101      MinimumObjectives = original.MinimumObjectives;
102      MaximumObjectives = original.MaximumObjectives;
103      MinimumSolutionLength = original.MinimumSolutionLength;
104      MaximumSolutionLength = original.MaximumSolutionLength;
105    }
106
107    protected MultiObjectiveTestFunction(int minimumObjectives, int maximumObjectives, int minimumSolutionLength, int maximumSolutionLength)
108      : base() {
109      Parameters.Add(new FixedValueParameter<IntValue>("Minimum Objectives",
110        "The dimensionality of the problem instance (number of variables in the function).",
111        (IntValue)new IntValue(minimumObjectives).AsReadOnly()) { GetsCollected = false });
112      Parameters.Add(new FixedValueParameter<IntValue>("Maximum Objectives", "The dimensionality of the problem instance (number of variables in the function).", (IntValue)new IntValue(maximumObjectives).AsReadOnly()) { GetsCollected = false });
113      Parameters.Add(new FixedValueParameter<IntValue>("Minimum SolutionLength", "The dimensionality of the problem instance (number of variables in the function).", (IntValue)new IntValue(minimumSolutionLength).AsReadOnly()) { GetsCollected = false });
114      Parameters.Add(new FixedValueParameter<IntValue>("Maximum SolutionLength", "The dimensionality of the problem instance (number of variables in the function).", (IntValue)new IntValue(maximumSolutionLength).AsReadOnly()) { GetsCollected = false });
115
116      MinimumObjectives = minimumObjectives;
117      MaximumObjectives = maximumObjectives;
118      MinimumSolutionLength = minimumSolutionLength;
119      MaximumSolutionLength = maximumSolutionLength;
120    }
121
122    /// <summary>
123    /// Evaluates the test function for a specific <paramref name="point"/>.
124    /// </summary>
125    /// <param name="point">N-dimensional point for which the test function should be evaluated.</param>
126    /// <returns>The result values of the function at the given point.</returns>
127    public abstract double[] Evaluate(RealVector point, int objectives);
128  }
129}
Note: See TracBrowser for help on using the repository browser.