1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
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
|
---|
21 |
|
---|
22 | using System;
|
---|
23 | using System.Collections;
|
---|
24 | using System.Collections.Generic;
|
---|
25 | using System.Linq;
|
---|
26 | using HeuristicLab.Common;
|
---|
27 | using HeuristicLab.Core;
|
---|
28 | using HeuristicLab.Problems.DataAnalysis;
|
---|
29 | using HeuristicLab.Random;
|
---|
30 | using MathNet.Numerics.Statistics;
|
---|
31 | using DoubleVector = MathNet.Numerics.LinearAlgebra.Vector<double>;
|
---|
32 |
|
---|
33 | namespace HeuristicLab.Problems.Instances.DataAnalysis {
|
---|
34 | public class AzzaliBenchmark3 : ArtificialRegressionDataDescriptor {
|
---|
35 | public override string Name { get { return "Azzali Benchmark3 B3 = CumMin[3,3](X1) * (X2 / X3) + X4"; } }
|
---|
36 | public override string Description { get { return "I. Azzali, L. Vanneschi, S. Silva, I. Bakurov, and M. Giacobini, “A Vectorial Approach to Genetic Programming,” EuroGP, pp. 213–227, 2019."; } }
|
---|
37 |
|
---|
38 | protected override string TargetVariable { get { return "B3"; } }
|
---|
39 | protected override string[] VariableNames { get { return AllowedInputVariables.Concat(new[] { TargetVariable }).ToArray(); } }
|
---|
40 | protected override string[] AllowedInputVariables { get { return new string[] { "X1", "X2", "X3", "X4", "X5" }; } }
|
---|
41 | protected override int TrainingPartitionStart { get { return 0; } }
|
---|
42 | protected override int TrainingPartitionEnd { get { return 70; } }
|
---|
43 | protected override int TestPartitionStart { get { return 70; } }
|
---|
44 | protected override int TestPartitionEnd { get { return 100; } }
|
---|
45 |
|
---|
46 | public int Seed { get; private set; }
|
---|
47 |
|
---|
48 | public AzzaliBenchmark3()
|
---|
49 | : this((int)DateTime.Now.Ticks) { }
|
---|
50 | public AzzaliBenchmark3(int seed)
|
---|
51 | : base() {
|
---|
52 | Seed = seed;
|
---|
53 | }
|
---|
54 |
|
---|
55 |
|
---|
56 | protected override List<List<double>> GenerateValues() { return null; }
|
---|
57 | protected override List<IList> GenerateValuesExtended() {
|
---|
58 | var rand = new MersenneTwister((uint)Seed);
|
---|
59 |
|
---|
60 | var x1Column = new List<DoubleVector>(100);
|
---|
61 | var x2Column = new List<double>(100);
|
---|
62 | var x3Column = new List<double>(100);
|
---|
63 | var x4Column = new List<double>(100);
|
---|
64 | var x5Column = new List<double>(100);
|
---|
65 | var b3Column = new List<DoubleVector>(100);
|
---|
66 |
|
---|
67 | for (int i = 0; i < 100; i++) {
|
---|
68 | var x1 = rand.NextDoubleVector(10, 30, 20);
|
---|
69 | var x2 = rand.NextDouble(50, 60);
|
---|
70 | var x3 = rand.NextDouble(5, 10);
|
---|
71 | var x4 = rand.NextDouble(-2, +2);
|
---|
72 | var x5 = rand.NextDouble(0, 1);
|
---|
73 |
|
---|
74 | const int p = 3, q = 3;
|
---|
75 | var cumulativeMin = DoubleVector.Build.DenseOfEnumerable(
|
---|
76 | Enumerable.Range(0, x1.Count)
|
---|
77 | .Select(idx => Enumerable.Range(idx - p, q)) // build index ranges for each target entry
|
---|
78 | .Select(indices => indices.Select(idx => idx < 0 ? 0 : x1[idx])) // take the values from the vector (fill with 0 if outside)
|
---|
79 | .Select(values => values.Min())
|
---|
80 | );
|
---|
81 | var b3 = (cumulativeMin * (x2 / x3)) + x4;
|
---|
82 |
|
---|
83 | x1Column.Add(x1);
|
---|
84 | x2Column.Add(x2);
|
---|
85 | x3Column.Add(x3);
|
---|
86 | x4Column.Add(x4);
|
---|
87 | x5Column.Add(x5);
|
---|
88 | b3Column.Add(b3);
|
---|
89 | }
|
---|
90 |
|
---|
91 | return new List<IList> { x1Column, x2Column, x3Column, x4Column, x5Column, b3Column };
|
---|
92 | }
|
---|
93 | }
|
---|
94 | } |
---|