1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.Threading.Tasks;
|
---|
6 | using HeuristicLab.Common;
|
---|
7 | using HeuristicLab.Core;
|
---|
8 | using HeuristicLab.Data;
|
---|
9 | using HeuristicLab.Encodings.RealVectorEncoding;
|
---|
10 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
11 | using HeuristicLab.Problems.MultiObjectiveTestFunction;
|
---|
12 |
|
---|
13 | namespace HeuristicLab.Problems.TestFunctions {
|
---|
14 | [Item("Kursawe", "from // http://darwin.di.uminho.pt/jecoli/index.php/Multiobjective_example [30.11.2015]")]
|
---|
15 | [StorableClass]
|
---|
16 | public class Kursawe : MultiObjectiveTestFunction {
|
---|
17 |
|
---|
18 | public override DoubleMatrix Bounds {
|
---|
19 | get {
|
---|
20 | return new DoubleMatrix(new double[,] { { -5, 5 } });
|
---|
21 | }
|
---|
22 | }
|
---|
23 |
|
---|
24 | public override bool[] Maximization {
|
---|
25 | get {
|
---|
26 | return new bool[] { false, false };
|
---|
27 | }
|
---|
28 | }
|
---|
29 |
|
---|
30 | public override int MaximumProblemSize {
|
---|
31 | get {
|
---|
32 | return int.MaxValue;
|
---|
33 | }
|
---|
34 | }
|
---|
35 |
|
---|
36 | public override int MaximumSolutionSize {
|
---|
37 | get {
|
---|
38 | return 2;
|
---|
39 | }
|
---|
40 | }
|
---|
41 |
|
---|
42 | public override int MinimumProblemSize {
|
---|
43 | get {
|
---|
44 | return 3;
|
---|
45 | }
|
---|
46 | }
|
---|
47 |
|
---|
48 | public override int MinimumSolutionSize {
|
---|
49 | get {
|
---|
50 | return 2;
|
---|
51 | }
|
---|
52 | }
|
---|
53 |
|
---|
54 | public override int ActualSolutionSize {
|
---|
55 | get {
|
---|
56 | return 2;
|
---|
57 | }
|
---|
58 |
|
---|
59 | set {
|
---|
60 | }
|
---|
61 | }
|
---|
62 |
|
---|
63 | [StorableConstructor]
|
---|
64 | protected Kursawe(bool deserializing) : base(deserializing) { }
|
---|
65 | protected Kursawe(Kursawe original, Cloner cloner) : base(original, cloner) { }
|
---|
66 | public Kursawe() : base() { }
|
---|
67 |
|
---|
68 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
69 | return new Kursawe(this, cloner);
|
---|
70 | }
|
---|
71 |
|
---|
72 |
|
---|
73 |
|
---|
74 | public override double[] Evaluate(RealVector r) {
|
---|
75 | //objective 1
|
---|
76 | double f0 = 0.0;
|
---|
77 | for (int i = 0; i < 2; i++) {
|
---|
78 | f0 += -10 * Math.Exp(-0.2 * Math.Sqrt(r[i] * r[i] + r[i + 1] * r[i + 1]));
|
---|
79 | }
|
---|
80 | //objective2
|
---|
81 | double f1 = 0.0;
|
---|
82 | for (int i = 0; i < 3; i++) {
|
---|
83 | f1 += Math.Pow(Math.Abs(r[i]), 0.8) + 5 * Math.Sin(Math.Pow(r[i], 3));
|
---|
84 | }
|
---|
85 |
|
---|
86 | return new double[] { f0, f1 };
|
---|
87 | }
|
---|
88 | }
|
---|
89 | }
|
---|