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 |
|
---|
22 | using System.Collections.Generic;
|
---|
23 | using HeuristicLab.Common;
|
---|
24 | using HeuristicLab.Core;
|
---|
25 | using HeuristicLab.Data;
|
---|
26 | using HeuristicLab.Encodings.RealVectorEncoding;
|
---|
27 | using HeuristicLab.Parameters;
|
---|
28 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
29 |
|
---|
30 | namespace 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 | public static double[] IllegalValue(int size, bool[] maximization) {
|
---|
38 | double[] res = new double[size];
|
---|
39 | for (int i = 0; i < size; i++) {
|
---|
40 | res[i] = maximization[i] ? double.MinValue : double.MaxValue;
|
---|
41 | }
|
---|
42 | return res;
|
---|
43 | }
|
---|
44 |
|
---|
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>
|
---|
54 | public abstract bool[] Maximization(int objectives);
|
---|
55 | /// <summary>
|
---|
56 | /// Gets the lower and upper bound of the function.
|
---|
57 | /// </summary>
|
---|
58 | public abstract double[,] Bounds(int objectives);
|
---|
59 | /// <summary>
|
---|
60 | /// Gets the minimum problem size.
|
---|
61 | /// </summary>
|
---|
62 | public abstract int MinimumSolutionLength { get; }
|
---|
63 | /// <summary>
|
---|
64 | /// Gets the maximum problem size.
|
---|
65 | /// </summary>
|
---|
66 | public abstract int MaximumSolutionLength { get; }
|
---|
67 |
|
---|
68 |
|
---|
69 | /// <summary>
|
---|
70 | /// Gets and sets the actual solution size.
|
---|
71 | /// </summary>
|
---|
72 | ///
|
---|
73 | [Storable]
|
---|
74 | private int objectives;
|
---|
75 | /// <summary>
|
---|
76 | /// Gets the minimum solution size.
|
---|
77 | /// </summary>
|
---|
78 | public abstract int MinimumObjectives { get; }
|
---|
79 | /// <summary>
|
---|
80 | /// Gets the maximum solution size.
|
---|
81 | /// </summary>
|
---|
82 | public abstract int MaximumObjectives { get; }
|
---|
83 |
|
---|
84 | /// <summary>
|
---|
85 | /// retrieves the optimal pareto front (if known from a file)
|
---|
86 | /// </summary>
|
---|
87 | public abstract IEnumerable<double[]> OptimalParetoFront(int objectives);
|
---|
88 |
|
---|
89 |
|
---|
90 | /// <summary>
|
---|
91 | /// returns a Reference Point for Hypervolume calculation (currently default=(11|11))
|
---|
92 | /// </summary>
|
---|
93 | public abstract double[] ReferencePoint(int objectives);
|
---|
94 |
|
---|
95 |
|
---|
96 | /// <summary>
|
---|
97 | /// returns the best known Hypervolume for this Problem (currently default=-1)
|
---|
98 | /// </summary>
|
---|
99 | public virtual double BestKnownHypervolume(int objectives) {
|
---|
100 | return -1;
|
---|
101 | }
|
---|
102 |
|
---|
103 | [StorableConstructor]
|
---|
104 | protected MultiObjectiveTestFunction(bool deserializing) : base(deserializing) { }
|
---|
105 | protected MultiObjectiveTestFunction(MultiObjectiveTestFunction original, Cloner cloner) : base(original, cloner) {
|
---|
106 | this.objectives = original.objectives;
|
---|
107 | }
|
---|
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)));
|
---|
113 | }
|
---|
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>
|
---|
120 | public abstract double[] Evaluate(RealVector point, int objectives);
|
---|
121 |
|
---|
122 | }
|
---|
123 | }
|
---|