Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/DTLZ/DTLZ3.cs @ 13620

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

#1087 regorganized testfunctions, added view for qualities

File size: 1.8 KB
Line 
1using System;
2using HeuristicLab.Common;
3using HeuristicLab.Core;
4using HeuristicLab.Encodings.RealVectorEncoding;
5using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
6
7namespace HeuristicLab.Problems.MultiObjectiveTestFunctions {
8  [Item("DTLZ3", "Testfunction as defined as DTLZ3 in http://repository.ias.ac.in/81671/ [30.11.15]")]
9  [StorableClass]
10  public class DTLZ3 : DTLZ {
11
12    public override double BestKnownHypervolume(int objectives) {
13      if (objectives == 2) return 121.0 - 1.0 / 4.0 * Math.PI;
14      return -1;
15    }
16
17    [StorableConstructor]
18    protected DTLZ3(bool deserializing) : base(deserializing) { }
19    protected DTLZ3(DTLZ3 original, Cloner cloner) : base(original, cloner) { }
20    public DTLZ3() : base() { }
21
22    public override IDeepCloneable Clone(Cloner cloner) {
23      return new DTLZ3(this, cloner);
24    }
25
26    public override double[] Evaluate(RealVector r, int objectives) {
27      if (r.Length < objectives) {
28        throw new Exception("The dimensionality of the problem(ProblemSize) must be larger or equal than the dimensionality of the solution(SolutionSize) ");
29      }
30      double[] res = new double[objectives];
31
32      //calculate g(Xm)
33      double sum = 0, length = 0;
34      for (int i = objectives; i < r.Length; i++) {
35        double d = r[i] - 0.5;
36        sum += d * d - Math.Cos(20 * Math.PI * d);
37        length += r[i] * r[i];
38      }
39      length = Math.Sqrt(length);
40      double g = 100 * (length + sum);
41
42      //calculating f0...fM-1
43      for (int i = 0; i < objectives; i++) {
44        double f = i == 0 ? 1 : (Math.Sin(r[objectives - i - 1] * Math.PI / 2)) * (1 + g);
45        for (int j = 0; j < objectives - i - 1; j++) {
46          f *= Math.Cos(r[j] * Math.PI / 2);
47        }
48        res[i] = f;
49      }
50      return res;
51    }
52  }
53}
Note: See TracBrowser for help on using the repository browser.