Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/DTLZ6.cs @ 13515

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

#1087 minor bugfixes and added unittests

File size: 3.2 KB
Line 
1using System;
2using HeuristicLab.Common;
3using HeuristicLab.Core;
4using HeuristicLab.Data;
5using HeuristicLab.Encodings.RealVectorEncoding;
6using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
7
8namespace HeuristicLab.Problems.MultiObjectiveTestFunctions {
9  [Item("DTLZ6", "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")]
10  [StorableClass]
11  public class DTLZ6 : MultiObjectiveTestFunction {
12
13    private int actualSolutionSize = 2;
14    public override int ActualSolutionSize {
15      get {
16        return actualSolutionSize;
17      }
18
19      set {
20        actualSolutionSize = value;
21      }
22    }
23
24    public override DoubleMatrix Bounds {
25      get {
26        return new DoubleMatrix(new double[,] { { 0, 1 } });
27      }
28    }
29
30    public override bool[] Maximization {
31      get {
32        return new bool[actualSolutionSize];
33      }
34    }
35
36    public override int MaximumProblemSize {
37      get {
38        return int.MaxValue;
39      }
40    }
41
42    public override int MaximumSolutionSize {
43      get {
44
45        return int.MaxValue;
46      }
47    }
48
49    public override int MinimumProblemSize {
50      get {
51        return Math.Max(2, ActualSolutionSize);
52      }
53    }
54
55    public override int MinimumSolutionSize {
56      get {
57        return 2;
58      }
59    }
60
61    public override RealVector[] OptimalParetoFront {
62      get {
63        throw new NotImplementedException();
64      }
65    }
66    public override RealVector ReferencePoint {
67      get { return new RealVector(new double[] { 11.0, 11.0 }); }
68    }
69
70    public override double BestKnownHypervolume {
71      get { return 116.1138716447221; }
72    }
73
74
75    [StorableConstructor]
76    protected DTLZ6(bool deserializing) : base(deserializing) { }
77    protected DTLZ6(DTLZ6 original, Cloner cloner) : base(original, cloner) { }
78    public DTLZ6() : base() { }
79
80    public override IDeepCloneable Clone(Cloner cloner) {
81      return new DTLZ6(this, cloner);
82    }
83
84
85
86    public override double[] Evaluate(RealVector r) {
87      return Evaluate(r, ActualSolutionSize);
88    }
89
90    private double[] Evaluate(RealVector r, int objectives) {
91      if (r.Length < objectives) {
92        throw new Exception("The dimensionality of the problem(ProblemSize) must be larger than or equal to the dimensionality of the solution(SolutionSize) ");
93      }
94      double[] res = new double[objectives];
95
96      //calculate g(Xm)
97      double g = 0, length = 0;
98      for (int i = objectives; i < r.Length; i++) {
99        g += r[i];
100        length += r[i] * r[i];
101      }
102      length = Math.Sqrt(length);
103      g = 1.0 + 9.0 / length * g;
104      if (length == 0) { g = 1; }
105
106      //calculating f0...fM-2
107      for (int i = 0; i < objectives - 1; i++) {
108        res[i] = r[i];
109      }
110      //calculate fM-1
111      double h = objectives;
112      for (int i = 0; i < objectives - 1; i++) {
113        h -= res[i] / (1 + g) * (1 + Math.Sin(3 * Math.PI * res[i]));
114      }
115      res[objectives - 1] = (1 + g) * h;
116
117      return res;
118    }
119  }
120}
Note: See TracBrowser for help on using the repository browser.