Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3040_VectorBasedGP/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/VectorData/AzzaliBenchmark1.cs @ 17448

Last change on this file since 17448 was 17448, checked in by pfleck, 5 years ago

#3040 Replaced own Vector with MathNet.Numerics Vector.

File size: 3.4 KB
Line 
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
22using System;
23using System.Collections;
24using System.Collections.Generic;
25using System.Linq;
26using HeuristicLab.Common;
27using HeuristicLab.Core;
28using HeuristicLab.Problems.DataAnalysis;
29using HeuristicLab.Random;
30using MathNet.Numerics.Statistics;
31
32using DoubleVector = MathNet.Numerics.LinearAlgebra.Vector<double>;
33
34namespace HeuristicLab.Problems.Instances.DataAnalysis {
35  public class AzzaliBenchmark1 : ArtificialRegressionDataDescriptor {
36    public override string Name { get { return "Azzali Benchmark1 B1 = (X4 + mean(X3)) - ((X3 · X4) - X2)  ( · = dot product)"; } }
37    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."; } }
38
39    protected override string TargetVariable { get { return "B1"; } }
40    protected override string[] VariableNames { get { return AllowedInputVariables.Concat(new[] { TargetVariable }).ToArray(); } }
41    protected override string[] AllowedInputVariables { get { return new string[] { "X1", "X2", "X3", "X4" }; } }
42    protected override int TrainingPartitionStart { get { return 0; } }
43    protected override int TrainingPartitionEnd { get { return 70; } }
44    protected override int TestPartitionStart { get { return 70; } }
45    protected override int TestPartitionEnd { get { return 100; } }
46
47    public int Seed { get; private set; }
48
49    public AzzaliBenchmark1()
50      : this((int)DateTime.Now.Ticks) { }
51    public AzzaliBenchmark1(int seed)
52      : base() {
53      Seed = seed;
54    }
55
56
57    protected override List<List<double>> GenerateValues() { return null; }
58    protected override List<IList> GenerateValuesExtended() {
59      var rand = new MersenneTwister((uint)Seed);
60
61      var x1Column = new List<double>(100);
62      var x2Column = new List<double>(100);
63      var x3Column = new List<DoubleVector>(100);
64      var x4Column = new List<DoubleVector>(100);
65      var b1Column = new List<DoubleVector>(100);
66
67      for (int i = 0; i < 100; i++) {
68        var x1 = rand.NextDouble(-10, +10);
69        var x2 = rand.NextDouble(-10, +10);
70        var x3 = rand.NextDoubleVector(10, 40, 10);
71        var x4 = rand.NextDoubleVector(-5, +5, 10);
72
73        var b1 = (x4 + x3.Mean()) - (x3.DotProduct(x4) - x2);
74
75        x1Column.Add(x1);
76        x2Column.Add(x2);
77        x3Column.Add(x3);
78        x4Column.Add(x4);
79        b1Column.Add(b1);
80      }
81
82      return new List<IList> { x1Column, x2Column, x3Column, x4Column, b1Column };
83    }
84  }
85}
Note: See TracBrowser for help on using the repository browser.