Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/ZDT1.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.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("ZDT1", "ZDT1 function as defined in http://www.tik.ee.ethz.ch/sop/download/supplementary/testproblems/ [30.11.2015]")]
10  [StorableClass]
11  public class ZDT1 : 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
49    public override int ActualSolutionSize {
50      get {
51        return 2;
52      }
53
54      set {
55      }
56    }
57
58    public override RealVector[] OptimalParetoFront {
59      get {
60        throw new NotImplementedException();
61      }
62    }
63
64    public override RealVector ReferencePoint {
65      get { return new RealVector(new double[]{ 11.0, 11.0}); }
66    }
67
68    public override double BestKnownHypervolume {
69      get { return 120 + 2.0 / 3; }
70    }
71
72    [StorableConstructor]
73    protected ZDT1(bool deserializing) : base(deserializing) { }
74    protected ZDT1(ZDT1 original, Cloner cloner) : base(original, cloner) { }
75    public ZDT1() : base() { }
76
77    public override IDeepCloneable Clone(Cloner cloner) {
78      return new ZDT1(this, cloner);
79    }
80
81
82
83    public override double[] Evaluate(RealVector r) {
84      double g = 0;
85      for (int i = 1; i < r.Length; i++) g += r[i];
86      g = 1.0 + 9.0 * g / (r.Length - 1);
87      double f1 = g * (1.0 - Math.Sqrt(r[0] / g));
88      return new double[] { r[0], f1};
89    }
90  }
91}
Note: See TracBrowser for help on using the repository browser.