Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/DTLZ/DTLZ6.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.6 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("DTLZ6", "Testfunction as defined as DTLZ5 in http://repository.ias.ac.in/81671/ [30.11.15]")]
9  [StorableClass]
10  public class DTLZ6 : DTLZ {
11
12    [StorableConstructor]
13    protected DTLZ6(bool deserializing) : base(deserializing) { }
14    protected DTLZ6(DTLZ6 original, Cloner cloner) : base(original, cloner) { }
15    public override IDeepCloneable Clone(Cloner cloner) {
16      return new DTLZ6(this, cloner);
17    }
18    public DTLZ6() : base() { }
19
20    public override double[] Evaluate(RealVector r, int objectives) {
21      if (r.Length < objectives) {
22        throw new Exception("The dimensionality of the problem(ProblemSize) must be larger than the dimensionality of the solution(SolutionSize) ");
23      }
24      double[] res = new double[objectives];
25
26      //calculate g(Xm)
27      double g = 0;
28      for (int i = objectives; i < r.Length; i++) {
29        g += Math.Pow(r[i], 0.1);
30      }
31
32      //phi definition
33      Func<double, double> phi;
34      phi = (double x) => { return Math.PI / (4 * (1 + g)) * (1 + 2 * g * x); };
35
36      //calculating f0...fM-1
37      for (int i = 0; i < objectives; i++) {
38        double f = i == 0 ? 1 : (Math.Sin(phi(r[objectives - i - 1]) * Math.PI / 2)) * (1 + g);
39        for (int j = 0; j < objectives - i - 1; j++) {
40          f *= Math.Cos(phi(r[j]) * Math.PI / 2);
41        }
42        res[i] = f;
43      }
44      return res;
45    }
46  }
47}
Note: See TracBrowser for help on using the repository browser.