Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/HeuristicLab.Problems.TestFunctions.MultiObjective/3.3/TestFunctions/Misc/Kursawe.cs @ 17317

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

#2875: Removed years in copyrights

File size: 3.0 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;
[13448]23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Encodings.RealVectorEncoding;
[16565]26using HEAL.Attic;
[13448]27
[14111]28namespace HeuristicLab.Problems.TestFunctions.MultiObjective {
[13515]29  [Item("Kursawe", "Kursawe function from // http://darwin.di.uminho.pt/jecoli/index.php/Multiobjective_example [30.11.2015]")]
[16565]30  [StorableType("9D38092B-2C55-450E-A27A-2C28714745ED")]
[13448]31  public class Kursawe : MultiObjectiveTestFunction {
[14068]32    protected override double[,] GetBounds(int objectives) {
[13620]33      return new double[,] { { -5, 5 } };
[13448]34    }
35
[14068]36    protected override bool[] GetMaximization(int objecitves) {
[13620]37      return new bool[2];
[13448]38    }
39
[14068]40    protected override IEnumerable<double[]> GetOptimalParetoFront(int objecitves) {
[14069]41      return ParetoFrontStore.GetParetoFront("Misc.ParetoFronts." + this.ItemName);
[13448]42    }
[14068]43
44    protected override double GetBestKnownHypervolume(int objectives) {
45      return Hypervolume.Calculate(GetOptimalParetoFront(objectives), GetReferencePoint(objectives), GetMaximization(objectives));
[13515]46    }
[14068]47
48    protected override double[] GetReferencePoint(int objectives) {
[13620]49      return new double[] { 11, 11 };
[13515]50    }
51
[13448]52    [StorableConstructor]
[16565]53    protected Kursawe(StorableConstructorFlag _) : base(_) { }
[13448]54    protected Kursawe(Kursawe original, Cloner cloner) : base(original, cloner) { }
55    public override IDeepCloneable Clone(Cloner cloner) {
56      return new Kursawe(this, cloner);
57    }
[14067]58    public Kursawe() : base(minimumObjectives: 2, maximumObjectives: 2, minimumSolutionLength: 3, maximumSolutionLength: int.MaxValue) { }
[13448]59
60
61
[13620]62
[13672]63
[13620]64    public override double[] Evaluate(RealVector r, int objectives) {
65      if (objectives != 2) throw new ArgumentException("The Kursawe problem must always have 2 objectives");
[13448]66      //objective 1
67      double f0 = 0.0;
[13672]68      for (int i = 0; i < r.Length - 1; i++) {
[13448]69        f0 += -10 * Math.Exp(-0.2 * Math.Sqrt(r[i] * r[i] + r[i + 1] * r[i + 1]));
70      }
71      //objective2
72      double f1 = 0.0;
[13515]73      for (int i = 0; i < r.Length; i++) {
[13451]74        f1 += Math.Pow(Math.Abs(r[i]), 0.8) + 5 * Math.Sin(Math.Pow(r[i], 3));
[13448]75      }
76
77      return new double[] { f0, f1 };
78    }
79  }
80}
Note: See TracBrowser for help on using the repository browser.