Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/ZDT2.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: 2.1 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("ZDT2", "ZDT2 function as defined in http://www.tik.ee.ethz.ch/sop/download/supplementary/testproblems/ [30.11.2015]")]
10  [StorableClass]
11  public class ZDT2 : MultiObjectiveTestFunction {
12
13    public override DoubleMatrix Bounds {
14      get {
15        return new DoubleMatrix(new double[,] { { 0, 1 } });
16      }
17    }
18
19    public override bool[] Maximization {
20      get {
21        return new bool[] { false, false };
22      }
23    }
24
25    public override int MaximumProblemSize {
26      get {
27        return int.MaxValue;
28      }
29    }
30
31    public override int MaximumSolutionSize {
32      get {
33        return 2;
34      }
35    }
36
37    public override int MinimumProblemSize {
38      get {
39        return 1;
40      }
41    }
42
43    public override int MinimumSolutionSize {
44      get {
45        return 2;
46      }
47    }
48    public override int ActualSolutionSize {
49      get {
50        return 2;
51      }
52
53      set {
54      }
55    }
56
57    public override RealVector[] OptimalParetoFront {
58      get {
59        throw new NotImplementedException();
60      }
61    }
62    public override RealVector ReferencePoint {
63      get { return new RealVector(new double[] { 11.0, 11.0 }); }
64    }
65
66    public override double BestKnownHypervolume {
67      get { return 120+1.0/3; }
68    }
69
70    [StorableConstructor]
71    protected ZDT2(bool deserializing) : base(deserializing) { }
72    protected ZDT2(ZDT2 original, Cloner cloner) : base(original, cloner) { }
73    public ZDT2() : base() { }
74
75    public override IDeepCloneable Clone(Cloner cloner) {
76      return new ZDT2(this, cloner);
77    }
78
79
80
81    public override double[] Evaluate(RealVector r) {
82      double g = 0;
83      for (int i = 1; i < r.Length; i++) g += r[i];
84      g = 1.0 + 9.0 * g / (r.Length - 1);
85      double d = r[0] / g;
86      return new double[] { r[0], g * (1.0 - d * d) };
87    }
88  }
89}
Note: See TracBrowser for help on using the repository browser.