Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/CIGTAB.cs @ 13936

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

#1087 added more functions (IHR1-4, IHR6, CIGTAB, ELLI)

File size: 3.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21using System;
22using System.Collections.Generic;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Encodings.RealVectorEncoding;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace HeuristicLab.Problems.MultiObjectiveTestFunctions {
29  [Item("CIGTAB", "to be aded")]
30  [StorableClass]
31  public class CIGTAB : MultiObjectiveTestFunction {
32
33    public override double[,] Bounds(int objectives) {
34      return new double[,] { { -10, 10 } };
35    }
36
37    public override bool[] Maximization(int objecitves) {
38      return new bool[2];
39    }
40
41    public override int MinimumSolutionLength
42    {
43      get { return 1; }
44    }
45    public override int MaximumSolutionLength
46    {
47      get { return int.MaxValue; }
48    }
49
50
51    public override int MinimumObjectives
52    {
53      get { return 2; }
54    }
55
56    public override int MaximumObjectives
57    {
58      get { return 2; }
59    }
60
61
62    public override double[] ReferencePoint(int objecitves) {
63      return new double[] { 11, 11 };
64    }
65
66
67    public override IEnumerable<double[]> OptimalParetoFront(int objecitves) {
68      List<double[]> res = new List<double[]>();
69      for (int i = 0; i <= 500; i++) {
70        RealVector r = new RealVector(2);
71        r[0] = 2 / 500.0 * i;
72        r[1] = 2 / 500.0 * i;
73        res.Add(this.Evaluate(r, 2));
74      }
75
76
77      return res;
78    }
79    public override double BestKnownHypervolume(int objectives) {
80      return Hypervolume.Calculate(OptimalParetoFront(objectives), ReferencePoint(objectives), Maximization(objectives));
81    }
82
83    [StorableConstructor]
84    protected CIGTAB(bool deserializing) : base(deserializing) { }
85    protected CIGTAB(CIGTAB original, Cloner cloner) : base(original, cloner) { }
86    public override IDeepCloneable Clone(Cloner cloner) {
87      return new CIGTAB(this, cloner);
88    }
89
90    public CIGTAB() : base(minimumObjectives: 2, maximumObjectives: 2, minimumSolutionLength: 1, maximumSolutionLength: int.MaxValue) { }
91
92    public override double[] Evaluate(RealVector r, int objectives) {
93      if (objectives != 2) throw new ArgumentException("The CIGTAB problem must always have 2 objectives");
94      double x = r[0];
95      double a = 1000;
96      double sum = x * x;
97      for (int i = 1; i < r.Length - 1; i++) {
98        sum += a * r[i] * r[i];
99      }
100      sum += a * a * r[r.Length - 1] * r[r.Length - 1];
101
102      //objective1
103      double f0 = 1 / (a * a * r.Length) * sum;
104
105      x = x - 2;
106      sum = x * x;
107      for (int i = 1; i < r.Length - 1; i++) {
108        sum += a * (r[i] - 2) * (r[i] - 2);
109      }
110
111      sum += a * a * (r[r.Length - 1] - 2) * (r[r.Length - 1] - 2);
112      //objective0
113      double f1 = 1 / (a * a * r.Length) * sum;
114
115      return new double[] { f0, f1 };
116    }
117  }
118}
Note: See TracBrowser for help on using the repository browser.