Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2943_MOBasicProblem_MOCMAES/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/CIGTAB.cs @ 17709

Last change on this file since 17709 was 16171, checked in by bwerth, 6 years ago

#2943 worked on MOBasicProblem - added Interfaces;reworked MOCalculators; several minor changes

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