1 | using System;
|
---|
2 | using HeuristicLab.Common;
|
---|
3 | using HeuristicLab.Core;
|
---|
4 | using HeuristicLab.Encodings.RealVectorEncoding;
|
---|
5 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
6 |
|
---|
7 | namespace HeuristicLab.Problems.MultiObjectiveTestFunctions {
|
---|
8 | [Item("DTLZ6", "Testfunction as defined as DTLZ5 in http://repository.ias.ac.in/81671/ [30.11.15]")]
|
---|
9 | [StorableClass]
|
---|
10 | public class DTLZ6 : DTLZ {
|
---|
11 |
|
---|
12 | [StorableConstructor]
|
---|
13 | protected DTLZ6(bool deserializing) : base(deserializing) { }
|
---|
14 | protected DTLZ6(DTLZ6 original, Cloner cloner) : base(original, cloner) { }
|
---|
15 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
16 | return new DTLZ6(this, cloner);
|
---|
17 | }
|
---|
18 | public DTLZ6() : base() { }
|
---|
19 |
|
---|
20 | public override double[] Evaluate(RealVector r, int objectives) {
|
---|
21 | if (r.Length < objectives) {
|
---|
22 | throw new Exception("The dimensionality of the problem(ProblemSize) must be larger than the dimensionality of the solution(SolutionSize) ");
|
---|
23 | }
|
---|
24 | double[] res = new double[objectives];
|
---|
25 |
|
---|
26 | //calculate g(Xm)
|
---|
27 | double g = 0;
|
---|
28 | for (int i = objectives; i < r.Length; i++) {
|
---|
29 | g += Math.Pow(r[i], 0.1);
|
---|
30 | }
|
---|
31 |
|
---|
32 | //phi definition
|
---|
33 | Func<double, double> phi;
|
---|
34 | phi = (double x) => { return Math.PI / (4 * (1 + g)) * (1 + 2 * g * x); };
|
---|
35 |
|
---|
36 | //calculating f0...fM-1
|
---|
37 | for (int i = 0; i < objectives; i++) {
|
---|
38 | double f = i == 0 ? 1 : (Math.Sin(phi(r[objectives - i - 1]) * Math.PI / 2)) * (1 + g);
|
---|
39 | for (int j = 0; j < objectives - i - 1; j++) {
|
---|
40 | f *= Math.Cos(phi(r[j]) * Math.PI / 2);
|
---|
41 | }
|
---|
42 | res[i] = f;
|
---|
43 | }
|
---|
44 | return res;
|
---|
45 | }
|
---|
46 | }
|
---|
47 | }
|
---|