Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/ZDT/ZDT4.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.5 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("ZDT4", "ZDT4 function as defined in http://www.tik.ee.ethz.ch/sop/download/supplementary/testproblems/ [30.11.2015]")]
9  [StorableClass]
10  public class ZDT4 : ZDT {
11
12    public override double[,] Bounds(int objectives) {
13      double[,] bounds = new double[objectives, 2];
14      bounds[0, 0] = 0; bounds[0, 1] = 1;
15      for (int i = 1; i < objectives; i++) {
16        bounds[i, 0] = -5;
17        bounds[i, 1] = 5;
18      }
19
20      return bounds;
21    }
22
23    public override double BestKnownHypervolume(int objectives) {
24      return 120 + 2.0 / 3;
25    }
26
27    [StorableConstructor]
28    protected ZDT4(bool deserializing) : base(deserializing) { }
29    protected ZDT4(ZDT4 original, Cloner cloner) : base(original, cloner) { }
30    public override IDeepCloneable Clone(Cloner cloner) {
31      return new ZDT4(this, cloner);
32    }
33    public ZDT4() : base() { }
34
35    public override double[] Evaluate(RealVector r) {
36      double g = 0;
37      for (int i = 1; i < r.Length; i++) {
38        double v = r[i];
39        g += v * v - 10 * Math.Cos(4 * Math.PI * v);
40      }
41      g = 1.0 + 10.0 * (r.Length - 1) + g;
42      double d = r[0] / g;
43      return new double[] { r[0], 1-Math.Sqrt(d) };
44    }
45  }
46}
Note: See TracBrowser for help on using the repository browser.