Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2645_ContextAlgorithms/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/DTLZ/DTLZ7.cs

Last change on this file was 15583, checked in by swagner, 7 years ago

#2640: Updated year of copyrights in license headers

File size: 2.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2018 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;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Encodings.RealVectorEncoding;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
29  [Item("DTLZ7", "Testfunction as defined as DTLZ6 in http://repository.ias.ac.in/81671/ [30.11.15] NOTE: The website http://people.ee.ethz.ch/~sop/download/supplementary/testproblems/dtlz7/index.php [16.12.2015] lables this function as DTLZ7")]
30  [StorableClass]
31  public class DTLZ7 : DTLZ {
32    protected override double GetBestKnownHypervolume(int objectives) {
33      if (objectives == 2) return 116.1138716447221;
34      return -1;
35    }
36
37    [StorableConstructor]
38    protected DTLZ7(bool deserializing) : base(deserializing) { }
39    protected DTLZ7(DTLZ7 original, Cloner cloner) : base(original, cloner) { }
40    public override IDeepCloneable Clone(Cloner cloner) {
41      return new DTLZ7(this, cloner);
42    }
43    public DTLZ7() : base() { }
44
45    public override double[] Evaluate(RealVector r, int objectives) {
46      if (r.Length < objectives) {
47        throw new ArgumentException("The dimensionality of the problem(ProblemSize) must be larger than or equal to the number of objectives");
48      }
49      double[] res = new double[objectives];
50
51      //calculate g(Xm)
52      double g = 0, length = length = r.Length - objectives + 1;
53      for (int i = objectives; i < r.Length; i++) {
54        g += r[i];
55      }
56      g = 1.0 + 9.0 / length * g;
57      if (length == 0) { g = 1; }
58
59      //calculating f0...fM-2
60      for (int i = 0; i < objectives - 1; i++) {
61        res[i] = r[i];
62      }
63      //calculate fM-1
64      double h = objectives;
65      for (int i = 0; i < objectives - 1; i++) {
66        h -= res[i] / (1 + g) * (1 + Math.Sin(3 * Math.PI * res[i]));
67      }
68      res[objectives - 1] = (1 + g) * h;
69
70      return res;
71    }
72  }
73}
Note: See TracBrowser for help on using the repository browser.