Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/DTLZ/DTLZ7.cs @ 13672

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

#1087 added Analyzers, reworked PFStore, added licence information, cleaned code

File size: 2.8 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;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Encodings.RealVectorEncoding;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace HeuristicLab.Problems.MultiObjectiveTestFunctions {
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
33    public override double BestKnownHypervolume(int objectives) {
34      if (objectives == 2) return 116.1138716447221;
35      return -1;
36    }
37
38
39    [StorableConstructor]
40    protected DTLZ7(bool deserializing) : base(deserializing) { }
41    protected DTLZ7(DTLZ7 original, Cloner cloner) : base(original, cloner) { }
42    public override IDeepCloneable Clone(Cloner cloner) {
43      return new DTLZ7(this, cloner);
44    }
45    public DTLZ7() : base() { }
46
47    public override double[] Evaluate(RealVector r, int objectives) {
48      if (r.Length < objectives) {
49        throw new Exception("The dimensionality of the problem(ProblemSize) must be larger than or equal to the dimensionality of the solution(SolutionSize) ");
50      }
51      double[] res = new double[objectives];
52
53      //calculate g(Xm)
54      double g = 0, length = 0;
55      for (int i = objectives; i < r.Length; i++) {
56        g += r[i];
57        length += r[i] * r[i];
58      }
59      length = Math.Sqrt(length);
60      g = 1.0 + 9.0 / length * g;
61      if (length == 0) { g = 1; }
62
63      //calculating f0...fM-2
64      for (int i = 0; i < objectives - 1; i++) {
65        res[i] = r[i];
66      }
67      //calculate fM-1
68      double h = objectives;
69      for (int i = 0; i < objectives - 1; i++) {
70        h -= res[i] / (1 + g) * (1 + Math.Sin(3 * Math.PI * res[i]));
71      }
72      res[objectives - 1] = (1 + g) * h;
73
74      return res;
75    }
76  }
77}
Note: See TracBrowser for help on using the repository browser.