Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/ELLI1.cs @ 13988

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

#1087 moved project bugfixes

File size: 3.5 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("ELLI", "to be aded")]
30  [StorableClass]
31  public class ELLI : 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      get { return 1; }
43    }
44    public override int MaximumSolutionLength {
45      get { return int.MaxValue; }
46    }
47
48    public override int MinimumObjectives {
49      get { return 2; }
50    }
51
52    public override int MaximumObjectives {
53      get { return 2; }
54    }
55
56    public override double[] ReferencePoint(int objecitves) {
57      return new double[] { 11, 11 };
58    }
59
60    public override IEnumerable<double[]> OptimalParetoFront(int objecitves) {
61      List<double[]> res = new List<double[]>();
62      for (int i = 0; i <= 500; i++) {
63        RealVector r = new RealVector(2);
64        r[0] = 2 / 500.0 * i;
65        r[1] = 2 / 500.0 * i;
66        res.Add(this.Evaluate(r, 2));
67      }
68      return res;
69    }
70
71    public override double BestKnownHypervolume(int objectives) {
72      return Hypervolume.Calculate(OptimalParetoFront(objectives), ReferencePoint(objectives), Maximization(objectives));
73    }
74
75    [StorableConstructor]
76    protected ELLI(bool deserializing) : base(deserializing) { }
77    protected ELLI(ELLI original, Cloner cloner) : base(original, cloner) { }
78    public override IDeepCloneable Clone(Cloner cloner) {
79      return new ELLI(this, cloner);
80    }
81
82    public ELLI() : base(minimumObjectives: 2, maximumObjectives: 2, minimumSolutionLength: 1, maximumSolutionLength: int.MaxValue) { }
83
84    public override double[] Evaluate(RealVector r, int objectives) {
85      if (objectives != 2) throw new ArgumentException("The ELLI problem must always have 2 objectives");
86      double x = r[0];
87      double a = 1000;
88      double sum = 0.0;
89      for (int i = 0; i < r.Length; i++) {
90        sum += Math.Pow(a, 2 * i / (r.Length - 1)) * r[i] * r[i];
91      }
92
93      //objective1
94      double f0 = 1 / (a * a * r.Length) * sum;
95
96      sum = 0.0;
97      for (int i = 0; i < r.Length; i++) {
98        sum += Math.Pow(a, 2 * i / (r.Length - 1)) * (r[i] - 2) * (r[i] - 2);
99      }
100      //objective0
101      double f1 = 1 / (a * a * r.Length) * sum;
102
103      return new double[] { f0, f1 };
104    }
105  }
106}
Note: See TracBrowser for help on using the repository browser.