Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.MultiObjectiveTestFunctions/HeuristicLab.Problems.MultiObjectiveTestFunctions/3.3/Testfunctions/SchafferN1.cs @ 13421

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

#1087 implemented skeleton structure and first testfunctions(Fonesca, SchafferN1 & SchafferN2)

File size: 1.9 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using HeuristicLab.Common;
7using HeuristicLab.Core;
8using HeuristicLab.Data;
9using HeuristicLab.Encodings.RealVectorEncoding;
10using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
11using HeuristicLab.Problems.MultiObjectiveTestFunction;
12
13namespace HeuristicLab.Problems.TestFunctions {
14  [Item("SchafferN1", "from // https://en.wikipedia.org/wiki/Test_functions_for_optimization [30.11.2015]")]
15  [Creatable(CreatableAttribute.Categories.CombinatorialProblems, Priority = 210)]
16  [StorableClass]
17  public class SchafferN1 : MultiObjectiveTestFunction {
18
19    public override DoubleMatrix Bounds {
20      get {
21        return new DoubleMatrix(new double[,] { { -1e5, 1e5 } });
22      }
23    }
24
25    public override bool[] Maximization {
26      get {
27        return new bool[] { false, false };
28      }
29    }
30
31    public override int MaximumProblemSize {
32      get {
33        return 1;
34      }
35    }
36
37    public override int MaximumSolutionSize {
38      get {
39        return 2;
40      }
41    }
42
43    public override int MinimumProblemSize {
44      get {
45        return 1;
46      }
47    }
48
49    public override int MinimumSolutionSize {
50      get {
51        return 2;
52      }
53    }
54
55    [StorableConstructor]
56    protected SchafferN1(bool deserializing) : base(deserializing) { }
57    protected SchafferN1(SchafferN1 original, Cloner cloner) : base(original, cloner) { }
58    public SchafferN1() : base() { }
59
60    public override IDeepCloneable Clone(Cloner cloner) {
61      return new SchafferN1(this, cloner);
62    }
63
64
65
66    public override double[] Evaluate(RealVector r) {
67      if (r.Length != 1) return null;
68      double x = r[0];
69
70      //objective1
71      double f0 = x * x;
72
73      //objective0
74      double f1 = x - 2;
75      f1 *= f1;
76
77     return new double[] { f0, f1 };
78    }
79  }
80}
Note: See TracBrowser for help on using the repository browser.