Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 17400 was 17400, checked in by pfleck, 4 years ago

#3040 Added Azzali benchmarks

File size: 3.2 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.Core;
27using HeuristicLab.Problems.DataAnalysis;
28using HeuristicLab.Random;
29
30namespace HeuristicLab.Problems.Instances.DataAnalysis {
31  public class VectorDataTestOne : ArtificialRegressionDataDescriptor {
32
33    public override string Name { get { return "Vector Data Test - I (Y = X1 * sum(V1) + X2 * avg(V2)"; } }
34    public override string Description { get { return ""; } }
35
36    protected override string TargetVariable { get { return "Y"; } }
37    protected override string[] VariableNames { get { return new string[] { "X1", "X2", "X3", "V1", "V2", "Y" }; } }
38    protected override string[] AllowedInputVariables { get { return new string[] { "X1", "X2", "X3", "V1", "V2" }; } }
39    protected override int TrainingPartitionStart { get { return 0; } }
40    protected override int TrainingPartitionEnd { get { return 80; } }
41    protected override int TestPartitionStart { get { return 80; } }
42    protected override int TestPartitionEnd { get { return 100; } }
43
44    public int Seed { get; private set; }
45
46    public VectorDataTestOne()
47      : this((int)DateTime.Now.Ticks) { }
48    public VectorDataTestOne(int seed)
49      : base() {
50      Seed = seed;
51    }
52
53
54    protected override List<List<double>> GenerateValues() { return null; }
55    protected override List<IList> GenerateValuesExtended() {
56      var rand = new MersenneTwister((uint)Seed);
57
58      double x1, x2, x3;
59      DoubleVector v1, v2;
60      double y;
61
62      var x1Column = new List<double>(100);
63      var x2Column = new List<double>(100);
64      var x3Column = new List<double>(100);
65      var v1Column = new List<DoubleVector>(100);
66      var v2Column = new List<DoubleVector>(100);
67      var yColumn = new List<double>(100);
68
69      for (int i = 0; i < 100; i++) {
70        x1 = rand.NextDouble(-2, 2);
71        x2 = rand.NextDouble(2, 6);
72        x3 = rand.NextDouble(0, 1);
73        int length = rand.Next(3, 6);
74        v1 = rand.NextDoubleVector(-2, 2, length);
75        v2 = rand.NextDoubleVector(3, 5, length);
76
77        y = x1 * v1.Sum() + x2 * v2.Mean();
78
79        x1Column.Add(x1);
80        x2Column.Add(x2);
81        x3Column.Add(x3);
82        v1Column.Add(v1);
83        v2Column.Add(v2);
84        yColumn.Add(y);
85      }
86
87      return new List<IList> { x1Column, x2Column, x3Column, v1Column, v2Column, yColumn };
88    }
89  }
90}
Note: See TracBrowser for help on using the repository browser.