Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 13771 was 13771, checked in by bwerth, 8 years ago

#1087 bugfix + additional relative HV calculation added

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