Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/CIGTAB.cs

Last change on this file was 17181, checked in by swagner, 5 years ago

#2875: Merged r17180 from trunk to stable

File size: 3.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 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 HEAL.Attic;
27
28namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
29  [Item("CIGTAB", "to be aded")]
30  [StorableType("1D78E29D-4697-44A1-8A53-3909E3B7D57D")]
31  public class CIGTAB : MultiObjectiveTestFunction {
32    protected override double[,] GetBounds(int objectives) {
33      return new double[,] { { -10, 10 } };
34    }
35
36    protected override bool[] GetMaximization(int objecitves) {
37      return new bool[2];
38    }
39
40    protected override double[] GetReferencePoint(int objecitves) {
41      return new double[] { 11, 11 };
42    }
43
44    protected override IEnumerable<double[]> GetOptimalParetoFront(int objecitves) {
45      List<double[]> res = new List<double[]>();
46      for (int i = 0; i <= 500; i++) {
47        RealVector r = new RealVector(2);
48        r[0] = 2 / 500.0 * i;
49        r[1] = 2 / 500.0 * i;
50        res.Add(this.Evaluate(r, 2));
51      }
52      return res;
53    }
54
55    protected override double GetBestKnownHypervolume(int objectives) {
56      return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
57    }
58
59    [StorableConstructor]
60    protected CIGTAB(StorableConstructorFlag _) : base(_) { }
61    protected CIGTAB(CIGTAB original, Cloner cloner) : base(original, cloner) { }
62    public override IDeepCloneable Clone(Cloner cloner) {
63      return new CIGTAB(this, cloner);
64    }
65
66    public CIGTAB() : base(minimumObjectives: 2, maximumObjectives: 2, minimumSolutionLength: 1, maximumSolutionLength: int.MaxValue) { }
67
68    public override double[] Evaluate(RealVector r, int objectives) {
69      if (objectives != 2) throw new ArgumentException("The CIGTAB problem must always have 2 objectives");
70      double x = r[0];
71      double a = 1000;
72      double sum = x * x;
73      for (int i = 1; i < r.Length - 1; i++) {
74        sum += a * r[i] * r[i];
75      }
76      sum += a * a * r[r.Length - 1] * r[r.Length - 1];
77
78      //objective1
79      double f0 = 1 / (a * a * r.Length) * sum;
80
81      x = x - 2;
82      sum = x * x;
83      for (int i = 1; i < r.Length - 1; i++) {
84        sum += a * (r[i] - 2) * (r[i] - 2);
85      }
86
87      sum += a * a * (r[r.Length - 1] - 2) * (r[r.Length - 1] - 2);
88      //objective0
89      double f1 = 1 / (a * a * r.Length) * sum;
90
91      return new double[] { f0, f1 };
92    }
93  }
94}
Note: See TracBrowser for help on using the repository browser.