Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/CIGTAB.cs @ 17228

Last change on this file since 17228 was 17180, checked in by swagner, 5 years ago

#2875: Removed years in copyrights

File size: 3.3 KB
RevLine 
[13672]1#region License Information
2/* HeuristicLab
[17180]3 * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[13672]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;
[13620]22using System.Collections.Generic;
23using HeuristicLab.Common;
[13421]24using HeuristicLab.Core;
25using HeuristicLab.Encodings.RealVectorEncoding;
[16565]26using HEAL.Attic;
[13421]27
[14111]28namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
[13936]29  [Item("CIGTAB", "to be aded")]
[16565]30  [StorableType("1D78E29D-4697-44A1-8A53-3909E3B7D57D")]
[13936]31  public class CIGTAB : MultiObjectiveTestFunction {
[14068]32    protected override double[,] GetBounds(int objectives) {
[13936]33      return new double[,] { { -10, 10 } };
[13421]34    }
35
[14068]36    protected override bool[] GetMaximization(int objecitves) {
[13620]37      return new bool[2];
[13421]38    }
39
[14068]40    protected override double[] GetReferencePoint(int objecitves) {
[13936]41      return new double[] { 11, 11 };
[13421]42    }
43
[14068]44    protected override IEnumerable<double[]> GetOptimalParetoFront(int objecitves) {
[13936]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;
[13448]53    }
[14068]54
55    protected override double GetBestKnownHypervolume(int objectives) {
56      return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
[13515]57    }
58
[13421]59    [StorableConstructor]
[16565]60    protected CIGTAB(StorableConstructorFlag _) : base(_) { }
[13936]61    protected CIGTAB(CIGTAB original, Cloner cloner) : base(original, cloner) { }
[13421]62    public override IDeepCloneable Clone(Cloner cloner) {
[13936]63      return new CIGTAB(this, cloner);
[13421]64    }
65
[13936]66    public CIGTAB() : base(minimumObjectives: 2, maximumObjectives: 2, minimumSolutionLength: 1, maximumSolutionLength: int.MaxValue) { }
[13421]67
[13620]68    public override double[] Evaluate(RealVector r, int objectives) {
[13936]69      if (objectives != 2) throw new ArgumentException("The CIGTAB problem must always have 2 objectives");
[13421]70      double x = r[0];
[13936]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];
[13421]77
78      //objective1
[13936]79      double f0 = 1 / (a * a * r.Length) * sum;
[13421]80
[13936]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);
[13421]88      //objective0
[13936]89      double f1 = 1 / (a * a * r.Length) * sum;
[13421]90
[13620]91      return new double[] { f0, f1 };
[13421]92    }
93  }
94}
Note: See TracBrowser for help on using the repository browser.