Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/Kursawe.cs @ 13620

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

#1087 regorganized testfunctions, added view for qualities

File size: 2.4 KB
Line 
1using System;
2using System.Collections.Generic;
3using HeuristicLab.Common;
4using HeuristicLab.Core;
5using HeuristicLab.Data;
6using HeuristicLab.Encodings.RealVectorEncoding;
7using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
8
9namespace HeuristicLab.Problems.MultiObjectiveTestFunctions {
10  [Item("Kursawe", "Kursawe function from // http://darwin.di.uminho.pt/jecoli/index.php/Multiobjective_example [30.11.2015]")]
11  [StorableClass]
12  public class Kursawe : MultiObjectiveTestFunction {
13
14    public override double[,] Bounds(int objectives) {
15      return new double[,] { { -5, 5 } };
16    }
17
18    public override bool[] Maximization(int objecitves) {
19      return new bool[2];
20    }
21
22    public override int MinimumObjectives {
23      get { return 2; }
24    }
25    public override int MaximumObjectives {
26      get {return 2;}
27    }
28
29    public override int MinimumSolutionLength {
30      get {return 3;}
31    }
32    public override int MaximumSolutionLength {
33      get { return int.MaxValue; }
34    }
35
36    public override IEnumerable<double[]> OptimalParetoFront(int objecitves) {
37        return PFStore.get(this.ItemName);
38    }
39    public override double BestKnownHypervolume(int objecitves) {
40        return new Hypervolume(ReferencePoint(objecitves), Maximization(2)).GetHypervolume(OptimalParetoFront(objecitves));
41    }
42    public override double[] ReferencePoint(int objectives) {
43      return new double[] { 11, 11 };
44    }
45
46    [StorableConstructor]
47    protected Kursawe(bool deserializing) : base(deserializing) { }
48    protected Kursawe(Kursawe original, Cloner cloner) : base(original, cloner) { }
49    public override IDeepCloneable Clone(Cloner cloner) {
50      return new Kursawe(this, cloner);
51    }
52    public Kursawe() : base() { }
53
54   
55
56
57
58    public override double[] Evaluate(RealVector r, int objectives) {
59      if (objectives != 2) throw new ArgumentException("The Kursawe problem must always have 2 objectives");
60      //objective 1
61      double f0 = 0.0;
62      for (int i = 0; i < r.Length-1; i++) {
63        f0 += -10 * Math.Exp(-0.2 * Math.Sqrt(r[i] * r[i] + r[i + 1] * r[i + 1]));
64      }
65      //objective2
66      double f1 = 0.0;
67      for (int i = 0; i < r.Length; i++) {
68        f1 += Math.Pow(Math.Abs(r[i]), 0.8) + 5 * Math.Sin(Math.Pow(r[i], 3));
69      }
70
71      return new double[] { f0, f1 };
72    }
73  }
74}
Note: See TracBrowser for help on using the repository browser.